Advertisement
MstrSparks

Untitled

Oct 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. # FutureLearn Week 1 Bot
  2.  
  3. # The Bot introduces itself and waits for instructions
  4. print("Hi, I am Marvin, your personal bot.")
  5. print("Let's get started....")
  6. users_name = input("Please enter your name: ")
  7.  
  8. # Marvin welcomes the user
  9. print("Welcome " + users_name + "!")
  10.  
  11. # Marvin wants to play with maths.
  12. # The following allows the user to enter two values to be added together
  13. print("I can be your maths bot.")
  14. print("lets add some numbers")
  15. input1 = int(input("Number 1> "))
  16. input2 = int(input("Number 2> "))
  17. result = input1 + input2
  18.  
  19. # The following line uses the str.format() formatting style
  20. # This does not require the data types to be cast
  21. print("The addition of {} + {} gives {}".format(input1, input2, result))
  22.  
  23. # Using str.format() combined with an inline calculation
  24. # The third value used in the str is the result of the subtraction calculation
  25. print("Subtracting the value {} from {} gives a result of {}".format(input1, input2, input2 - input1))
  26.  
  27. print("Lets calculate the area of a square.")
  28. side_of_a_square = float(input("Please enter the length of an edge of your square:"))
  29. print("The area of the square with a side length of {} is {}\n"
  30.       "If you want it as a cube the volume would be {}"
  31.       .format(side_of_a_square, side_of_a_square*side_of_a_square, side_of_a_square**3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement