Advertisement
DrAungWinHtut

fun1.py

Feb 27th, 2023
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. def greeting(name):
  2.     print("Hello " + name)
  3.     print()
  4.     print()
  5.  
  6.  
  7. def area(l, w):
  8.     a = l * w
  9.     print('area = ', a)
  10.     print()
  11.     print()
  12.  
  13.  
  14. def tempF2C(tf):
  15.     tc = ((5/9)*tf) - 32
  16.     print('tc = ', tc)
  17.     print()
  18.     print()
  19.  
  20.  
  21. def square(n):
  22.     return n*n
  23.  
  24.  
  25. def menu():
  26.     while True:
  27.         print('Menu')
  28.         print('=====')
  29.         print('1-calculate area: ')
  30.         print('2-calculate temperature: ')
  31.         print('3-calculate square: ')
  32.         print('0-Exit')
  33.         print()
  34.  
  35.         ans = input('Please choose (0,1,2,3): ')
  36.         if (ans == '1'):
  37.             l = eval(input('Please enter L: '))
  38.             w = eval(input('Please enter W: '))
  39.             area(l, w)
  40.  
  41.         elif (ans == '2'):
  42.             tf = eval(input('Please enter tf: '))
  43.             tempF2C(tf)
  44.  
  45.         elif (ans == '3'):
  46.             n = eval(input('Please enter n: '))
  47.             s = square(n)
  48.             print('square = ', s)
  49.             print()
  50.             print()
  51.  
  52.         elif (ans == '0'):
  53.             exit()
  54.  
  55.  
  56. # Program Start here!
  57. name = input('What is your name: ')
  58. greeting(name)
  59. menu()
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement