Professional Documents
Culture Documents
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 following:
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
totalrent = monthlyrate * 10
print("The total rent for the whole school year is:", totalrent)
totalprepayment = totalmonthlycontribution * 10
print("The total prepayment for the whole school year is:", totalprepayment)
T-CPET121LA
Introduction to Computational Thinking
De La Salle University - Dasmariñas 2
CEAT – Engineering Department
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
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)
num1 = float(input("first number: "))
num2 = float(input("second number: "))
operator = input("operator? (ADD, SUB, MUL, DIV): ")
if operator == "ADD":
result = num1 + num2
elif operator == "SUB":
result = num1 - num2
elif operator == "MUL": T-CPET121LA
result = num1 * num2 Introduction to Computational Thinking
elif operator == "DIV":
if num2 == 0:
print("ERROR: Cannot divide by zero")
De La Salle University - Dasmariñas 3
CEAT – Engineering Department
4. The fuel tank capacity of Car A is 20L, Car B is 30L and Car C is 35L. Your script will ask for an input price per
liter
pricediesel = float(input("Enter price per liter of diesel: "))
of
priceunleaded = float(input("Enter price per liter of unleaded: "))
tanka = 20
tankb = 30
tankc = 35
diesel and unleaded; and display how much is needed of each car for a full tank, both for diesel and unleaded.
5. Input three numbers, display the LARGEST number among the three.
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 ‘and’ If both operands is true then its true if not then its false
OR ‘or’ The operator needs at least 1 true to be true otherwise its false
NOT ‘not’ If operand is true the its false and vice versa
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
T-CPET121LA
Introduction to Computational Thinking