0% found this document useful (0 votes)
18 views

IT112

Uploaded by

shiroereyes214
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

IT112

Uploaded by

shiroereyes214
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Project in

IT 112
Submitted to: Mr. Alvin Taneza
Submitted by: Group 1

Anna Margarita Cargo


Lee Mark Pajela
Nouah Inocencio
Richmond Dizon
John Clyde Bernales
Alijah Jesse Mesa
Arithmetic operators
Problem
1. Write a python program to print the result of the following operations.
Test Data:
a. -5 + 8 * 6
b. (55+9) % 9
c. 20 + -3*5 / 8
d. 5 + 15 / 3 * 2 - 8 % 3

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:

print(" +\"\"\"\"\"+ ")


print("[| o o |]")
print(" | _ | ")
print(" | '-' | ")
print(" +-----+ ")

Output

+"""""+
[| o o |]
| _ |
| '-' |
+-----+
Problem:

3. Create a program to compute the monthly electric bill of a particular


consumer. The user must input the previous reading, present reading, rate
per kilowatt, and balance then display the monthly bill.

Formula:
Readmeters = presentreading – previousreading
Monthlybill = (rateperkilowatt*readmeters)+balance

Solution:

previous_reading = int(input("Enter the previous reading: "))


present_reading = int(input("Enter the present reading: "))
rate_per_kilowatt = int(input("Enter the rate per kilowatt: "))
balance = int(input("Enter the balance: "))

usage = present_reading - previous_reading


total_bill = (usage * rate_per_kilowatt) + balance

print(f"Monthly Electric Bill: ${total_bill:.2f}")

Output:

Enter the previous reading: 500


Enter the present reading: 300
Enter the rate per kilowatt: 456
Enter the balance: 124
Monthly Electric Bill: $-91076.00
Problem:

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

radius = (input("Enter the radius of the circle: "))


area_result = compute_circle_area(radius)

print("The area of the circle with radius {radius} is: {area_result}")

Output:

Enter the radius of the circle: 32


The area of the circle with radius {radius} is: {area_result}
Problem:
5. Create a Python program that will reverses the character based on the user
input.

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:

userinput = input("Enter a number: ")


number = int(userinput)
if number % 2 == 0:
print("is an even number.")
else:
print("is an odd number.")
print("-----------------------------------------")
userinput = input("Enter a number: ")
number = int(userinput)
if number % 2 == 0:
print("is an even number.")
else:
print("is an odd number.")

Output

Enter a number: 23
is an odd number.
-----------------------------------------
Enter a number: 32
is an even number.
Problem:

7. Create a python program to compute the electric bill of an individual


concessionaire based on the following condition below.

Key Character Rate per kilowatt


‘R’ or ‘r’ 20.00
‘C’ or ‘c’ 35.00
‘I’ or ‘i’ 45.00
Note:
R = Residential
C = Commercial
I = Industrial

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("===================================================")

if Key == 'R' or Key == 'r':


M=Meterused*20+Balance
print(Name, "Your Monthlybill Electric Bill is:", M)
print("Type of Building: Residential")
elif Key=='C' or Key=='c':
M = Meterused * 35 + Balance
print(Name, "Your Monthlybill Electric Bill is:", M)
print("Type of Building: Commercial")
elif Key == 'I' or Key == 'i':
M = Meterused * 45 + Balance
print(Name, "Your Monthlybill Electric Bill is:", M)
print("Type of Building: Industrial")

Output:

Enter Name of Customer:Clyde


R Residential
C Commercial
I Industrial
Enter Key Character:R
Enter Present Reading:234
Enter Previous Reading:321
Enter Balance:1500
===================================================
Clyde Your Monthlybill Electric Bill is: -240
Type of Building: Residential

Problem:
8. Create a python program that will determine the user input if it is a
negative, positive or a zero.

Solution:

num = int(input("Enter a number: "))


if num > 0:
print("The input is Positive")
elif num == 0:
print("The input is Zero")
else:
print("The input is Negative")
print("----------------------------------")
num = int(input("Enter a number: "))
if num > 0:
print("The input is Positive")
elif num == 0:
print("The input is Zero")
else:
print("The input is Negative")
print("----------------------------------")
num = int(input("Enter a number: "))
if num > 0:
print("The input is Positive")
elif num == 0:
print("The input is Zero")
else:
print("The input is Negative")
print("----------------------------------")

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.

Key Character Rateperday


‘R’ 600.00
‘C’ 350.00
‘P’ 400.00

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:"))

deductions = pagibig + sss + philhealth


grosspay = (working_days * rateperday)+ overtime_pay
netpay = grosspay - deductions
print("===================================================")
print("Name:", name)
print("grossPay:", grosspay)
print("deductions:", deductions)
print("netpay:", netpay)

Output:

Enter the name of the employee: Anna


Enter employee position:Secretary
Enter keycharacter:R
Enter the Pag-IBIG contribution: 200
Enter the SSS contribution: 200
Enter the PhilHealth contribution: 350
Enter the total number of working days: 25
Enter rate per day:15
Enter the overtimepay:1500
===================================================
Name: Anna
grossPay: 1875
deductions: 750
netpay: 1125

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:

Enter your age: 24


You're not 18, 19, or 20

For Loop and While Loop


Problem:

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:

start = int(input("Enter first number: "))


end = int(input("Enter second number: "))

sum_of_numbers = 0

current_number = start
while current_number <= end:
sum_of_numbers += current_number
current_number += 1

print(f"The sum of inputted numbers from {start} to {end} is:


{sum_of_numbers}")

Output:

Enter first number: 10


Enter second number: 50
The sum of inputted numbers from 10 to 50 is: 1230

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:

Welcome to ISU San Mateo


I AM ANNA CARGO
BSIT 1D
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to ISU San Mateo
I AM ANNA CARGO
BSIT 1D
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to ISU San Mateo
I AM ANNA CARGO
BSIT 1D
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to ISU San Mateo
I AM ANNA CARGO
BSIT 1D
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python Function
Problem:
14. Create a python program using function that will compute the area of circle with the formula:
Area = Pi * r2, where Pi = 3.1415.
**Note: Please use a function in solving these problem

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:

Enter the radius of a circle:5


Area of a circle = 78.50

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:

Enter a number: -243


The entered number is negative.

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:

The largest number is 62

You might also like