0% found this document useful (0 votes)
19 views3 pages

Assignment 5 Basic Class Room Questions

Uploaded by

Shubham Chaubey
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)
19 views3 pages

Assignment 5 Basic Class Room Questions

Uploaded by

Shubham Chaubey
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
You are on page 1/ 3

03/08/2024, 23:57 Assignment_5_Basic_class_room_questions

In [1]: #Ramesh’s basic salary is input through the keyboard. His dearness allowance is
#house rent allowance is 20% of basic salary. Write a program to calculate his g

basic_salary = float(input("Enter Ramesh's basic salary: "))


dearness_allowance = 0.40 * basic_salary
house_rent_allowance = 0.20 * basic_salary
gross_salary = basic_salary + dearness_allowance + house_rent_allowance
print("Ramesh's gross salary is:", gross_salary)

Ramesh's gross salary is: 40000.0

In [2]: #The distance between two cities (in km.) is input through the keyboard. Write a
#print this distance in meters, feet, inches and centimeters.

distance_km = eval(input("Enter the distance between two cities in km: "))


distance_m = distance_km * 1000
distance_ft = distance_km * 3280.84
distance_in = distance_km * 39370.1
distance_cm = distance_km * 100000
print("Distance in meters:", distance_m)
print("Distance in feet:", distance_ft)
print("Distance in inches:", distance_in)
print("Distance in centimeters:", distance_cm)

Distance in meters: 200000


Distance in feet: 656168.0
Distance in inches: 7874020.0
Distance in centimeters: 20000000

In [3]: #If the marks obtained by a student in five different subjects are input through
#aggregate marks and percentage marks obtained by the student. Assume that the m
#can be obtained by a student in each subject is 100.

marks1 = eval(input("Enter marks in subject 1: "))


marks2 = eval(input("Enter marks in subject 2: "))
marks3 = eval(input("Enter marks in subject 3: "))
marks4 = eval(input("Enter marks in subject 4: "))
marks5 = eval(input("Enter marks in subject 5: "))
aggregate_marks = marks1 + marks2 + marks3 + marks4 + marks5
percentage_marks = (aggregate_marks / 500) * 100
print("Aggregate marks:", aggregate_marks)
print("Percentage marks:", percentage_marks)

Aggregate marks: 260


Percentage marks: 52.0

In [4]: #Temperature of a city in Fahrenheit degrees is input through the keyboard. Writ
#temperature into Centigrade degrees.

temperature_fahrenheit = eval(input("Enter temperature in Fahrenheit: "))


temperature_centigrade = (temperature_fahrenheit - 32) * 5 / 9
print("Temperature in Centigrade:", temperature_centigrade)

Temperature in Centigrade: 18.333333333333332

In [5]: #The length & breadth of a rectangle and radius of a circle are input through th
#to calculate the area & perimeter of the rectangle, and the area & circumferenc

file:///C:/Users/Shubham/Downloads/Assignment_5_Basic_class_room_questions.html 1/3
03/08/2024, 23:57 Assignment_5_Basic_class_room_questions

length = eval(input("Enter the length of the rectangle: "))


breadth = eval(input("Enter the breadth of the rectangle: "))
radius = eval(input("Enter the radius of the circle: "))

# Rectangle calculations
area_rectangle = length * breadth
perimeter_rectangle = 2 * (length + breadth)
print("Area of the rectangle:", area_rectangle)
print("Perimeter of the rectangle:", perimeter_rectangle)

# Circle calculations
area_circle = 3.14159 * radius * radius
circumference_circle = 2 * 3.14159 * radius
print("Area of the circle:", area_circle)
print("Circumference of the circle:", circumference_circle)

Area of the rectangle: 2500


Perimeter of the rectangle: 200
Area of the circle: 78.53975
Circumference of the circle: 31.4159

In [6]: #Two numbers are input through the keyboard into two locations C and D. Write a
#the contents of C and D.

C = input("Enter the first number (C): ")


D = input("Enter the second number (D): ")
C, D = D, C
print("After interchanging, C =", C)
print("After interchanging, D =", D)

After interchanging, C = 2
After interchanging, D = 1

In [7]: #If a five-digit number is input through the keyboard, write a program to revers

number = input("Enter a five-digit number: ")


reversed_number = number[::-1]
print("Reversed number:", reversed_number)

Reversed number: 54321

In [8]: #If a four-digit number is input through the keyboard, write a program to obtain
#digit of this number.

number = input("Enter a four-digit number: ")


first_digit = int(number[0])
last_digit = int(number[-1])
sum_of_digits = first_digit + last_digit
print("Sum of the first and last digit:", sum_of_digits)

Sum of the first and last digit: 5

In [9]: #In a town, the percentage of men is 52. The percentage of total literacy is 48.
#men is 35 of the total population, write a program to find the total number of
#the population of the town is 80,000.

total_population = 80000
men_percentage = 0.52
total_literate_percentage = 0.48
literate_men_percentage = 0.35

file:///C:/Users/Shubham/Downloads/Assignment_5_Basic_class_room_questions.html 2/3
03/08/2024, 23:57 Assignment_5_Basic_class_room_questions

men_population = total_population * men_percentage


women_population = total_population - men_population
literate_population = total_population * total_literate_percentage
literate_men = total_population * literate_men_percentage
literate_women = literate_population - literate_men
illiterate_men = men_population - literate_men
illiterate_women = women_population - literate_women

print("Number of illiterate men:", illiterate_men)


print("Number of illiterate women:", illiterate_women)

Number of illiterate men: 13600.0


Number of illiterate women: 28000.0

In [12]: #A cashier has currency notes of denominations 10, 50 and 100. If the amount to
#through the keyboard in hundreds, find the total number of currency notes of ea
#cashier will have to give to the withdrawer.

amount_hundreds = int(input("Enter the amount to withdraw (in hundreds): "))

notes_100 = amount_hundreds // 100


remaining_amount = amount_hundreds % 100

notes_50 = remaining_amount // 50
remaining_amount = remaining_amount % 50

notes_10 = remaining_amount // 10

print("Number of 100 notes:", notes_100)


print("Number of 50 notes:", notes_50)
print("Number of 10 notes:", notes_10)

Number of 100 notes: 5


Number of 50 notes: 1
Number of 10 notes: 3

In [ ]:

file:///C:/Users/Shubham/Downloads/Assignment_5_Basic_class_room_questions.html 3/3

You might also like