From aa2911b5e72f7efd6fed4a4d2f1a70f4c56d72d9 Mon Sep 17 00:00:00 2001 From: BloodYce Date: Sun, 8 Sep 2024 11:12:38 +0200 Subject: [PATCH 1/2] solution-m4/001 --- projects/001-taxi-fare/python/main.py | 19 +++++++++++++++++++ .../002-shipping-calculator/python/main.py | 13 +++++++++++++ 2 files changed, 32 insertions(+) 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. +''' + From e8b926ee74e61f078af8e47a1f6f917ef1a8a4c5 Mon Sep 17 00:00:00 2001 From: BloodYce Date: Thu, 10 Oct 2024 23:33:35 +0200 Subject: [PATCH 2/2] solution-m4/014 --- projects/014-magic-dates/python/main.py | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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