From 765ae17beb78c9d7549d5f48fcaec07e446c0e55 Mon Sep 17 00:00:00 2001 From: Mohammad_Falah Date: Mon, 6 Feb 2023 20:06:01 +0100 Subject: [PATCH] Class8_Week4_File_I_O_Exception_Handling_Mohammad_Falah --- Assignment_3.py | 20 +++++++ file_for_the_first_assignment/Assignment_1.py | 9 ++++ .../English_letter.txt | 26 +++++++++ file_for_the_second_assignment/A.txt | 0 .../Assignment_2.py | 5 ++ file_for_the_second_assignment/B.txt | 0 file_for_the_second_assignment/C.txt | 0 file_for_the_second_assignment/D.txt | 0 file_for_the_second_assignment/E.txt | 0 file_for_the_second_assignment/F.txt | 0 file_for_the_second_assignment/G.txt | 0 file_for_the_second_assignment/H.txt | 0 file_for_the_second_assignment/I.txt | 0 file_for_the_second_assignment/J.txt | 0 file_for_the_second_assignment/K.txt | 0 file_for_the_second_assignment/L.txt | 0 file_for_the_second_assignment/M.txt | 0 file_for_the_second_assignment/N.txt | 0 file_for_the_second_assignment/O.txt | 0 file_for_the_second_assignment/P.txt | 0 file_for_the_second_assignment/Q.txt | 0 file_for_the_second_assignment/R.txt | 0 file_for_the_second_assignment/S.txt | 0 file_for_the_second_assignment/T.txt | 0 file_for_the_second_assignment/U.txt | 0 file_for_the_second_assignment/V.txt | 0 file_for_the_second_assignment/W.txt | 0 file_for_the_second_assignment/X.txt | 0 file_for_the_second_assignment/Y.txt | 0 file_for_the_second_assignment/Z.txt | 0 function_files/Assignment_4.py | 50 ++++++++++++++++++ .../add_function_file.cpython-311.pyc | Bin 0 -> 364 bytes .../divide_function_file.cpython-311.pyc | Bin 0 -> 370 bytes .../multiply_function_file.cpython-311.pyc | Bin 0 -> 374 bytes .../sub_function_file.cpython-311.pyc | Bin 0 -> 364 bytes function_files/add_function_file.py | 2 + function_files/divide_function_file.py | 2 + function_files/multiply_function_file.py | 2 + function_files/sub_function_file.py | 2 + tempCodeRunnerFile.py | 4 ++ 40 files changed, 122 insertions(+) create mode 100644 Assignment_3.py create mode 100644 file_for_the_first_assignment/Assignment_1.py create mode 100644 file_for_the_first_assignment/English_letter.txt create mode 100644 file_for_the_second_assignment/A.txt create mode 100644 file_for_the_second_assignment/Assignment_2.py create mode 100644 file_for_the_second_assignment/B.txt create mode 100644 file_for_the_second_assignment/C.txt create mode 100644 file_for_the_second_assignment/D.txt create mode 100644 file_for_the_second_assignment/E.txt create mode 100644 file_for_the_second_assignment/F.txt create mode 100644 file_for_the_second_assignment/G.txt create mode 100644 file_for_the_second_assignment/H.txt create mode 100644 file_for_the_second_assignment/I.txt create mode 100644 file_for_the_second_assignment/J.txt create mode 100644 file_for_the_second_assignment/K.txt create mode 100644 file_for_the_second_assignment/L.txt create mode 100644 file_for_the_second_assignment/M.txt create mode 100644 file_for_the_second_assignment/N.txt create mode 100644 file_for_the_second_assignment/O.txt create mode 100644 file_for_the_second_assignment/P.txt create mode 100644 file_for_the_second_assignment/Q.txt create mode 100644 file_for_the_second_assignment/R.txt create mode 100644 file_for_the_second_assignment/S.txt create mode 100644 file_for_the_second_assignment/T.txt create mode 100644 file_for_the_second_assignment/U.txt create mode 100644 file_for_the_second_assignment/V.txt create mode 100644 file_for_the_second_assignment/W.txt create mode 100644 file_for_the_second_assignment/X.txt create mode 100644 file_for_the_second_assignment/Y.txt create mode 100644 file_for_the_second_assignment/Z.txt create mode 100644 function_files/Assignment_4.py create mode 100644 function_files/__pycache__/add_function_file.cpython-311.pyc create mode 100644 function_files/__pycache__/divide_function_file.cpython-311.pyc create mode 100644 function_files/__pycache__/multiply_function_file.cpython-311.pyc create mode 100644 function_files/__pycache__/sub_function_file.cpython-311.pyc create mode 100644 function_files/add_function_file.py create mode 100644 function_files/divide_function_file.py create mode 100644 function_files/multiply_function_file.py create mode 100644 function_files/sub_function_file.py create mode 100644 tempCodeRunnerFile.py diff --git a/Assignment_3.py b/Assignment_3.py new file mode 100644 index 0000000..2f22cfa --- /dev/null +++ b/Assignment_3.py @@ -0,0 +1,20 @@ +## Question 3 +## LCM + +import sys +import math +list1 = [] +while 1 : + try: + number = input("please enter the numbers : " ) + int(number) + list1.append(int(number)) + + if len(list1) == 4 : + break + except ValueError : + print("its not number please try again :( ") +print("The numbers that you enter it : " ,list1) +print("The LCM for the numbers that you enter it : ",math.lcm(list1[0],list1[1],list1[2],list1[3])) +gcd_number = math.gcd(list1[0],list1[1],list1[2],list1[3]) +print("The GCD for the numbers that you enter it : ",gcd_number) diff --git a/file_for_the_first_assignment/Assignment_1.py b/file_for_the_first_assignment/Assignment_1.py new file mode 100644 index 0000000..0a3a9f9 --- /dev/null +++ b/file_for_the_first_assignment/Assignment_1.py @@ -0,0 +1,9 @@ +## Question 1 +with open("C:/Users/sande/Documents/GitHub/Class8-Week4-File-I-O-Exception-Handling/file_for_the_first_assignment/English_letter.txt","w") as f : + for i in range(65,91) : + upper_case_letters = chr(i) + lower_case_letters = upper_case_letters.lower() + f.write(upper_case_letters) + f.write(lower_case_letters) + f.write('\t') + f.write('\n') \ No newline at end of file diff --git a/file_for_the_first_assignment/English_letter.txt b/file_for_the_first_assignment/English_letter.txt new file mode 100644 index 0000000..024e5c5 --- /dev/null +++ b/file_for_the_first_assignment/English_letter.txt @@ -0,0 +1,26 @@ +Aa +Bb +Cc +Dd +Ee +Ff +Gg +Hh +Ii +Jj +Kk +Ll +Mm +Nn +Oo +Pp +Qq +Rr +Ss +Tt +Uu +Vv +Ww +Xx +Yy +Zz diff --git a/file_for_the_second_assignment/A.txt b/file_for_the_second_assignment/A.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/Assignment_2.py b/file_for_the_second_assignment/Assignment_2.py new file mode 100644 index 0000000..f42ad59 --- /dev/null +++ b/file_for_the_second_assignment/Assignment_2.py @@ -0,0 +1,5 @@ +#Question 2 +for i in range(65,91): + txt_name = chr(i) + with open("C:/Users/sande/Documents/GitHub/Class8-Week4-File-I-O-Exception-Handling/file_for_the_second_assignment/" f"{txt_name}.txt",'w') as f : + pass \ No newline at end of file diff --git a/file_for_the_second_assignment/B.txt b/file_for_the_second_assignment/B.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/C.txt b/file_for_the_second_assignment/C.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/D.txt b/file_for_the_second_assignment/D.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/E.txt b/file_for_the_second_assignment/E.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/F.txt b/file_for_the_second_assignment/F.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/G.txt b/file_for_the_second_assignment/G.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/H.txt b/file_for_the_second_assignment/H.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/I.txt b/file_for_the_second_assignment/I.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/J.txt b/file_for_the_second_assignment/J.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/K.txt b/file_for_the_second_assignment/K.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/L.txt b/file_for_the_second_assignment/L.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/M.txt b/file_for_the_second_assignment/M.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/N.txt b/file_for_the_second_assignment/N.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/O.txt b/file_for_the_second_assignment/O.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/P.txt b/file_for_the_second_assignment/P.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/Q.txt b/file_for_the_second_assignment/Q.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/R.txt b/file_for_the_second_assignment/R.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/S.txt b/file_for_the_second_assignment/S.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/T.txt b/file_for_the_second_assignment/T.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/U.txt b/file_for_the_second_assignment/U.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/V.txt b/file_for_the_second_assignment/V.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/W.txt b/file_for_the_second_assignment/W.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/X.txt b/file_for_the_second_assignment/X.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/Y.txt b/file_for_the_second_assignment/Y.txt new file mode 100644 index 0000000..e69de29 diff --git a/file_for_the_second_assignment/Z.txt b/file_for_the_second_assignment/Z.txt new file mode 100644 index 0000000..e69de29 diff --git a/function_files/Assignment_4.py b/function_files/Assignment_4.py new file mode 100644 index 0000000..65eabcf --- /dev/null +++ b/function_files/Assignment_4.py @@ -0,0 +1,50 @@ + +#Question 4 + +from add_function_file import add_function +from sub_function_file import sub_function +from divide_function_file import divide_function +from multiply_function_file import multiply_function +import math + +while True : + while 1 : + + + try: + number1 = float(input("please enter first number : ")) + if type(number1) == float or type(number1) == int : + break + except ValueError : + print("Sorry its not a number please try again :( ") + + while 1 : + try: + number2 = float(input("please enter second number : ")) + + if type(number2) == float or type(number2) == int : + break + except ValueError : + print("Sorry its not a number please try again :( ") + + user_choise = str(input("please choise one of this options (+ , - , * , / ) : ")) + if user_choise == "+" : + result = add_function(number1 , number2) + print("Result : ",math.ceil(result)) + elif user_choise == "-" : + result = sub_function(number1 , number2) + print("Result : ",math.ceil(result)) + elif user_choise == "*" : + result = multiply_function(number1 , number2) + print("Result : ",math.ceil(result)) + elif user_choise == "/" : + result = divide_function(number1 , number2) + print("Result : ",math.ceil(result)) + try_again = str(input("do you want to try again (y/n) ? ")) + if try_again != "y" : + break + + + + + diff --git a/function_files/__pycache__/add_function_file.cpython-311.pyc b/function_files/__pycache__/add_function_file.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..99de3d7e2edfa40774cec455419eb930c37d92c1 GIT binary patch literal 364 zcmZ3^%ge<81OaazBzpkq#~=<2FhUuhd4P=R3@HpP3{eazjKK_=Ovy|zML-(FW(H!Y zx*CQW#ws8esE*NZB~bA#_Po;Eq|_oq7{jO-q(wpDS5C53OlWaxQE^OhVqQvWj7xrU zX>Mv>NpXyOW{F2>QjBv>VsWvBZg^^Hwu!D=W=^WEr>?)QYejNuK}lwQo~{Q_TTW(P zdQ4hrUNT4|J`Jd-I3_VAB_2gcub}c453*(;sRbpO`FXk?Ky5jh zdFe4}rFqF9k@z&AqT-m8%(Bds)OZw8y@JYH{AdzI>_CTr{8`KkBpMiQa0^WczsN0f zfkoysP=LWtlM$?>2;{#a4iLcxBz|$&c0Doj$9smFU literal 0 HcmV?d00001 diff --git a/function_files/__pycache__/multiply_function_file.cpython-311.pyc b/function_files/__pycache__/multiply_function_file.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..54c171750a87842bfcdbcfd23e8316d21aff8437 GIT binary patch literal 374 zcmZ3^%ge<81fp*qB>MvC#~=<2FhUuhd4P=R3@HpP3{eazjKK_=Ovy|zML-(FW(H!Y zx*CQW#wu0@2B11dzm-76x7hPabCXhw3}FnTVvrUEg(;sRbpO`FXk?Ky5jh zdFe4}rFqF9k@z&AqT-m`(wvgaf}F~D6mh+R%3FdMQbp`Q$AJ7=%nKwM7;bP2O$fip zEpvfI<}*-$!B3MBtfUC!$0808!3HFLaoFVMr3yl KKQLetVEq873tl|{ literal 0 HcmV?d00001 diff --git a/function_files/__pycache__/sub_function_file.cpython-311.pyc b/function_files/__pycache__/sub_function_file.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..51fb4ce31b5d59864e2ed5542e84f91209e4d7cb GIT binary patch literal 364 zcmZ3^%ge<81h;)3CVK$s#~=<2FhUuhd4P=R3@HpP3{eazjKK_=Ovy|zML-(FW(H!Y zx*CQW#wwtxKy{3MD}jn{vFDZMCZ!e`!Wc%yAT0_CzjBhTVnT~ki;8246Z2A1V_fo+ zOLJ56N{VCLGfO;5lVY565{rv1bi-3qvrTl}GILUOJ$3zcT`Q7P3raHc^K?Cc+Hx}U z(qqy}^O8X#@o7LsK;uf2;!%Y33My~$Ad42U1Dyc!VKFa|XkfU(Ei@tgBDc&17MagL z0R}%!MzE41kk5)ZKm;3*_{Cw9o1apelWJGQ3FLwekOMM4Ff%eTeqdr`l>NYfNr3eO E01DYz?*IS* literal 0 HcmV?d00001 diff --git a/function_files/add_function_file.py b/function_files/add_function_file.py new file mode 100644 index 0000000..de20d0c --- /dev/null +++ b/function_files/add_function_file.py @@ -0,0 +1,2 @@ +def add_function(number1 , number2 ) : + return number1 + number2 diff --git a/function_files/divide_function_file.py b/function_files/divide_function_file.py new file mode 100644 index 0000000..b49ef7b --- /dev/null +++ b/function_files/divide_function_file.py @@ -0,0 +1,2 @@ +def divide_function(number1 , number2 ) : + return number1 / number2 diff --git a/function_files/multiply_function_file.py b/function_files/multiply_function_file.py new file mode 100644 index 0000000..e29066d --- /dev/null +++ b/function_files/multiply_function_file.py @@ -0,0 +1,2 @@ +def multiply_function(number1 , number2 ) : + return number1 * number2 diff --git a/function_files/sub_function_file.py b/function_files/sub_function_file.py new file mode 100644 index 0000000..c3fe561 --- /dev/null +++ b/function_files/sub_function_file.py @@ -0,0 +1,2 @@ +def sub_function(number1 , number2 ) : + return number1 - number2 diff --git a/tempCodeRunnerFile.py b/tempCodeRunnerFile.py new file mode 100644 index 0000000..aa79c6b --- /dev/null +++ b/tempCodeRunnerFile.py @@ -0,0 +1,4 @@ + int(first_number) + int(second_number) + int(third_number) + int(fourth_number) \ No newline at end of file