python-program-file-CLASS-9TH
python-program-file-CLASS-9TH
PYTHON
Student Name :
Roll No. :
Variable declaration
Data types: integers, floats, strings, and booleans
Example:
name = "John"
age = 15
height = 5.8
is_student = True
print(name, age, height, is_student)
Output:
2.Operators
a = 10
b = 20
print("Sum:", a + b)
print("Is a greater than b?", a > b)
Output:
3.Input and Output
Output
4.Control Structures
Output
Copy code
for i in range(1, 6):
print("Number:", i)
Output:
Copy code
n=5
while n > 0:
print(n)
n -= 1
Output:
6. Functions
def greet(name):
return "Hello, " + name
print(greet("Alice"))
Output:
fruits[1] = "orange"
print(fruits) # Output: ["apple", "orange", "cherry"]
Output:
Example:
Copy code
student = {"name": "Alice", "age": 14, "class": "9th"}
print(student["name"]) # Output: Alice
Output:
Example:
Copy code
unique_numbers = {1, 2, 3, 4, 4, 5}
print(unique_numbers) # Output: {1, 2, 3, 4, 5}
Output:
Output:
Output: