Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GO-4-UR-GOAL-MQTT-Integrative-Project/Topic functions.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
72 lines (44 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Functions for topics (includes calculations, formulas etc.) | |
def speed (distance, time): | |
speed = distance / time | |
print("You averaged a speed of", speed, "km/h today.") | |
print(speed(3, 1)) | |
def time (distance, speed): | |
time = distance / speed | |
print("It took you", time, "hours to travel", distance, "km today.") | |
print(time(3, 3)) | |
def distance (speed, time): | |
distance = speed * time | |
print("You travelled", distance, "km today.") | |
print(distance(3, 1)) | |
def calories (age, weight, heartrate, time): | |
calories = ((age * 0.2757) + (weight * 0.03295) + (heartrate * 1.0781) - 75.4991) * time / 8.368 | |
print("You burned", round(calories, 1), "kcal during your workout today.") | |
print(calories(18, 165, 120, 120)) | |
class bpm: | |
def __init__(self, age): | |
self.age = age | |
def maxrate(self): | |
max_rate = 220 - self.age | |
return max_rate | |
def rate1_1(self): | |
zone_1_1 = self.maxrate() * 0.50 | |
return zone_1_1 | |
def rate1_2(self): | |
zone_1_2 = self.maxrate() * 0.60 | |
return zone_1_2 | |
def rate1_3(self): | |
zone_1_3 = self.maxrate() * 0.70 | |
return zone_1_3 | |
def rate1_4(self): | |
zone_1_4 = self.maxrate() * 0.80 | |
return zone_1_4 | |
def rate1_5(self): | |
zone_1_5 = self.maxrate() * 0.90 | |
return zone_1_5 | |
ratezones = bpm(18) | |
print(f"Your bpm for the first zone is {round(ratezones.rate1_1(), 1)} to {round(ratezones.rate1_2(), 1)} bpm.") | |
print(f"Your bpm for the second zone is {round(ratezones.rate1_2(), 1)} to {round(ratezones.rate1_3(), 1)} bpm.") | |
print(f"Your bpm for the third zone is {round(ratezones.rate1_3(), 1)} to {round(ratezones.rate1_4(), 1)} bpm.") | |
print(f"Your bpm for the fourth zone is {round(ratezones.rate1_4(), 1)} to {round(ratezones.rate1_5(), 1)} bpm.") | |
print(f"Your bpm for the fifth zone is {round(ratezones.rate1_5(), 1)} to {round(ratezones.maxrate(), 1)} bpm.") |