├── .gitignore ├── Assignment5.pdf ├── Assignment_2.pdf ├── Assignment_3.pdf ├── Assignment_4.pdf ├── Assignment_6.pdf ├── LICENSE ├── Programming_Assignment1.py ├── Programming_Assignment2.py ├── Programming_Assignment3.py ├── Programming_Assignment4.py ├── Programming_Assignment5.py └── Regex_Assignment_1.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /Assignment5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Assignment5.pdf -------------------------------------------------------------------------------- /Assignment_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Assignment_2.pdf -------------------------------------------------------------------------------- /Assignment_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Assignment_3.pdf -------------------------------------------------------------------------------- /Assignment_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Assignment_4.pdf -------------------------------------------------------------------------------- /Assignment_6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Assignment_6.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Jalpa Patel Desai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Programming_Assignment1.py: -------------------------------------------------------------------------------- 1 | # 1. Write a Python program to print "Hello Python"? 2 | print("Hello Python") 3 | 4 | # 2. Write a Python program to do arithmetical operations addition and division.? 5 | x = 10 6 | y = 20 7 | add = x+y 8 | div = x/y 9 | print(f'{x}+{y} = {add}') 10 | print(f'{x}/{y} = {div}') 11 | 12 | # 3. Write a Python program to find the area of a triangle? 13 | 14 | a = int(input("enter the length of the side of the triangle - ")) 15 | b = int(input("enter the length of the side of the triangle - ")) 16 | c = int(input("enter the length of the side of the triangle - ")) 17 | area = 0.5*(a+b+c) 18 | print(f'area of the given triangle is {area}') 19 | 20 | # 4. Write a Python program to swap two variables? 21 | 22 | a = 10 23 | b = 20 24 | a,b = b,a 25 | print(f'swaped value of a is {a}') 26 | print(f'swaped value of b is {b}') 27 | 28 | # 5. Write a Python program to generate a random number? 29 | 30 | import numpy as np 31 | print(np.random.randint(90,100)) -------------------------------------------------------------------------------- /Programming_Assignment2.py: -------------------------------------------------------------------------------- 1 | # 1. Write a Python program to convert kilometers to miles? 2 | km = float(input('enter the kilometer you want to convert to miles- ')) 3 | miles = 0.621371*(km) 4 | print(f'total miles is {miles}') 5 | 6 | # 2. Write a Python program to convert Celsius to Fahrenheit? 7 | Celsius = float(input('enter the temperature you want to convert to farenheit- ')) 8 | Farenheit = 32 + (Celsius)*9/5 9 | print(f'Temperature in Farenheit is {Farenheit}') 10 | 11 | # 3. Write a Python program to display calendar? 12 | 13 | import calendar 14 | year = 2023 15 | month = 5 16 | 17 | print(calendar.month(year,month)) 18 | 19 | # 4. Write a Python program to solve quadratic equation? 20 | import cmath 21 | # quadratic equation is of the form a*(x**2) + b*x + C 22 | a = int(input("enter a")) 23 | b = int(input('enter b')) 24 | c = int(input('enter c')) 25 | # calculating discriminant 26 | d = (b**2 - 4*a*c) 27 | if d == 0: 28 | x = (-b) / (2 * a) 29 | print(f'the equation has only one root which is {x}') 30 | else: 31 | x1 = (-b + cmath.sqrt(d)) / (2 * a) 32 | x2 = (-b - cmath.sqrt(d)) / (2 * a) 33 | print(f'two solutions of the given equation would be {x1},{x2}') 34 | 35 | 36 | # 5. Write a Python program to swap two variables without temp variable? 37 | a = 10 38 | b = 20 39 | a,b = b,a 40 | print(f'swaped value of a is {a}') 41 | print(f'swaped value of b is {b}') -------------------------------------------------------------------------------- /Programming_Assignment3.py: -------------------------------------------------------------------------------- 1 | # 1. Write a Python Program to Check if a Number is Positive, Negative or Zero? 2 | num = int(input('enter the number')) 3 | if num>0: 4 | print('Entered number is positive') 5 | elif num == 0: 6 | print('Entered number is zero') 7 | else: 8 | print('Entered number is negative') 9 | 10 | # 2. Write a Python Program to Check if a Number is Odd or Even? 11 | num = int(input('enter the number')) 12 | if num%2==0: 13 | print("Entered number is even") 14 | else: 15 | print("It is an odd number") 16 | 17 | # 3. Write a Python Program to Check Leap Year? 18 | y = int(input("enter the year")) 19 | if y%4==0 and y%100!=0: 20 | print("it is a leap year") 21 | elif y%4==0 and y%100==0 and y%400==0: 22 | print("it is a leap year") 23 | else: 24 | print("the year is not a leap year") 25 | 26 | 27 | # 4. Write a Python Program to Check Prime Number? 28 | num =int(input("enter the number to be checked")) 29 | for i in range(2, num): 30 | if num % i == 0: 31 | print("it is not a prime number") 32 | break 33 | else: 34 | print("this is a prime number") 35 | 36 | # 5. Write a Python Program to Print all Prime Numbers in an Interval of 1-10000?) 37 | l=[] 38 | for num in range(2,10000): 39 | for j in range(2,num): 40 | if num%j==0: 41 | break 42 | else: 43 | l.append(num) 44 | 45 | print(l) -------------------------------------------------------------------------------- /Programming_Assignment4.py: -------------------------------------------------------------------------------- 1 | # 1. Write a Python Program to Find the Factorial of a Number? 2 | # num = int(input("enter the number")) 3 | # fac = 1 4 | # for i in range(1,num+1): 5 | # fac = fac*i 6 | # print(fac) 7 | 8 | # 2. Write a Python Program to Display the multiplication Table? 9 | # num = int(input("enter the number for which multiplication table has to be displayed")) 10 | # for i in range(1,11): 11 | # print(f'{num}*{i} = {num*i}') 12 | 13 | # 3. Write a Python Program to Print the Fibonacci sequence? 14 | 15 | # a = int(input("enter the first number")) 16 | # b = int(input("enter th second number")) 17 | # l = [a,b] 18 | # seq = int(input("enter how many times you want to iterate the series")) 19 | # for i in range(1,seq): 20 | # c = l[-1]+l[-2] 21 | # l.append(c) 22 | # a = l[-2] 23 | # b = l[-1] 24 | # print(l) 25 | 26 | # 4. Write a Python Program to Check Armstrong Number? 27 | # num = int(input("enter the number")) 28 | # pow = len(str(num)) 29 | # sum = 0 30 | # for i in range(0,pow): 31 | # sum = sum + int(str(num)[i])**pow 32 | # if sum == num: 33 | # print("entered number is an armstrong number") 34 | # else: 35 | # print("number is not an armstrong number") 36 | 37 | # 5. Write a Python Program to Find Armstrong Number in an Interval? 38 | # interval = int(input("enter the number")) 39 | # l = [] 40 | # for i in range(0,interval+1): 41 | # pow = len(str(i)) 42 | # sum = 0 43 | # for j in range(0,pow): 44 | # sum = sum + int(str(i)[j])**pow 45 | # if sum==i: 46 | # l.append(i) 47 | # 48 | # print(l) 49 | 50 | # 6. Write a Python Program to Find the Sum of Natural Numbers? 51 | n=int(input("enter for how much numbers you want to know the sum")) 52 | sum = (n*(n+1))/2 53 | print(f"the sum of first {n} is {sum}") 54 | 55 | 56 | -------------------------------------------------------------------------------- /Programming_Assignment5.py: -------------------------------------------------------------------------------- 1 | # 1. Write a Python Program to Find LCM? 2 | hcf = 0 3 | def hcf(a,b): 4 | if a>b: 5 | a,b = b,a 6 | for i in range(1,a+1): 7 | if a%i ==0 and b%i==0: 8 | hcf = i 9 | return hcf 10 | 11 | def lcm(a,b): 12 | return (a*b)/(hcf(a,b)) 13 | 14 | print(lcm(18,24)) 15 | 16 | 17 | # 2. Write a Python Program to Find HCF? 18 | hcf = 0 19 | def hcf(a,b): 20 | if a>b: 21 | a,b = b,a 22 | for i in range(1,a+1): 23 | if a%i ==0 and b%i==0: 24 | hcf = i 25 | return hcf 26 | 27 | print(hcf(20,100)) 28 | 29 | # 3. Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal? 30 | num = int(input("enter the number")) 31 | def binary(): 32 | binary = bin(num).replace('0b', "") 33 | print(f'binary representation of {num} is {binary}') 34 | 35 | def octal(): 36 | octal = oct(num).replace('0o',"") 37 | print(f'octal representation of {num} is {octal}') 38 | 39 | def hexadecimal(): 40 | hexa = hex(num).replace('0x',"") 41 | print(f'hexadecimal representation of {num} is {hexa}') 42 | 43 | binary() 44 | octal() 45 | hexadecimal() 46 | 47 | # 4. Write a Python Program To Find ASCII value of a character? 48 | char = input("enter the character") 49 | ascii_val = ord(char) 50 | print(f"ascii value of {char} is {ascii_val}") 51 | 52 | # 5. Write a Python Program to Make a Simple Calculator with 4 basic mathematical operations? 53 | 54 | def addition(a,b): 55 | return a+b 56 | 57 | def subtraction(a,b): 58 | return a-b 59 | 60 | def div(a,b): 61 | return a/b 62 | 63 | def multi(a,b): 64 | return a*b 65 | 66 | def operation(): 67 | print("Which operation you want to perform?") 68 | print("1.Addition\n2.Subtraction\n3.Division\n4.Multiplication") 69 | response=int(input("enter the response - ")) 70 | num1 = int(input("enter first number - ")) 71 | num2 = int(input("enter second number - ")) 72 | if response == 1: 73 | print(addition(num1,num2)) 74 | elif response ==2: 75 | print(subtraction(num1,num2)) 76 | elif response ==3: 77 | print(div(num1,num2)) 78 | elif response == 79 | print(multi(num1,num2)) 80 | 81 | operation() -------------------------------------------------------------------------------- /Regex_Assignment_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jalpa-08/Python_Assignment_Practice/d9db0197249fe10676a6e6ff250235e689f94d4b/Regex_Assignment_1.pdf --------------------------------------------------------------------------------