0% found this document useful (0 votes)
5 views4 pages

Class11 Python Programs

The document contains a series of Python programming exercises that cover various topics such as displaying jokes, reading dates, generating specific outputs, calculating averages, converting measurements, and performing mathematical operations. Each exercise includes a brief description and the corresponding code implementation. The exercises are designed to help learners practice and enhance their programming skills in Python.

Uploaded by

abijithps704
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Class11 Python Programs

The document contains a series of Python programming exercises that cover various topics such as displaying jokes, reading dates, generating specific outputs, calculating averages, converting measurements, and performing mathematical operations. Each exercise includes a brief description and the corresponding code implementation. The exercises are designed to help learners practice and enhance their programming skills in Python.

Uploaded by

abijithps704
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Write a program that displays a joke.

(Hint: You can use input())

# Joke display program

input("Do you want to hear a joke? Press Enter to continue...")

print("Why don't scientists trust atoms?")

input("Press Enter for the punchline...")

print("Because they make up everything!")

2. Write a program to read today's date (only date) and the current month.

from datetime import date

today = [Link]()

print("Today's Date:", [Link])

print("Current Month:", [Link])

3. Write a program that generates the following output:

5 10

95

print("5 10")

print("9 5")

4. Modify the above program so as to print output as 5@10#9.

print("5@10#9")

5. Write the program with maximum five variables and then print them.

a, b, c, d, e = 10, 20, 30, 40, 50

print(a, b, c, d, e)

6. Write a Python program that accepts marks in 5 subjects and outputs average marks.

marks = [int(input(f"Enter marks for subject {i+1}: ")) for i in range(5)]

average = sum(marks)/5
print("Average Marks:", average)

7. Write a short program that asks for your height in centimetres and then converts your

height to feet and inches.

cm = float(input("Enter your height in cm: "))

inches = cm / 2.54

feet = int(inches // 12)

remaining_inches = inches % 12

print(f"Height: {feet} feet and {remaining_inches:.2f} inches")

8. Write a program to find area of a circle and prints its area.

radius = float(input("Enter radius: "))

area = 3.14159 * radius * radius

print("Area of Circle:", area)

9. Write a program to compute simple interest and compound interest.

p = float(input("Enter principal: "))

r = float(input("Enter rate: "))

t = float(input("Enter time in years: "))

# Simple Interest

si = (p * r * t) / 100

# Compound Interest

ci = p * ((1 + r/100)**t) - p

print("Simple Interest:", si)

print("Compound Interest:", ci)

10. Write a program to print n, n^2 and n^4.

n = int(input("Enter number: "))

print("n =", n)
print("n^2 =", n**2)

print("n^4 =", n**4)

11. Write a program to read number of inches (1 foot = 12 inches, 1 inch = 2.54 cm) and

convert it to cm.

inches = float(input("Enter inches: "))

cm = inches * 2.54

print("Centimetres:", cm)

12. Write a program to input a number and print its first five multiples.

n = int(input("Enter a number: "))

for i in range(1, 6):

print(n * i)

13. Write a program to input a number and output as 5@10@9.

n = int(input("Enter a number: "))

print(f"{n}@{n*2}@{n+4}")

14. Write a program to input a single digit (1-9). Multiply it with 2 and 3 and print:

input digit = 4 => output 4*2 = 8, 4*3 = 12

digit = int(input("Enter digit (1-9): "))

print("Double:", digit*2)

print("Triple:", digit*3)

15. Write a program to read three numbers, and swap two variables with the third

respectively.

a = int(input("Enter first number: "))

b = int(input("Enter second number: "))

c = int(input("Enter third number: "))


a, b, c = b, c, a

print("After swapping:")

print("a =", a)

print("b =", b)

print("c =", c)

You might also like