Lab Assignment
Lab Assignment
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"))
1
Problem_2
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
Problem - 3
Write a program to find the maximum number out of the given three numbers.
[5]: list = []
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
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
1
Problem_5
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)
1
Problem_6
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: "))
1
Problem_7
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]}")
1
Problem_8
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
1
Problem_9
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
else:
even_sum += i
1
Problem_10
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)