PYTHON PROGRAMMING ASSIGNMENT
Name: Saksham Kaushik | Class: 11th-B | School: Bohra Public School
1. Write a program to print "Hello Python" on the screen.
print("Hello Python")
2. Write a program to display your name, class, section, and school name.
print("Name: Saksham Kaushik")
print("Class: 11th")
print("Section: B")
print("School Name: Bohra Public School")
3. Write a program to input two numbers and display their sum.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
total_sum = num1 + num2
print("The sum of", num1, "and", num2, "is:", total_sum)
4. Write a program to find the square and cube of a number.
number = float(input("Enter a number: "))
o = input("Square or cube? (s/c): ").lower()
if o == 's':
print("Square:", number ** 2)
elif o == 'c':
print("Cube:", number ** 3)
else:
print("Invalid option selected.")
5. Write a program to calculate the area of rectangle.
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
area = length * width
print("The area of the rectangle is:", area)
Saksham Kaushik | Class 11th-B 1
6. Write a program to calculate the perimeter of a rectangle.
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
perimeter = 2 * (length + width)
print("The perimeter of the rectangle is:", perimeter)
7. Write a program to calculate the area of a circle.
radius = float(input("Enter the radius of the circle: "))
area = 3.14159 * (radius ** 2)
print("The area of the circle is:", area)
8. Write a program to convert temperature from Celsius to Fahrenheit.
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print("Temperature in Fahrenheit:", fahrenheit)
9. Write a program to convert temperature from Fahrenheit to Celsius.
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print("Temperature in Celsius:", celsius)
10. Write a program to swap two numbers using a third variable.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
temp = num1
num1 = num2
num2 = temp
print("After swapping:")
print("First number:", num1)
print("Second number:", num2)
Saksham Kaushik | Class 11th-B 2
11. Write a program to swap two numbers without using a third variable.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num1 = num1 + num2
num2 = num1 - num2
num1 = num1 - num2
print("After swapping:")
print("First number:", num1)
print("Second number:", num2)
12. Write a program to calculate the simple interest.
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time in years: "))
simple_interest = (principal * rate * time) / 100
print("The simple interest is:", simple_interest)
13. Write a program to calculate the average of three numbers.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
average = (num1 + num2 + num3) / 3
print("The average of the three numbers is:", average)
14. Write a program to perform type conversion using int(), float(), and str().
num = float(input("Enter a number: "))
print("Integer value:", int(num))
print("Float value:", float(num))
print("String value:", str(num))
Saksham Kaushik | Class 11th-B 3
15. Write a program to check whether a number is even or odd.
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is an even number.")
else:
print(num, "is an odd number.")
16. Write a program to find the largest of two numbers.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if num1 > num2:
print(num1, "is greater than", num2)
elif num2 > num1:
print(num2, "is greater than", num1)
else:
print("Both numbers are equal.")
17. Write a program to demonstrate arithmetic operators in Python.
a = 10
b = 5
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Modulus:", a % b)
print("Exponentiation:", a ** b)
18. Write a program to demonstrate relational operators in Python.
a = 10
b = 5
print("Equal to:", a == b)
print("Not equal to:", a != b)
print("Greater than:", a > b)
print("Less than:", a < b)
print("Greater than or equal to:", a >= b)
print("Less than or equal to:", a <= b)
Saksham Kaushik | Class 11th-B 4
19. Write a program to demonstrate logical operators in Python.
a = True
b = False
print("Logical AND:", a and b)
print("Logical OR:", a or b)
print("Logical NOT:", not a)
20. Write a program to demonstrate assignment operators in Python.
a = 10
print("Initial value of a:", a)
a += 5
print("After a += 5:", a)
a -= 3
print("After a -= 3:", a)
a *= 2
print("After a *= 2:", a)
a /= 4
print("After a /= 4:", a)
a %= 3
print("After a %= 3:", a)
Saksham Kaushik | Class 11th-B 5