Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.24 KB | None | 0 0
  1. def test_input(i):
  2.     if i == "s":
  3.         return True
  4.     elif i == "r":
  5.         return True
  6.     elif i == "c":
  7.         return True
  8.     elif i == "q":
  9.         return True
  10.     elif i > 0:
  11.         return True
  12.  
  13.     else:
  14.         return False
  15.  
  16.  
  17. def nelioa(s1, s2):
  18.     return s1 * s2
  19.  
  20.  
  21. def nelios(s1, s2):
  22.     return 2 * s1 + 2 * s2
  23.  
  24.  
  25. def nelios2(s):
  26.     return s*4
  27.  
  28.  
  29. def nelioa2(s):
  30.     return s * s
  31.  
  32.  
  33. def ympyra(r):
  34.     import math
  35.     return r * math.pi * 2
  36.  
  37.  
  38. def ympyra_a(r):
  39.     import math
  40.     return math.pi * r * r
  41.  
  42.  
  43. def main():
  44.     i=0
  45.     while str(i) != "q":
  46.         i = str(
  47.             input("Enter the pattern's first letter, q stops this (s/r/q): "))
  48.         while test_input(i) is False:
  49.             print("Incorrect entry, try again!")
  50.             i = input(
  51.                 "Enter the pattern's first letter, q stops this (s/r/q): ")
  52.  
  53.         if i == str("s"):
  54.             sivu1 = float(
  55.                 input("Enter the length of the rectangle's side 1: "))
  56.             while test_input(sivu1) is False:
  57.                 sivu1 = float(
  58.                     input("Enter the length of the rectangle's side 1: "))
  59.             sivu2 = float(
  60.                 input("Enter the length of the rectangle's side 2: "))
  61.             while test_input(sivu2) is False:
  62.                 sivu2 = float(
  63.                     input("Enter the length of the rectangle's side 2: "))
  64.             print("The total circumference is " + str(nelios(sivu1, sivu2)))
  65.  
  66.             print("The surface area is " + str(nelioa(sivu1, sivu2)))
  67.         if i == "r":
  68.             sqr = float(input("Enter the length of the square's side: "))
  69.             while test_input(sqr) is False:
  70.                 sqr = float(input("Enter the length of the square's side: "))
  71.             print("The total circumference is " + str(nelios2(sqr)))
  72.             print("The surface area is " + str(nelioa2(sqr)))
  73.         if i == "c":
  74.             radi = float(input("Enter the circle's radius: "))
  75.             while test_input(radi) is False:
  76.                 radi = float(input("Enter the circle's radius: "))
  77.             print("The total circumference is " + str(ympyra(radi)))
  78.             print("The surface area is " + str(ympyra_a(radi)))
  79.  
  80.  
  81. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement