Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # FutureLearn Week 1 Bot
- # The Bot introduces itself and waits for instructions
- print("Hi, I am Marvin, your personal bot.")
- print("Let's get started....")
- users_name = input("Please enter your name: ")
- # Marvin welcomes the user
- print("Welcome " + users_name + "!")
- # Marvin wants to play with maths.
- # The following allows the user to enter two values to be added together
- print("I can be your maths bot.")
- print("lets add some numbers")
- input1 = int(input("Number 1> "))
- input2 = int(input("Number 2> "))
- result = input1 + input2
- # The following line uses the str.format() formatting style
- # This does not require the data types to be cast
- print("The addition of {} + {} gives {}".format(input1, input2, result))
- # Using str.format() combined with an inline calculation
- # The third value used in the str is the result of the subtraction calculation
- print("Subtracting the value {} from {} gives a result of {}".format(input1, input2, input2 - input1))
- print("Lets calculate the area of a square.")
- side_of_a_square = float(input("Please enter the length of an edge of your square:"))
- print("The area of the square with a side length of {} is {}\n"
- "If you want it as a cube the volume would be {}"
- .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