Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions projects/001-taxi-fare/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'''
In a particular jurisdiction, taxi fares consist of:
- base fare of €4.00,
- plus €0.25 for every 140 meters travelled.

Write a function named **taxi fare** that takes the distance travelled (in kilometers) as its only parameter
and returns the total fare as its only result.
Write a main program that demonstrates the function.
'''

def taxi_fare(kilometers):
addedtaxes = kilometers // 140
taxfare = 0.25 * addedtaxes
totalfare = 4.00 + taxfare
return totalfare

kilometers = int(input("Kilometers: "))
totalfare = taxi_fare(kilometers)
print("Total fare = ", totalfare)
13 changes: 13 additions & 0 deletions projects/002-shipping-calculator/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'''
An online retailer provides express shipping for many of its items at a rate of:
- €10.99 for the first item in an order
- €2.99 for each subsequent item in the same order.

Write a function named **shipping calculator** that takes the number of items in the order as its **only parameter**.

Return the shipping charge for the order as the function’s result.

Include a main program that reads the number of items purchased from the user
and displays the shipping charge.
'''

28 changes: 28 additions & 0 deletions projects/014-magic-dates/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'''
A magic date is a date where the day multiplied by the month is equal to the two digit year.

For example, June 10, 1960 is a magic date because June is the sixth month, and 6 times 10 is 60, which is equal to the two digit year.

Write a function named is magic date that determines whether a date is a magic date. Your function will take two parameters:

the day as integer
the month as an integer between 1 and 12
the year as a four digit integer And should return True if the date is a magic date otherwise it should return False.
Use your function to create a main program that finds and displays all the magic dates in the 20th century.
'''

def magic_date(userday, usermonth, useryear):
magicdaymonth = userday * usermonth
trueyear = useryear % 100
if magicdaymonth < 100:
if magicdaymonth == trueyear:
print("The date it's a magic date!")
else:
print("The date it's NOT a magic date!")
else:
print("Error: the sum of the integer inserted ")

userday = int(input("Please insert day of the month as integer: "))
usermonth = int(input("Please insert a month as integer: "))
useryear = int(input("Please insert a year as a 4-digit integer: "))
finalresult = magic_date(userday, usermonth, useryear)