IT112
IT112
IT 112
Submitted to: Mr. Alvin Taneza
Submitted by: Group 1
Expected Output:
43
1
19
13
Solution
print("a. Result:", a)
print("b. Result:", b)
print("c. Result:", c)
print("d. Result:", d)
Output
a. Result: 43
b. Result: 1
c. Result: 18.125
d. Result: 13.0
Problem:
2. Write a Python program to print a face base on the given example below.
Expected Output
+"""""+
[| o o |]
| _ |
| '-' |
+-----+
Solution:
Output
+"""""+
[| o o |]
| _ |
| '-' |
+-----+
Problem:
Formula:
Readmeters = presentreading – previousreading
Monthlybill = (rateperkilowatt*readmeters)+balance
Solution:
Output:
4. Create a python program that will compute the area of circle with a
formula Area = where . The program will display the computed area of
circle.
Solution:
def compute_circle_area(radius):
pi = 3.1416
area = pi * radius ** 2
return area
Output:
Expected Output:
Enter string 1: P
Enter string 2: R
Enter string 3: O
Enter string 4: G
Enter string 5: R
Enter string 6: A
Enter string 7: M
Enter string 8: M
Enter string 9: I
Enter string 10: N
Enter string 11: G
The reverse word is: GNIMMARGORP
Solution:
user_input = [input(f"Enter string {i + 1}: ") for i in range(11)]
reversed_word = ''.join(user_input[::-1])
print("The reverse word is:", reversed_word)
Output:
Enter string 1: P
Enter string 2: R
Enter string 3: O
Enter string 4: G
Enter string 5: R
Enter string 6: A
Enter string 7: M
Enter string 8: M
Enter string 9: I
Enter string 10: N
Enter string 11: G
The reverse word is: GNIMMARGORP
If Conditional statement
Problem:
6. Create a python program that will evaluate the user input if it is an “even
number” or “odd number”
Solution:
Output
Enter a number: 23
is an odd number.
-----------------------------------------
Enter a number: 32
is an even number.
Problem:
Formula:
Meterused = presentreading – previousreading
Monthlybill = meterused*rateperkilowatt+ balance
Note: monthly electric bill may vary on the key character input
Solution:
Name = input("Enter Name of Customer:")
print("R Residential")
print("C Commercial")
print("I Industrial")
Key = input("Enter Key Character:")
Present = int(input("Enter Present Reading:"))
Previous = int(input("Enter Previous Reading:"))
Balance = int(input("Enter Balance:"))
Meterused = Present - Previous
print("===================================================")
Output:
Problem:
8. Create a python program that will determine the user input if it is a
negative, positive or a zero.
Solution:
Output:
Enter a number: 0
The input is Zero
----------------------------------
Enter a number: 43
The input is Positive
----------------------------------
Enter a number: -52
The input is Negative
----------------------------------
Problem:
9.
Create a python program to compute the salary of an individual employee based on
the following condition below. The program will display the employees name,
corresponding key charater of an employee, rate per day, workdays, overtime,
deductions, grosspay and netpay.
Note:
R = Regular
C = Contractual
P = Probationary
Formula:
Deductions = pagibig + SSS + Philhealth
Grosspay = (workdays * rateperday)+overtime
Netpay = grosspay-deductions
Solution:
name = input("Enter the name of the employee: ")
position = input("Enter employee position:")
keycharacter= input("Enter keycharacter:")
pagibig = int(input("Enter the Pag-IBIG contribution: "))
sss = int(input("Enter the SSS contribution: "))
philhealth = int(input("Enter the PhilHealth contribution: "))
working_days = int(input("Enter the total number of working days: "))
rateperday = int(input("Enter rate per day:"))
overtime_pay = int(input("Enter the overtimepay:"))
Output:
Problem:
10 .Create a python program to allow the user to input his or her age then the
program will determine the input of the user base on the given conditions below.
Condition:
if age is 18 “you’re 18 years old”
if age is 19 “you’re 19 years old”
if age is 20 “you’re 20 years old”
else “you’re not 18,19 or 20”
Solution:
age = int(input("Enter your age: "))
if age == 18:
print("You're 18 years old")
elif age == 19:
print("You're 19 years old")
elif age == 20:
print("You're 20 years old")
else:
print("You're not 18, 19, or 20")
Output:
11. Create a python program using for loop to display the following output.
Solution:
for _ in range(10):
print('* ' * 20)
Output:
********************
********************
********************
********************
********************
********************
********************
********************
********************
********************
Problem:
12. Create a program using while loop to get the sum of the inputted value.
Solution:
sum_of_numbers = 0
current_number = start
while current_number <= end:
sum_of_numbers += current_number
current_number += 1
Output:
Problem:
13. Create a python program using while loop to display the following output.
Solution:
count = 0
while count < 4:
print("Welcome to ISU San Mateo")
print("I AM ANNA CARGO")
print("BSIT 1D")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~")
count += 1
Output:
Solution:
PI = 3.14
r = int(input("Enter the radius of a circle:"))
area = PI * r * r
print("Area of a circle = %.2f" %area)
Output:
Problem:
15. Create a python program using function that will ask the user to input a number and then,
the program will check if the given number is a zero, positive or a negative number. The
program will display the output on the screen.
Solution:
def check_number():
number = int(input("Enter a number: "))
if number == 0:
print("The entered number is zero.")
elif number > 0:
print("The entered number is positive.")
else:
print("The entered number is negative.")
check_number()
Output:
Problem:
16. Create a python program using function to find the maximum of three numbers.
Solution:
num1 = 31
num2 = 47
num3 = 62
def find_largest_number(num1, num2, num3):
if num1 >= num2 and num1 >= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3
largest = find_largest_number(num1, num2, num3)
print("The largest number is", largest)
Output: