├── Day_20 ├── Project_01 │ ├── Readme.md │ └── Calculator.py └── Project_02 │ └── Project_02.py ├── Day_16 ├── Q_151 │ └── Q_151.py ├── Q_153 │ └── Q_153.py ├── Q_156 │ └── Q_156.py ├── Q_152 │ └── Q_152.py ├── Q_155 │ └── Q_155.py ├── Q_158 │ └── Q_158.py ├── Q_157 │ └── Q_157.py ├── Q_159 │ └── Q_159.py ├── Q_160 │ └── Q_160.py └── Q_154 │ └── Q_154.py ├── Day_17 ├── Q_162 │ └── Q_162.py ├── Q_163 │ └── Q_163.py ├── Q_167 │ └── Q_167.py ├── Q_168 │ └── Q_168.py ├── Q_161 │ └── Q_161.py ├── Q_165 │ └── Q_165.py ├── Q_169 │ └── Q_169.py ├── Q_170 │ └── Q_170.py ├── Q_164 │ └── Q_164.py ├── Q_173 │ └── Q_173.py ├── Q_172 │ └── Q_172.py ├── Q_174 │ └── Q_174.py ├── Q_171 │ └── Q_171.py └── Q_166 │ └── Q_166.py ├── Day_12 ├── Q_91 │ └── Q_91.py ├── Q_95 │ └── Q_95.py ├── Q_96 │ └── Q_96.py ├── Q_98 │ └── Q_98.py ├── Q_92 │ └── Q_92.py ├── Q_97 │ └── Q_97.py ├── Q_99 │ └── Q_99.py ├── Q_93 │ └── Q_93.py ├── Q_101 │ └── Q_101.py ├── Q_94 │ └── Q_94.py └── Q_100 │ └── Q_100.py ├── Day_14 ├── Q_115 │ └── Q_115.py ├── Q_121 │ └── Q_121.py ├── Q_122 │ └── Q_122.py ├── Q_127 │ └── Q_127.py ├── Q_116 │ └── Q_116.py ├── Q_128 │ └── Q_128.py ├── Q_129 │ └── Q_129.py ├── Q_119 │ └── Q_119.py ├── Q_130 │ └── Q_130.py ├── Q_120 │ └── Q_120.py ├── Q_118 │ └── Q_118.py ├── Q_123 │ └── Q_123.py ├── Q_124 │ └── Q_124.py ├── Q_125 │ └── Q_125.py ├── Q_131 │ └── Q_131.py ├── Q_126 │ └── Q_126.py └── Q_117 │ └── Q_117.py ├── Day_19 ├── Q_187 │ └── Q_187.py ├── Q_186 │ └── Q_186.py ├── Q_193 │ └── Q_193.py ├── Q_191 │ └── Q_191.py ├── Q_188 │ └── Q_188.py ├── Q_194 │ └── Q_194.py ├── Q_190 │ └── Q_190.py ├── Q_195 │ └── Q_195.py ├── Q_189 │ └── Q_189.py └── Q_192 │ └── Q_192.py ├── Day_18 ├── Q_175 │ └── Q_175.py ├── Q_176 │ └── Q_176.py ├── Q_179 │ └── Q_179.py ├── Q_177 │ └── Q_177.py ├── Q_178 │ └── Q_178.py ├── Q_181 │ └── Q_181.py ├── Q_180 │ └── Q_180.py ├── Q_183 │ └── Q_183.py ├── Q_182 │ └── Q_182.py ├── Q_184 │ └── Q_184.py └── Q_185 │ └── Q_185.py ├── Day_15 ├── Q_136 │ └── Q_136.py ├── Q_132 │ └── Q_132.py ├── Q_142 │ └── Q_142.py ├── Q_143 │ └── Q_143.py ├── Q_149 │ └── Q_149.py ├── Q_150 │ └── Q_150.py ├── Q_144 │ └── Q_144.py ├── Q_133 │ └── Q_133.py ├── Q_135 │ └── Q_135.py ├── Q_134 │ └── Q_134.py ├── Q_141 │ └── Q_141.py ├── Q_147 │ └── Q_147.py ├── Q_140 │ └── Q_140.py ├── Q_146 │ └── Q_146.py ├── Q_137 │ └── Q_137.py ├── Q_139 │ └── Q_139.py ├── Q_138 │ └── Q_138.py ├── Q_145 │ └── Q_145.py └── Q_148 │ └── Q_148.py ├── Day_03 ├── Q_22 │ └── Q_22.py ├── Q_21 │ └── Q_21.py ├── Q_23 │ └── Q_23.py ├── Q_18 │ └── Q_18.py ├── Q_19 │ └── Q_19.py ├── Q_16 │ └── Q_16.py ├── Q_20 │ └── Q_20.py ├── Q_17 │ └── Q_17.py └── Q_24 │ └── Q_24.py ├── Day_05 ├── Q_42 │ └── Q_42.py ├── Q_40 │ └── Q_40.py ├── Q_41 │ └── Q_41.py ├── Q_45 │ └── Q_45.py ├── Q_50 │ └── Q_50.py ├── Q_51 │ └── Q_51.py ├── Q_44 │ └── Q_44.py ├── Q_49 │ └── Q_49.py ├── Q_43 │ └── Q_43.py ├── Q_52 │ └── Q_52.py ├── Q_48 │ └── Q_48.py ├── Q_46 │ └── Q_46.py ├── Q_47 │ └── Q_47.py └── Q_39 │ └── Q_39.py ├── Day_01 ├── Q_03 │ └── Q_03.py ├── Q_04 │ └── Q_04.py ├── Q_01 │ └── Q_01.py └── Q_02 │ └── Q_02.py ├── Day_04 ├── Q_25 │ └── Q_25.py ├── Q_26 │ └── Q_26.py ├── Q_35 │ └── Q_35.py ├── Q_33 │ └── Q_33.py ├── Q_36 │ └── Q_36.py ├── Q_28 │ └── Q_28.py ├── Q_34 │ └── Q_34.py ├── Q_27 │ └── Q_27.py ├── Q_29 │ └── Q_29.py ├── Q_30 │ └── Q_30.py ├── Q_38 │ └── Q_38.py ├── Q_31 │ └── Q_31.py ├── Q_37 │ └── Q_37.py └── Q_32 │ └── Q_32.py ├── Day_02 ├── Q_09 │ └── Q_09.py ├── Q_08 │ └── Q_08.py ├── Q_10 │ └── Q_10.py ├── Q_13 │ └── Q_13.py ├── Q_12 │ └── Q_12.py ├── Q_11 │ └── Q_11.py ├── Q_05 │ └── Q_05.py ├── Q_14 │ └── Q_14.py ├── Q_07 │ └── Q_07.py ├── Q_15 │ └── Q_15.py └── Q_06 │ └── Q_06.py ├── Day_07 ├── Q_64 │ └── Q_64.py ├── Q_63 │ └── Q_63.py └── Q_62 │ └── Q_62.py ├── Day_11 ├── Q_89 │ └── Q_89.py ├── Q_90 │ └── Q_90.py ├── Q_87 │ └── Q_87.py ├── Q_86 │ └── Q_86.py └── Q_88 │ └── Q_88.py ├── Day_13 ├── Q_112 │ └── Q_112.py ├── Q_105 │ └── Q_105.py ├── Q_111 │ └── Q_111.py ├── Q_104 │ └── Q_104.py ├── Q_106 │ └── Q_106.py ├── Q_107 │ └── Q_107.py ├── Q_102 │ └── Q_102.py ├── Q_103 │ └── Q_103.py ├── Q_108 │ └── Q_108.py ├── Q_110 │ └── Q_110.py ├── Q_109 │ └── Q_109.py ├── Q_113 │ └── Q_113.py └── Q_114 │ └── Q_114.py ├── Day_08 ├── Q_66 │ └── Q_66.py ├── Q_67 │ └── Q_67.py ├── Q_65 │ └── Q_65.py ├── Q_70 │ └── Q_70.py ├── Q_68 │ └── Q_68.py └── Q_69 │ └── Q_69.py ├── Day_09 ├── Q_71 │ └── Q_71.py ├── Q_78 │ └── Q_78.py ├── Q_73 │ └── Q_73.py ├── Q_74 │ └── Q_74.py ├── Q_72 │ └── Q_72.py ├── Q_75 │ └── Q_75.py ├── Q_77 │ └── Q_77.py ├── Q_76 │ └── Q_76.py ├── Q_79 │ └── Q_79.py └── Q_80 │ └── Q_80.py ├── Day_06 ├── Q_57 │ └── Q_57.py ├── Q_60 │ └── Q_60.py ├── Q_53 │ └── Q_53.py ├── Q_58 │ └── Q_58.py ├── Q_61 │ └── Q_61.py ├── Q_56 │ └── Q_56.py ├── Q_55 │ └── Q_55.py ├── Q_54 │ └── Q_54.py └── Q_59 │ └── Q_59.py ├── .vscode ├── tasks.json └── launch.json ├── Day_10 ├── Q_85 │ └── Q_85.py ├── Q_82 │ └── Q_82.py ├── Q_81 │ └── Q_81.py ├── Q_83 │ └── Q_83.py └── Q_84 │ └── Q_84.py ├── Day_22 ├── Project_05 │ └── Project_05.py └── Project_06 │ └── Project_06.py ├── Day_21 ├── Project_04 │ └── Project_04.py └── Project_03 │ └── Project_03.py └── README.md /Day_20/Project_01/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Day_16/Q_151/Q_151.py: -------------------------------------------------------------------------------- 1 | # 151. Write a Python program to create a tuple. 2 | tuple1=(1,2,3) 3 | print(type(tuple1)) -------------------------------------------------------------------------------- /Day_17/Q_162/Q_162.py: -------------------------------------------------------------------------------- 1 | # 162. Write a Python program to create a set with elements. 2 | set1={1,4,3,2,5,6} 3 | print(set1) -------------------------------------------------------------------------------- /Day_12/Q_91/Q_91.py: -------------------------------------------------------------------------------- 1 | # 91. Write a python to Print first 10 numbers using a for loop. 2 | 3 | for i in range(11): 4 | print(i) -------------------------------------------------------------------------------- /Day_16/Q_153/Q_153.py: -------------------------------------------------------------------------------- 1 | #153. Write a Python program to find the length of a tuple. 2 | 3 | tuple1=(1,2,3,4,5) 4 | print(len(tuple1)) -------------------------------------------------------------------------------- /Day_17/Q_163/Q_163.py: -------------------------------------------------------------------------------- 1 | # 163. Write a Python program to add an element to a set. 2 | set1={1,4,3,2,5,6} 3 | set1.add(8) 4 | print(set1) -------------------------------------------------------------------------------- /Day_14/Q_115/Q_115.py: -------------------------------------------------------------------------------- 1 | # 115. Write a Python Program to find the length of string. 2 | name="Kousar Raza" 3 | print("Length is: ",len(name)) -------------------------------------------------------------------------------- /Day_17/Q_167/Q_167.py: -------------------------------------------------------------------------------- 1 | # 167. Write a Python program to check if an element exists in a set. 2 | set1={1,4,3,2,5,6} 3 | print(4 in set1) -------------------------------------------------------------------------------- /Day_17/Q_168/Q_168.py: -------------------------------------------------------------------------------- 1 | # 168. Write a Python program to find the union of two sets. 2 | a={1,3,5,7,9} 3 | b={2,4,6,8} 4 | c=a|b 5 | print(c) -------------------------------------------------------------------------------- /Day_17/Q_161/Q_161.py: -------------------------------------------------------------------------------- 1 | # 161. Write a Python program to create an empty set. 2 | #Sets are denoted by curly braces 3 | set1={''} 4 | print(type(set1)) -------------------------------------------------------------------------------- /Day_19/Q_187/Q_187.py: -------------------------------------------------------------------------------- 1 | # 187. Define a function that takes two parameters and returns their sum. 2 | def sum(a,b): 3 | print(a+b) 4 | sum(4,5) -------------------------------------------------------------------------------- /Day_16/Q_156/Q_156.py: -------------------------------------------------------------------------------- 1 | # 156. Write a Python program to concatenate two tuples. 2 | tuple1=(1,3,5,7) 3 | tuple2=(2,4,6,8) 4 | print(tuple1+tuple2) 5 | -------------------------------------------------------------------------------- /Day_17/Q_165/Q_165.py: -------------------------------------------------------------------------------- 1 | # 165. Write a Python program to find the length of a set. 2 | set1={"banana","kiwi","melon","mango","cherry"} 3 | print(len(set1)) -------------------------------------------------------------------------------- /Day_17/Q_169/Q_169.py: -------------------------------------------------------------------------------- 1 | # 169. Write a Python program to find the intersection of two sets. 2 | a={1,2,3,4,5,7,9} 3 | b={2,4,6,8} 4 | c=a&b 5 | print(c) -------------------------------------------------------------------------------- /Day_19/Q_186/Q_186.py: -------------------------------------------------------------------------------- 1 | # 186. Define a simple function that prints "Hello, World!" when called. 2 | def hello(): 3 | print("Hello, World") 4 | hello() -------------------------------------------------------------------------------- /Day_14/Q_121/Q_121.py: -------------------------------------------------------------------------------- 1 | # 121. Write a Python program to convert lowercase string to uppercase. 2 | 3 | str1=input("Enter a String: ") 4 | print(str1.lower()) -------------------------------------------------------------------------------- /Day_14/Q_122/Q_122.py: -------------------------------------------------------------------------------- 1 | # 122. Write a Python program to convert upercase string to lowercase. 2 | 3 | str1=input("Enter a String: ") 4 | print(str1.upper()) -------------------------------------------------------------------------------- /Day_17/Q_170/Q_170.py: -------------------------------------------------------------------------------- 1 | # 170. Write a Python program to find the difference between two sets. 2 | 3 | a={1,2,3,4,5,7,9} 4 | b={2,4,6,8} 5 | c=a-b 6 | print(c) -------------------------------------------------------------------------------- /Day_19/Q_193/Q_193.py: -------------------------------------------------------------------------------- 1 | # Write a function that display the Multiply result of two argument using lamda function. 2 | 3 | x=lambda a, b: a*b 4 | print(x(4,6)) -------------------------------------------------------------------------------- /Day_12/Q_95/Q_95.py: -------------------------------------------------------------------------------- 1 | # 95. Write a python to print the first twenty(20) even numbers. 2 | 3 | for num in range(21): 4 | if(num%2==0): 5 | print(num) -------------------------------------------------------------------------------- /Day_12/Q_96/Q_96.py: -------------------------------------------------------------------------------- 1 | # 96. Write a python to print the first twenty(20) odd numbers. 2 | 3 | for num in range(21): 4 | if(num%2==1): 5 | print(num) -------------------------------------------------------------------------------- /Day_18/Q_175/Q_175.py: -------------------------------------------------------------------------------- 1 | # 175. Write a Python program to create a dictionary and print their content. 2 | fruits={"apple":5,"banana":2,"orange":9} 3 | print(fruits) -------------------------------------------------------------------------------- /Day_19/Q_191/Q_191.py: -------------------------------------------------------------------------------- 1 | def reverse_string(s): 2 | return s[::-1] 3 | 4 | string = "hello" 5 | print("Reverse of", string, "is", reverse_string(string)) 6 | -------------------------------------------------------------------------------- /Day_12/Q_98/Q_98.py: -------------------------------------------------------------------------------- 1 | # 98. Write a Python to generate a list of numbers from 9 to 50 divisible by 2. 2 | for i in range(9,51): 3 | if(i%2==0): 4 | print(i) -------------------------------------------------------------------------------- /Day_15/Q_136/Q_136.py: -------------------------------------------------------------------------------- 1 | # 136. Write a Python program to count the number of elements in a list. 2 | list1=[2,3,4,5,5,2,2,5,5,2] 3 | count=list1.count(4) 4 | print(count) -------------------------------------------------------------------------------- /Day_17/Q_164/Q_164.py: -------------------------------------------------------------------------------- 1 | # 164. Write a Python program to remove an element from a set. 2 | set1={"banana","kiwi","melon","mango"} 3 | set1.remove("kiwi") 4 | print(set1) -------------------------------------------------------------------------------- /Day_17/Q_173/Q_173.py: -------------------------------------------------------------------------------- 1 | # 173. Write a Python program to check if one set is a subset of another set. 2 | a={2,4,6,3,5,9} 3 | b={1,2,3,4,5,6,7,8,9} 4 | c=a<=b 5 | print(c) -------------------------------------------------------------------------------- /Day_18/Q_176/Q_176.py: -------------------------------------------------------------------------------- 1 | # 176. Write a Python program to create a dictionary and print their keys 2 | fruits={"apple":5,"banana":2,"orange":9} 3 | print(fruits.keys()) -------------------------------------------------------------------------------- /Day_18/Q_179/Q_179.py: -------------------------------------------------------------------------------- 1 | # 179. Write a Python program to concatenate two dictionaries. 2 | d1={"a":1,"b":2} 3 | d2={"c":3,"d":4,"e":5} 4 | d1.update(d2) 5 | print(d1) -------------------------------------------------------------------------------- /Day_15/Q_132/Q_132.py: -------------------------------------------------------------------------------- 1 | # 132. Write a Python program to create a list containing your favorite colors. 2 | colors=['Blue',"Green","Red"] 3 | for i in colors: 4 | print(i) -------------------------------------------------------------------------------- /Day_16/Q_152/Q_152.py: -------------------------------------------------------------------------------- 1 | # 152. Write a Python program to convert a tuple to a list. 2 | tuple1=(1,2,3) 3 | print(type(tuple1)) 4 | tuple1=list(tuple1) 5 | print(type(tuple1)) -------------------------------------------------------------------------------- /Day_17/Q_172/Q_172.py: -------------------------------------------------------------------------------- 1 | # 172. Write a Python program to find the symmetric difference between two sets. 2 | a={2,4,6,3,5,9} 3 | b={1,2,3,4,5,6,7,8,9} 4 | c=a^b 5 | print(c) -------------------------------------------------------------------------------- /Day_17/Q_174/Q_174.py: -------------------------------------------------------------------------------- 1 | # 174. Write a Python program to check if one set is a superset of another set. 2 | a={2,4,6,3,5,9} 3 | b={1,2,3,4,5,6,7,8,9} 4 | c=a>b 5 | print(c) -------------------------------------------------------------------------------- /Day_18/Q_177/Q_177.py: -------------------------------------------------------------------------------- 1 | # 177. Write a Python program to create a dictionary and print their values. 2 | fruits={"apple":5,"banana":2,"orange":9} 3 | print(fruits.values()) -------------------------------------------------------------------------------- /Day_19/Q_188/Q_188.py: -------------------------------------------------------------------------------- 1 | # 188. Write a Python function that calculates the square of a number passed as an argument. 2 | def square(n): 3 | print(n*n) 4 | square(6) 5 | -------------------------------------------------------------------------------- /Day_03/Q_22/Q_22.py: -------------------------------------------------------------------------------- 1 | # # 22. Write a Python program to find the cube of the number. 2 | 3 | n1=int(input("Enter a number")) 4 | cube=n1*n1*n1 5 | print("Cubeof ",n1," is: ",cube) -------------------------------------------------------------------------------- /Day_05/Q_42/Q_42.py: -------------------------------------------------------------------------------- 1 | # 42. Write a Python program to convert months into days. 2 | 3 | months=int(input("Enter number of months: ")) 4 | days=months*30 5 | print("Days: ",days) -------------------------------------------------------------------------------- /Day_14/Q_127/Q_127.py: -------------------------------------------------------------------------------- 1 | # 127. Write a Python program to Converts the first character to upper case in string. 2 | 3 | str1=input("Enter a String: ") 4 | print(str1.capitalize()) -------------------------------------------------------------------------------- /Day_15/Q_142/Q_142.py: -------------------------------------------------------------------------------- 1 | # 142. Write a Python program to combine two lists into a single list. 2 | list1=[0,2,4,6,8] 3 | list2=[1,3,5,7,9] 4 | list1=list1+list2 5 | print(list1) -------------------------------------------------------------------------------- /Day_18/Q_178/Q_178.py: -------------------------------------------------------------------------------- 1 | # 178. Write a Python program to create a dictionary and get the dictionary size 2 | 3 | fruits={"apple":5,"banana":2,"orange":9} 4 | print(len(fruits)) -------------------------------------------------------------------------------- /Day_01/Q_03/Q_03.py: -------------------------------------------------------------------------------- 1 | #2. Write a python program to print your name, date of birth, and mobile number. 2 | 3 | print("Kousar Raza") 4 | print("21/05/2002") 5 | print("0300-0000000") -------------------------------------------------------------------------------- /Day_03/Q_21/Q_21.py: -------------------------------------------------------------------------------- 1 | # 21. Write a Python program to find the square of the number. 2 | 3 | n1=int(input("Enter a number")) 4 | square=n1*n1 5 | print("Square of ",n1," is: ",square) -------------------------------------------------------------------------------- /Day_05/Q_40/Q_40.py: -------------------------------------------------------------------------------- 1 | # 40. Write a Python program to convert years into months. 2 | 3 | years=int(input("Enter number of years: ")) 4 | months=12*years 5 | print("Months: ",months) -------------------------------------------------------------------------------- /Day_05/Q_41/Q_41.py: -------------------------------------------------------------------------------- 1 | # 41. Write a Python program to convert months into years. 2 | 3 | months=int(input("Enter number of months: ")) 4 | years=months/12 5 | print("Years: ",years) -------------------------------------------------------------------------------- /Day_04/Q_25/Q_25.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to convert specified meters into km. 2 | 3 | m=int(input("Enter meters ")) 4 | k=m/1000 5 | 6 | print("Distance in kilometers: ",k) 7 | 8 | -------------------------------------------------------------------------------- /Day_04/Q_26/Q_26.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to convert km into meters. 2 | 3 | k=int(input("Enter kilometers ")) 4 | m=k*1000 # 1km=1000m 5 | 6 | print("Distance in meters: ",m) 7 | -------------------------------------------------------------------------------- /Day_04/Q_35/Q_35.py: -------------------------------------------------------------------------------- 1 | # 35. Write a Python program to convert mintues into hours. 2 | 3 | mint=int(input("Enter number of Mintues ")) 4 | 5 | clock=mint/60 6 | print("Clock : ",clock) -------------------------------------------------------------------------------- /Day_14/Q_116/Q_116.py: -------------------------------------------------------------------------------- 1 | # 116. Write a Python Program to concatenate two strings. 2 | str1=input("Enter first string: ") 3 | str2=input("Enter second string: ") 4 | 5 | print(str1+str2) -------------------------------------------------------------------------------- /Day_15/Q_143/Q_143.py: -------------------------------------------------------------------------------- 1 | #143.Write a Python program to sort a list in ascending. 2 | thislist = ["orange", "mango", "kiwi", "pineapple", "banana"] 3 | thislist.sort() 4 | print(thislist) -------------------------------------------------------------------------------- /Day_15/Q_149/Q_149.py: -------------------------------------------------------------------------------- 1 | # 149. Write a Python program to find the index of an item in a specified list. 2 | fruits = ['apple', 'banana', 'cherry'] 3 | x = fruits.index("cherry") 4 | print(x) -------------------------------------------------------------------------------- /Day_15/Q_150/Q_150.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to remove the index of an item in a specified list. 2 | thislist = ["apple", "banana", "cherry"] 3 | thislist.pop(1) 4 | print(thislist) 5 | -------------------------------------------------------------------------------- /Day_16/Q_155/Q_155.py: -------------------------------------------------------------------------------- 1 | # 155. Write a Python program to find the sum of elements in a tuple. 2 | 3 | tuple1=(34,56,22,12,135,1) 4 | sum=0 5 | for i in tuple1: 6 | sum+=i 7 | print(sum) -------------------------------------------------------------------------------- /Day_16/Q_158/Q_158.py: -------------------------------------------------------------------------------- 1 | # 158. Write a Python program to reverse a tuple. 2 | tuple1=(4,8,1,3,9,2,5) 3 | tuple1=list(tuple1) 4 | tuple1.reverse() 5 | tuple1=tuple(tuple1) 6 | print(tuple1) -------------------------------------------------------------------------------- /Day_17/Q_171/Q_171.py: -------------------------------------------------------------------------------- 1 | # 171. Write a Python program to check if two sets have any common elements. 2 | 3 | a={1,2,3,4,5,7,9} 4 | b={2,4,6,8} 5 | c= (len(a.intersection(b))) 6 | print(c) -------------------------------------------------------------------------------- /Day_18/Q_181/Q_181.py: -------------------------------------------------------------------------------- 1 | # 181. Write a Python program to sum all the items in a dictionary. 2 | fruits={"apple":5,"banana":2,"orange":9} 3 | result=sum(fruits.values()) 4 | print(result) 5 | -------------------------------------------------------------------------------- /Day_19/Q_194/Q_194.py: -------------------------------------------------------------------------------- 1 | # 194. Write a function that display the Summarize argument a, b, and c and return the result using lamda function. 2 | x= lambda a,b,c: a+b+c 3 | print(x(3,5,8)) -------------------------------------------------------------------------------- /Day_04/Q_33/Q_33.py: -------------------------------------------------------------------------------- 1 | # 33. Write a Python program to convert seconds into mintues. 2 | 3 | sec=int(input("Enter number of Seconds: ")) 4 | 5 | mint=sec/60 6 | print("Seconds in mintues: ",mint) -------------------------------------------------------------------------------- /Day_04/Q_36/Q_36.py: -------------------------------------------------------------------------------- 1 | # 36. Write a Python program to convert clock into mintues. 2 | 3 | clock=int(input("Enter number of Clock ")) 4 | 5 | mint=60*clock 6 | print("Mintues in clock : ",mint) -------------------------------------------------------------------------------- /Day_05/Q_45/Q_45.py: -------------------------------------------------------------------------------- 1 | # 45. Write a Python program to convert days into weeks. 2 | 3 | days=int(input("Enter number of days: ")) 4 | week=days//7 5 | print("Weeks: ",week) 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Day_15/Q_144/Q_144.py: -------------------------------------------------------------------------------- 1 | # 144. Write a Python program to find the length of a list (number of elements) 2 | 3 | list1= ["orange", "mango", "kiwi", "pineapple", "banana"] 4 | print(len(list1)) -------------------------------------------------------------------------------- /Day_16/Q_157/Q_157.py: -------------------------------------------------------------------------------- 1 | #157. Write a Python program to sort a tuple. 2 | tuple1=(4,8,1,3,9,2,5) 3 | tuple1=list(tuple1) 4 | tuple1.sort() 5 | tuple1=tuple(tuple1) 6 | print(tuple1) 7 | 8 | 9 | -------------------------------------------------------------------------------- /Day_17/Q_166/Q_166.py: -------------------------------------------------------------------------------- 1 | # 166. Write a Python program to clear a set. 2 | set1={"banana","kiwi","melon","mango","cherry"} 3 | print(set1) 4 | print("After Clear") 5 | set1.clear() 6 | print(set1) -------------------------------------------------------------------------------- /Day_04/Q_28/Q_28.py: -------------------------------------------------------------------------------- 1 | # 28. Write a Python program to convert m into cm. 2 | 3 | m=int(input("Enter length in meter ")) 4 | cm=m * 100 # 1m= 100cm 5 | 6 | print("Distance in centimeters: ",cm) -------------------------------------------------------------------------------- /Day_04/Q_34/Q_34.py: -------------------------------------------------------------------------------- 1 | # 33. Write a Python program to convert mintues into seconds. 2 | 3 | mint=int(input("Enter number of Mintues ")) 4 | 5 | sec=mint*60 6 | print("Mintues in seconds : ",sec) -------------------------------------------------------------------------------- /Day_14/Q_128/Q_128.py: -------------------------------------------------------------------------------- 1 | # 128. Write a Python program to Count the character in string. 2 | 3 | txt = "I love apples, apple are my favorite fruit" 4 | 5 | x = txt.count("apple") 6 | 7 | print(x) -------------------------------------------------------------------------------- /Day_16/Q_159/Q_159.py: -------------------------------------------------------------------------------- 1 | # 159. Write a Python program to remove an element from a tuple. 2 | t1=("apple","banana","mango","kiwi") 3 | t1=list(t1) 4 | t1.remove("banana") 5 | t1=tuple(t1) 6 | print(t1) -------------------------------------------------------------------------------- /Day_04/Q_27/Q_27.py: -------------------------------------------------------------------------------- 1 | # 27. Write a Python program to convert cm into m. 2 | 3 | cm=int(input("Enter length in centimeter ")) 4 | m=cm/100 # 1m= 100cm 5 | 6 | print("Distance in meters: ",m) 7 | 8 | -------------------------------------------------------------------------------- /Day_14/Q_129/Q_129.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to remove any white spaces at the end of the string. 2 | 3 | txt = " banana " 4 | x = txt.rstrip() 5 | print("of all fruits", x, "is my favorite") -------------------------------------------------------------------------------- /Day_15/Q_133/Q_133.py: -------------------------------------------------------------------------------- 1 | # 133. Write a Python program to sum all the items in a list. 2 | 3 | ages=[23,31,8,9,12,20] 4 | sum=0 5 | for i in ages: 6 | sum+=i 7 | print("Sum of ",ages," is: ",sum) 8 | -------------------------------------------------------------------------------- /Day_02/Q_09/Q_09.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the diameter of circle. 2 | 3 | radius=int(input("Enter Radius ")) 4 | D=2 * radius # diameter = 2*r 5 | print("circumference of circle is ",D) 6 | -------------------------------------------------------------------------------- /Day_03/Q_23/Q_23.py: -------------------------------------------------------------------------------- 1 | #23. Write a Python program to calculate the Power of the number. 2 | 3 | n1=int(input("Enter a number")) 4 | b= int(input("Enter a Power")) 5 | p=n1**b 6 | print("Cubeof ",n1," is: ",p) -------------------------------------------------------------------------------- /Day_15/Q_135/Q_135.py: -------------------------------------------------------------------------------- 1 | # 135. Write a Python program to find the average of elements in a list. 2 | list1=[2,4,6] 3 | avg=0 4 | for i in list1: 5 | avg+=i 6 | l=len(list1) 7 | avg=avg//l 8 | print(avg) -------------------------------------------------------------------------------- /Day_14/Q_119/Q_119.py: -------------------------------------------------------------------------------- 1 | # 119. Write a Python program to reverse a string. 2 | 3 | str1=input("Enter a String: ") 4 | print("Before Reverse ") 5 | print(str1) 6 | print("After Reverse") 7 | print(str1[-1::-1],) -------------------------------------------------------------------------------- /Day_15/Q_134/Q_134.py: -------------------------------------------------------------------------------- 1 | # 134 Write a Python program to multiply all the items in a list. 2 | list1=[2,3,4,5,6] 3 | multiply=1 4 | for i in list1: 5 | multiply*=i 6 | print("Multiply of ",list1," is: ",multiply) -------------------------------------------------------------------------------- /Day_16/Q_160/Q_160.py: -------------------------------------------------------------------------------- 1 | # 160. Write a Python program to find the index of an element in a tuple. 2 | fruits = ('apple', 'banana', 'cherry','kiwi') 3 | fruits=list(fruits) 4 | x=fruits.index("cherry") 5 | print(x) -------------------------------------------------------------------------------- /Day_04/Q_29/Q_29.py: -------------------------------------------------------------------------------- 1 | # 29. Write a Python program to convert centimetres to millimetres 2 | 3 | cm=int(input("Enter length in centimeter ")) 4 | mm=cm * 10 # 1cm= 10mm 5 | 6 | print("Distance in milimeters: ",mm) -------------------------------------------------------------------------------- /Day_04/Q_30/Q_30.py: -------------------------------------------------------------------------------- 1 | # 30. Write a Python program to convert millimetres to centimetres 2 | 3 | mm=int(input("Enter length in milimeter ")) 4 | cm=mm / 10 # 1cm= 10mm 5 | 6 | print("Distance in centimeters: ",cm) -------------------------------------------------------------------------------- /Day_15/Q_141/Q_141.py: -------------------------------------------------------------------------------- 1 | # 141. Write a Python program to reverse the order of elements in a list. 2 | list1=[1,3,5,7,9] 3 | print("Before Reverse ") 4 | print(list1) 5 | print("After Reverse ") 6 | print(list1[::-1]) -------------------------------------------------------------------------------- /Day_15/Q_147/Q_147.py: -------------------------------------------------------------------------------- 1 | # 147. Write a Python program to remove a specified item in the list. 2 | list1=["orange", "mango", "kiwi", "pineapple", "banana"] 3 | #remove kiwi 4 | list1.remove("kiwi") 5 | print(list1) -------------------------------------------------------------------------------- /Day_16/Q_154/Q_154.py: -------------------------------------------------------------------------------- 1 | # 154. Write a Python program to check if an element exists in a tuple. 2 | tuple1=(34,56,22,12,135,1) 3 | if 135 in tuple1: 4 | print("Exit") 5 | else: 6 | print("Not Exit") 7 | 8 | -------------------------------------------------------------------------------- /Day_05/Q_50/Q_50.py: -------------------------------------------------------------------------------- 1 | # 50. Write a Python program to input temperature in Celsius and convert to Kelvin 2 | Celsius=int(input("Enter Temperature in Celsius: ")) 3 | Kelvin=Celsius+273.15 4 | print("In Kelvin: ",Kelvin) -------------------------------------------------------------------------------- /Day_05/Q_51/Q_51.py: -------------------------------------------------------------------------------- 1 | # 51. Write a Python program to input temperature in Kelvin and convert to Celsius. 2 | Kelvin=int(input("Enter Temperature in Kelvin: ")) 3 | Celsius=Kelvin -273.15 4 | print("In Celsisu: ",Celsius) -------------------------------------------------------------------------------- /Day_07/Q_64/Q_64.py: -------------------------------------------------------------------------------- 1 | # 64.Write a Python program to check whether a given number is even or odd. 2 | 3 | num=int(input("Enter a Number: ")) 4 | 5 | if(num%2==0): 6 | print("Even") 7 | else: 8 | print("Odd") 9 | -------------------------------------------------------------------------------- /Day_12/Q_92/Q_92.py: -------------------------------------------------------------------------------- 1 | # 92. Write a python to Print first 10 numbers and their sum using a for loop. 2 | sum=0 3 | for num in range(11): 4 | print(num) 5 | sum+=num 6 | print("-----------------------") 7 | print(sum) -------------------------------------------------------------------------------- /Day_15/Q_140/Q_140.py: -------------------------------------------------------------------------------- 1 | # 140. Write a Python program to check if a list is empty or not. 2 | 3 | list1=[1,2] 4 | if len(list1) == 0: 5 | print("List is Empty") 6 | else: 7 | print("List is Not Empty") 8 | -------------------------------------------------------------------------------- /Day_02/Q_08/Q_08.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the circumference of circle. 2 | 3 | pi=22/7 4 | radius=int(input("Enter Radius ")) 5 | C=2 * pi * radius # circumference = 2πr 6 | print("circumference of circle is ",C) -------------------------------------------------------------------------------- /Day_14/Q_130/Q_130.py: -------------------------------------------------------------------------------- 1 | 2 | input_string = "This is a sample sentence to count words" 3 | words_list = input_string.split() 4 | num_words = len(words_list) 5 | 6 | print(f"The total number of words in the string is: {num_words}") -------------------------------------------------------------------------------- /Day_19/Q_190/Q_190.py: -------------------------------------------------------------------------------- 1 | # 190 Define a Python function that takes a list as an argument and returns the sum of all elements in the list. 2 | result=0 3 | def Sum(a): 4 | print(a) 5 | list1=[1,2,3] 6 | a=sum(list1) 7 | Sum(a) -------------------------------------------------------------------------------- /Day_02/Q_10/Q_10.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the radius of circle. 2 | 3 | pi=22/7 4 | C=int(input("Enter circumference ")) #circumference 5 | 6 | r= C/pi*2 # radius = C/2*pi 7 | print("radius of circle is ",r) 8 | -------------------------------------------------------------------------------- /Day_02/Q_13/Q_13.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the Area of a Square 2 | 3 | s=int(input("Enter Base ")) #length of side 4 | A=s*s # Area of a Square = length of side * length of side 5 | print( " Area of a Square is ", A) 6 | -------------------------------------------------------------------------------- /Day_05/Q_44/Q_44.py: -------------------------------------------------------------------------------- 1 | # 44. Write a Python program to convert weeks into months & days. 2 | week=int(input("Enter number of weeks: ")) 3 | months=week/4 4 | days=week*7 5 | print("Months: ",months) 6 | print("Days: ",days) 7 | 8 | -------------------------------------------------------------------------------- /Day_05/Q_49/Q_49.py: -------------------------------------------------------------------------------- 1 | # 49. Write a Python program to input temperature in Celsius and convert to Fahrenheit 2 | Celsius=int(input("Enter Temperature in Celsius: ")) 3 | Fahrenheit=Celsius*(9/5)+32 4 | print("In Fahrenheit: ",Fahrenheit) -------------------------------------------------------------------------------- /Day_15/Q_146/Q_146.py: -------------------------------------------------------------------------------- 1 | # 146 Write a Python program to extend nested list by adding the sublist. 2 | list1=["orange", "mango", "kiwi", "pineapple", "banana"] 3 | list2=["cherry","melon","apple"] 4 | list1.extend(list2) 5 | print(list1) 6 | -------------------------------------------------------------------------------- /Day_05/Q_43/Q_43.py: -------------------------------------------------------------------------------- 1 | # 43. Write a Python program to convert days into months & days. 2 | 3 | days=int(input("Enter number of days: ")) 4 | months=days//30 5 | remaining_days=days%30 6 | print("Months: ",months) 7 | print("Days: ",remaining_days) -------------------------------------------------------------------------------- /Day_03/Q_18/Q_18.py: -------------------------------------------------------------------------------- 1 | # 18 Write a Python program to find a remainder when a number is divided by 2. 2 | 3 | num=int(input("Enter a Number ")) 4 | 5 | remainder = num % 2 6 | 7 | print('Remainder when the number is divided by 2 is:', remainder) 8 | -------------------------------------------------------------------------------- /Day_11/Q_89/Q_89.py: -------------------------------------------------------------------------------- 1 | # 89. Write a Python program to check the data type. 2 | 3 | name="Kousar" 4 | age=23 5 | height=5.6 6 | weight=45.5 7 | 8 | print(type(name)) 9 | print(type(age)) 10 | print(type(height)) 11 | print(type(weight)) 12 | -------------------------------------------------------------------------------- /Day_13/Q_112/Q_112.py: -------------------------------------------------------------------------------- 1 | # 112. Write a Python program to print all lower alphabets using while loop. 2 | alphabet = ord('a') 3 | print("Alphabets from a to z: ") 4 | while alphabet <= ord('z'): 5 | print(chr(alphabet), end=' ') 6 | alphabet += 1 -------------------------------------------------------------------------------- /Day_15/Q_137/Q_137.py: -------------------------------------------------------------------------------- 1 | # 137. Write a Python program to get the largest number from a list. 2 | list1=[213,4,34,12,9,1] 3 | largest=list1[0] 4 | for i in range(1,len(list1)): 5 | if list1[i] >largest: 6 | largest=list1[i] 7 | print(largest) -------------------------------------------------------------------------------- /Day_15/Q_139/Q_139.py: -------------------------------------------------------------------------------- 1 | # 139. Write a Python program to remove duplicates from a list. 2 | list1=[213,4,34,12,9,11,4,12] 3 | final_list = [] 4 | for num in list1: 5 | if num not in final_list: 6 | final_list.append(num) 7 | print(final_list) -------------------------------------------------------------------------------- /Day_02/Q_12/Q_12.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the area of a rectangle. 2 | 3 | l=int(input("Enter Base ")) #length 4 | b=int(input("Enter Height ")) #breadth 5 | A= l*b # Area of rectangle = Length x Breadth 6 | 7 | print("Area of rectangle is ",A) -------------------------------------------------------------------------------- /Day_08/Q_66/Q_66.py: -------------------------------------------------------------------------------- 1 | # 66. Write a Python program to check whether a number is divisible by 5 and 11 or not. 2 | 3 | num=int(input("Enter a Number: ")) 4 | if((num%5==0 )and(num%11==0 )): 5 | print("Divisible by 5 and 11") 6 | else: 7 | print("not") -------------------------------------------------------------------------------- /Day_13/Q_105/Q_105.py: -------------------------------------------------------------------------------- 1 | # 105.Write a Python program to input a number and calculate sum of digits using for loop. 2 | num = int(input("Enter a number: ")) 3 | sum = 0 4 | for digit in str(num): 5 | sum += int(digit) 6 | print("Sum of digits =", sum) 7 | -------------------------------------------------------------------------------- /Day_13/Q_111/Q_111.py: -------------------------------------------------------------------------------- 1 | # 111. Write a Python program to print all uppercase alphabets using while loop. 2 | alphabet = ord('A') 3 | print("Alphabets from A to Z: ") 4 | while alphabet <= ord('Z'): 5 | print(chr(alphabet), end=' ') 6 | alphabet += 1 -------------------------------------------------------------------------------- /Day_15/Q_138/Q_138.py: -------------------------------------------------------------------------------- 1 | # 138. Write a Python program to get the smallest number from a list. 2 | 3 | list1=[213,4,34,12,9,11] 4 | largest=list1[0] 5 | for i in range(1,len(list1)): 6 | if list1[i] b): 7 | print("Max is:",a) 8 | else: 9 | print("Max is ",b) 10 | -------------------------------------------------------------------------------- /Day_15/Q_145/Q_145.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to add new item to list after a specified item. 2 | list1= ["orange", "mango", "kiwi", "pineapple", "banana"] 3 | print(list1) 4 | list1.insert(1,"watermelon") 5 | print(list1) 6 | list1.append("orange") 7 | print(list1) -------------------------------------------------------------------------------- /Day_02/Q_05/Q_05.py: -------------------------------------------------------------------------------- 1 | #5. Write a Python program that accepts the user's first and last name and prints them in reverse order with a space between them. 2 | 3 | first_name=input("Enter First Name") 4 | last_name=input("Enter Last Name") 5 | print(last_name+" " +first_name) -------------------------------------------------------------------------------- /Day_08/Q_65/Q_65.py: -------------------------------------------------------------------------------- 1 | # 65. Write a Python program to whether a number is negative, positive or zero. 2 | num=int(input("Enter a Number: ")) 3 | if(num>0): 4 | print("Positive Number ") 5 | elif(num<0): 6 | print("Negative Number ") 7 | else: 8 | print("Zero ") -------------------------------------------------------------------------------- /Day_12/Q_97/Q_97.py: -------------------------------------------------------------------------------- 1 | # 97. Write a Python program to find the factorial value of any number entered through the keyboard. 2 | num = int(input("Enter the number: ")) 3 | fact=1 4 | for i in range(1,num+1): 5 | fact*=i 6 | print("The factorial of", num, "is", fact) 7 | -------------------------------------------------------------------------------- /Day_12/Q_99/Q_99.py: -------------------------------------------------------------------------------- 1 | # 99. Write a Python program to display Fibonacci series up to 10 terms. 2 | 3 | first=0 4 | second=1 5 | third=0 6 | for i in range(0,10): 7 | third=first+second 8 | print(first,end=" ") 9 | first=second 10 | second=third 11 | -------------------------------------------------------------------------------- /Day_09/Q_71/Q_71.py: -------------------------------------------------------------------------------- 1 | # 71. Write a Python program to check whether a year is leap year or not. 2 | 3 | year = int(input("Enter a year: ")) 4 | if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): 5 | print("Leap year") 6 | else: 7 | print("Not a leap year") 8 | -------------------------------------------------------------------------------- /Day_15/Q_148/Q_148.py: -------------------------------------------------------------------------------- 1 | #148 Write a Python program to remove all occurrences of a specific item from a list. 2 | list1=["red","blue","green","red","white","green","green","blue","pink"] 3 | element="red" 4 | while element in list1: 5 | list1.remove(element) 6 | print(list1) -------------------------------------------------------------------------------- /Day_13/Q_104/Q_104.py: -------------------------------------------------------------------------------- 1 | # 104.Write a Python program to input a number from user and count number of digits in the given integer using loop. 2 | count=0 3 | num=int(input("Enter a Number: ")) 4 | while(num!=0): 5 | num//=10 6 | count+=1 7 | print("Total Digits:",count) 8 | -------------------------------------------------------------------------------- /Day_13/Q_106/Q_106.py: -------------------------------------------------------------------------------- 1 | # 106. Write a Python program to input a number from user and calculate product of its digits. 2 | num = int(input("Enter a number: ")) 3 | product = 1 4 | for digit in str(num): 5 | product *= int(digit) 6 | 7 | print("Product of digits =", product) 8 | -------------------------------------------------------------------------------- /Day_02/Q_14/Q_14.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the Area of Parallelogram. 2 | 3 | b=int(input("Enter Base ")) #base 4 | h=int(input("Enter Height ")) # vertical height 5 | A= b * h # Area of Parallelogram = base * vertical height 6 | print("Area of Parallelogram is ", A) 7 | -------------------------------------------------------------------------------- /Day_03/Q_20/Q_20.py: -------------------------------------------------------------------------------- 1 | # 20. Write a Python program to calculate average of two numbers entered by the user. 2 | 3 | num1=int(input("Enter !st Number ")) 4 | num2=int(input("Enter 2nd Number ")) 5 | 6 | average=(num1+num2)/2 7 | 8 | print("Average of two numbers is : ",average) 9 | -------------------------------------------------------------------------------- /Day_08/Q_70/Q_70.py: -------------------------------------------------------------------------------- 1 | # 70. Write a Python program to check whether a character is alphabet or not. 2 | ch=input("Enter a character: ") 3 | 4 | if((ch>='a' and ch<='z') or (ch=='A' and ch<='Z')): 5 | print("It is Alphabet") 6 | else: 7 | print("It is not Alphabet") 8 | -------------------------------------------------------------------------------- /Day_19/Q_195/Q_195.py: -------------------------------------------------------------------------------- 1 | # 195. Write a function that calculates the average of a list of numbers. 2 | def calculate_average(a,b): 3 | return(sum (values)/len(values)) 4 | values = [3,4,5,6,7] 5 | a = sum(values) 6 | b = len(values) 7 | print(calculate_average(a,b)) 8 | 9 | 10 | -------------------------------------------------------------------------------- /Day_02/Q_07/Q_07.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to calculate the area of circle 2 | 3 | pi=3.14 # 22/7 is equal to 3.14 PI Value 4 | radius=int(input("Enter Radius ")) 5 | Area_of_Circle= pi*radius*radius # Formula calculate the area of circle 6 | 7 | print(" Area of Circle is ",Area_of_Circle) -------------------------------------------------------------------------------- /Day_07/Q_63/Q_63.py: -------------------------------------------------------------------------------- 1 | # 63. Write a Python program to accept two integers and check whether they are equal or not. 2 | 3 | a=int(input("Enter 1st Number: ")) 4 | b=int(input("Enter 2nd Number: ")) 5 | 6 | if(a==b): 7 | print("They are Equal") 8 | else: 9 | print("They are not Equal") -------------------------------------------------------------------------------- /Day_14/Q_120/Q_120.py: -------------------------------------------------------------------------------- 1 | # 120. Write a Python program to check if a string is a palindrome. 2 | wrd=input("Please enter a word: ") 3 | wrd=str(wrd) 4 | rvs=wrd[::-1] 5 | print(rvs) 6 | if wrd == rvs: 7 | print("This word is a palindrome") 8 | else: 9 | print("This word is not a palindrome") -------------------------------------------------------------------------------- /Day_19/Q_189/Q_189.py: -------------------------------------------------------------------------------- 1 | # 189. Create a Python function that checks if a number is even or odd and returns the result. 2 | def even_odd(num): 3 | if (num%2==0): 4 | print("Even Number") 5 | else: 6 | print("Odd Number") 7 | num=int(input("Enter a Number: ")) 8 | even_odd(num) -------------------------------------------------------------------------------- /Day_13/Q_107/Q_107.py: -------------------------------------------------------------------------------- 1 | # 107. Write a Python program to input a number from user and find all factors of the given number using for loop. 2 | num = int(input("Enter a number: ")) 3 | print("Factors of",num,"are: ") 4 | 5 | for i in range(1,num+1): 6 | if(num%i==0): 7 | print(i," ") 8 | -------------------------------------------------------------------------------- /Day_14/Q_118/Q_118.py: -------------------------------------------------------------------------------- 1 | # 118. Write a Python program to create a new string made of the middle three characters of an input string. 2 | 3 | str1="Islamabad" 4 | print("Original String is", str1) 5 | mi = int(len(str1) / 2) 6 | res = str1[mi - 1:mi + 2] 7 | print("Middle three chars are:", res) 8 | -------------------------------------------------------------------------------- /Day_04/Q_38/Q_38.py: -------------------------------------------------------------------------------- 1 | # 38. Write a Python program to convert days into hours ,mintues & seconds. 2 | 3 | days=int(input("Enter number of days: ")) 4 | 5 | hours=days* 24 6 | mint=days*1440 7 | sec=days*86400 8 | 9 | print("Hours: ",hours) 10 | print("Mintues: ",mint) 11 | print("Seconds ",sec) -------------------------------------------------------------------------------- /Day_09/Q_78/Q_78.py: -------------------------------------------------------------------------------- 1 | # 78. Write a Python program to read the age of a candidate and determine whether he is eligible to cast his/her own vote. 2 | 3 | age=int(input("Enter a age: ")) 4 | if(age>=18): 5 | print("Your are eligible for vote ") 6 | else: 7 | print("Your are not eligible for vote ") -------------------------------------------------------------------------------- /Day_04/Q_31/Q_31.py: -------------------------------------------------------------------------------- 1 | # 31. Write a Python program to input length in centimeter and convert it to meter and kilometer. 2 | 3 | cm=int(input("Enter length in centimeter : ")) 4 | 5 | m=cm/100 # 100cm=1 m 6 | km=cm/10000 # 1km=1000m 7 | print("Distance in meters: ",m) 8 | print("Distance in kilometers: ",km) -------------------------------------------------------------------------------- /Day_02/Q_15/Q_15.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to find the Perimeter of a rectangle = 2(Length + Width) 2 | ''' 3 | l=int(input("Enter Length ")) 4 | w=int(input("Enter Width ")) 5 | 6 | P= 2*(l + w) # Perimeter of a rectangle = 2(Length + Width) 7 | 8 | print(" Perimeter of a rectangle is ",P) 9 | 10 | -------------------------------------------------------------------------------- /Day_05/Q_46/Q_46.py: -------------------------------------------------------------------------------- 1 | # 46. Write a Python program to convert days into months,weeks & days. 2 | 3 | days=int(input("Enter number of days: ")) 4 | months=days//30 5 | week=(days%30)//7 6 | remaining_days=days%7 7 | print("Months:",months) 8 | print("Weeks: ",week) 9 | print("Days: ",remaining_days) 10 | -------------------------------------------------------------------------------- /Day_18/Q_183/Q_183.py: -------------------------------------------------------------------------------- 1 | # 183. Write a Python program to add elements to a dictionary. 2 | # Adding elements to a dictionary 3 | my_dict = {'apple': 5, 'banana': 3, 'orange': 7} 4 | 5 | # Adding a new key-value pair 6 | my_dict['grape'] = 4 7 | 8 | # Printing the updated dictionary 9 | print(my_dict) 10 | -------------------------------------------------------------------------------- /Day_06/Q_57/Q_57.py: -------------------------------------------------------------------------------- 1 | # 57.Write a Python program to display the result in Identity Operators. 2 | x="Kousar" 3 | y="Raza" 4 | 5 | 6 | print(x is "Kousar") #Returns True if both variables are the same object 7 | print( y is not x) # Returns True if both variables are not the same object 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Day_14/Q_123/Q_123.py: -------------------------------------------------------------------------------- 1 | # 123 Write a Python program to count the number of vowels in a given string. 2 | 3 | str1=input("Enter a String: ") 4 | vowels = 'aeiouAEIOU' 5 | vowel_count = 0 6 | for char in str1: 7 | if char in vowels: 8 | vowel_count += 1 9 | print(f"The number of vowels in '{str1}' is: {vowel_count}") -------------------------------------------------------------------------------- /Day_02/Q_06/Q_06.py: -------------------------------------------------------------------------------- 1 | #6. Write a Python Program that ask the user for two numbers and then print their sum. 2 | 3 | n1=int(input("Enter First Number ")) # input take always string then why we use int() to convert it into number. 4 | n2=int(input("Enter Second Number ")) 5 | 6 | print("Sum of", n1 ," and ",n2," is ",n1+n2) 7 | -------------------------------------------------------------------------------- /Day_03/Q_17/Q_17.py: -------------------------------------------------------------------------------- 1 | # #Q_16 Write a Python program to find the Perimeter of General triangle. 2 | 3 | a=int(input("Enter the size of all sides of the triangle : ")) #length of sides a,b,c 4 | b=int(input()) 5 | c=int(input()) 6 | 7 | P= a+b+c # Perimeter of General triangle P=a+b+c 8 | print( " Perimeter of square is ", P) -------------------------------------------------------------------------------- /Day_06/Q_60/Q_60.py: -------------------------------------------------------------------------------- 1 | # Q_60. Write a Python program to calculate simple interest 2 | 3 | p=float(input("Enter the Principle amount: ")) 4 | t = float(input("Enter the Time Period: ")) 5 | r = float(input("Enter the Rate of Interest: ")) 6 | 7 | simple_interest=(p*t*r)/100 8 | print("Simple interest is: ",simple_interest) 9 | -------------------------------------------------------------------------------- /Day_04/Q_37/Q_37.py: -------------------------------------------------------------------------------- 1 | # 37. Write a Python program to convert seconds into hours ,mintues & seconds. 2 | 3 | sec=int(input("Enter number of Seconds: ")) 4 | 5 | hours=sec//3600 6 | mint=(sec % 3600) //60 7 | remaining_sec=sec%60 8 | 9 | print("Hours: ",hours) 10 | print("Mintues: ",mint) 11 | print("Seconds ",remaining_sec) 12 | -------------------------------------------------------------------------------- /Day_09/Q_73/Q_73.py: -------------------------------------------------------------------------------- 1 | # 73. Write a Python program to check whether a character is Uppercase or Lowercase 2 | ch=input("Enter a character: ") 3 | if(ch>='A' and ch<='Z'): 4 | print(" It is a upercase letter") 5 | elif(ch>='a' and ch<='z'): 6 | print(" It is a lowercase letter") 7 | else: 8 | print("It is not an alphabetic character") -------------------------------------------------------------------------------- /Day_13/Q_102/Q_102.py: -------------------------------------------------------------------------------- 1 | # 102.Write a program that prompts the user to input an integer and then outputs the number with the digits reversed. 2 | reverse=0 3 | digit=0 4 | num=int(input("Enter a Number: ")) 5 | while(num!=0): 6 | digit=num%10 7 | reverse =reverse * 10 + digit 8 | num //= 10 9 | print("Reverse ",reverse) 10 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "echo", 8 | "type": "shell", 9 | "command": "echo Hello" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /Day_06/Q_53/Q_53.py: -------------------------------------------------------------------------------- 1 | # 53. Write a Python program to find the third angle of triangle if two angles are given. 2 | 3 | a=int(input("Enter first angle of triangle")) 4 | b=int(input("Enter second angle of triangle")) 5 | 6 | # sum of angles of triangle=180' 7 | #a+b+c=180' 8 | 9 | c=180-(a+b) 10 | print("Third angle of triangle is: ",c) -------------------------------------------------------------------------------- /Day_08/Q_68/Q_68.py: -------------------------------------------------------------------------------- 1 | # 68. Write a Python program to find maximum between three numbers. 2 | a=int(input("Enter 1st Number: ")) 3 | b=int(input("Enter 2nd Number: ")) 4 | c=int(input("Enter 3rd Number: ")) 5 | if(a>b and a>c): 6 | print("Max is:",a) 7 | elif(b>a and b>c): 8 | print("Max is:",b) 9 | else: 10 | print("Max is:",c) 11 | -------------------------------------------------------------------------------- /Day_12/Q_93/Q_93.py: -------------------------------------------------------------------------------- 1 | # 93. Write a python to print the multiplication table for a given number entered by the user: 2 | num = int(input("Enter the number for multiplication table: ")) 3 | 4 | print("Multiplication Table for", num) 5 | print("----------------------------------------") 6 | for i in range(1, 11): 7 | print(num, "x", i, "=", num * i) 8 | 9 | -------------------------------------------------------------------------------- /Day_08/Q_69/Q_69.py: -------------------------------------------------------------------------------- 1 | # 69. Write a Python program to find minimum between three numbers. 2 | 3 | a=int(input("Enter 1st Number: ")) 4 | b=int(input("Enter 2nd Number: ")) 5 | c=int(input("Enter 3rd Number: ")) 6 | if(a 0) and (b>0 and c>0)): 9 | print("Triangle is valid ") 10 | else: 11 | print("Triangle is not valid ") -------------------------------------------------------------------------------- /Day_09/Q_72/Q_72.py: -------------------------------------------------------------------------------- 1 | # 72. Write a Python program to take input any character and check whether it is alphabet, digit or special character. 2 | ch=input("Enter a character: ") 3 | if((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')): 4 | print("It is Alphbet") 5 | elif(ch>= '0' and ch<='9'): 6 | print("It is Digit") 7 | else: 8 | print(" It is Special character") -------------------------------------------------------------------------------- /Day_13/Q_103/Q_103.py: -------------------------------------------------------------------------------- 1 | # 103. Write a Python program to print all alphabets from a to z using while loop. 2 | alphabet = ord('a') # ASCII value of 'a' 3 | print("Alphabets from a to z:") 4 | while alphabet <= ord('z'): 5 | print(chr(alphabet), end=' ') # Print the current alphabet 6 | alphabet += 1 # Move to the next alphabet by incrementing ASCII value 7 | 8 | -------------------------------------------------------------------------------- /Day_13/Q_108/Q_108.py: -------------------------------------------------------------------------------- 1 | # 108. Write a Python program to input a number and check whether the number is Perfect number or not. 2 | 3 | num = int(input("Enter a number: ")) 4 | sum=0 5 | for i in range(1,num): 6 | if(num%i==0): 7 | sum+=i 8 | if(sum==num): 9 | print(num," is a perfect number. ") 10 | else: 11 | print(num," is not a perfect number. ") -------------------------------------------------------------------------------- /Day_05/Q_47/Q_47.py: -------------------------------------------------------------------------------- 1 | # 47. Write a Python program to convert specified days into years,months, weeks and days. 2 | 3 | days=int(input("Enter number of days: ")) 4 | years=days//365 5 | months=(days%365)//30 6 | week=(days%30)//7 7 | remaining_days=days%7 8 | print("Years: ",years) 9 | print("Months:",months) 10 | print("Weeks: ",week) 11 | print("Days: ",remaining_days) 12 | -------------------------------------------------------------------------------- /Day_18/Q_182/Q_182.py: -------------------------------------------------------------------------------- 1 | # 182. Write a Python program to remove a key from a dictionary. 2 | fruits={"apple":5,"banana":2,"orange":9} 3 | 4 | if 'apple' in fruits: 5 | # If 'a' is in the dictionary, delete the key-value pair with the key 'a'. 6 | del fruits['apple'] 7 | 8 | # Print the updated dictionary 'myDict' after deleting the key 'a' (if it existed). 9 | print(fruits) -------------------------------------------------------------------------------- /Day_18/Q_184/Q_184.py: -------------------------------------------------------------------------------- 1 | # 184. Write a Python program to iterate over a dictionary. 2 | # Iterating over a dictionary 3 | my_dict = {'apple': 5, 'banana': 3, 'orange': 7} 4 | 5 | # Iterating through keys 6 | for key in my_dict: 7 | print(key, my_dict[key]) 8 | 9 | # Iterating through key-value pairs 10 | for key, value in my_dict.items(): 11 | print(key, value) 12 | -------------------------------------------------------------------------------- /Day_14/Q_124/Q_124.py: -------------------------------------------------------------------------------- 1 | # 124. Write a Python program to find all occurrences of a substring in a given string by ignoring the case. 2 | str1 = "Welcome to USA. usa awesome, isn't it?" 3 | sub_string = "USA" 4 | 5 | # convert string to lowercase 6 | temp_str = str1.lower() 7 | 8 | # use count function 9 | count = temp_str.count(sub_string.lower()) 10 | print("The USA count is:", count) -------------------------------------------------------------------------------- /Day_04/Q_32/Q_32.py: -------------------------------------------------------------------------------- 1 | # 32. Write a Python program to input length in milimeter and convert it into centimeter,meter and kilometer. 2 | 3 | mm=int(input("Enter length in milimeter : ")) 4 | cm=mm/10 # 1cm=10mm 5 | m=mm/1000# 100cm=1 m 6 | km=cm/100000 # 1km=1000m 7 | 8 | print("Distance in centimeters: ",cm) 9 | print("Distance in meters: ",m) 10 | print("Distance in kilometers: ",km) -------------------------------------------------------------------------------- /Day_14/Q_125/Q_125.py: -------------------------------------------------------------------------------- 1 | # 125. Write a Python program to Calculate the sum and average of the digits present in a string. 2 | 3 | input_str = "KouSarRaza29@#8496" 4 | total = 0 5 | cnt = 0 6 | for char in input_str: 7 | if char.isdigit(): 8 | total += int(char) 9 | cnt += 1 10 | 11 | # average = sum / count of digits 12 | avg = total / cnt 13 | print("Sum is:", total, "Average is ", avg) -------------------------------------------------------------------------------- /Day_06/Q_58/Q_58.py: -------------------------------------------------------------------------------- 1 | # 58.Write a Python program to display the result in Membership Operators. 2 | ''' embership operators are used to test if a sequence is presented in an object''' 3 | 4 | f=["Banana","Apple","Mango"] 5 | 6 | print("Banana" in f) # Returns True if a sequence with the specified value is present in the object 7 | 8 | print("Kewi" not in f) 9 | 10 | print("Apple" not in f) 11 | 12 | 13 | -------------------------------------------------------------------------------- /Day_13/Q_110/Q_110.py: -------------------------------------------------------------------------------- 1 | # 110. Write a program in Python to input a number and check whether the number is prime number or not using for loop. 2 | num = int(input("Enter a number: ")) 3 | flag=1 4 | for i in range(2,num//2): 5 | if(num%i==0): 6 | flag=0 7 | break 8 | 9 | if(flag==1 and num>1): 10 | print(num,"is prime number ") 11 | else: 12 | print(num,"is not prime number ") -------------------------------------------------------------------------------- /Day_06/Q_61/Q_61.py: -------------------------------------------------------------------------------- 1 | # Q_61. Write a Python program to calculate compound interest. 2 | 3 | p=float(input("Enter the Principle amount: ")) 4 | r = float(input("Enter the Rate of Interest: ")) 5 | t = float(input("Enter the Time Period: ")) 6 | n = float(input("Enter the Number of times that interest is compounded per unit t:")) 7 | compound_interest=p*((1+r/100)**t-1) 8 | print("Compound interest is: ",compound_interest) 9 | -------------------------------------------------------------------------------- /Day_03/Q_24/Q_24.py: -------------------------------------------------------------------------------- 1 | # 24. Write a Python program to calculate average and product of three numbers entered by the user. 2 | 3 | num1=int(input("Enter !st Number ")) 4 | num2=int(input("Enter 2nd Number ")) 5 | num3=int(input("Enter 3rd Number ")) 6 | 7 | multi=num1*num2*num3 8 | average=(num1+num2+num3)/2 9 | 10 | print("Average of Three numbers is : ",average) 11 | print("Multiply of Three numbers is : ",multi) 12 | -------------------------------------------------------------------------------- /Day_05/Q_39/Q_39.py: -------------------------------------------------------------------------------- 1 | #39. Write a Python program to convert mintues into days,hours ,mintues & seconds. 2 | 3 | mint=int(input("Enter number of mintues: ")) 4 | days=mint//(24 * 60) 5 | remaining_mint=mint%(24 * 60) 6 | hours=remaining_mint//60 7 | mint_remaining=remaining_mint % 60 8 | 9 | sec=mint_remaining*60 10 | 11 | print("Days: ",days ) 12 | print("Hours: ",hours) 13 | print("Mintues: ",mint) 14 | print("Seconds ",sec) -------------------------------------------------------------------------------- /Day_09/Q_75/Q_75.py: -------------------------------------------------------------------------------- 1 | # 75. Write a Python program to take input week number and print week day. 2 | 3 | num=int(input("Enter a Week Day")) 4 | if(num==1): 5 | print("Monday") 6 | elif(num==2): 7 | print("Tuesday") 8 | elif(num==3): 9 | print("Wednesday") 10 | elif(num==4): 11 | print("Thursday") 12 | elif(num==5): 13 | print("Friday") 14 | elif(num==6): 15 | print("Saturday") 16 | else: 17 | print("Sunday") -------------------------------------------------------------------------------- /Day_12/Q_94/Q_94.py: -------------------------------------------------------------------------------- 1 | # 94.Write a python to print the first ten numbers square,cube and their sum. 2 | 3 | snum=ssquare=scube=0 4 | print("Number\t","Square\t","Cube") 5 | print("----------------------------------------") 6 | for i in range(1, 11): 7 | print(i, "\t", i*i, "\t", i*i*i) 8 | snum+=i 9 | ssquare+=i*i 10 | scube+=i*i*i 11 | print("----------------------------------------") 12 | print(snum,"\t",ssquare,"\t",scube) -------------------------------------------------------------------------------- /Day_13/Q_109/Q_109.py: -------------------------------------------------------------------------------- 1 | # 109. Write a Python program to input a number from user and check whether given number is Armstrong number or not. 2 | 3 | num = int(input("Enter a number: ")) 4 | temp=num 5 | sum=0 6 | while(num>0): 7 | r=num%10 8 | sum= sum+(r*r*r) 9 | num=num//10 10 | if(temp==sum): 11 | print(temp,"is an Armstrong number") 12 | else: 13 | print(temp, "is not an Armstrong number") 14 | -------------------------------------------------------------------------------- /Day_19/Q_192/Q_192.py: -------------------------------------------------------------------------------- 1 | # 192. Write a function called "count_vowels" that takes a string as input and returns the number of vowels (a, e, i, o, u) in that string. 2 | text = input("Enter a string : ") 3 | vowels = ['a','e','i','o','u'] 4 | count = [] 5 | def count_vowels(text): 6 | for i in text: 7 | if i in vowels: 8 | count.append(i) 9 | print("Number of vowels in given text are :",len(count)) 10 | count_vowels(text) -------------------------------------------------------------------------------- /Day_12/Q_100/Q_100.py: -------------------------------------------------------------------------------- 1 | # 100 Write a Python program that reads a set of integers from user, and then prints the sum of the even and odd integers. 2 | start=int(input("Enter First Number: ")) 3 | end=int(input("Enter Last Number: ")) 4 | even_sum=0 5 | odd_sum=0 6 | for i in range(start,end+1): 7 | if(i%2==0): 8 | even_sum+=i 9 | else: 10 | odd_sum+=i 11 | print("Sum of Even Number: ",even_sum,"\nSum of Odd Number",odd_sum) 12 | 13 | -------------------------------------------------------------------------------- /Day_14/Q_131/Q_131.py: -------------------------------------------------------------------------------- 1 | # 131. Write a python program to replace first occurrence of a character with another in a string. 2 | 3 | text = "Hello, world!" 4 | old_char = 'o' 5 | new_char = 'X' 6 | if text.index('') == -1: 7 | text 8 | elif text.index('')== 0: 9 | new_char + text[1:] 10 | 11 | modified_text=text[:text.index('')] + new_char + text[text.index('')+1:] 12 | 13 | print(f"Original text: {text}") 14 | print(f"Modified text: {modified_text}") -------------------------------------------------------------------------------- /Day_06/Q_56/Q_56.py: -------------------------------------------------------------------------------- 1 | # 56. Write a Python program take two numbers from user and display the result in Logical Operators. 2 | 3 | a=int(input("Enter first number ")) 4 | b=int(input("Enter second number ")) 5 | 6 | print(a==5 and b==2) # return True if both statement are True 7 | 8 | print(a!=b or b>=100) # return True if one of statement is True 9 | 10 | print(not(a<5 and b>10)) #reverse the result ,return False if the result is True 11 | 12 | 13 | -------------------------------------------------------------------------------- /Day_09/Q_77/Q_77.py: -------------------------------------------------------------------------------- 1 | # 77. Write a Python program to calculate profit or loss. 2 | 3 | cost_price = float(input("Enter cost price: ")) 4 | selling_price = float(input("Enter selling price: ")) 5 | 6 | if selling_price > cost_price: 7 | profit = selling_price - cost_price 8 | print("Profit:", profit) 9 | elif selling_price < cost_price: 10 | loss = cost_price - selling_price 11 | print("Loss:", loss) 12 | else: 13 | print("No profit, no loss.") 14 | -------------------------------------------------------------------------------- /Day_18/Q_185/Q_185.py: -------------------------------------------------------------------------------- 1 | # Write a Python program to demonstrating various dictionary methods. 2 | # Dictionary methods 3 | my_dict = {'apple': 5, 'banana': 3, 'orange': 7} 4 | 5 | # Length of dictionary 6 | print(len(my_dict)) 7 | 8 | # Check if a key exists 9 | print('apple' in my_dict) 10 | 11 | # Get value for a key 12 | print(my_dict.get('banana')) 13 | 14 | # Remove all items 15 | my_dict.clear() 16 | 17 | # Printing the empty dictionary 18 | print(my_dict) 19 | -------------------------------------------------------------------------------- /Day_09/Q_76/Q_76.py: -------------------------------------------------------------------------------- 1 | # 76. Write a Python program to check whether the triangle is equilateral, isosceles or scalene triangle. 2 | 3 | print("Enter the lengths of three sides of the triangle: ") 4 | a=int(input()) 5 | b=int(input()) 6 | c=int(input()) 7 | 8 | if(a==b and b==c): 9 | print("The triangle is an equilateral triangle ") 10 | elif(a==b or a==c or b==c ): 11 | print("The triangle is an isosceles triangle") 12 | else: 13 | print("The triangle is a scalene triangle ") -------------------------------------------------------------------------------- /Day_13/Q_113/Q_113.py: -------------------------------------------------------------------------------- 1 | # 113. Write a Python program that asks the user to enter a number and prints the sum of the divisors of that number. The sum of the divisors of a number is an important function in number theory 2 | 3 | num = int(input("Enter a number: ")) 4 | divisors_sum = 0 5 | for i in range(1, num + 1): 6 | if num % i == 0: 7 | divisors_sum += i 8 | 9 | # Calculate the sum of divisors and print the result 10 | print("Sum of divisors of", num, "is:", divisors_sum) 11 | -------------------------------------------------------------------------------- /Day_14/Q_126/Q_126.py: -------------------------------------------------------------------------------- 1 | # 126. Write a Python program to replace each special symbol with # in the following string. 2 | import string 3 | str1 = '/*Jon is @developer & musician!!' 4 | print("The original string is : ", str1) 5 | 6 | # Replace punctuations with # 7 | replace_char = '#' 8 | 9 | # string.punctuation to get the list of all special symbols 10 | for char in string.punctuation: 11 | str1 = str1.replace(char, replace_char) 12 | 13 | print("The strings after replacement : ", str1) -------------------------------------------------------------------------------- /Day_10/Q_85/Q_85.py: -------------------------------------------------------------------------------- 1 | # 85.Write a Python program to Determine the season based on the month. 2 | 3 | month = int(input("Enter a month number (1-12): ")) 4 | season='' 5 | if(month in(12,1,2)): 6 | season="Winter" 7 | elif(month in(3,4)): 8 | season="Spring" 9 | elif(month in(5,6,7,8,9)): 10 | season="Summer" 11 | elif(month in(10,11)): 12 | season="Fall" 13 | else: 14 | print("Invalid month number. Please enter a value between 1 and 12.") 15 | print(f"{month} falls in {season}.") -------------------------------------------------------------------------------- /Day_01/Q_04/Q_04.py: -------------------------------------------------------------------------------- 1 | # 4. Write a Python program to print the following string in a specific format (see the output). 2 | 3 | "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" 4 | 5 | 6 | print("Twinkle, twinkle, little star, \n\tHow I wonder what you are! \n\t\tUp above the world so high, \n\t\tLike a diamond in the sky. \nTwinkle, twinkle, little star, \n\tHow I wonder what you are!") 7 | -------------------------------------------------------------------------------- /Day_13/Q_114/Q_114.py: -------------------------------------------------------------------------------- 1 | # 114. Write a Python program that counts how many of the squares of the numbers from 1 to 100 end in a 4 and how many end in a 9. 2 | 3 | count_4 = 0 4 | count_9 = 0 5 | for num in range(1, 101): 6 | square = num ** 2 7 | last_digit = square % 10 8 | if last_digit == 4: 9 | count_4 += 1 10 | elif last_digit == 9: 11 | count_9 += 1 12 | 13 | print("Number of squares ending in 4:", count_4) 14 | print("Number of squares ending in 9:", count_9) 15 | -------------------------------------------------------------------------------- /Day_11/Q_90/Q_90.py: -------------------------------------------------------------------------------- 1 | # 90. Write a Python program for type casting. 2 | 3 | a=5 4 | b=4.4 5 | c='5' 6 | 7 | print(type(a)) 8 | print(type(b)) 9 | print(type(c)) 10 | print("After type casting") 11 | # change int into float then calculate sum 12 | a=float(a) 13 | print(type(a)) 14 | print(a+b) 15 | 16 | #change float into int then calculate multiply 17 | a=int(a) 18 | print(a*b) 19 | 20 | #change int into string 21 | a=str(a) 22 | print(type(a)) 23 | 24 | #string into int 25 | c=int(c) 26 | print(type(c)) -------------------------------------------------------------------------------- /Day_06/Q_55/Q_55.py: -------------------------------------------------------------------------------- 1 | # 55. Write a Python program take two numbers from user and display the result in Assignment operators. 2 | 3 | a=int(input("Enter first number ")) 4 | b=int(input("Enter second number ")) 5 | print(a=b) # a=b 6 | 7 | print("a+=2",a + = 2) #a=a+2 8 | 9 | print("b-=a",b - = a) # b=b-a 10 | 11 | print("a*=b",a*=b) # a= a*b 12 | 13 | print("b/=a",b/=a) # b=b/a 14 | 15 | print("a%=b",a%=b) # a=a%b 16 | 17 | print("a**=b",a**=b) #a=a**b 18 | 19 | print("a//=b",a//=b) # a=a//b 20 | 21 | -------------------------------------------------------------------------------- /Day_06/Q_54/Q_54.py: -------------------------------------------------------------------------------- 1 | # Write a Python program take two numbers from user and display the result in Comparison operators 2 | 3 | a=int(input("Enter first number ")) 4 | b=int(input("Enter second number ")) 5 | 6 | print(a==40) # equal operator (==) 7 | print(a!=b) # not equal operator (!=) 8 | 9 | print(a>b) # greater than operator (>) 10 | print(a=b) # greater than equal to operator (>=) 13 | 14 | print(a<=b) # less than equal to operator (<=) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Day_14/Q_117/Q_117.py: -------------------------------------------------------------------------------- 1 | # 117. Write a Python program to create a new string made of an input string’s first, middle, and last character. 2 | str1=input("Enter a String: ") 3 | 4 | print("Original String is", str1) 5 | 6 | # Get first character 7 | res = str1[0] 8 | 9 | # Get string size 10 | l = len(str1) 11 | # Get middle index number 12 | mi = int(l / 2) 13 | # Get middle character and add it to result 14 | res = res + str1[mi] 15 | 16 | # Get last character and add it to result 17 | res = res + str1[l - 1] 18 | 19 | print("New String:", res) -------------------------------------------------------------------------------- /Day_01/Q_01/Q_01.py: -------------------------------------------------------------------------------- 1 | #1. Write a Python program to find out what version of Python you are using. 2 | 3 | import sys # Import the sys module to access system-specific parameters and functions 4 | 5 | # Print the Python version to the console 6 | print("Python version") 7 | 8 | # Use the sys.version attribute to get the Python version and print it 9 | print(sys.version) 10 | 11 | # Print information about the Python version 12 | print("Version info.") 13 | 14 | # Use the sys.version_info attribute to get detailed version information and print it 15 | print(sys.version_info) -------------------------------------------------------------------------------- /Day_09/Q_79/Q_79.py: -------------------------------------------------------------------------------- 1 | # 79. Write a program in Python to read any digit and display it in the word. 2 | 3 | digit=int(input("Enter a digit (0-9) ")) 4 | 5 | if(digit==1): 6 | print("One") 7 | elif(digit==2): 8 | print("Two") 9 | elif(digit==3): 10 | print("Three") 11 | elif(digit==4): 12 | print("Four") 13 | 14 | elif(digit==5): 15 | print("Five") 16 | 17 | elif(digit==6): 18 | print("Six") 19 | elif(digit==7): 20 | print("Seven") 21 | elif(digit==8): 22 | print("Eight") 23 | elif(digit==9): 24 | print("Nine") 25 | else: 26 | print("Invalid Digit") -------------------------------------------------------------------------------- /Day_11/Q_87/Q_87.py: -------------------------------------------------------------------------------- 1 | # 87 Write a Python program to ask the user for a temperature. Then ask them what units, Celsius or Fahrenheit, the temperature is in. Your program should convert the temperature to the other unit. The conversions 2 | 3 | temperature=float(input("Enter the temperature: ")) 4 | 5 | print("Select Temperature unit:") 6 | print(" F for Fahrenheit and C for Celsius") 7 | 8 | temp=input() 9 | if temp=='F': 10 | F=9/5*(temperature+32) 11 | print(" Fahrenheit is: ",F) 12 | elif (temp=='C'): 13 | C=5/9*(temperature-32) 14 | print(" Celsius is: ",C) 15 | else: 16 | print("Invalid Temperature") -------------------------------------------------------------------------------- /Day_01/Q_02/Q_02.py: -------------------------------------------------------------------------------- 1 | #Write a Python program to display the current date and time. 2 | 3 | # Import the 'datetime' module to work with date and time 4 | import datetime 5 | 6 | # Get the current date and time 7 | now = datetime.datetime.now() 8 | 9 | # Create a datetime object representing the current date and time 10 | 11 | # Display a message indicating what is being printed 12 | print("Current date and time : ") 13 | 14 | # Print the current date and time in a specific format 15 | print(now.strftime("%Y-%m-%d %H:%M:%S")) 16 | 17 | # Use the 'strftime' method to format the datetime object as a string with the desired format 18 | -------------------------------------------------------------------------------- /Day_10/Q_82/Q_82.py: -------------------------------------------------------------------------------- 1 | # 82. Write a Python program to input basic salary of an employee and calculate its Gross salary according to following: 2 | ''' 3 | Basic Salary <= 10000 : HRA = 20%, DA = 80% 4 | Basic Salary <= 20000 : HRA = 25%, DA = 90% 5 | Basic Salary > 20000 : HRA = 30%, DA = 95% ''' 6 | 7 | basic_salary=int(input("Enter basic salary: ")) 8 | if(basic_salary<=10000): 9 | HRA=basic_salary*0.2 10 | DA=basic_salary*0.8 11 | elif(basic_salary<=20000): 12 | HRA=basic_salary*0.25 13 | DA=basic_salary*0.9 14 | else: 15 | HRA=basic_salary* 0.3 16 | DA=basic_salary*0.95 17 | gross_salary=basic_salary+HRA+DA 18 | print("Gross Salary: ",gross_salary) 19 | -------------------------------------------------------------------------------- /Day_11/Q_86/Q_86.py: -------------------------------------------------------------------------------- 1 | # 86. Write a Python program to find maximum and minimum between four numbers. 2 | 3 | a=int(input("Enter 1st Number: ")) 4 | b=int(input("Enter 2nd Number: ")) 5 | c=int(input("Enter 3rd Number: ")) 6 | d=int(input("Enter 4th Number: ")) 7 | if(a>b and a>c and a>d): 8 | print("Max is:",a) 9 | elif(b>a and b>c and b>d): 10 | print("Max is:",b) 11 | elif(c>a and c>b and c>d): 12 | print("Max is: ",c) 13 | else: 14 | print("Max is: ",d) 15 | if(a secret_num: 18 | print('LOWER.', 5-num_guesses, 'guesses left.\n') 19 | else: 20 | print('You got it!') 21 | # check the answer 22 | if num_guesses==5 and guess != secret_num: 23 | print('You lose. The correct number is', secret_num) -------------------------------------------------------------------------------- /Day_22/Project_06/Project_06.py: -------------------------------------------------------------------------------- 1 | import random 2 | #Function to generate random numbers 3 | def generate_question(): 4 | num1 = random.randint(1, 10) 5 | num2 = random.randint(1, 10) 6 | return num1, num2 7 | 8 | print("Welcome to the Multiplication Game!\n") 9 | 10 | correct_answers = 0 11 | #game loop 12 | for i in range(1,11): 13 | #call the function 14 | num1, num2 = generate_question() 15 | # Ask the question 16 | answer = int(input(f"Question {i}: {num1} * {num2} = ")) 17 | 18 | # check the answer 19 | if answer == num1 * num2: 20 | print("Correct!") 21 | # Update score 22 | correct_answers += 1 23 | else: 24 | print(f"Wrong. The answer is {num1 * num2}") 25 | # Print final results 26 | print(f"You got {correct_answers} out of 10 questions correct.") 27 | 28 | -------------------------------------------------------------------------------- /Day_21/Project_04/Project_04.py: -------------------------------------------------------------------------------- 1 | import random 2 | # Define options for the game 3 | choices = ["rock", "paper", "scissors"] 4 | # Get user input 5 | user_choice = input("Enter your choice (rock, paper, or scissors): ").lower() 6 | 7 | # Check for valid input 8 | if user_choice not in choices: 9 | print("Invalid choice. Please enter rock, paper, or scissors.") 10 | exit() 11 | 12 | # Generate computer's random choice 13 | computer_choice = random.choice(choices) 14 | 15 | # Determine the winner 16 | print("Computer's choice:", computer_choice) 17 | 18 | if user_choice == computer_choice: 19 | print("It's a tie!") 20 | elif (user_choice == "rock" and computer_choice == "scissors") or (user_choice == "paper" and computer_choice == "rock") or (user_choice == "scissors" and computer_choice == "paper"): 21 | print("You win!") 22 | else: 23 | print("Computer wins!") -------------------------------------------------------------------------------- /Day_06/Q_59/Q_59.py: -------------------------------------------------------------------------------- 1 | # 59. Write a Python to read an amount (integer value) and break the amount into the smallest possible number of bank notes. 2 | # Note: The possible banknotes are 1000, 500, 100, 50,20,10, 5, 2 and 1. 3 | 4 | amount=int(input("Enter a amount: ")) 5 | 6 | notes_1000=(amount//1000) 7 | print(notes_1000," Notes of Rs. 1000 ") 8 | notes_500=(amount%1000)//500 9 | print(notes_500," Notes of Rs. 500 ") 10 | notes_100=(amount%500)//100 11 | print(notes_100," Notes of Rs. 100 ") 12 | notes_50=(amount%100)//50 13 | print(notes_50," Notes of Rs. 50 ") 14 | notes_20=(amount%50)//20 15 | print(notes_20," Notes of Rs. 20 ") 16 | notes_10=(amount%20)//10 17 | print(notes_10," Notes of Rs. 10 ") 18 | notes_5=(amount%10)//5 19 | print(notes_5," Notes of Rs. 5 ") 20 | notes_2=(amount%5)//2 21 | print(notes_2," Notes of Rs. 2 ") 22 | notes_1=(amount%2)//1 23 | print(notes_1," Notes of Rs. 1 ") 24 | 25 | -------------------------------------------------------------------------------- /Day_10/Q_81/Q_81.py: -------------------------------------------------------------------------------- 1 | # 81. 42. Write a Python program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following: 2 | ''' Percentage >= 90% : Grade A 3 | Percentage >= 80% : Grade B 4 | Percentage >= 70% : Grade C 5 | Percentage >= 60% : Grade D 6 | Percentage >= 40% : Grade E 7 | Percentage < 40% : Grade F ''' 8 | 9 | Physics=int(input("Enter marks of Physics: ")) 10 | Chemistry=int(input("Enter marks of Chemistry: ")) 11 | Biology=int(input("Enter marks of Biology: ")) 12 | Mathematics=int(input("Enter marks of Mathematics: ")) 13 | Computer=int(input("Enter marks of Computer: ")) 14 | 15 | total=Physics+Chemistry+Biology+Mathematics+Computer 16 | percentage=(total/500)*100 17 | 18 | if(percentage>=90): 19 | print("Grade A") 20 | elif(percentage>=80): 21 | print("Grade B") 22 | elif(percentage>70): 23 | print("Grade C") 24 | elif(percentage>=60): 25 | print("Grade D") 26 | elif(percentage>=40): 27 | print("Grade E") 28 | else: 29 | print("Grade F") 30 | -------------------------------------------------------------------------------- /Day_10/Q_83/Q_83.py: -------------------------------------------------------------------------------- 1 | # 83. Write a Python program to input electricity unit charges and calculate total electricity bill according to the given condition: 2 | ''' 3 | For first 50 units Rs. 0.50/unit 4 | For next 100 units Rs. 0.75/unit 5 | For next 100 units Rs. 1.20/unit 6 | For unit above 250 Rs. 1.50/unit 7 | An additional surcharge of 20% is added to the bill ''' 8 | 9 | units=int(input("Enter number of units: ")) 10 | bill_amount = 0 11 | if(units<=50): 12 | bill_amount = units * 0.50 13 | elif(units<=150): 14 | bill_amount = (50 * 0.50) + ((units - 50) * 0.75) 15 | elif(units<= 250): 16 | bill_amount = (50 * 0.50) + (100 * 0.75) + ((units - 150) * 1.20) 17 | else: 18 | bill_amount = (50 * 0.50) + (100 * 0.75) + (100 * 1.20) + ((units - 250) * 1.50) 19 | 20 | surcharge = bill_amount * 0.20 21 | total_bill = bill_amount + surcharge 22 | 23 | 24 | print("Electricity Bill ") 25 | print("Units Consumed:", units) 26 | print("Bill Amount: Rs.",bill_amount) 27 | print("Surcharge (20%): Rs. ",surcharge) 28 | print("Total Bill Amount: Rs. ",total_bill) 29 | 30 | -------------------------------------------------------------------------------- /Day_10/Q_84/Q_84.py: -------------------------------------------------------------------------------- 1 | # 84.. Write a Python program to given an age, figure out whether someone's a baby, toddler, child, teenager, adult or old codger. 2 | 3 | age = int(input("Enter a person's age: ")) 4 | life_stage=0 5 | if (age <= 0): 6 | life_stage="Invalid Age" 7 | elif (age <= 1): 8 | life_stage="Baby" 9 | elif (age <= 3): 10 | life_stage="Toddler" 11 | elif age <= 12: 12 | life_stage="Child" 13 | elif age <= 19: 14 | life_stage="Teenager" 15 | elif age <= 65: 16 | life_stage="Adult" 17 | else: 18 | life_stage="Old Codger" 19 | print(f"{age} years old is considered {life_stage}.") -------------------------------------------------------------------------------- /Day_11/Q_88/Q_88.py: -------------------------------------------------------------------------------- 1 | #86. Write a Python program to ask the user to enter a temperature in Celsius. 2 | #The program should print a message based on the temperature: 3 | 4 | ''' 5 | • If the temperature is less than -273.15, print that the temperature is invalid because it is 6 | below absolute zero. 7 | • If it is exactly -273.15, print that the temperature is absolute 0. 8 | • If the temperature is between -273.15 and 0, print that the temperature is below freezing. 9 | • If it is 0, print that the temperature is at the freezing point. 10 | • If it is between 0 and 100, print that the temperature is in the normal range. 11 | • If it is 100, print that the temperature is at the boiling point. 12 | • If it is above 100, print that the temperature is above the boiling point. ''' 13 | 14 | temp=float(input("Enter the temperature in Celsius: ")) 15 | 16 | if(temp<-273.15): 17 | print(("It is invalid because it is below absolute zero.")) 18 | elif(temp==-273.15): 19 | print(' The temperature is absolute 0.') 20 | elif(temp in(-273.15,0)): 21 | print("The temperature is below freezing.") 22 | elif(temp==0): 23 | print("The temperature is at the freezing point.") 24 | elif(temp in(0,100)): 25 | print("The temperature is in the normal range.") 26 | elif(temp==100): 27 | print("The temperature is is at the boiling point.") 28 | else: 29 | print("the temperature is above the boiling point.") 30 | -------------------------------------------------------------------------------- /Day_20/Project_01/Calculator.py: -------------------------------------------------------------------------------- 1 | # Calculator 2 | 3 | # Chose a option 4 | operation = input(''' 5 | Please select operation you would like to complete: 6 | 1 for Addition 7 | 2 for Subtraction 8 | 3 for Multiplication 9 | 4 for Division 10 | 5 for Floor Division 11 | 6 for Modulus 12 | 7 for Exponentiation 13 | Enter the number corresponding to the operation: ''') 14 | 15 | # Input two numbers from the user 16 | number_1 = int(input('Enter your first number: ')) 17 | number_2 = int(input('Enter your second number: ')) 18 | 19 | # perform addition 20 | if operation == '1': 21 | print('{} + {} = '.format(number_1, number_2),(number_1+number_2)) 22 | 23 | 24 | elif operation == '2': 25 | print('{} - {} = '.format(number_1, number_2),(number_1 - number_2)) 26 | 27 | elif operation == '3': 28 | print('{} * {} = '.format(number_1, number_2),(number_1 * number_2)) 29 | 30 | elif operation == '4': 31 | print('{} / {} = '.format(number_1, number_2),(number_1 / number_2)) 32 | elif operation == '5': 33 | if number_2 == 0: 34 | print("Error! Division by zero is not allowed.") 35 | else: 36 | print('{} // {} = '.format(number_1, number_2),(number_1 // number_2)) 37 | 38 | elif operation == '6': 39 | if number_2 == 0: 40 | print("Error! Modulus by zero is not allowed.") 41 | else: 42 | print('{} % {} = '.format(number_1, number_2),(number_1 % number_2)) 43 | elif operation == '7': 44 | print('{} ** {} = '.format(number_1, number_2),(number_1 ** number_2)) 45 | 46 | else: 47 | print('You have not typed a valid operator, please run the program again.') -------------------------------------------------------------------------------- /Day_07/Q_62/Q_62.py: -------------------------------------------------------------------------------- 1 | # 62. Write a Python program to swap a number by using diffrent methods. 2 | 3 | n1=int(input("Enter 1st Number: ")) 4 | n2=int(input("Enter 2nd Number: ")) 5 | 6 | #Swap Numbers Using Temporary Variable 7 | print("Swap Numbers Using Temporary Variable ") 8 | 9 | print("Before Swap ") 10 | print("1st Number is: ",n1) 11 | print("2nd Number is: ",n2) 12 | temp=n1 13 | n1=n2 14 | n2=temp 15 | print("After Swap ") 16 | print("1st Number is: ",n1) 17 | print("2nd Number is: ",n2) 18 | 19 | #Swap Numbers Without Using Temporary Variables 20 | 21 | print("Swap Numbers by using + and - operators ") 22 | 23 | print("Before Swap ") 24 | print("1st Number is: ",n1) 25 | print("2nd Number is: ",n2) 26 | 27 | n1=n1+n2 28 | n2= n1-n2 29 | n1=n1-n2 30 | 31 | print("After Swap ") 32 | print("1st Number is: ",n1) 33 | print("2nd Number is: ",n2) 34 | 35 | 36 | 37 | #Swap Numbers using + and - Arthemetic Operators and without third Variable 38 | 39 | print("Swap Numbers by using + and - operators ") 40 | 41 | print("Before Swap ") 42 | print("1st Number is: ",n1) 43 | print("2nd Number is: ",n2) 44 | 45 | n1=n1+n2 46 | n2= n1-n2 47 | n1=n1-n2 48 | 49 | print("After Swap ") 50 | print("1st Number is: ",n1) 51 | print("2nd Number is: ",n2) 52 | 53 | #Swap Numbers using * and / Arthemetic Operators and without third Variable. 54 | 55 | print("Swap Numbers by using * and / operators ") 56 | 57 | print("Before Swap ") 58 | print("1st Number is: ",n1) 59 | print("2nd Number is: ",n2) 60 | 61 | n1=n1*n2 62 | n2= n1//n2 63 | n1=n1//n2 64 | 65 | print("After Swap ") 66 | print("1st Number is: ",n1) 67 | print("2nd Number is: ",n2) 68 | 69 | 70 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "args": [ 10 | "--extensionDevelopmentPath=${workspaceFolder}" 11 | ], 12 | "name": "Launch Extension", 13 | "outFiles": [ 14 | "${workspaceFolder}/out/**/*.js" 15 | ], 16 | "preLaunchTask": "npm", 17 | "request": "launch", 18 | "type": "pwa-extensionHost" 19 | }, 20 | { 21 | "args": [ 22 | "--extensionDevelopmentPath=${workspaceFolder}" 23 | ], 24 | "name": "Launch Extension", 25 | "outFiles": [ 26 | "${workspaceFolder}/out/**/*.js" 27 | ], 28 | "preLaunchTask": "npm", 29 | "request": "launch", 30 | "type": "pwa-extensionHost" 31 | }, 32 | { 33 | "name": "Attach to Chrome", 34 | "port": 9222, 35 | "request": "attach", 36 | "type": "pwa-chrome", 37 | "webRoot": "${workspaceFolder}" 38 | }, 39 | { 40 | "name": "Launch Chrome", 41 | "request": "launch", 42 | "type": "pwa-chrome", 43 | "url": "http://localhost:8080", 44 | "webRoot": "${workspaceFolder}" 45 | }, 46 | { 47 | "type": "pwa-chrome", 48 | "request": "launch", 49 | "name": "Launch Chrome against localhost", 50 | "url": "http://localhost:8080", 51 | "webRoot": "${workspaceFolder}" 52 | } 53 | ] 54 | } -------------------------------------------------------------------------------- /Day_21/Project_03/Project_03.py: -------------------------------------------------------------------------------- 1 | def count_articles(text): 2 | articles = ['a', 'an', 'the'] 3 | article_count = {'a': 0, 'an': 0, 'the': 0} 4 | words = text.lower().split() 5 | 6 | for word in words: 7 | if word in articles: 8 | article_count[word] += 1 9 | 10 | return article_count 11 | 12 | def count_words(text): 13 | return len(text.split()) 14 | 15 | def count_prepositions(text): 16 | prepositions = ['of', 'in', 'on', 'at', 'by', 'with', 'from', 'to', 'into', 'during', 'including', 'until', 'against', 'among', 'throughout', 'despite', 'towards', 'upon', 'within', 'without', 'before', 'after', 'above', 'below', 'across', 'along', 'around', 'behind', 'between', 'beyond', 'down', 'from', 'in', 'into', 'near', 'off', 'on', 'onto', 'out', 'over', 'past', 'since', 'through', 'throughout', 'till', 'to', 'toward', 'under', 'underneath', 'until', 'up', 'upon', 'with', 'within', 'without'] 17 | preposition_count = 0 18 | words = text.lower().split() 19 | 20 | for word in words: 21 | if word in prepositions: 22 | preposition_count += 1 23 | 24 | return preposition_count 25 | 26 | def count_vowels_consonants(text): 27 | vowels = 'aeiou' 28 | vowel_count = 0 29 | consonant_count = 0 30 | 31 | for char in text.lower(): 32 | if char.isalpha(): 33 | if char in vowels: 34 | vowel_count += 1 35 | else: 36 | consonant_count += 1 37 | 38 | return vowel_count, consonant_count 39 | 40 | # Get input from the user 41 | user_text = input("Enter some text: ") 42 | 43 | # Count the articles 44 | articles = count_articles(user_text) 45 | print("Articles:") 46 | for article, count in articles.items(): 47 | print(f"{article.capitalize()}: {count}") 48 | 49 | # Count the words 50 | num_words = count_words(user_text) 51 | print(f"Words: {num_words}") 52 | 53 | # Count the prepositions 54 | num_prepositions = count_prepositions(user_text) 55 | print(f"Prepositions: {num_prepositions}") 56 | 57 | # Count the vowels and consonants 58 | vowels, consonants = count_vowels_consonants(user_text) 59 | print(f"Vowels: {vowels}") 60 | print(f"Consonants: {consonants}") 61 | -------------------------------------------------------------------------------- /Day_20/Project_02/Project_02.py: -------------------------------------------------------------------------------- 1 | # import random for random numbers 2 | import random 3 | # Create a Empty list 4 | L = [] 5 | # Generate a list of 20 random numbers between 1 and 100 6 | for i in range(20): 7 | (L.append(random.randint(1, 100))) 8 | 9 | # Print the list 10 | print("Generated List:",L) 11 | 12 | # Sorted the elements of the list 13 | sorted_list = sorted(L) 14 | 15 | # Calculate the product of the elements in the list 16 | product = 1 17 | for a in L: 18 | product *= a 19 | 20 | # Calculate sum of the elements in the list 21 | Sum =sum(L) 22 | 23 | # Find the largest and smallest values in the list 24 | largest=max(L) 25 | smallest=min(L) 26 | 27 | # Calculate the average of the elements in the list 28 | Avg= sum(L) / len(L) 29 | 30 | 31 | # Find the second largest and second smallest entries in the list 32 | second_largest = sorted_list[-2] 33 | second_smallest = sorted_list[1] 34 | 35 | # Count the number of even numbers in the list 36 | even_count = sum(1 for num in L if num % 2 == 0) 37 | 38 | # Count the number of odd numbers in the list 39 | odd_count = sum(1 for num in L if num % 2 == 1) 40 | 41 | # Find the Square of the list 42 | squared_list = [num ** 2 for num in L] 43 | 44 | # Find the Cube of the list 45 | cubed_list = [num ** 3 for num in L] 46 | 47 | # Find the range of the list 48 | range_value = largest - smallest 49 | 50 | # Find the median of the list 51 | sorted_numbers = sorted(L) 52 | n = len(sorted_numbers) 53 | if n % 2 == 0: 54 | median = (sorted_numbers[n // 2 - 1] + sorted_numbers[n // 2]) / 2 55 | else: 56 | median = sorted_numbers[n // 2] 57 | 58 | # Find the mode of the list 59 | 60 | count_dict = {} 61 | for num in L: 62 | count_dict[num] = count_dict.get(num, 0) + 1 63 | mode_count = max(count_dict.values()) 64 | mode = [num for num, count in count_dict.items() if count == mode_count] 65 | 66 | 67 | print("Sorted List:",sorted_list) 68 | print("Squared list:", squared_list) 69 | print("Cubed list:", cubed_list) 70 | print("Sum of the elements in the list:",Sum) 71 | print("Product of the elements in the list:", product) 72 | print("Average of list:",avg) 73 | print("Largest Value:",largest) 74 | print("Smallest Value:",smallest) 75 | print("Second Largest Value:", second_largest) 76 | print("Second Smallest Value:", second_smallest) 77 | print("Number of Even Numbers in the list:", even_count) 78 | print("Number of Odd Numbers in the list:", odd_count) 79 | print("Median of the list:", median) 80 | if len(mode) == len(L): 81 | print("Mode of the list: No mode, all values are unique") 82 | else: 83 | print("Mode of the list:", mode) 84 | print("Range:", range_value) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

100 Days of Code Learning with Kousar Raza

2 | 3 | ------------------------------------------ 4 | ![100-days-of-code](https://user-images.githubusercontent.com/98851253/155425637-9ac7250e-52a3-429a-a679-ac619f5ff6ea.gif) 5 | 6 | 7 | # Introduction 8 | 9 | ***Welcome to the 100 Days of Code Learning Challenge in Python. This repository was collected from GitHub and the Internet. I collected it to practice and solve all the listed 10 | real-world coding-related problems with Python. Even after these collected problems are all set up, I will try to add more problems soon. If you are a very beginner with Python then I hope this repository will help you a lot to get your hands free with Python.*** 11 | ***In this repository, I will be gradually updating the codebase of the given problems with my solutions.*** 12 | 13 | # 🔰 Beginner 14 | * **[Day 1:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_01)**- ***Question 1-4*** 15 | 16 | * **[Day 2:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_02)**- ***Question 5-15*** 17 | 18 | * **[Day 3:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_03)**- ***Question 16-24*** 19 | * **[Day 4:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_04)**- ***Question 25-38*** 20 | * **[Day 5:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_05)**- ***Question 39-52*** 21 | * **[Day 6:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_06)**- ***Question 53-61*** 22 | * **[Day 7:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_07)**- ***Question 62-64*** 23 | * **[Day 8:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_08)**- ***Question 65-70*** 24 | * **[Day 9:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_09)**- ***Question 71-80*** 25 | * **[Day 10:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_10)**- ***Question 81-85*** 26 | * **[Day 11:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_11)**- ***Question 86-90*** 27 | * **[Day 12:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_12)**- ***Question 91-101*** 28 | * **[Day 13:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_13)**- ***Question 102-114*** 29 | * **[Day 14:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_14)**- ***Question 115-131*** 30 | * **[Day 15:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_15)**- ***Question 132-150*** 31 | * **[Day 16:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_16)**- ***Question 151-160*** 32 | * **[Day 17:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_17)**- ***Question 161-174*** 33 | * **[Day 18:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_18)**- ***Question 175-185*** 34 | * **[Day 19:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_19)**- ***Question 186-195*** 35 | * **[Day 20:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_20)**- ***Project 01-02*** 36 | * **[Day 21:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_21)**- ***Project 03-04*** 37 | * **[Day 22:](https://github.com/kousarraza/100-Days-of-Code_Zero_to_Hero/tree/master/Day_22)**- ***Project 05-06*** 38 | ---------------------------------------------- 39 | 40 | # Need Help? 41 | 42 | ***If you need any help, feel free to connect with me on **[LinkedIn](https://www.linkedin.com/in/kousarraza110/)** and I'll do my best to try to offer some assistance. If you think there's an issue with the curriculum or have a recommendation, see the contributing section below.*** 43 | 44 | # 🤗 Contributing 45 | ---------------------------------------- 46 | 47 | ## Spread the Word 48 | 49 | If you appreciate the work done here, you can contribute significantly by spreading the word about this repository, including things like: 50 | 51 | * Starring and forking this repository 52 | * Sharing this repository on social media 53 | 54 | # Contribute to this Repository 55 | 56 | This is a work in progress and I very much appreciate any help in maintaining this knowledge base! 57 | 58 | When contributing to this repository, please first discuss the change you wish to make via issue before making a change. Otherwise, it will be very hard to understand your proposal and could potentially result in you putting in a lot of work to a change that won't get merged. 59 | 60 | Please note that everyone involved in this project is either trying to learn or trying to help--Please be nice! 61 | 62 | -------------------------------- 63 | 64 | ## Pull Request Process 65 | 66 | 1. Create an issue outlining the proposed pull request. 67 | 2. Obtain approval from a project owner to make the proposed change. 68 | 3. Create the pull request. 69 | 70 | # 🙋‍♂️ Support 71 | 💙 If you like this project, give it a ⭐ and share it with friends! 72 | # ✍️ Random Day Quote 73 | 74 |

75 | "Programs must be written for people to read, and only incidentally for machines to execute." 76 |

77 | --------------------------------------------------------------------------------