From 9870ca8dba8228e7698e568747814fcc0e836938 Mon Sep 17 00:00:00 2001 From: Ammar Esam Date: Mon, 6 Feb 2023 23:27:27 +0100 Subject: [PATCH 1/2] Update files --- Q1.py | 8 ++++++++ Q2.py | 4 ++++ Q3.py | 22 ++++++++++++++++++++++ Q4.py | 0 README.md | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Q1.py create mode 100644 Q2.py create mode 100644 Q3.py create mode 100644 Q4.py diff --git a/Q1.py b/Q1.py new file mode 100644 index 0000000..b587443 --- /dev/null +++ b/Q1.py @@ -0,0 +1,8 @@ +import string + +n = int(input("Enter the number of letters in each line:")) +with open("letters.txt", "w") as f: + alphabet = string.ascii_letters + for i in range(0, len(alphabet), n): + letters = [alphabet[i:i + n] + "\n"] + f.writelines(letters) diff --git a/Q2.py b/Q2.py new file mode 100644 index 0000000..872a7e9 --- /dev/null +++ b/Q2.py @@ -0,0 +1,4 @@ +import string +char = list(string.ascii_uppercase) +for i in range(len(char)): + open(f"{char[i]}.txt", 'x') diff --git a/Q3.py b/Q3.py new file mode 100644 index 0000000..f6af8dc --- /dev/null +++ b/Q3.py @@ -0,0 +1,22 @@ +from math import gcd +from functools import reduce + + +def lcm_function(list): + return reduce(lambda a, b: a * b // gcd(a, b), list) + + +list = [] +for i in range(1, 5): + try: + num = int(input(f"Enter number {i} : ")) + num != None + list.append(num) + + except ValueError: + print("Value can't be empty or non numerical") + exit() + +print(list) +result = lcm_function(list) +print("The L.C.M is :", result) diff --git a/Q4.py b/Q4.py new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 44f5fa1..3f34a88 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Letters for each line -Write a Python program to create a file where all letters of English alphabet(uppercase and lowercase both) are listed by specified number of letters on each line. + aa ## Question 2 From 20699dcc1e11684e139e092d3f7d4381875bdf11 Mon Sep 17 00:00:00 2001 From: Ammar Esam Date: Tue, 7 Feb 2023 17:51:24 +0100 Subject: [PATCH 2/2] Update files --- Q4.py | 0 Q4/__pycache__/addition.cpython-311.pyc | Bin 0 -> 340 bytes Q4/__pycache__/division.cpython-311.pyc | Bin 0 -> 340 bytes Q4/__pycache__/multiplication.cpython-311.pyc | Bin 0 -> 348 bytes Q4/__pycache__/subtraction.cpython-311.pyc | Bin 0 -> 343 bytes Q4/addition.py | 3 ++ Q4/division.py | 3 ++ Q4/main.py | 47 ++++++++++++++++++ Q4/multiplication.py | 3 ++ Q4/subtraction.py | 3 ++ README.md | 2 +- 11 files changed, 60 insertions(+), 1 deletion(-) delete mode 100644 Q4.py create mode 100644 Q4/__pycache__/addition.cpython-311.pyc create mode 100644 Q4/__pycache__/division.cpython-311.pyc create mode 100644 Q4/__pycache__/multiplication.cpython-311.pyc create mode 100644 Q4/__pycache__/subtraction.cpython-311.pyc create mode 100644 Q4/addition.py create mode 100644 Q4/division.py create mode 100644 Q4/main.py create mode 100644 Q4/multiplication.py create mode 100644 Q4/subtraction.py diff --git a/Q4.py b/Q4.py deleted file mode 100644 index e69de29..0000000 diff --git a/Q4/__pycache__/addition.cpython-311.pyc b/Q4/__pycache__/addition.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..78dea82e88a96775f80e8fdf6b216f8d86cc3bc1 GIT binary patch literal 340 zcmZ3^%ge<81gbTUlFfkhV-N=h7@>^MJV3^Dh7^VthA4&<#$X0brer3VA|MT7GXwEw z0U$A*p@yM`u?onlWvXEUs%7+B$)L%6iz&|#h>dQs6{QxJ=9CnJG$<%2{0dLDiU}=F zEh>(2%*{%gjmD_0;v(b*)HF zEhx#%&(rlt%uC71%uA06G>J(}Ny!8W>J?PpVg_=GIDoc*yip8tS_8ukUj7M8ouLhG zH@F2Gd_M!l82mID!K#Wt4l3dV5$r(X7l%!5eoARhs$CH%fWT(R0T~~d85tQrFflO- KePF;O!1@7k$xU|v literal 0 HcmV?d00001 diff --git a/Q4/__pycache__/division.cpython-311.pyc b/Q4/__pycache__/division.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5dd8c4213b02cd63748eddb1b47f4a31abe90d19 GIT binary patch literal 340 zcmZ3^%ge<81jlP0C0hdN#~=<2FhUuhd4P=R3@HpP3{eazjKK_=Ovy|zML-(FW(MNV z0zhIqLk&X>V-+_8LoHJc6HqOq-%18e=37j8hCpm|i>)ZNxHPAv7^Fc#LE%?;vQV-+g{LoHJc6HqOq-%18e=37j8hCpm|i>)ZNxHPAv7^Fc#LE%?yvQD*^=+*bF%!;{!7z RBjX1qCPtwT444F1KLG9TQQiOm literal 0 HcmV?d00001 diff --git a/Q4/__pycache__/subtraction.cpython-311.pyc b/Q4/__pycache__/subtraction.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1700f36208c32bab37bfa7002c9a6b9f29180d81 GIT binary patch literal 343 zcmZ3^%ge<81P^N-C0hdN#~=<2FhUuhd4P=R3@HpP3{eazjKK_=Ovy|zML-(FW(MNV z0zhIqLk&X>V-?WUTBaH%pjt-1l?gIln{_cKt8!B3MBtf~m)rXo%d!44#TaoFVMr