Skip to content

Shariful v1 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions starter/Problem-1/solution1.py
Original file line number Diff line number Diff line change
@@ -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))




2 changes: 2 additions & 0 deletions starter/Problem-10/solution10.py
Original file line number Diff line number Diff line change
@@ -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]
21 changes: 21 additions & 0 deletions starter/Problem-11/solution11.py
Original file line number Diff line number Diff line change
@@ -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)")
16 changes: 16 additions & 0 deletions starter/Problem-12/solution12.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions starter/Problem-13/solution13.py
Original file line number Diff line number Diff line change
@@ -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'}
11 changes: 11 additions & 0 deletions starter/Problem-14/solution14.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions starter/Problem-15/solution15.py
Original file line number Diff line number Diff line change
@@ -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]
4 changes: 4 additions & 0 deletions starter/Problem-2/solution2.py
Original file line number Diff line number Diff line change
@@ -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))
12 changes: 12 additions & 0 deletions starter/Problem-3/solution3.py
Original file line number Diff line number Diff line change
@@ -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.")
5 changes: 5 additions & 0 deletions starter/Problem-4/solution4.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions starter/Problem-5/solution5.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions starter/Problem-6/solution6.py
Original file line number Diff line number Diff line change
@@ -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))
15 changes: 15 additions & 0 deletions starter/Problem-7/solution7.py
Original file line number Diff line number Diff line change
@@ -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!")
20 changes: 20 additions & 0 deletions starter/Problem-8/solution8.py
Original file line number Diff line number Diff line change
@@ -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")
14 changes: 14 additions & 0 deletions starter/Problem-9/solution9.py
Original file line number Diff line number Diff line change
@@ -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