Problems (Lab2)
Problems (Lab2)
Satish Paudel
Q.2 Write a Python program to calculate shaded area of the shape below. Note that the shape is
made up of a rectangle and a triangle so you can find the total shaded area by summing up the area
of those small parts.
Hint: Area of triangle =
Exercise 3. Write a program to calculate a cylinder in the following format. There program should
receive values of each parameter. The formula of a cylinder is r 2h. For this question, the Pi value
is equal to 3.1415926535. The output is format as follows "%.5f".
Question 4: Write a program that gets the full score and real score (not greater than full score)
from keyboard, and then show the percentage value of the full score.
Example screen:
----------------------------
--- Calculate Percentage ---
----------------------------
Full Score: 150 Real Score: 60
----------------------------
Percentage: 40.00%
----------------------------
All scores are float values.
The percent can print in the output using "%%".
Examples:
Prepared by Sr. Lect. Dr. Satish Paudel
Exercise 5: Write a program to receive a four-digit integer from the user. First, print out the result
of first two-digit sum last two-digit. Then print out the result of first two-digit minus last two-digit.
Last print out the result of integer value and remainder value of first two-digit divided by last two-
digit. All the numbers and the operations are using Integer.
(Hint: Find first two-digit and last two-digit) 2000 floor division 100 is equal to 20. 20 is then
become the first two digit. The 15 is the remainder from 2015 subtracts with 2000.
Input and Output:
Enter a four-digit integer: 2015
The result of 20 + 15 = 35
The result of 20 - 15 = 5
The integer value of 20/15 = 1
The remainder of 20/15 = 5
Prepared by Sr. Lect. Dr. Satish Paudel
Problem 6 Input three float numbers. Print out the average, summation and multiplication of
those numbers. The output is a format in 2 decimal points. The placeholder %.2f indicates two
decimal points format
Input and Output:
Exercise 7: Write a program that converts your weight and height from kilograms and centimeters
to pounds and feet, respectively. (1 kilogram = 2.20462262 pounds, 1 centimeter = 0.032808399
feet). The program output should look like this:
Enter your weight in kg.: 60
Enter your height in cm.: 170
Your weight in pounds = 132.27
Your height in feet = 5.58
Exercise 8: Write a program to takes two integer numbers as input data and display their sum,
difference, product (multiplication), and quotient. The program output should look like this:
Enter the first integer number: 8
Enter the second integer number: 22
The sum is 30
The difference is -14
The product is 176
The quotient is 0
Prepared by Sr. Lect. Dr. Satish Paudel
Q.10 Calculate GPA from 3 subjects (ITS100, EL171, and SCS183) by multiply each subject with
its number of credits. After that, sum up all result and divide by total number of credits. Print out
the GPA result.
Note: ITS100 and EL171 have 3 credits. SCS183 has 1 credit.