Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Assignment 4
- ---------------------
- #This program by Colin Dong tells the user information about their name.
- first_name = input('What is your first name?')
- print 'Your first name has', len(first_name), 'letters.'
- last_name = input('What is your last name?')
- full_name = first_name + (' ') + last_name
- print 'Hello', full_name + ', I hope you\'re having a great day!'
- print 'The last letter of your name is', full_name[-1:] + '.'
- print 'The first three letters of your name are:', full_name[:3] + '.'
- Assignment 6
- ---------------------
- # This hella lit program by Colin Dong shows a few
- # examples of functions in python.
- # This function takes in length, width and height
- # and returns the volume of a box
- def box_volume(length,width,height):
- box_volume = length*width*height
- return box_volume
- print box_volume(3.0, 4.0, 5.0)
- # This function takes in base and height and returns
- #the area of a triangle
- def triangle_area(base,height):
- triangle_area = base*height/2
- return triangle_area
- print triangle_area(8.0, 5.0)
- # This function that takes in length, width and height and
- #returns the surface area of a box
- def box_surface(l,w,h):
- box_surface = 2*(w*l+h*l+w*h)
- return box_surface
- print box_surface(3.0, 4.0, 5.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement