Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # my code for futurelearn course on programming
- # created 22/04/2019 by CJW
- # variables - usersname - holds the name entered by the user
- # input1 - height entered ( as text)
- # input2 - base entered ( as text)
- # result - input 1 + input 2
- # number1 - integer of input1
- # number2 - integer of input2
- # output - resut as a string
- # Purpose - calculates the area of a triangle
- # starts
- print ("Hi, I'm Esmeralda and am your personal bot")
- usersname = input("Whats your name? " ) # gathers username
- print ("Great to see you again, " + usersname + " Lets begin")
- print ("Lets work out the area of a triangle")
- input1 = input("Please enter height in cm ") # gets height number
- input2 = input("Please enter length of base in cm ") # gets base length number
- number1 = int(input1) # saves as an integer
- number2 = int(input2) # saves as an integer
- result = (number1/2) * number2
- output = str(result)
- 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