Created
July 14, 2016 17:38
-
-
Save uroybd/e20d1e1c4a8c01ca55761f004ac3915d to your computer and use it in GitHub Desktop.
URI 1118 python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_input(): | |
inp = float(input()) | |
if inp > 10 or inp < 0: | |
print("nota invalida") | |
return get_input() | |
else: | |
return inp | |
def calculate(): | |
a = get_input() | |
b = get_input() | |
return (a + b)/2 | |
def redo(): | |
X = float(input()) | |
print("novo calculo (1-sim 2-nao)") | |
if X < 1 or X > 2: | |
print("novo calculo (1-sim 2-nao)") | |
redo() | |
elif int(X) == 2: | |
return False | |
elif int(X) == 1: | |
return True | |
while True: | |
print("media = " + str(calculate())) | |
x = redo() | |
if not x: | |
break |
my code faced with run time error? can you please explain why it's happen my code is given below :
n = 0
c= 0
while 1:
x = float(input())
if(x >= 0 and x<=10.0):
n += 1
c += x
if n == 2:
print("media = %.2f"%(c/2))
n = 0
c = 0
temp = int(input("novo calculo (1-sim 2-nao)"))
if temp == 2:
break
elif temp == 1:
continue
else:
temp = int(input("novo calculo (1-sim 2-nao)"))else: print("nota invalida")
Your indentation is broke. Can you please fix it so that I can read it properly? Also, be more elaborate. What are you trying to achieve? And what sort of error you're getting?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my code faced with run time error? can you please explain why it's happen my code is given below :
n = 0
c= 0
while 1:
x = float(input())
if(x >= 0 and x<=10.0):
n += 1
c += x
if n == 2:
print("media = %.2f"%(c/2))
n = 0
c = 0
temp = int(input("novo calculo (1-sim 2-nao)"))
if temp == 2:
break
elif temp == 1:
continue
else:
temp = int(input("novo calculo (1-sim 2-nao)"))