Q1.
BEG
Write a program to calculate the perimeter and the area of a rectangle. Take the length and the width of a rectangle from user and then prints the value of perimeter and area of that given rectangle.
Expected Output:
Enter the length of a rectangle: 10 // user input
Enter the width of a rectangle: 5 // user input
Perimeter: 30
Area: 50
// Perimeter = 2 * (l + w) = 2 * (10 + 5) = 30
// Area = l * w = 10 * 5 = 50Q2.
What will be the output of the following programs?
You have to predict the output yourself without running/executing the code.
I.
BEG
print(6 + 5 * 4 % 3)II.
BEG
a = 3 a += 1 print(a) a /= 2 print(a)III.
BEG
x = '420' y = '96' print(x + y)IV.
BEG
x = 9 y = 2 z = x // y print(z) x = z % y print(x) y = z ** x print(y)V.
INT
i = 5 * 2; print(i); j = i * i print(j)VI.
BEG
GRAVITY = 9.8 mass = 68 weight = mass * GRAVITY print(weight) GRAVITY = 10 weight = mass * GRAVITY print(weight)
Q3.
INT
There are 10 seats placed in a circle for an event, numbered from 1 to 10. People are arriving and standing in a waiting line (queue). Each person is given a seat based on their position in the line.
Write a program where the user enters their position in the waiting line (queue) and the program tells them which seat number they will get.
(For e.g. if someone is 11th in line, they should get seat 1 again because the seats are arranged in a circle. If someone is 12th, they get seat 2 and so on.)
Expected Output:
Enter your queue number: 23 // user input
Your seat number is: 3Q4.
What will be the output of the following programs?
You have to predict the output yourself without running/executing the code.
I.
INT
message1 = "Linus Torvalds, the creator of the linux kernel once said -" message2 = "Most of the good programmers do programming not because they expect to get paid or get adulation by the public," message3 = "but because it is fun to program." print(message1) print('{} {}'.format(message2, message3))II.
BEG
show_name = "Monty Python's Flying Circus" print("The name of the Python programming language comes from an old BBC television comedy sketch series called -", end=' ') print(show_name)III.
INT
fname = "Guido" mname = "van" lname = "Rossum" print('{1} {2} {3}'.format(fname, mname, lname))IV.
BEG
name = "Albert Einstein" quote = '"Computers are incredibly fast, accurate, and stupid. Human beings are ' \ 'incredibly slow, inaccurate, and brilliant. Together they are powerful beyond imagination."' print(quote) print(f"- {name}")V.
INT
print(1,00,000) print(1_00_000)
Q5.
BEG
Write a program that takes the cost of any 3 food items from the user (e.g. a packet of biscuit, a packet of waffer, an icecream cone) and then -
- Print the Total Cost of the items
- Then calculate a 18% GST (tax) on the total cost of the items and print that GST Amount
- Finally print the Total Bill amount, adding Total Cost & GST Amount
Expected Output:
Enter the cost of 3 food items: 50 20 60 // user input
Total Cost: 130
GST Amount : 23.4
Total Bill: 153.4
// Total Cost = 50 + 20 + 60 = 130
// GST Amount = Total Cost * 18 / 100 = 130 * 18 / 100 = 23.4
// Total Bill = Total Cost + GST Amount = 130 + 23.4 = 153.4Q6.
BEG
Write a program that takes a value of radius from user, then find the circumference and area of a circle for a given radius.
Take 3.14 as the value of pi.
Expected Output:
Enter the value of radius: 5 // user input
Circumference: 31.4
Area: 78.5
// Circumference = 2 * pi * r = 2 * 3.14 * 5 = 31.4
// Area = pi * r * r = 3.14 * 5 * 5 = 78.5Q7.
BEG
Write a program that takes a value of temperature in Celsius from user, then convert it into Kelvin and Fahrenheit.
The formulas for Celsius to Kelvin and Celsius to Fahrenheit are -
Kelvin = Celsius + 273Fahrenheit = 9/5 * Celsius + 32
Expected Output:
Enter the value of temperature in Celsius: 30 // user input
temperature in Kelvin: 303
temperature in Fahrenheit: 86
// Kelvin = Celsius + 273 = 30 + 273 = 303
// Fahrenheit = 9/5 * Celsius + 32 = 9/5 * 30 + 32 = 86Q8.
INT
You’re helping a government planning department analyze how a country’s population is expected to grow over time. Based on the current population, an estimated annual growth rate and a time period in years, you need to calculate what the population will be at the end of that period.
Population growth can be calculated by looking at the change in population over time. The formula for population growth is -
pt = p0 x (1 + r)tWhere,
pt- total population after time tp0- initial populationr- rate of growtht- total time in years
Expected Output:
Enter the initial population (in crores): 142 // user input
Enter the rate of growth (in %): 0.875 // user input
Enter the time (in years): 5 // user input
Total population after given time (in crores): 148.322Q9.
What will be the output of the following programs?
You have to predict the output result without running/executing the code.
I.
BEG
x = 10 y = 5 print((x - 3) == (y + 2)) print((x - 5) >= (y + 2)) print((x - 4) != (y + 2))II.
BEG
x = 10 y = 5 print(((x > 20) and (y < 10))) print(((x > 20) or (y < 10))) print(((x > 20) or (not (y < 10))))III.
INT
w = True x = False y = False z = False print((w or x or y and z)) print((x or w and y or z)) print(((w or x or y) and z)) print((w or (x or not y and z)))IV.
ADV
x = (100.0 - 99.99) y = (10.0 - 9.99) print(x == y) print(x < y) print(x > y)
Q10.
BEG
A bank wants to alert its customers when their daily balance swing is large.
- Ask the user for their opening balance and closing balance for the day.
- Calculate the absolute change in balance and print it.
Expected Output:
// case 1
Enter opening balance (rs.): 2500.00 // user input
Enter closing balance (rs.): 1200.75 // user input
Alert! Your balance swung by rs.1299.25 today.
// case 2
Enter opening balance (rs.): 1300.00 // user input
Enter closing balance (rs.): 2600.75 // user input
Alert! Your balance swung by rs.1300.75 today.Q11.
BEG
Your car’s onboard computer needs a quick summary of mileage. Write a program that -
- Asks for distance traveled (in km) and fuel consumed (in liters).
- Calculates fuel efficiency as km per liter and displays it.
Display the calculated result rounded to two decimal places.
Expected Output:
Enter distance travelled (km): 512.3 // user input
Enter fuel used (L): 36.8 // user input
Your fuel efficiency is 13.92 km/L.Q12.
ADV
Consider the following division and remainder operations, and try to predict the result.
You have to predict the output yourself without running/executing the code.
- 10 / 3
- 10.0 / 3.0
- 10 // 3
- 10 // 3.0
- 10 // -3
- -10 // -3
- 10 % 3
- 10.0 % 3
- -10 % 3
- 10 % -3
Q13.
INT
A workshop organizer needs to make a system to determine at what hour a workshop ends on a 12-hour clock, given its start time and duration. Write a Python program that -
- Prompts the user for the workshop’s start hour (1-12) and its duration in hours.
- Calculates and prints the resulting end time (1-12).
Don’t worry about AM/PM for now - just work with the clock numbers.
Expected Output:
Enter the workshop starting time (1-12): 11 // user input
Enter the workshop duration (in hours): 3 // user input
The workshop will end at 2.