Advertisement
timber101

Untitled

Apr 22nd, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. #  my code for futurelearn course on programming
  2. #  created 22/04/2019 by CJW
  3. #  variables - usersname - holds the name entered by the user
  4. #               input1 - height entered ( as text)
  5. #               input2 - base entered ( as text)
  6. #               result - input 1 + input 2
  7. #               number1 - integer of input1
  8. #               number2 - integer of input2
  9. #               output - resut as a string
  10. # Purpose - calculates the area of a triangle
  11.  
  12. #  starts
  13. print ("Hi, I'm Esmeralda and am your personal bot")
  14. usersname = input("Whats your name?  " ) # gathers username
  15. print ("Great to see you again, " + usersname + " Lets begin")
  16. print ("Lets work out the area of a triangle")
  17. input1 = input("Please enter height in cm ") # gets height number
  18. input2 = input("Please enter length of base in cm ") # gets base length number
  19. number1 = int(input1) # saves as an integer
  20. number2 = int(input2) # saves as an integer
  21. result = (number1/2) * number2
  22. output = str(result)
  23. print (" Drum roll ....  The area of a triangle with height " + input1 + "cm and base with a length of " + input2 + "cm is " + output + "cm^2")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement