- Genral Purpose
- Easy to Learn
- Object Oriented
- Has high level data structures
- Dynamically typed
- Scripting Language
- Versatile Domains(Web Development, Data Science, Machine Learning etc)
- Interpreter
# Print the classic "Hello World" message to the console, showcasing a simple output operation.
print('Hello World')
# Print the result of the arithmetic operation 1 + 2, demonstrating basic math and the `print` function.
print(1+2)
# Assign a string value to the variable `greet`. This demonstrates variable initialization and string handling.
greet = "Welcome To our Course"
# Check if the value of the `greet` variable matches the string "Good Morning". Demonstrates an `if` statement for conditional logic.
if greet=="Good Morning":
# If the condition is true, this line executes and prints "Good Morning" to the console.
print("Good Morning")
else:
# If the condition is false, this line executes and prints "Learn and Contribute" to the console.
print("Learn and Contribute")
- Output
Hello World
3
Learn and Contribute
Note
Indentation in Python refers to the spaces or tabs at the beginning of a code line. Unlike many programming languages that use braces {} or other delimiters to define code blocks, Python uses indentation to indicate a block of code. This makes Python code more readable and visually structured.
- It is a part of the syntax
- Indentation is not optional in Python
- Improper indentation leads to a IndentationError
- Each nested block increases the indentation level.
- Use the same number of spaces (or tabs) for all lines in a block.
-
- Atoms are the smallest units of code that cannot be broken down further.
-
- Identifiers are the names used to identify variables, functions, classes, modules, or other objects in Python.
- Rules for Naming Identifiers:
- Can only contain letters (A-Z, a-z), digits (0-9), and underscores (_).
- Must start with a letter or underscore (_), not a digit.
- Cannot use Python keywords or built-in function names.
- Case-sensitive (Name and name are different).
-
- They are fixed values assigned to variables in the program.
# Integer literal num = 42 # 42 A whole number # Float literal x = 5.1454 # 3.15 A decimal number # String literal name = "ChatGPT" # A sequence of characters # Complex literal complex_num = 2 + 3j # A complex number with a real and imaginary part # None literal value = None # Represents the absence of a value or null # Multiline string literal multiline_text = """This is a multiline string."""
- They are fixed values assigned to variables in the program.
-
- Constants are fixed, unmodifiable values.
- Keywords are reserved words in Python that have predefined meanings and cannot be used as identifiers.
- Case Sensitive
- 35 Keywords
-
#Use keyword module to list all keywords import keyword print(keyword.kwlist)
-
""" ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] """
Course Outline
- Understanding Data Types: The building blocks of Python.
- Mastering Operators: Perform calculations and logical operations.
- Input and Output Handling: Interacting with users and displaying results.
- Conditional Statements and Branching: Decision-making in Python.
- Looping Constructs: Repeating tasks efficiently.
- Functions: Modularize and reuse code effectively.
- Recursion: The art of self-referential functions.
- Classes, Objects, and Methods: Exploring the world of Object-Oriented Programming.
- Data Structures and Algorithms: Organize and manipulate data like a pro.
- Searching and Sorting Techniques: Optimizing data retrieval and organization.
- Check if a number is prime or not *
- Find the factorial of a number *
- Check if a string is a palindrome *
- Write a Python Program to generate first 'N' Fibonacci Series/numbers *
- Sum of natural numbers
- Armstrong number
- Reverse a string
- Write a menu driven program using user defined functions to find Area of a circle *
- Generate Multiplication Table
- Calculate GCD of two numbers *
- Count the occurrence of a character in a string
- Convert temperature from Celsius to Fahrenheit
- Check if a year is a leap year
- Find the largest number in a list
- Sort a list of numbers
- Generate a random number
- Solve quadratic equations
- Count vowels and consonants in a string
- Write a menu driven program using user defined functions to Calculate the area of a rectangle/square *
- Check if a number is an even or odd number
- Generate a histogram from a list
- Check if a number is a perfect number
- Calculate the LCM of two numbers
- Solve a basic mathematical expression (e.g., arithmetic operations)
- Remove vowels from a string
- Check if a string is a valid email
- Check if a number is a palindrome
- Create a simple calculator with basic operations
- Find the sum of digits of a number
- Implement a simple password validator
- Count the number of elements greater than a given value in a list
- Check if a number is a power of 2
- Convert binary to decimal and vice versa
- Generate combinations of a given length
- Create a simple to-do list
- Calculate the area of a parallelogram
- Count the number of special characters in a string
- Check if a list contains duplicate elements
- Remove a string from a list in Python.
- Check if a string appears in another string from a list in Python.
- Write a Python program to perform
Insertion sort
of an array/list. * - Write a Python program to perform
Selection sort
of an array/list. * - Write a Python program to perform
Bubble sort
of an array/list. * - Write a python program that implements Stack Operation *
- Write a python program that implements Queue Operation *
- Implement Queue using List *
- Write a python program to implement a Circular Queue *
- Write a program to print following pattern in Python *
*
**
***
****
*****
- Write a Python Code to perform
Binary Search
Technique. * - Write a Python Code to Perform
Linear Srarch
Technique. * - Write a Python Program to that find out factorial of a number using recursion. *
- Write a Python Program Using recursion to generate ten odd numbers. *
- Write a Python Program to find the sum of series: * S = 1/1! - 2/2! + 3/3! - 4/4! + ... + (-1)^(n+1) * n/n!
- Write a Python Program to add two Matrix *
- WAP to calculate total marks, percentage and grade of a student. Marks obtained in each of
the three subjects are to be input by the user. Assign grades according to the following
criteria :
Grade A: Percentage >=80 Grade B: Percentage>=70 and <80 Grade C: Percentage>=60 and <70 Grade D: Percentage>=40 and <60 Grade E: Percentage<40
- Write a menu driven program to convert the given temperature from Fahrenheit to Celsius and vice versa depending upon users choice.
- Evaluate the prefix expression
*+23+54
. - Evaluate the postfix expression
23+54+*
. - Convert infix to postfix for
((3 + 4) * (5 - 2))
. - Convert infix to prefix for
((3 + 4) * (5 - 2))
. - Evaluate the prefix expression
+ * 5 3 - 8 2
. - Evaluate the postfix expression
23 45 6 * +
. - Identify errors in prefix expression
*+23-54
. - Evaluate the postfix expression
5 1 2 + 4 * + 3 -
. - Validate prefix expression
* + 2 3 5
. - Validate postfix expression
23 45 + *
.