You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromcalculatorimportCalculatorimportmathclassFunctional_calculator(Calculator):
def__init__(self):
super().__init__() #get all of calculator's methodsdefcircle_area(self, r):
returnmath.pi*(r*r) #pi r squareddefsquare_area(self, x):
returnx*x#x squareddeftriangle_area(self, x, h):
return0.5*x*h#half base times height
Age & Permission
classAgeCheck:
age=19drivers_licence=Truedefloop(self):
whileTrue:
self.age=input("Please enter your age: ")
if(self.age.lower() =="exit"):
breakself.drivers_licence=input("Please enter your age: ")
if (self.drivers_licence.lower() =="exit"):
breakif(self.age>=18):
if(self.drivers_licence==True):
print("You can vote and drive")
else:
print("You can vote but can't drive")
elif(16<=self.age<18):
print("You can't legally drink but your mates/uncles might have your back")
else:
if(self.drivers_licence==True):
print("You can't vote but you can drive")
else:
print("You're too young, go back to school!")
foriinrange(10):
print("Hello")
names= []
whileTrue:
name=input("What is your first name? ")
names.append(name.strip().capitalize())
print("Welcome", name.strip().capitalize(), ":)")
response=input("Would you like to enter another name? (y/n) ")
ifresponse.upper() !='Y':
break;
list_names_lower= []
fori, xinenumerate(names):
list_names_lower.append(names[i].lower())
if (len(names[i])%2==0):
print("name "+str(i) +" is even")
else:
print("name "+str(i) +" is odd")
Guess what year you were born
importdatetimenow=datetime.datetime.now()
age=input("type in your age: ")
name=input("type in your name: ")
print("OMG "+name+", you are "+age+" years old so you were born in "+str(now.year-int(age)) + \
" or "+str(now.year-int(age)-1))