diff --git a/projects/001-taxi-fare/python/main.py b/projects/001-taxi-fare/python/main.py index e69de29..fdd3204 100644 --- a/projects/001-taxi-fare/python/main.py +++ b/projects/001-taxi-fare/python/main.py @@ -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) \ No newline at end of file diff --git a/projects/002-shipping-calculator/python/main.py b/projects/002-shipping-calculator/python/main.py index e69de29..39f4aa0 100644 --- a/projects/002-shipping-calculator/python/main.py +++ b/projects/002-shipping-calculator/python/main.py @@ -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. +''' + diff --git a/projects/014-magic-dates/python/main.py b/projects/014-magic-dates/python/main.py index e69de29..29a1d84 100644 --- a/projects/014-magic-dates/python/main.py +++ b/projects/014-magic-dates/python/main.py @@ -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) \ No newline at end of file