Challenges 3
Challenges 3
3a). A Gym has membership options that reduce the cost of using the Gym. A gold member pays £5 per hour for instance whereas a Bronze member pays £9 per hour.
Low: Get them to enter their Membership type and the number of hours that they used the gym and then print out the total cost.
Med: do Low and then if they have membership of anything that isn't Gold suggest they upgrade to gold.
High: do Med but also show them how much the gym would have been under gold if they were Silver or Bronze.
3b). Get someone to enter a float number and then:
Low: Print out the square of that number. ** if the symbol for power of. So 4**4 would give 4 to the power of 4.
Med: Do Low and then print out square root of that number.
Example: (Put imports always at top of whole code)
import math
print(math.sqrt(6))
High: Do Med and then print out whether it is odd or even.
Hint: Use %2 to check.
Look here for tips..
3c). Get someone to enter a new password twice (to check for spelling mistakes) then:
Low: Check if both the 2 passwords are a match.
Med: Do Low and also check if the length of the password is at least 8 character. Use the len command to find out the length. If it is printed accepted else print invalid.
High: Do Med and then check if there is at least 1 digit in the password.
The code here checks if the string s has a digit in it. contains_digit will be either True or False after this so use that to see if it contained a digit.
s = "abc1"
contains_digit = any(map(str.isdigit, s))