Problem_1
August 10, 2024
Question - 1
Write a program to compute the simple interest.
[1]: p = float(input("Enter principal amount"))
r = float(input("Enter rate of interest"))
t = float(input("Enter time of interest"))
Enter principal amount 100
Enter rate of interest 8
Enter time of interest 1
[2]: simple_interest = p * (r/100) * t
print(f"The simple interest is : {simple_interest} and the interested amount is␣
↪: {simple_interest+p}")
The simple interest is : 8.0 and the interested amount is : 108.0
1
Problem_2
August 10, 2024
Question - 2
Write a program to check whether the given character is an uppercase letter or lowercase letter or
a digit or a special character.
[1]: character = input("Enter input: ")
if len(character) == 1:
if character.isupper():
print("Uppercase Alphabet")
elif character.islower():
print("Lowercase Alphabet")
elif character.isdigit():
print("Digit")
else:
print("Special character")
else:
print("Enter single character")
Enter input: A
Uppercase Alphabet
1
Problem_3
August 10, 2024
Problem - 3
Write a program to find the maximum number out of the given three numbers.
[5]: list = []
[6]: for i in range(3):
user_input = input(f"Enter input {i+1}: ")
list.append(user_input)
Enter input 1: 10
Enter input 2: 20
Enter input 3: 30
[7]: list.sort()
print(f"Highest number is {list[2]}")
Highest number is 30
1
Problem_4
August 10, 2024
Problem - 4
Write a program that read the customer number & power consumed and prints the amount to be
paid by the customer.
[5]: unit = float(input("Enter number of electrical units of power consumed: "))
if unit <= 100:
cost = unit
elif unit > 100 and unit <301:
cost = 100 + (units - 100) * 1.25
elif unit > 300 and unit < 501:
cost = 350 + (unit - 300) * 1.5
else:
cost = 650 + (unit - 500) * 1.75
print(f"Amount to be paid by customer: {cost}")
Enter number of electrical units of power consumed: 301
Amount to be paid by customer: 351.5
1
Problem_5
August 10, 2024
Problem - 5
Write a program to display summation of first N natural numbers.
[2]: n = int(input("Enter number of natural numbers to be added: "))
sum = 0
for i in range(n+1):
sum += i
print(sum)
Enter number of natural numbers to be added: 10
55
1
Problem_6
August 10, 2024
Problem - 6
Write a program to print a multiplication table of any positive integer N.
[1]: n = int(input("Enter the number to see tables: "))
for i in range(1, 11):
print(f"{n} * {i} = {n * i}")
Enter the number to see tables: 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
1
Problem_7
August 10, 2024
Problem - 7
Write a program to create a list of students’ marks with user-defined values and find the total and
maximum of the marks.
[1]: list = []
for i in range(6):
marks = int(input(f"Enter marks {i+1}: "))
list.append(marks)
Enter marks 1: 85
Enter marks 2: 45
Enter marks 3: 90
Enter marks 4: 55
Enter marks 5: 65
Enter marks 6: 60
[2]: list.sort()
print(f"Total marks: {sum(list)} Highest marks: {list[5]}")
Total marks: 400 Highest marks: 90
1
Problem_8
August 10, 2024
Problem - 8
Write a program to create a list of numbers and find the sum of the even elements and the sum of
the odd elements present in it.
[1]: list = []
even_sum = 0
odd_sum = 0
[2]: n = int(input("Enter the number of entries required in the list"))
for i in range(n):
num = int(input())
list.append(num)
Enter the number of entries required in the list 6
5
3
4
2
7
6
[3]: for j in list:
if (j%2) == 0:
even_sum += j
else:
odd_sum += j
[4]: print(f"Even Sum : {even_sum} Odd Sum : {odd_sum}")
Even Sum : 12 Odd Sum : 15
1
Problem_9
August 10, 2024
Problem - 9
Write a program to create a list of numbers and find the sum of the even location elements and the
sum of the odd location elements present in it.
[6]: input_list = []
odd_sum = 0
even_sum = 0
[7]: n = int(input("Enter number of required entries in list: "))
for i in range(n):
user_input = int(input(f"Enter input {i+1}: "))
input_list.append(user_input)
Enter number of required entries in list: 6
Enter input 1: 5
Enter input 2: 3
Enter input 3: 4
Enter input 4: 2
Enter input 5: 7
Enter input 6: 6
[8]: for i in input_list:
if input_list.index(i) % 2 == 0:
odd_sum += i
else:
even_sum += i
[11]: print(f"Sum of Odd Indexes: {odd_sum}")
print(f"Sum of Even Indexes: {even_sum}")
Sum of Odd Indexes: 16
Sum of Even Indexes: 11
1
Problem_10
August 10, 2024
Question - 10
Write a program to find the factorial value of N. Accept the value of N from the user.
[1]: n = int(input("Enter factorial input: "))
product = 1
if n == 1 or n == 0:
print(1)
else:
for i in range(1, n+1):
product = product * i
print(product)
Enter factorial input: 5
120