diff --git a/advanced-level/Problem-1/solution1.py b/advanced-level/Problem-1/solution1.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-10/solution10.py b/advanced-level/Problem-10/solution10.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-2/solution2.py b/advanced-level/Problem-2/solution2.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-3/solution3.py b/advanced-level/Problem-3/solution3.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-4/solution4.py b/advanced-level/Problem-4/solution4.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-5/solution5.py b/advanced-level/Problem-5/solution5.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-6/solution6.py b/advanced-level/Problem-6/solution6.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-7/solution7.py b/advanced-level/Problem-7/solution7.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-8/solution8.py b/advanced-level/Problem-8/solution8.py new file mode 100644 index 0000000..e69de29 diff --git a/advanced-level/Problem-9/solution9.py b/advanced-level/Problem-9/solution9.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-1/solution1.py b/beginner-level/Problem-1/solution1.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-10/solution10.py b/beginner-level/Problem-10/solution10.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-2/solution2.py b/beginner-level/Problem-2/solution2.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-3/solution3.py b/beginner-level/Problem-3/solution3.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-4/solution4.py b/beginner-level/Problem-4/solution4.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-5/solution5.py b/beginner-level/Problem-5/solution5.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-6/solution6.py b/beginner-level/Problem-6/solution6.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-7/solution7.py b/beginner-level/Problem-7/solution7.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-8/solution8.py b/beginner-level/Problem-8/solution8.py new file mode 100644 index 0000000..e69de29 diff --git a/beginner-level/Problem-9/solution9.py b/beginner-level/Problem-9/solution9.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-1/solution1.py b/intermediate-level/Problem-1/solution1.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-10/solution10.py b/intermediate-level/Problem-10/solution10.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-2/solution2.py b/intermediate-level/Problem-2/solution2.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-3/solution3.py b/intermediate-level/Problem-3/solution3.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-4/solution4.py b/intermediate-level/Problem-4/solution4.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-5/solution5.py b/intermediate-level/Problem-5/solution5.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-6/solution6.py b/intermediate-level/Problem-6/solution6.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-7/solution7.py b/intermediate-level/Problem-7/solution7.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-8/solution8.py b/intermediate-level/Problem-8/solution8.py new file mode 100644 index 0000000..e69de29 diff --git a/intermediate-level/Problem-9/solution9.py b/intermediate-level/Problem-9/solution9.py new file mode 100644 index 0000000..e69de29 diff --git a/starter/Problem-1/solution1.py b/starter/Problem-1/solution1.py new file mode 100644 index 0000000..d1396d4 --- /dev/null +++ b/starter/Problem-1/solution1.py @@ -0,0 +1,10 @@ +## Python Starter Problems +### Problem-1: Write a program to find the length of the variable name + +# Variable, name="Hello there" +name="Hello there" +#print("1. Length is: ", len(name)) + + + + diff --git a/starter/Problem-10/solution10.py b/starter/Problem-10/solution10.py new file mode 100644 index 0000000..fb7d00c --- /dev/null +++ b/starter/Problem-10/solution10.py @@ -0,0 +1,2 @@ +### Problem-10: The list below is the collection of the ages of people from a village. Clean up the data and store only numbers in another list. +# data_list = [13, 24, 'Karim', {'name': 'guru'}, 45, 17] \ No newline at end of file diff --git a/starter/Problem-11/solution11.py b/starter/Problem-11/solution11.py new file mode 100644 index 0000000..8202e7d --- /dev/null +++ b/starter/Problem-11/solution11.py @@ -0,0 +1,21 @@ + +### Problem-11: Find the most frequent character in the paragraph +# rhyme = 'Twinkle, twinkle, little star. How I wonder what you are! + +# File: most_frequent_char.py + +from collections import Counter +import string + +rhyme = 'Twinkle, twinkle, little star. How I wonder what you are!' + +# Normalize: lowercase & filter alphabetic characters +cleaned = ''.join(c for c in rhyme.lower() if c in string.ascii_lowercase) + +# Count frequency +counts = Counter(cleaned) + +# Get most common character +most_common_char, freq = counts.most_common(1)[0] + +print(f"Most frequent character: '{most_common_char}' (appears {freq} times)") diff --git a/starter/Problem-12/solution12.py b/starter/Problem-12/solution12.py new file mode 100644 index 0000000..c474379 --- /dev/null +++ b/starter/Problem-12/solution12.py @@ -0,0 +1,16 @@ +### Problem-12: Find the common items between the lists +# and make SUM of the new list items which are common between the lists. +# list1 = [3, 5, 7, 4, 8, 8] +# list2 = [4, 9, 8, 7, 1, 1, 13] + +list1 = [3, 5, 7, 4, 8, 8] +list2 = [4, 9, 8, 7, 1, 1, 13] + +# Find unique common items +common = list(set(list1) & set(list2)) # & represnt intersection in set + +# Sum of common items +total = sum(common) + +print("Common items:", common) +print("Sum of common items:", total) diff --git a/starter/Problem-13/solution13.py b/starter/Problem-13/solution13.py new file mode 100644 index 0000000..e587be6 --- /dev/null +++ b/starter/Problem-13/solution13.py @@ -0,0 +1,5 @@ + +### Problem-13: Compare the two dictionaries and find the common items based on KEYs of the dictionaries +# dict1 = {'age': 13, 'id': 12, 'address': 'Banani', 'course': 'Python'} + +# dict2 = {'address': 'Rupnagar', 'id': 25, 'course': 'MERN'} \ No newline at end of file diff --git a/starter/Problem-14/solution14.py b/starter/Problem-14/solution14.py new file mode 100644 index 0000000..344f600 --- /dev/null +++ b/starter/Problem-14/solution14.py @@ -0,0 +1,11 @@ +### Problem-14: Sort the list in DESCENDING order and find the subtraction of maximum and minimum numbers. +# list_1 = [4, 9, 8, 7, 5, 2, 13] +list_1 = [4, 9, 8, 7, 5, 2, 13] +list_1.sort(reverse=True) + +print("Maximum number: ", list_1[0]) +print("Minimum number: ", list_1[len(list_1)-1]) + +subs = list_1[0] - list_1[len(list_1)-1] + +print("Substraction is : ", subs) \ No newline at end of file diff --git a/starter/Problem-15/solution15.py b/starter/Problem-15/solution15.py new file mode 100644 index 0000000..8c459b0 --- /dev/null +++ b/starter/Problem-15/solution15.py @@ -0,0 +1,6 @@ +### Problem-15: Write conditional statements to identify the student’s average marks. +# If any subject’s mark is less than 40, you should print FAILED instead of making average marks + +student_1 = [40, 35, 70, 90, 56] + +student_2 = [57, 35, 80, 98, 46] \ No newline at end of file diff --git a/starter/Problem-2/solution2.py b/starter/Problem-2/solution2.py new file mode 100644 index 0000000..d788aa6 --- /dev/null +++ b/starter/Problem-2/solution2.py @@ -0,0 +1,4 @@ +### Problem-2: Write a program to find the type of the variable name +# name="Hello there" +name="Hello there" +print("2. Type is: ", type(name)) \ No newline at end of file diff --git a/starter/Problem-3/solution3.py b/starter/Problem-3/solution3.py new file mode 100644 index 0000000..156fbcf --- /dev/null +++ b/starter/Problem-3/solution3.py @@ -0,0 +1,12 @@ +### Problem-3: Write a function that takes 2 numbers as arguments (age of two brothers) and find who is elder +# Hints: Use condition inside the function + +brother1Age=input("Enter brother 1 age: ") +brother2Age=input("Enter brother 2 age: ") + +print("Brother 1 age is: ", brother1Age, ", Brother 2 age is: ", brother2Age) + +if brother1Age>brother2Age: + print("Brother 1 is the elder one.") +else: + print("Brother 2 is the elder one.") \ No newline at end of file diff --git a/starter/Problem-4/solution4.py b/starter/Problem-4/solution4.py new file mode 100644 index 0000000..43788fa --- /dev/null +++ b/starter/Problem-4/solution4.py @@ -0,0 +1,5 @@ +### Problem-4: Write a program to find the index of 7 +## numbers=[3, 5, 1, 9, 7, 2, 8 ] + +numbers=[3, 5, 1, 9, 7, 2, 8 ] +print("Index of 7 is: ", numbers.index(7)) \ No newline at end of file diff --git a/starter/Problem-5/solution5.py b/starter/Problem-5/solution5.py new file mode 100644 index 0000000..b492e3a --- /dev/null +++ b/starter/Problem-5/solution5.py @@ -0,0 +1,7 @@ +### Problem-5: Write a program to sort the numbers in Ascending order +# numbers=[3, 5, 1, 9, 7, 2, 8 ] + +numbers=[3, 5, 1, 9, 7, 2, 8 ] +numbers.sort() + +print("Sorted array: ", numbers) \ No newline at end of file diff --git a/starter/Problem-6/solution6.py b/starter/Problem-6/solution6.py new file mode 100644 index 0000000..c0ea044 --- /dev/null +++ b/starter/Problem-6/solution6.py @@ -0,0 +1,12 @@ +### Problem-6: Write a function named "isLandscape" that takes 2 numbers (image width and height) +# as arguments and the function returns +# Landscape if the image width has a higher value than height. Returns Portrait otherwise +# Hints: Use condition inside the function + +def isLandscape(width, height): + if width>height: + return "Landscape" + else: + return "Portrait" + +print(isLandscape(3,5)) \ No newline at end of file diff --git a/starter/Problem-7/solution7.py b/starter/Problem-7/solution7.py new file mode 100644 index 0000000..f5d7781 --- /dev/null +++ b/starter/Problem-7/solution7.py @@ -0,0 +1,15 @@ +### Problem-7: Write a function that takes 1 number as argument. The function should return “Fizz” +# if the number is divisible by 3, the function should return “Buzz” if the number is divisible by 5, +# the function should return “FizzBuzz” if the number is divisible by both 5 and 3, otherwise return “Not a Fizz-buzz number” +# Hints: Use condition inside the function + +number=int(input("Enter any number:")) + +if number%3==0 and number%5==0: + print("FizzBuzz") +elif number%3==0: + print("Fizz") +elif number%5==0: + print("Buzz") +else: + print("Not a FizzBuzz number!") \ No newline at end of file diff --git a/starter/Problem-8/solution8.py b/starter/Problem-8/solution8.py new file mode 100644 index 0000000..50268af --- /dev/null +++ b/starter/Problem-8/solution8.py @@ -0,0 +1,20 @@ +### Problem-8: Guessing game + +# Write a function that takes a number 1 to 9 from the user input (use input function inside a function). +# Store a number in a variable (let’s assume 6). If the input value is less than the variable, +# print (your guess is almost there), +# if the input value is greater than the variable, print - your guess is higher, +# if the input value and variable are equals, print - Your Guess Is Correct! + +num = int(input("Enter any number between 1 to 10:")) +expectedValue = 6 + +if num<1 or num>9: + print("Given number is not between 1-10. Can not proceed.") +else: + if num==expectedValue: + print("Your Guess Is Correct!") + elif num < expectedValue: + print("Your guess is almost there") + else: + print("Your guess is higher") \ No newline at end of file diff --git a/starter/Problem-9/solution9.py b/starter/Problem-9/solution9.py new file mode 100644 index 0000000..bed97a4 --- /dev/null +++ b/starter/Problem-9/solution9.py @@ -0,0 +1,14 @@ +### Problem-9: Find if 6 is available in the list +# my_list = [4, 8, 7, 4,3,6,2,1,9] + +my_list = [4, 8, 7, 4,3,6,2,1,9] + +print(my_list[:3]) +print(my_list[2:5]) +print(my_list[3:]) +print(my_list[:-2]) + +for data in my_list: + if data == 6: + print("6 is available in the list!") + break \ No newline at end of file