[Link] A Program that input 10 integers from keyboard and display their sum.
total = 0
print("Enter 10 integers:")
for i in range(10):
num = int(input(f"Enter number {i+1}: "))
total += num
print("The sum of the 10 integers is:", total)
[Link] a simple python program to input dimensions of a circle from the user and
calculate the area.
radius = float(input("Enter the radius of the circle: "))
area = 3.14159 * radius * radius
print("The area of the circle is:", area)
3. Write a program to user input marks of 06 subjects and then display average marks of
the student.
total = 0
print("Enter marks of 6 subjects:")
for i in range(6):
marks = float(input(f"Enter marks for subject {i+1}: "))
total += marks
average = total / 6
print("The average marks of the student is:", average)
[Link] a program to whether the user input alphabet is Vowel or Consonant
char = input("Enter an alphabet: ").lower()
if char in ['a', 'e', 'i', 'o', 'u']:
print(char, "is a Vowel")
else:
print(char, "is a Consonant")
[Link] to find the eldest person among 3 persons
age1 = int(input("Enter the age of person 1: "))
age2 = int(input("Enter the age of person 2: "))
age3 = int(input("Enter the age of person 3: "))
if age1 > age2 and age1 > age3:
print("Person 1 is the eldest.")
elif age2 > age1 and age2 > age3:
print("Person 2 is the eldest.")
elif age3 > age1 and age3 > age2:
print("Person 3 is the eldest.")
else:
print("Two or more persons have the same highest age.")
[Link] to identify whether the no. entered by the user is even and odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is Even")
else:
print(num, "is Odd")
7. Write a program to compute surface area and volume of a cuboid
length = float(input("Enter the length of the cuboid: "))
width = float(input("Enter the width of the cuboid: "))
height = float(input("Enter the height of the cuboid: "))
# Volume formula: V = l × w × h
volume = length * width * height
# Surface Area formula: SA = 2(lw + lh + wh)
surface_area = 2 * (length * width + length * height + width * height)
print("Volume of the cuboid:", volume)
print("Surface area of the cuboid:", surface_area)
[Link] to display whether the person is eligible to vote or no.
age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
9. Write a program to compute simple interest and compound interest on a
user input amount.
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest (in %): "))
time = float(input("Enter the time period (in years): "))
# Simple Interest
simple_interest = (principal * rate * time) / 100
# Compound Interest
compound_amount = principal * (1 + rate/100) ** time
compound_interest = compound_amount - principal
# Display the results
print("\n----- Results -----")
print(f"Simple Interest = {simple_interest:.2f}")
print(f"Compound Interest = {compound_interest:.2f}")
print(f"Total Amount (CI) = {compound_amount:.2f}")
10. Write a program to print even Numbers Within a user defined Range
start = int(input("Enter the start of the range: "))
end = int(input("Enter the end of the range: "))
print("\nEven numbers in the given range:")
for num in range(start, end + 1):
if num % 2 == 0:
print(num)
11. Print numbers from 1 to 10
i=1
while i <= 10:
print(i)
i += 1
12. Print sum of first 10 natural numbers
i = 1
total = 0
while i <= 10:
total += i
i += 1
print("Sum =", total)
13. Print the table of a given number
num = int(input("Enter a number: "))
i=1
while i <= 10:
print(num, "x", i, "=", num * i)
i += 1
14. Reverse a number
num = int(input("Enter a number: "))
rev = 0
while num > 0:
rev = rev * 10 + (num % 10)
num //= 10
print("Reversed number:", rev)
15. Print Day According to Number
num = int(input("Enter a number (1-7): "))
if num == 1:
print("Monday")
elif num == 2:
print("Tuesday")
elif num == 3:
print("Wednesday")
elif num == 4:
print("Thursday")
elif num == 5:
print("Friday")
elif num == 6:
print("Saturday")
elif num == 7:
print("Sunday")
else:
print("Invalid Input! Enter a number between 1 and 7.")