PYTHON BASIC KEYWORDS
PYTHON BASIC KEYWORDS
Introduction
Web development
Data Types
print() function
Variables
User Input
input() function
Example: name = input("Enter your name: ")
Arithmetic Operators
String Methods
Conditional Operators
If/Else/Elif
Syntax:
if condition:
# code
elif condition:
# code
else:
# code
Collections
Loops
For Loop :
for i in range(10):
print(i)
While Loop :
while condition:
# code
Comprehensions
List comprehension:
[i for i in range(10)]
Dictionary comprehension:
python
Copy
Functions
return x + y
Scope
Exceptions
Lambda Functions
lambda x: x + 5
map(function, iterable)
filter(function, iterable)
F-Strings
python
name = "Tim"
print(f"Hello, {name}")
Conclusion
Keyword Notes:
1. Functions
Closure : Inner function "remembers" the environment (variables) from the outer
function.
Returning function : Function can return another function without calling it.
2. Arguments Handling
4. Merging Dictionaries
5. Print Behavior
Invalid unpacking : Using ** outside valid contexts like function calls or dictionary
merging.
Passing arguments : Using *args and **kwargs for flexible function signatures.