Python Notes
Python Notes
To execute Python from the command line, use the command python or python3 followed by the file
python3 script.py
Output:
Hello, World!
2. Tuples in Python
A tuple is an immutable, ordered collection of elements. Tuples are written with parentheses () and
print(my_tuple)
Output:
3. Lambda in Python
A lambda function is an anonymous, small function defined with the lambda keyword. It can have
print(add(5, 3))
Output:
A class is a blueprint for creating objects. Define a class using the class keyword followed by the
class name.
class MyClass:
def greet(self):
obj = MyClass()
print(obj.greet())
Output:
Hello, World!
Relational operators: Compare values (==, !=, >, <, >=, <=).
Logical operators: Combine conditional statements (and, or, not).
x, y = 5, 10
Output:
False
True