Advertisement
lubattillah

operations challenge

May 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. print("Let's do some maths")
  2. a=int(input("enter number1: "))
  3. b=int(input("enter number2: "))
  4. command=input("choose operation: ")
  5. if command=="+":
  6. result=a+b
  7. print(a, "+" ,b, "=",result)
  8. elif command=="-":
  9. result=a-b
  10. print(a, "-" ,b, "=",result)
  11. elif command=="*":
  12. result=a*b
  13. print(a, "*" ,b, "=",result)
  14. elif command=="/":
  15. result=a/b
  16. print(a, "/" ,b, "=",result)
  17. elif command=="%":
  18. result=a%b
  19. print(a, "%" ,b, "=",result)
  20. else:
  21. print("Sorry I dont understand what is this kind of operation")
  22. """
  23. Here is another problem for computing an area of a triangle(assuming measurements are in cm)
  24. and shows how much my weekly shopping costs.
  25. """
  26. #Area of a triangle
  27. area=0.5*a*b
  28. print("Area of triangle is: ",area, "cm sq")
  29.  
  30. #Shopping in $
  31. clothing=int(input("cost for clothes: "))
  32. stationery=int(input("cost for stationery: "))
  33. food=int(input("cost for food: "))
  34. shoes=int(input("cost for shoes: "))
  35. sum=clothing + stationery + food + shoes
  36. print("My Weekly Shopping Cost was: $",sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement