Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Assignment 4
  2. ---------------------
  3.  
  4. #This program by Colin Dong tells the user information about their name.
  5.  
  6. first_name = input('What is your first name?')
  7. print 'Your first name has', len(first_name), 'letters.'
  8.  
  9. last_name = input('What is your last name?')
  10.  
  11. full_name = first_name + (' ') + last_name
  12. print 'Hello', full_name + ', I hope you\'re having a great day!'
  13.  
  14. print 'The last letter of your name is', full_name[-1:] + '.'
  15.  
  16. print 'The first three letters of your name are:', full_name[:3] + '.'
  17.  
  18.  
  19. Assignment 6
  20. ---------------------
  21. # This hella lit program by Colin Dong shows a few
  22. # examples of functions in python.
  23.  
  24. # This function takes in length, width and height
  25. # and returns the volume of a box
  26. def box_volume(length,width,height):
  27. box_volume = length*width*height
  28. return box_volume
  29.  
  30. print box_volume(3.0, 4.0, 5.0)
  31.  
  32. # This function takes in base and height and returns
  33. #the area of a triangle
  34. def triangle_area(base,height):
  35. triangle_area = base*height/2
  36. return triangle_area
  37.  
  38. print triangle_area(8.0, 5.0)
  39.  
  40. # This function that takes in length, width and height and
  41. #returns the surface area of a box
  42. def box_surface(l,w,h):
  43. box_surface = 2*(w*l+h*l+w*h)
  44. return box_surface
  45.  
  46. print box_surface(3.0, 4.0, 5.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement