Portál AbcLinuxu, 26. července 2025 16:03
g=input('Nasobit [1]:\n Scitat [2]:\n Delit [3]:\n')
Řešení dotazu:
import sys
def scitani(x,y):
m=x+y
print('Vysledne cislo je: %d'%m)
sys.exit()
def nasobeni(x,y):
m=x*y
print('Vysledne cislo je: %d'%m)
sys.exit()
def deleni(x,y):
m=x*y
print('Vysledne cislo je: %d'%m)
sys.exit()
a=input('zadej A:')
b=input('Zadej B:')
if a and b is not None:
try:
a=int(a)
b=int(b)
print('Cisla jsou zadana... good')
print("co chces delat ?\n")
g=input('Nasobit [1]:\n Scitat [2]:\n Delit [3]:\n')
except ValueError as err:
print("Byl zadan retezec!!! Koncim program ...")
sys.exit()
else:
sys.exit()
if g is 1:
nasobeni(a, b)
elif g is 2:
scitani(a, b)
elif g is 2:
deleni (a, b)
==
a is
.
print(g) # 1
print(g is 1) # False
if g == 1:
nasobeni(a, b)
elif g == 2:
scitani(a, b)
elif g == 3:
deleni(a, b)
if g == 1:ale porovnání s řetězcem ano:
if g == "1":
aha, tak to uz jsem opravil, ale stejně to nejde :(Tak tam asi niekde bude bug
if int(g) == 1:
tabulka = {"jedna":1, "dva":2, "tri":3} try: if int(g) == 1: ... except ValueError: if g.lower() in tabulka.keys(): g = tabulka[g.lower()] else: print('nerozumiem')Možno niečo takéto?
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.