Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_input(i):
- if i == "s":
- return True
- elif i == "r":
- return True
- elif i == "c":
- return True
- elif i == "q":
- return True
- elif i > 0:
- return True
- else:
- return False
- def nelioa(s1, s2):
- return s1 * s2
- def nelios(s1, s2):
- return 2 * s1 + 2 * s2
- def nelios2(s):
- return s*4
- def nelioa2(s):
- return s * s
- def ympyra(r):
- import math
- return r * math.pi * 2
- def ympyra_a(r):
- import math
- return math.pi * r * r
- def main():
- i=0
- while str(i) != "q":
- i = str(
- input("Enter the pattern's first letter, q stops this (s/r/q): "))
- while test_input(i) is False:
- print("Incorrect entry, try again!")
- i = input(
- "Enter the pattern's first letter, q stops this (s/r/q): ")
- if i == str("s"):
- sivu1 = float(
- input("Enter the length of the rectangle's side 1: "))
- while test_input(sivu1) is False:
- sivu1 = float(
- input("Enter the length of the rectangle's side 1: "))
- sivu2 = float(
- input("Enter the length of the rectangle's side 2: "))
- while test_input(sivu2) is False:
- sivu2 = float(
- input("Enter the length of the rectangle's side 2: "))
- print("The total circumference is " + str(nelios(sivu1, sivu2)))
- print("The surface area is " + str(nelioa(sivu1, sivu2)))
- if i == "r":
- sqr = float(input("Enter the length of the square's side: "))
- while test_input(sqr) is False:
- sqr = float(input("Enter the length of the square's side: "))
- print("The total circumference is " + str(nelios2(sqr)))
- print("The surface area is " + str(nelioa2(sqr)))
- if i == "c":
- radi = float(input("Enter the circle's radius: "))
- while test_input(radi) is False:
- radi = float(input("Enter the circle's radius: "))
- print("The total circumference is " + str(ympyra(radi)))
- print("The surface area is " + str(ympyra_a(radi)))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement