There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Fri Feb 21, 2025
Python is a powerful, easy-to-learn programming language used in various fields. This guide covers fundamental concepts to help beginners get started.
Python supports different data types such as strings, integers, floats, and booleans.
name = "Alice"
age = 25
height = 5.4
is_student = True
print(name, age, height, is_student)
You can take input from users using the input()
function.
name = input("Enter your name: ")
print("Hello, " + name + "!")
Use if-else
to execute code based on conditions.
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Loops allow you to iterate over a sequence of values.
for i in range(1, 6):
print("Hello", i)
Functions allow code reuse and modularity.
def greet(name):
print("Hello, " + name + "!")
greet("Alice")
Lists store multiple items in a single variable.
fruits = ["Apple", "Banana", "Cherry"]
print(fruits[0])
Dictionaries store key-value pairs.
person = {"name": "Alice", "age": 25}
print(person["name"])
Python supports OOP with classes and objects.
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def greet(self):
print("Hello, my name is " + self.name)
p1 = Person("Alice", 25)
p1.greet()