My Game
Press the Button to Download
Challenge
CS First : Art
Activity 1
|
Activity 2
|
Activity 3
|
Activity 4
|
Activity 5
|
Activity 6
|
Activity 7
|
Activity 8
|
Math Function Code
# -*- coding: utf-8 -*-
def main():
print "**********************************************"
print "* Welcome to Our Class's Python Project *"
print "* *"
print "* Our program was created to assist anyone *"
print "* who needed help with calculating perimeter,*"
print "* area, surface area, and volume. *"
print
print "Please make a selection from the following list"
print "Type 1 for Perimeter, 2 for Area, 3 for Surface Area, 4 for Volume"
print
s=input("Please enter here: ")
if s==1:
per()
elif s==2:
area()
elif s==3:
surface_area()
elif s==4:
vol()
else:
print "Sorry. I didn't get that."
def area_cir():
a =input("Put 1 for diameter, or 2 for radius?")
if a ==1:
d=input("What is your diameter?")
print " The area of your of your circle is...",d/.2**2*3.14
else:
r=input("What is your radius?")
print "The area of your circle is...",r**2*3.1
def area_sqr():
s=input("What is the length of your square?")
print " The area of your square is",s**2
def area_tri():
a =input ("What is the length of your triangle?")
b =input (" What is the width of your triangle?")
print " The area of your triangle is", a*b/2
def area_trap():
a=input ("what is the length of the top base?")
b=input ("what is the length of the bottom base?")
h=input ("what is the length of the height?")
print "the area of your trapezoid is",0.5*(a+b)*h
def area_rec():
a=input("What is the length of your rectangle")
b=input("What is is the width of your rectangle")
print "the area of your rectangle is", a*b
def area_plg():
s=input("What is the length of your parallelagram?")
l=input("What is your height?")
print "The area of your parallelagram is",s*l
def area():
k=input("Put 1 for circle, 2 for square, 3 for triangle, 4 for trapizoid, 5 for rectangle, and 6 for parallelagram")
if k==1:
area_cir()
elif k==2:
area_sqr()
elif k==3:
area_tri()
elif k==4:
area_trap()
elif k==5:
area_rec()
elif k==6:
area_plg()
else:
print "Invalid Number"
area()
def sphere():
r = input("What is the radius?")
print "The volume is", r ** 3 * 3.14 * 4/3
vol()
def triangular_prism():
l=input("what is the length?")
w=input("what is the width?")
h=input("what is the height?")
print "The volume is,", l*w*h/2.0
vol()
def cone ():
r = input ("what is the radius?")
h = input ("what is the hieght?")
print "the volume is", r**2*3.14*(h/3)
vol()
def cylinder():
h=input("What is the height?")
r=input("What is the radius?")
print "The volume is",r**2*3.14*h
vol()
def rectangular_prism():
h = input("Name Your Height")
w = input("Name Your Width")
l = input("Name Your Length")
print "The Volume is,", h*w*l
vol()
def pyramid():
l=input("What is the length?")
w=input("What is the width")
h=input("What is the height?")
print
print "The volume is... ", (l*w*h)/3.
quit()
def vol():
z=input("What shape would you like? Rectangular Prism=1,Triangular Prism=2,Cone=3,Cylinder=4,Sphere=5, pyramid=6")
if z==1:
rectangular_prism()
if z==2:
triangular_prism()
if z==3:
cone()
if z==4:
cylinder()
if z==5:
sphere()
if z==6:
pyramid()
def surface_area():
print"1 for cube, 2 for square pyramid, 3 for rectangular prism, 4 for cylinder, 5 for sphere, 6 for cone, 7 for equilateral tetrahetdron"
c=input("Which formula would you like to use? ")
if c==1:
sa_cube()
elif c==2:
sa_square_pyramid()
elif c==3:
sa_rectangular_prism()
elif c==4:
sa_cylinder()
elif c==5:
sa_sphere()
elif c==6:
sa_cone()
elif c==7:
sa_equal_tetrah()
else:
print"I don't understand. Please choose again from the list."
surface_area()
def sa_cube():
s=input("Enter the length of the side; ")
print "The surface area of the cube is",(s**2)*6
def sa_square_pyramid():
b=input("Enter The Base: ")
h=input("Enter The Height: ")
print "The surface area of the pyramid is", b*h/2*4+b*b
def sa_rectangular_prism():
l=input("Enter the length: ")
w=input("Enter the width: ")
h=input("Enter the height: ")
print"The surface area of the rectangular prism is", l*w*2+h*w*2+l*h*2
def sa_cylinder():
r=input(" Enter the radius: ")
h=input("Enter the height: ")
print"The surface area of your cylinder is", r**2*3.14*2+r*2*3.14*h
def sa_sphere():
r=input("Enter the radius: ")
print"The Surface Area Of Your Sphere Is", r**2*3.14*2
def sa_cone():
r=input("Enter The Radius: ")
h=input("Enter the height: ")
print"The Surface Area Of The Cone is" , r**2*3.14+3.14*r*h+3.14*r**2
def sa_equal_tetrah():
l=input("Enter The Length: ")
print"The Surface Area Of Your Equilateral Tetrahedron is" , l*l**2/3
# -*- coding: utf-8 -*-
def per():
q=input("What shape would you like? circle=1 triangle=2 square=3 rectangle=4 trapezoid=5 parallelogram=6")
if q==1:
per_circle()
elif q==2:
per_triangle()
elif q==3:
per_sqr()
elif q==4:
per_rectangle()
elif q==5:
per_trapezoid()
elif q==6:
per_parellelogram()
else:
print "Sorry,I didn't get that"
def per_sqr():
S= input("what is the length of a side? ")
print ("your square perimeter is",S*4)
def per_circle():
C = input ("Would you like to use radius or diameter? 1 for radius,2 for diameter")
if (C==1):
r = input ("What is the radius of the circle?")
print("Your perimeter of the circle is",3.14*r*2)
if (C==2):
d = input ("What is the diameter of the circle?")
print("Your perimeter of the circle is",3.14*d)
def per_triangle():
a=input("How long is your first side? ")
b=input("How long is your second side? ")
c=input("How long is your last side? ")
print("Your triangle's perimeter is",a+b+c)
def per_parellelogram():
q=input("what is the length of one of the sides, that is also equivalent to another side? ")
p=input ("what is the length of one of the other sides that are also equivalent to another side? ")
print (" Your parallelogram’s perimeter is", (q+q)+(p+p) )
def per_rectangle():
d=input ("What is the length of one side?")
g=input ("What is the height of the otherside?")
print("Your rectangle's perimeter is",(d+g)*2)
def per_trapezoid( ):
j=input("What is the length of your first side?")
m=input("What is the length of your second side?")
g=input("What is the length of your third side?")
e=input("What is the length of your fourth side?")
print("Your trapezoid's perimeter is",j+m+g+e)
def main():
print "**********************************************"
print "* Welcome to Our Class's Python Project *"
print "* *"
print "* Our program was created to assist anyone *"
print "* who needed help with calculating perimeter,*"
print "* area, surface area, and volume. *"
print "Please make a selection from the following list"
print "Type 1 for Perimeter, 2 for Area, 3 for Surface Area, 4 for Volume"
s=input("Please enter here: ")
if s==1:
per()
elif s==2:
area()
elif s==3:
surface_area()
elif s==4:
vol()
else:
print "Sorry. I didn't get that."
def area_cir():
a =input("Put 1 for diameter, or 2 for radius?")
if a ==1:
d=input("What is your diameter?")
print " The area of your of your circle is...",d/.2**2*3.14
else:
r=input("What is your radius?")
print "The area of your circle is...",r**2*3.1
def area_sqr():
s=input("What is the length of your square?")
print " The area of your square is",s**2
def area_tri():
a =input ("What is the length of your triangle?")
b =input (" What is the width of your triangle?")
print " The area of your triangle is", a*b/2
def area_trap():
a=input ("what is the length of the top base?")
b=input ("what is the length of the bottom base?")
h=input ("what is the length of the height?")
print "the area of your trapezoid is",0.5*(a+b)*h
def area_rec():
a=input("What is the length of your rectangle")
b=input("What is is the width of your rectangle")
print "the area of your rectangle is", a*b
def area_plg():
s=input("What is the length of your parallelagram?")
l=input("What is your height?")
print "The area of your parallelagram is",s*l
def area():
k=input("Put 1 for circle, 2 for square, 3 for triangle, 4 for trapizoid, 5 for rectangle, and 6 for parallelagram")
if k==1:
area_cir()
elif k==2:
area_sqr()
elif k==3:
area_tri()
elif k==4:
area_trap()
elif k==5:
area_rec()
elif k==6:
area_plg()
else:
print "Invalid Number"
area()
def sphere():
r = input("What is the radius?")
print "The volume is", r ** 3 * 3.14 * 4/3
vol()
def triangular_prism():
l=input("what is the length?")
w=input("what is the width?")
h=input("what is the height?")
print "The volume is,", l*w*h/2.0
vol()
def cone ():
r = input ("what is the radius?")
h = input ("what is the hieght?")
print "the volume is", r**2*3.14*(h/3)
vol()
def cylinder():
h=input("What is the height?")
r=input("What is the radius?")
print "The volume is",r**2*3.14*h
vol()
def rectangular_prism():
h = input("Name Your Height")
w = input("Name Your Width")
l = input("Name Your Length")
print "The Volume is,", h*w*l
vol()
def pyramid():
l=input("What is the length?")
w=input("What is the width")
h=input("What is the height?")
print "The volume is... ", (l*w*h)/3.
quit()
def vol():
z=input("What shape would you like? Rectangular Prism=1,Triangular Prism=2,Cone=3,Cylinder=4,Sphere=5, pyramid=6")
if z==1:
rectangular_prism()
if z==2:
triangular_prism()
if z==3:
cone()
if z==4:
cylinder()
if z==5:
sphere()
if z==6:
pyramid()
def surface_area():
print"1 for cube, 2 for square pyramid, 3 for rectangular prism, 4 for cylinder, 5 for sphere, 6 for cone, 7 for equilateral tetrahetdron"
c=input("Which formula would you like to use? ")
if c==1:
sa_cube()
elif c==2:
sa_square_pyramid()
elif c==3:
sa_rectangular_prism()
elif c==4:
sa_cylinder()
elif c==5:
sa_sphere()
elif c==6:
sa_cone()
elif c==7:
sa_equal_tetrah()
else:
print"I don't understand. Please choose again from the list."
surface_area()
def sa_cube():
s=input("Enter the length of the side; ")
print "The surface area of the cube is",(s**2)*6
def sa_square_pyramid():
b=input("Enter The Base: ")
h=input("Enter The Height: ")
print "The surface area of the pyramid is", b*h/2*4+b*b
def sa_rectangular_prism():
l=input("Enter the length: ")
w=input("Enter the width: ")
h=input("Enter the height: ")
print"The surface area of the rectangular prism is", l*w*2+h*w*2+l*h*2
def sa_cylinder():
r=input(" Enter the radius: ")
h=input("Enter the height: ")
print"The surface area of your cylinder is", r**2*3.14*2+r*2*3.14*h
def sa_sphere():
r=input("Enter the radius: ")
print"The Surface Area Of Your Sphere Is", r**2*3.14*2
def sa_cone():
r=input("Enter The Radius: ")
h=input("Enter the height: ")
print"The Surface Area Of The Cone is" , r**2*3.14+3.14*r*h+3.14*r**2
def sa_equal_tetrah():
l=input("Enter The Length: ")
print"The Surface Area Of Your Equilateral Tetrahedron is" , l*l**2/3
# -*- coding: utf-8 -*-
def per():
q=input("What shape would you like? circle=1 triangle=2 square=3 rectangle=4 trapezoid=5 parallelogram=6")
if q==1:
per_circle()
elif q==2:
per_triangle()
elif q==3:
per_sqr()
elif q==4:
per_rectangle()
elif q==5:
per_trapezoid()
elif q==6:
per_parellelogram()
else:
print "Sorry,I didn't get that"
def per_sqr():
S= input("what is the length of a side? ")
print ("your square perimeter is",S*4)
def per_circle():
C = input ("Would you like to use radius or diameter? 1 for radius,2 for diameter")
if (C==1):
r = input ("What is the radius of the circle?")
print("Your perimeter of the circle is",3.14*r*2)
if (C==2):
d = input ("What is the diameter of the circle?")
print("Your perimeter of the circle is",3.14*d)
def per_triangle():
a=input("How long is your first side? ")
b=input("How long is your second side? ")
c=input("How long is your last side? ")
print("Your triangle's perimeter is",a+b+c)
def per_parellelogram():
q=input("what is the length of one of the sides, that is also equivalent to another side? ")
p=input ("what is the length of one of the other sides that are also equivalent to another side? ")
print (" Your parallelogram’s perimeter is", (q+q)+(p+p) )
def per_rectangle():
d=input ("What is the length of one side?")
g=input ("What is the height of the otherside?")
print("Your rectangle's perimeter is",(d+g)*2)
def per_trapezoid( ):
j=input("What is the length of your first side?")
m=input("What is the length of your second side?")
g=input("What is the length of your third side?")
e=input("What is the length of your fourth side?")
print("Your trapezoid's perimeter is",j+m+g+e)