add
This commit is contained in:
BIN
23-10/calculator_practica/__pycache__/calc.cpython-313.pyc
Normal file
BIN
23-10/calculator_practica/__pycache__/calc.cpython-313.pyc
Normal file
Binary file not shown.
40
23-10/calculator_practica/calc.py
Normal file
40
23-10/calculator_practica/calc.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
def menu():
|
||||||
|
while True:
|
||||||
|
print(":: Calculator lesson 23-10 ::")
|
||||||
|
a = int(input("(1)-:: "))
|
||||||
|
b = int(input("(2)-:: "))
|
||||||
|
print(":: Menu ::\n" "1::+\t" "2::-\n" "3::-*\t" "4::-/\n" "0::exit\n")
|
||||||
|
oper = int(input("Enter oper :: "))
|
||||||
|
if oper == 0:
|
||||||
|
print(":: exit!")
|
||||||
|
break
|
||||||
|
calc(a,b,oper)
|
||||||
|
|
||||||
|
def calc(num1,num2,ans):
|
||||||
|
result=0
|
||||||
|
def summ():
|
||||||
|
return num1+num2
|
||||||
|
def deff():
|
||||||
|
return num1-num2
|
||||||
|
def diff():
|
||||||
|
if num2 == 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return num1/num2
|
||||||
|
def multi():
|
||||||
|
return num1*num2
|
||||||
|
def printf():
|
||||||
|
print(f"{num1}{ans}{num2}={result}")
|
||||||
|
if ans == 1:
|
||||||
|
ans = "+"
|
||||||
|
result = summ(num1,num2)
|
||||||
|
elif ans == 2:
|
||||||
|
ans = "-"
|
||||||
|
result = deff(num1,num2)
|
||||||
|
elif ans == 4:
|
||||||
|
ans = "/"
|
||||||
|
result = diff(num1,num2)
|
||||||
|
elif ans == 3:
|
||||||
|
ans = "*"
|
||||||
|
result = multi(num1,num2)
|
||||||
|
printf(result,ans)
|
||||||
4
23-10/calculator_practica/main.py
Normal file
4
23-10/calculator_practica/main.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from calc import menu
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
menu()
|
||||||
34
23-10/home_work.py
Normal file
34
23-10/home_work.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
def one_task():
|
||||||
|
print("\n\"Don\'t compare yourself with anyone in this world...if you do so, you are insulting\nyourself.\""
|
||||||
|
"\n\nBill Gates \n")
|
||||||
|
|
||||||
|
def two_task():
|
||||||
|
list_numbers=[]
|
||||||
|
one_num = int(input("1_число :: "))
|
||||||
|
two_num = int(input("2_число :: "))
|
||||||
|
for nums in range(one_num,two_num+1):
|
||||||
|
if nums%2==0:
|
||||||
|
nums.append()
|
||||||
|
print(f"Четные числа: {nums}")
|
||||||
|
|
||||||
|
def tasks(ans):
|
||||||
|
if ans == 1:
|
||||||
|
one_task()
|
||||||
|
if ans == 2:
|
||||||
|
two_task()
|
||||||
|
if ans == 3:
|
||||||
|
thr_task()
|
||||||
|
|
||||||
|
def menu():
|
||||||
|
while True:
|
||||||
|
print("Домашнее задание от 23.10.25\nВыберите номер задания:\n"
|
||||||
|
"::1 формат текст\t" "::2 четн числа\n" "::3 квадрат\t\t"
|
||||||
|
"::0 Выход\n")
|
||||||
|
answer = int(input(":: "))
|
||||||
|
if answer == 0:
|
||||||
|
print(":: exit!")
|
||||||
|
break
|
||||||
|
tasks(answer)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
menu()
|
||||||
Reference in New Issue
Block a user