├── 1-even-odd.py ├── 10-average.py ├── 11-rectangle-area-perimeter.py ├── 12-compound-interest.py ├── 13-days-to-year-week-days.py ├── 14-valid-IP.py ├── 15-string-reverse.py ├── 16-count-even-odd.py ├── 17-print-number.py ├── 18-fibonacci-series.py ├── 19-vowel-consonant.py ├── 2-maximum-num.py ├── 20-2D-array.py ├── 21-FizzBuzz.py ├── 22-count-digit-letters.py ├── 23-print-number2.py ├── 24-2D-array2.py ├── 25-loop-number-pattern.py ├── 26-X-pattern.py ├── 27-O-pattern.py ├── 28-nested-loop-pattern.py ├── 29-check-integer.py ├── 3-minimum-num.py ├── 30-factorial-function.py ├── 31-max-num-function.py ├── 32-reverse-string-function.py ├── 33-multiply-list-num-function.py ├── 34-sum-num-list-function.py ├── 35-palindrome-function.py ├── 36-pangram-function.py ├── 37-pascals-triangle.py ├── 38-pangram-string-function.py ├── 39-access-function.py ├── 5-circle-area.py ├── 6-n-value.py ├── 7-calender.py ├── 8-sphere-volume.py ├── 9-triangle-area.py ├── Problem-list.txt ├── README.md ├── other.py ├── simple-calculator-p1.py └── third-angle-triangle.py /1-even-odd.py: -------------------------------------------------------------------------------- 1 | # Find Even or Odd number. 2 | 3 | num = int(input("Enter a number: ")) 4 | 5 | if num%2 == 0: 6 | print(f"{num} is a Even number") 7 | else: 8 | print(f"{num} is Odd number") -------------------------------------------------------------------------------- /10-average.py: -------------------------------------------------------------------------------- 1 | # 10. Write a python program to calculate total average of five subjects. 2 | 3 | sub1 = float(input("Enter the sub1 marks: ")) 4 | sub2 = float(input("Enter the sub2 marks: ")) 5 | sub3 = float(input("Enter the sub3 marks: ")) 6 | sub4 = float(input("Enter the sub4 marks: ")) 7 | sub5 = float(input("Enter the sub5 marks: ")) 8 | 9 | total_marks = sub1 + sub2 + sub3 + sub4 + sub5 10 | avg_marks = total_marks / 5 11 | print(f"Average marks of five subjects: {avg_marks}") -------------------------------------------------------------------------------- /11-rectangle-area-perimeter.py: -------------------------------------------------------------------------------- 1 | # 11. Write a python program that prints the perimeter of a rectangle to take its height and width as input. 2 | 3 | width = float(input("Enter the width of the rectangle: ")) 4 | height = float(input("Enter the height of the rectangle: ")) 5 | 6 | area = width * height 7 | perimeter = 2 * (width + height) 8 | 9 | print("The area of the rectangle: {0: 0.2f}".format(area)) 10 | print("The perimeter of the rectangle: {0: 0.2f}".format(perimeter)) -------------------------------------------------------------------------------- /12-compound-interest.py: -------------------------------------------------------------------------------- 1 | # 12. Write a python program to calculate Compound Interest. 2 | 3 | def compoundInterest (principle, rate, time): 4 | return principle * (pow((1+rate), time)) 5 | 6 | p = float(input("Enter the Principal amount: ")) 7 | r = float(input("Enter the rate: ")) 8 | t = float(input("Enter the Time: ")) 9 | 10 | interest = compoundInterest(p, r, t) - p 11 | print(f"Compound Interest: {interest}") -------------------------------------------------------------------------------- /13-days-to-year-week-days.py: -------------------------------------------------------------------------------- 1 | # 13. Write a program to convert given number of days in terms of Years, Weeks and Days. 2 | 3 | def find(num_of_days): 4 | year = int(num_of_days / 365) 5 | week = int((num_of_days % 365)/7) 6 | days = int((num_of_days % 365) % 7) 7 | print(f"Year: {year} \nWeek: {week} \nDays: {days}") 8 | 9 | days = int(input("Enter the number of days: ")) 10 | find(days) -------------------------------------------------------------------------------- /14-valid-IP.py: -------------------------------------------------------------------------------- 1 | # 14. Write a program to valid and IP address. 2 | 3 | import socket 4 | addr = input("Enter your IP address: ") 5 | 6 | try: 7 | socket.inet_aton(addr) 8 | print("Valid IP") 9 | except socket.error: 10 | print("Invalid IP") -------------------------------------------------------------------------------- /15-string-reverse.py: -------------------------------------------------------------------------------- 1 | # 15. Write a program that accepts a word the user and reverse it. 2 | word = input("Enter a string/word: ") 3 | 4 | for i in range(len(word)-1, -1, -1): 5 | print (word[i], end="") 6 | 7 | 8 | # alternative 9 | 10 | # word = input("Enter a string/word: ") 11 | 12 | # rev_word = word[::-1] 13 | # print (rev_word) 14 | -------------------------------------------------------------------------------- /16-count-even-odd.py: -------------------------------------------------------------------------------- 1 | # 16. Write a program to count the number of even and odd numbers from the series of numbers. 2 | 3 | numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) 4 | 5 | count_even = 0 6 | count_odd = 0 7 | 8 | for i in numbers: 9 | if i % 2 == 0: 10 | count_even += 1 11 | else: 12 | count_odd += 1 13 | 14 | print(f"Number of even numbers: {count_even}") 15 | print(f"Number of odd numbers: {count_odd}") -------------------------------------------------------------------------------- /17-print-number.py: -------------------------------------------------------------------------------- 1 | # 17. Write a program that prints all the numbers from 0 to 6 except 3 and 6. 2 | for x in range(1, 7): 3 | if x == 3 or x == 6: 4 | continue 5 | print(x, end=' ') -------------------------------------------------------------------------------- /18-fibonacci-series.py: -------------------------------------------------------------------------------- 1 | # 18. Write a program to get the fibonacci series between 0 to 50. 2 | 3 | x, y = 0, 1 4 | print(x, end=" ") 5 | while y < 50: 6 | print (y, end=" ") 7 | x , y = y , x+y -------------------------------------------------------------------------------- /19-vowel-consonant.py: -------------------------------------------------------------------------------- 1 | # 19. Write a program to check whether an alphabet is a vowel or consonant. 2 | 3 | letter = input("Enter a letter: ") 4 | 5 | vowel = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') 6 | 7 | if letter in vowel: 8 | print("Vowel") 9 | else: 10 | print("Consonant") 11 | -------------------------------------------------------------------------------- /2-maximum-num.py: -------------------------------------------------------------------------------- 1 | # find maximum number from three number 2 | 3 | a = int(input("Enter num1: ")) 4 | b = int(input("Enter num2: ")) 5 | c = int(input("Enter num3: ")) 6 | 7 | if a > b and a > c: 8 | print(f"{a} is Largest number") 9 | elif b > a and b > c: 10 | print(f"{b} is Largest number") 11 | else: 12 | print(f"{c} is Largest number") -------------------------------------------------------------------------------- /20-2D-array.py: -------------------------------------------------------------------------------- 1 | # 20. Write a program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. 2 | 3 | m = int(input("Enter number of row: ")) 4 | n = int(input("Enter number of column: ")) 5 | 6 | multi_list = [[0 for col in range(n)] for row in range(m)] 7 | 8 | for row in range (m): 9 | for col in range(n): 10 | multi_list[row][col]=row*col 11 | 12 | print(multi_list) -------------------------------------------------------------------------------- /21-FizzBuzz.py: -------------------------------------------------------------------------------- 1 | # 21. Write a program which iterates the integers form 1 to 50. For multiples of three print Fizz instead of the number and form the multiples of five print Buzz. For numbers which are multiples of both three and five print FizzBuzz. 2 | 3 | for i in range (1, 51): 4 | if i % 5 == 0 and i % 3 == 0: 5 | print("FizzBuzz") 6 | continue 7 | elif i % 5 == 0: 8 | print("Buzz") 9 | continue 10 | elif i % 3 == 0: 11 | print("Fizz") 12 | continue 13 | print (i) 14 | -------------------------------------------------------------------------------- /22-count-digit-letters.py: -------------------------------------------------------------------------------- 1 | # 22. Write a program to check a string and calculate the number of digits and letters. 2 | 3 | s = input("Enter a string: ") 4 | digit = 0 5 | letter = 0 6 | 7 | for c in s: 8 | if c.isdigit(): 9 | digit += 1 10 | elif c.isalpha(): 11 | letter += 1 12 | 13 | print(f"Number of digits: {digit}") 14 | print(f"Number of letters: {letter}") 15 | -------------------------------------------------------------------------------- /23-print-number2.py: -------------------------------------------------------------------------------- 1 | # 23. Write a program that prints all the numbers form 0 to 6 except 2 and 6. 2 | 3 | for i in range(0, 7): 4 | if i == 2 or i == 6: 5 | continue 6 | print(i, end=" ") -------------------------------------------------------------------------------- /24-2D-array2.py: -------------------------------------------------------------------------------- 1 | # 24. Write a program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i = 0, 1, ....., m-1 and j = 0, 1, ......, n-1 2 | 3 | m = int(input("Input number of row: ")) 4 | n = int(input("Number of column: ")) 5 | 6 | multi_list = [ [0 for col in range(n)] for row in range(m)] 7 | 8 | for row in range(m): 9 | for col in range(n): 10 | multi_list[row][col] = row*col 11 | print(multi_list) -------------------------------------------------------------------------------- /25-loop-number-pattern.py: -------------------------------------------------------------------------------- 1 | # 25. Write a program to construct the following pattern, using nested loop number. 2 | 3 | n = int(input("Enter row number of pattern: ")) 4 | 5 | for i in range(n): 6 | print(str(i)*i) 7 | -------------------------------------------------------------------------------- /26-X-pattern.py: -------------------------------------------------------------------------------- 1 | # 26. Write a program to print alphabet pattern X. 2 | 3 | n = 5 4 | 5 | 6 | for row in range(0, n): 7 | for col in range(0, n): 8 | if ((row == 0 or row == 4) and (col == 0 or col == 4)) or ((row == 1 or row == 3) and (col == 1 or col == 3)) or (row == col): 9 | print ("#", end=" ") 10 | else: 11 | print(" ", end=" ") 12 | print("\n") -------------------------------------------------------------------------------- /27-O-pattern.py: -------------------------------------------------------------------------------- 1 | # 27. Write a program to print alphabet pattern O. 2 | 3 | n = 5 4 | 5 | for row in range(n): 6 | for col in range(n): 7 | if ((row == 0 or row == 4) and (col == 1 or col == 2 or col == 3)) or ((row == 1 or row == 2 or row == 3) and ((col == 0 or col == 4))): 8 | print("*", end=" ") 9 | else: 10 | print(" ", end=" ") 11 | print("\n") -------------------------------------------------------------------------------- /28-nested-loop-pattern.py: -------------------------------------------------------------------------------- 1 | # 28. Write a program to construct the following pattern, using nested loop. 2 | 3 | n = 5 4 | for i in range(n): 5 | for j in range(i): 6 | print("*", end=" ") 7 | print("\n") 8 | 9 | for i in range(n, 0, -1): 10 | for j in range(i): 11 | print("*", end=" ") 12 | print("\n") -------------------------------------------------------------------------------- /29-check-integer.py: -------------------------------------------------------------------------------- 1 | # 29. Write a program to check a string represent an integer or not. 2 | 3 | text = input("Enter a string: ") 4 | text = text.strip() 5 | if len(text)<1: 6 | print("Input a valid text.") 7 | else: 8 | if (text[0] in "+-") and all(text[i] in "0123456789" for i in range(1, len(text))): 9 | print("This String is an integer") 10 | elif all(text[i] in "0123456789" for i in range(len(text))): 11 | print("This String is an integer") 12 | -------------------------------------------------------------------------------- /3-minimum-num.py: -------------------------------------------------------------------------------- 1 | # find minimum number of three numbers 2 | 3 | a = int(input("Enter num1: ")) 4 | b = int(input("Enter num2: ")) 5 | c = int(input("Enter num3: ")) 6 | 7 | if a < b and a < c: 8 | print(f"{a} is smallest number") 9 | elif b < c and b < a: 10 | print(f"{b} is smallest number") 11 | else: 12 | print(f"{c} is smallest number") -------------------------------------------------------------------------------- /30-factorial-function.py: -------------------------------------------------------------------------------- 1 | # 30. Write a function to calculate the factorial of a number ( a non negative integer ). The function accepts the number as an argument. 2 | 3 | def factorial(n): 4 | if n == 0: 5 | return 1 6 | else: 7 | return n * factorial(n-1) 8 | 9 | num = int(input("Enter a number: ")) 10 | print(f"Factrial: {factorial(num)}") -------------------------------------------------------------------------------- /31-max-num-function.py: -------------------------------------------------------------------------------- 1 | # 31. Write a function to find the Max of three numbers. 2 | 3 | def max_of_two(a , b): 4 | if a > b: 5 | return a 6 | else: 7 | return b 8 | 9 | def max_of_three(a , b, c): 10 | return max_of_two(a, max_of_two(b, c)) 11 | 12 | a = int(input("Enter a num1: ")) 13 | b = int(input("Enter a num2: ")) 14 | c = int(input("Enter a num3: ")) 15 | 16 | print(f"Max Num: {max_of_three(a, b, c)}") -------------------------------------------------------------------------------- /32-reverse-string-function.py: -------------------------------------------------------------------------------- 1 | # 32. Write a function to reverse a string. 2 | 3 | def rev_string(text): 4 | rev_str = "" 5 | if len(text) > 0: 6 | for i in range(len(text)-1, -1, -1): 7 | rev_str += text[i] 8 | return rev_str 9 | else: 10 | return "This is empty string." 11 | 12 | str1 = input("Enter a string: ") 13 | print(rev_string(str1)) 14 | -------------------------------------------------------------------------------- /33-multiply-list-num-function.py: -------------------------------------------------------------------------------- 1 | # 33. Write a function to multiply all the numbers in a list. 2 | 3 | def mul_list(list): 4 | total = 1 5 | for i in list: 6 | total *= i 7 | return total 8 | 9 | l = (10, 20, 30, 40, 50) 10 | print(mul_list(l)) -------------------------------------------------------------------------------- /34-sum-num-list-function.py: -------------------------------------------------------------------------------- 1 | # 34. Write a function to sum all the numbers in a list. 2 | 3 | def sum_list(list): 4 | total = 0 5 | for i in list: 6 | total += i 7 | return total 8 | 9 | l = (1, 2, 3, 4, 5, 6) 10 | 11 | print(f"Sum of list: {sum_list(l)}") -------------------------------------------------------------------------------- /35-palindrome-function.py: -------------------------------------------------------------------------------- 1 | # 35. Write a function that checks whether a passed string in palindrome or not. NOTE: A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. 2 | 3 | def check_palindrome(word): 4 | left = 0 5 | right = len(word) -1 6 | 7 | while left < right: 8 | if word[left] == word[right]: 9 | return "It is palindrome" 10 | else: 11 | return "It is not palindrome" 12 | right -= 1 13 | left += 1 14 | 15 | word = input("Enter a string/word:") 16 | print(check_palindrome(word)) -------------------------------------------------------------------------------- /36-pangram-function.py: -------------------------------------------------------------------------------- 1 | # 36. Write a function to check whether a string in a pangram or not. NOTE: Pangrams are words or sentences containing every letter of the alphabet at least once. 2 | 3 | import string, sys 4 | def ispangram(str1, alphabet = string.ascii_lowercase): 5 | alphaset = set(alphabet) 6 | return alphaset <= set(str1.lower()) 7 | 8 | print(ispangram("zxcvbnmasdfghjklqwertyuiop")) -------------------------------------------------------------------------------- /37-pascals-triangle.py: -------------------------------------------------------------------------------- 1 | # 37. Write a function that prints out the first n rows of pascal's triangle. 2 | 3 | def pascal_triangle(n): 4 | trow = [1] 5 | y = [0] 6 | for x in range(max(n, 0)): 7 | print(trow) 8 | trow = [l+r for l, r in zip(trow+y, y + trow)] 9 | return n>=1 10 | 11 | num = int(input("Enter a number: ")) 12 | pascal_triangle(num) -------------------------------------------------------------------------------- /38-pangram-string-function.py: -------------------------------------------------------------------------------- 1 | # 38. Write a function to create and print a list where the values are sequence of numbers between 1 and 30 (both included). 2 | 3 | import string, sys 4 | def ispangram(str1, alphabet=string.ascii_lowercase): 5 | alphaset = set(alphabet) 6 | return alphaset <= set(str1.lower()) 7 | 8 | text = input("Enter a string: ") 9 | print(ispangram(text)) -------------------------------------------------------------------------------- /39-access-function.py: -------------------------------------------------------------------------------- 1 | # 39. Write a program to access a function inside a function. 2 | 3 | def test(a): 4 | def add(b): 5 | return a + b 6 | return add 7 | 8 | func = test(4) 9 | print(func(3)) -------------------------------------------------------------------------------- /5-circle-area.py: -------------------------------------------------------------------------------- 1 | # 5. Write a python program which accepts the radius of a circle from the user and compute the area. 2 | 3 | from math import pi 4 | 5 | r = float(input("Enter the radius of the circle: ")) 6 | 7 | print(f"Area of circle: {pi*r*r}") -------------------------------------------------------------------------------- /6-n-value.py: -------------------------------------------------------------------------------- 1 | # 6. Write a python program that accepts an integer (n) and computes the value of n+nn+nnn. 2 | 3 | a = int(input("Enter num: ")) 4 | 5 | n = int ("%s"%a) 6 | n2 = int ("%s%s"%(a,a)) 7 | n3 = int ("%s%s%s"%(a,a,a)) 8 | 9 | print(n+n2+n3) 10 | -------------------------------------------------------------------------------- /7-calender.py: -------------------------------------------------------------------------------- 1 | # 7. Write a python program to print the calendar of a given month and year. 2 | 3 | import calendar 4 | 5 | month = int (input("Enter the month: ")) 6 | year = int (input("Enter the year: ")) 7 | 8 | print(calendar.month(year, month)) 9 | -------------------------------------------------------------------------------- /8-sphere-volume.py: -------------------------------------------------------------------------------- 1 | # 8. Write a python program to get the volume of a sphere with radius 6. 2 | from math import pi 3 | 4 | r = 6.0 5 | v = 4.0/3.0*pi*r**3 6 | print(f"The volume of the sphere: {v}") -------------------------------------------------------------------------------- /9-triangle-area.py: -------------------------------------------------------------------------------- 1 | # 9. Write a python program that will accept the base and height of a triangle and compute the area. 2 | 3 | base = float(input("Enter the base of the triangle:")) 4 | height = float(input("Enter the height of the triangle:")) 5 | 6 | area = 0.5 * base * height 7 | print(f"The area of the triangle: {area}") -------------------------------------------------------------------------------- /Problem-list.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fahimahammed/problem-solving-with-python/be97b72eadfd9a1e976ae523a8b93d593aeb2651/Problem-list.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # problem-solving-with-python 2 | 3 | #### CONDITION #### CONDITION #### CONDITION #### CONDITION #### CONDITION #### 4 | 5 | 1. Find Even or Odd number. 6 | 2. Write a Python program to find maximum number from three number. 7 | 3. Write a Python program to find minimum number from three number. 8 | 4. Write a python program to find third angle of a triangle if two angles are given 9 | 5. Write a python program which accepts the radius of a circle from the user and compute the area. 10 | 6. Write a python program that accepts an integer (n) and computes the value of n+nn+nnn. 11 | 7. Write a python program to print the calendar of a given month and year. 12 | 8. Write a python program to get the volume of a sphere with radius 6. 13 | 9. Write a python program that will accept the base and height of a triangle and compute the area. 14 | 10. Write a python program to calculate total average of five subjects. 15 | 11. Write a python program that prints the perimeter of a rectangle to take its height and width as input. 16 | 12. Write a python program to calculate Compound Interest. 17 | 13. Write a program to convert given number of days in terms of Years, Weeks and Days. 18 | 14. Write a program to valid and IP address. 19 | 20 | ###### LOOP ##### LOOP ##### LOOP ##### LOOP ##### LOOP ##### 21 | 22 | 15. Write a program that accepts a word the user and reverse it. 23 | 16. Write a program to count the number of even and odd numbers from the series of numbers. 24 | 17. Write a program that prints all the numbers from 0 to 6 except 3 and 6. 25 | 18. Write a program to get the fibonacci series between 0 to 50. 26 | 19. Write a program to check whether an alphabet is a vowel or consonant. 27 | 20. Write a program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. 28 | 21. Write a program which iterates the integers form 1 to 50. For multiples of three print Fizz instead of the number and form the multiples of five print Buzz. For numbers which are multiples of both three and five print FizzBuzz. 29 | 22. Write a program to check a string and calculate the number of digits and letters. 30 | 23. Write a program that prints all the numbers form 0 to 6 except 2 and 6. 31 | 24. Write a program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i = 0, 1, ....., m-1 and j = 0, 1, ......, n-1 32 | 25. Write a program to construct the following pattern, using nested loop number. 33 | 26. Write a program to print alphabet pattern X. 34 | 27. Write a program to print alphabet pattern O. 35 | 28. Write a program to construct the following pattern, using nested loop. 36 | 29. Write a program to check a string represent an integer or not. 37 | 38 | #### FUNCTION ##### FUNCTION ##### FUNCTION ##### FUNCTION ##### 39 | 40 | 30. Write a function to calculate the factorial of a number ( a non negative integer ). The function accepts the number as an argument. 41 | 31. Write a function to find the Max of three numbers. 42 | 32. Write a function to reverse a string. 43 | 33. Write a function to multiply all the numbers in a list. 44 | 34. Write a function to sum all the numbers in a list. 45 | 35. Write a function that checks whether a passed string in palindrome or not. NOTE: A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. 46 | 36. Write a function to check whether a string in a pangram or not. NOTE: Pangrams are words or sentences containing every letter of the alphabet at least once. 47 | 48 | 37. Write a function that prints out the first n rows of pascal's triangle. 49 | 38. Write a function to create and print a list where the values are sequence of numbers between 1 and 30 (both included). 50 | 39. Write a program to access a function inside a function. 51 | 40. Write a program to find the greatest common divisor (gsd) of two integers. 52 | 41. Write a program to calculate the sum of the positive integers of n + (n -2) + (n - 4).... (until n-x =<0) 53 | 42. Write a program to calculate the harmonic sum of n-1. 54 | 43. Write a program to calculate the geometric sum of n-1. 55 | 44. Write a program to calculate the value of a to the power of b. 56 | 57 | 58 | -------------------------------------------------------------------------------- /other.py: -------------------------------------------------------------------------------- 1 | ## Other string 2 | 3 | txt = input("Enter a text: ") 4 | word = input("Enter a word: ") 5 | count = 0 6 | 7 | for word in txt: 8 | print(word) 9 | 10 | -------------------------------------------------------------------------------- /simple-calculator-p1.py: -------------------------------------------------------------------------------- 1 | ## simple calculator 2 | 3 | def add_num(num1, num2): 4 | return num1 + num2 5 | 6 | def sub_num(num1, num2): 7 | return num1 - num2 8 | 9 | def mul_num(num1, num2): 10 | return num1 * num2 11 | 12 | def div_num(num1, num2): 13 | return num1 / num2 14 | 15 | option = 1 16 | 17 | while option != 0: 18 | print("\n-----------------------") 19 | print("Chose your option: \n-----------------------") 20 | print("1. Addition") 21 | print("2. Subtraction") 22 | print("3. Division") 23 | print("4. Multiplication") 24 | print("0. Exit") 25 | print("-----------------------") 26 | 27 | option = int(input("Input num that you selected: ")) 28 | if option > 4: 29 | print("\n\n# Please select the correct option") 30 | elif option <=4 and option >= 1: 31 | a = int(input("Enter a number1: ")) 32 | b = int(input("Enter a number2: ")) 33 | if option == 1: 34 | print(f"Result: {add_num(a, b)}") 35 | elif option == 2: 36 | print(f"Result: {sub_num(a, b)}") 37 | elif option == 3: 38 | print(f"Result: {div_num(a, b)}") 39 | else: 40 | print(f"Result: {mul_num(a, b)}") 41 | -------------------------------------------------------------------------------- /third-angle-triangle.py: -------------------------------------------------------------------------------- 1 | # finding third angle of triangle. 2 | 3 | a = float(input("Enter the first angle of triangle: ")) 4 | b = float(input("Enter the second angle of triangle: ")) 5 | 6 | c = 180 - (a+b) 7 | 8 | print(f"Third angle of triangle is: {c}") --------------------------------------------------------------------------------