From 17726882bf638eaa4452a1acfef36618ff2e2df9 Mon Sep 17 00:00:00 2001 From: yunusemre000 Date: Thu, 9 Feb 2023 12:35:30 +0100 Subject: [PATCH] week4 week 4 --- Numbered letters.txt | 52 +++++++++++++++++++++++++++++++++++++ Q4calculator/CALCULATOR.py | 48 ++++++++++++++++++++++++++++++++++ Q4calculator/add.py | 5 ++++ Q4calculator/division.py | 6 +++++ Q4calculator/multiply.py | 5 ++++ Q4calculator/subtraction.py | 6 +++++ deneme.py | 10 +++++++ q1.py | 5 ++++ q2.py | 6 +++++ q3LCM.py | 12 +++++++++ 10 files changed, 155 insertions(+) create mode 100644 Numbered letters.txt create mode 100644 Q4calculator/CALCULATOR.py create mode 100644 Q4calculator/add.py create mode 100644 Q4calculator/division.py create mode 100644 Q4calculator/multiply.py create mode 100644 Q4calculator/subtraction.py create mode 100644 deneme.py create mode 100644 q1.py create mode 100644 q2.py create mode 100644 q3LCM.py diff --git a/Numbered letters.txt b/Numbered letters.txt new file mode 100644 index 0000000..fdac389 --- /dev/null +++ b/Numbered letters.txt @@ -0,0 +1,52 @@ +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 h +9 i +10 j +11 k +12 l +13 m +14 n +15 o +16 p +17 q +18 r +19 s +20 t +21 u +22 v +23 w +24 x +25 y +26 z +27 A +28 B +29 C +30 D +31 E +32 F +33 G +34 H +35 I +36 J +37 K +38 L +39 M +40 N +41 O +42 P +43 Q +44 R +45 S +46 T +47 U +48 V +49 W +50 X +51 Y +52 Z diff --git a/Q4calculator/CALCULATOR.py b/Q4calculator/CALCULATOR.py new file mode 100644 index 0000000..77bdad7 --- /dev/null +++ b/Q4calculator/CALCULATOR.py @@ -0,0 +1,48 @@ +import math +from division import division +from add import add +from subtraction import sub +from multiply import multiply +operations = { + '/': division, + '+': add, + '-': sub, + '*': multiply +} + +#operation=input('Which operation do you want to use?Choose one of +,-,*,/') +while True: + try: + user_choosen_option=input('Which operation do you want to use?Choose one of +,-,*,/') + assert user_choosen_option=="+"or user_choosen_option=="-" or user_choosen_option=="*" or user_choosen_option=="/" + break + except: + print("Please choose correct operation") + + +while 1: + try: + number1=float(input("Enter first number")) + number2=float(input("Enter second number")) + assert type(number1)==float and type(number2)==float + break + except: + print("Please enter only numbers") + +if user_choosen_option == '+': + print("result: ", add(number1, number2)) + +elif user_choosen_option == '-': + print("result: ", sub(number1, number2)) + +elif user_choosen_option == '*': + print("result: ", multiply(number1, number2)) + +elif user_choosen_option == '/': + print("result: ", division(number1, number2)) + + + + + + \ No newline at end of file diff --git a/Q4calculator/add.py b/Q4calculator/add.py new file mode 100644 index 0000000..9eec199 --- /dev/null +++ b/Q4calculator/add.py @@ -0,0 +1,5 @@ +import math +def add(num1,num2): + sum=num1+num2 + return math.ceil(sum) + diff --git a/Q4calculator/division.py b/Q4calculator/division.py new file mode 100644 index 0000000..428c951 --- /dev/null +++ b/Q4calculator/division.py @@ -0,0 +1,6 @@ +import math +def division(num1,num2): + div=num1/num2 + return math.ceil(div) + +print(division(100,98)) diff --git a/Q4calculator/multiply.py b/Q4calculator/multiply.py new file mode 100644 index 0000000..5471766 --- /dev/null +++ b/Q4calculator/multiply.py @@ -0,0 +1,5 @@ +import math +def multiply(num1,num2): + mul=num1*num2 + return math.ceil(mul) + diff --git a/Q4calculator/subtraction.py b/Q4calculator/subtraction.py new file mode 100644 index 0000000..fe93584 --- /dev/null +++ b/Q4calculator/subtraction.py @@ -0,0 +1,6 @@ +import math + +def sub(num1,num2): + sub=num1-num2 + return math.ceil(sub) + diff --git a/deneme.py b/deneme.py new file mode 100644 index 0000000..505c5ac --- /dev/null +++ b/deneme.py @@ -0,0 +1,10 @@ +import string +index = 1 + + +def numbered_letters(): +with open("alphabet.txt", "w") as f: + for value in string.ascii_letters: + f.write(f'{index} {value}\n') + index += 1 + diff --git a/q1.py b/q1.py new file mode 100644 index 0000000..32054be --- /dev/null +++ b/q1.py @@ -0,0 +1,5 @@ +import string + +with open("Numbered letters.txt", 'w', encoding='utf-8') as f: + for i, letter in enumerate(string.ascii_letters, 1): + f.write(f'{i}\t{letter}\n') \ No newline at end of file diff --git a/q2.py b/q2.py new file mode 100644 index 0000000..245cb57 --- /dev/null +++ b/q2.py @@ -0,0 +1,6 @@ +import string + + +for i in string.ascii_uppercase: + with open(f'{i}.txt', 'x'): + pass \ No newline at end of file diff --git a/q3LCM.py b/q3LCM.py new file mode 100644 index 0000000..b163746 --- /dev/null +++ b/q3LCM.py @@ -0,0 +1,12 @@ + +while True: + try: + num1,num2,num3,num4=[int(input('Enter an integer')) for i in range(4)] + i=1 + while True: + i+=1 + if i%num1==0 and i%num2==0 and i%num3==0 and i%num4==0: + print(i) + break + except: + print("Invalid input. Please enter integer numbers.") \ No newline at end of file