Advertisement
HBSB

Python 101: 2.15 challenge

Dec 25th, 2020
1,855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. print("Hello there.  My name is Marvin and I'm your personal bot.")
  2. user_name=input("What's your name?")
  3. print("Hello " + user_name + " and welcome.")
  4. command = input("What can I help you with?")
  5. if command == "add" or command == "subtract" or command == "multiply" or command == "divide" :
  6.     print("Let's " + command + " some numbers.")
  7.     input1=input("Number1 > ")
  8.     input2=input("Number2 > ")
  9.     number1=int(input1)
  10.     number2=int(input2)
  11.     result=number1+number2
  12.     output=str(result)
  13.     print(input1 + "+" + input2 + "=" + output)
  14.     print("Now we can try a multiplication.")
  15.     input3=input("Number3 > ")
  16.     input4=input("Number4 > ")
  17.     number3=int(input3)
  18.     number4=int(input4)
  19.     result=number3*number4
  20.     output=str(result)
  21.     print(input3 + "*" + input4 + "=" + output)
  22.     print("And now a division.")
  23.     input5=input("Number5 > ")
  24.     input6=input("Number6 > ")
  25.     number5=int(input5)
  26.     number6=int(input6)
  27.     result=number5/number6
  28.     output=str(result)
  29.     print(input5 + "/" + input6 + "=" + output)
  30.     print("Finally let's try finding the area of a rectangle. You will need to give me the lengths of the two different sides.")
  31.     input7=input("Number7 > ")
  32.     input8=input("Number8 > ")
  33.     number7=float(input7)
  34.     number8=float(input8)
  35.     result=number7*number8
  36.     output=str(result)
  37.     print(input7 + "*" + input8 + "=" + output + " sq.m")
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement