You are on page 1of 5

De La Salle University - Dasmariñas 1

CEAT – Engineering Department

T-CPET121LA – Introduction to Computational Thinking


PROBLEM SETS A
Name: Yuan Patrick R. Casurao_______________________________________
Year and Section: CPE11_________________ Date: _3/22/23_______________Rating:

INSTRUCTION: Upload this document (as PDF file) with your python code and output screenhot as your answer.

1. Andrew, Andrei and Andres are engineering classmates looking for a dormitory to stay for the coming school year.
They will share the monthly payment for the dormitory according to their agreement. This is their agreement.
Andrew will pay 40%, Andrei will pay 35% while Andres will pay the remaining balance. Create a program that will
ask for the monthly rate of the dormitory, and will display the follo wing:
a. How much is the total monthly contribution of Andrew, Andrei and Andres.
b. How much is the total rent in the dormitory for the whole school year, assuming it will last for 10 months
c. How much will Andrew, Andrei and Andres prepare for the whole school year

x = int(input("Please input the monthly rate:")) Paste program output screenshot here*

print("Andrew:", x*0.40, "\nAndrei:", x*0.35,


"\nAndres:", x*(1-0.35-0.40))
print("\nThe yearly rate is", x*10)
print("\nAndrew:", (x*10)*0.40,
"\nAndrei:", (x*10)*0.35,
"\nAndres:", (x*10)*(1-0.35-0.40))

2. Create a python script for a simple cashier system that will satisfy the following conditions.
a. Input the price of three items the customer bought in a department store, as well as the customer’s
payment.
b. A customer will have a 20% discount if the total amount rendered is greater than 5000php.
c. Get the tax of 10% from the discounted price
d. If the payment is insufficient, display “Insufficient Funds”
e. If the payment is exact amount, display “Thank you for giving an exact amount”
f. Display the change of the transaction

T-CPET121LA
Introduction to Computational Thinking
De La Salle University - Dasmariñas 2
CEAT – Engineering Department

x = int(input("Input the cost of the first item: "))


y = int(input("Input the cost of the second item: "))
z = int(input("Input the cost of the third item: "))
pay = int(input("Input your payment: "))
price = x+y+z
tax = int
if price>5000:
price = price-(price*0.20)
print("You are eligible for the discount! Your new price is", price)
tax = price*.1
Nprice = tax+price
print("10% tax:", tax, "Your new price is", Nprice)
if pay < Nprice:
print("Insufficient Funds")
elif pay == Nprice:
print("Thank you for giving an exact amount")
else:
print("Your change is", pay-Nprice)
else:
if pay < price:
print("Insufficient Payment")
elif pay == price:
print("Thank you for giving an exact amount")
else:
print("Your change is", pay-price)

T-CPET121LA
Introduction to Computational Thinking
De La Salle University - Dasmariñas 3
CEAT – Engineering Department

3. Create a simple calculator. Your python script will require you to input two numbers and the keyword that
corresponds to the arithmetic operator to be performed, and then display the result. The following below are the
keyword with the operators to be used. Display “ERROR” if the user input wrong operator.
ADD – Addition SUB – Subtraction
MUL – Multiplication DIV – Division (show separately the remainder)
x =int(input("Input the first number: "))
y = int(input("Input the second number: "))
action = str(input("Input an operation:\nADD = Adddition\nSUB = Subtraction\nMUL =
Multiplication\nDIV = Division\n: "))
if action == "ADD":
print("SUM:", x+y)
elif action == "SUB":
print("DIFFERENCE:", x-y)
elif action == "MUL":
print("PRODUCT:", x*y)
elif action == "DIV":
print("QUOTIENT:", x//y, "REMAINDER", x%y)
else:
print("Invalid")

4. The fuel tank capacity of CarA is 20L, CarB is 30L and CarC is 35L. Your script will ask for an input price per liter
of diesel and unleaded; and display how much is needed of each car for a full tank, both for diesel and unleaded.

T-CPET121LA
Introduction to Computational Thinking
De La Salle University - Dasmariñas 4
CEAT – Engineering Department

x = int(input("Input the diesel price per liter: "))


y = int(input("Input the unleaded price per liter: "))
print("Car A needs", x*20, "Pesos for Diesel and", y*20, "Pesos for Unleaded")
print("Car B needs", x*30, "Pesos for Diesel and", y*30, "Pesos for Unleaded")
print("Car C needs", x*35, "Pesos for Diese l and", y*35, "Pesos for Unleaded")

5. Input three numbers, display the LARGEST number among the three.
x = int(input("Input the first number: "))
y = int(input("Input the second number: "))
z = int(input("Input the third number: "))
if (x>y):
if(x>z):
print("The largest number among the three is: ", x)
else:
print("The largest number among the three is:", z)
else:
if(y>z):
print("The largest number among the three is:", y)
else:
print("The largest number among the three is:", z)

6. Search on available resources regarding Python Logical Operators/Compound Statements. Complete the table
below.
Logical Explain how does this logical operator works. When will it return a
Symbol
Operator TRUE?

AND && Returns TRUE if both statements are TRUE


OR || Returns TRUE if one of the statements is TRUE
NOT ! Returns FALSE if the result is TRUE

7. Input three numbers, display the LARGEST number among the three. (Use Logical Operator)

T-CPET121LA
Introduction to Computational Thinking
De La Salle University - Dasmariñas 5
CEAT – Engineering Department

x = int(input("Input the first number: "))


y = int(input("Input the second number: "))
z = int(input("Input the third number: "))
if x>y and x>z:
print("The largest number among the three is", x)
elif y>x and y>z:
print("The largest number among the three is", y)
else:
print("The largest number among the three is", z)

T-CPET121LA
Introduction to Computational Thinking

You might also like