Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Assignment_3.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions file_for_the_first_assignment/Assignment_1.py
Original file line number Diff line number Diff line change
@@ -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')
26 changes: 26 additions & 0 deletions file_for_the_first_assignment/English_letter.txt
Original file line number Diff line number Diff line change
@@ -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
Empty file.
5 changes: 5 additions & 0 deletions file_for_the_second_assignment/Assignment_2.py
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
50 changes: 50 additions & 0 deletions function_files/Assignment_4.py
Original file line number Diff line number Diff line change
@@ -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





Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions function_files/add_function_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def add_function(number1 , number2 ) :
return number1 + number2
2 changes: 2 additions & 0 deletions function_files/divide_function_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def divide_function(number1 , number2 ) :
return number1 / number2
2 changes: 2 additions & 0 deletions function_files/multiply_function_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def multiply_function(number1 , number2 ) :
return number1 * number2
2 changes: 2 additions & 0 deletions function_files/sub_function_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def sub_function(number1 , number2 ) :
return number1 - number2
4 changes: 4 additions & 0 deletions tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int(first_number)
int(second_number)
int(third_number)
int(fourth_number)