├── HelloWorld.py ├── Mod Divmod.py ├── Power - Mod Power.py ├── Input().py ├── Triangle Quest.py ├── Print Function.py ├── Set.add( ).py ├── Polar Coordinates.py ├── Integers Come In All Sizes.py ├── Tuples.py ├── Triangle Quest 2.py ├── Loops.py ├── sWAP cASE.py ├── Python Evaluation.py ├── Python_Division.py ├── itertools.product().py ├── Compress the String!.py ├── String Split and Join.py ├── What's Your Name.py ├── Maximize it!.py ├── Arithmetic Operators.py ├── Zipped!.py ├── Mutations.py ├── Set .intersection() Operation.py ├── Set .difference() Operation.py ├── String Validators.py ├── Introduction to Sets.py ├── Set .union() Operation.py ├── Find Angle MBC.py ├── Set .symmetric_difference() Operation.py ├── Designer Door Mat.py ├── Find the Runner-Up Score!.py ├── Text Wrap.py ├── Exceptions.py ├── Any or All.py ├── Python If-Else.py ├── itertools.permutations().py ├── Write a function.py ├── itertools.combinations_with_replacement().py ├── Set .discard(), .remove() & .pop().py ├── itertools.combinations().py ├── No Idea!.py ├── Merge the Tools!.py ├── List Comprehensions.py ├── Find a string.py ├── Check Subset.py ├── Finding the percentage.py ├── Words Score.py ├── Nested Lists.py ├── ginortS.py ├── Capitalize!.py ├── Lists.py ├── Default Arguments.py ├── Set Mutations.py ├── README.md └── Alphabet Rangoli.py /HelloWorld.py: -------------------------------------------------------------------------------- 1 | print("Hello, World!") 2 | -------------------------------------------------------------------------------- /Mod Divmod.py: -------------------------------------------------------------------------------- 1 | a = int(input("")) 2 | b = int(input("")) 3 | print('{}\n{}\n{}'.format((a//b),(a%b),divmod(a,b))) 4 | -------------------------------------------------------------------------------- /Power - Mod Power.py: -------------------------------------------------------------------------------- 1 | a = int(input("")) 2 | b = int(input("")) 3 | c = int(input("")) 4 | print(a**b) 5 | print(a**b%c) 6 | -------------------------------------------------------------------------------- /Input().py: -------------------------------------------------------------------------------- 1 | x , k = map(int , input("").split(' ')) 2 | m = eval(input("")) 3 | print("{}".format('True' if k==m else 'False')) 4 | -------------------------------------------------------------------------------- /Triangle Quest.py: -------------------------------------------------------------------------------- 1 | for i in range(1,int(input())): 2 | print([0,1,22,333,4444,55555,666666,7777777,88888888,999999999][i]) 3 | -------------------------------------------------------------------------------- /Print Function.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | for i in range(1,n+1): 4 | print(i,end='') 5 | -------------------------------------------------------------------------------- /Set.add( ).py: -------------------------------------------------------------------------------- 1 | n=int(input("")) 2 | s = set() 3 | for i in range(n): 4 | m=input("") 5 | s.add(m) 6 | 7 | print(len(s)) 8 | -------------------------------------------------------------------------------- /Polar Coordinates.py: -------------------------------------------------------------------------------- 1 | import cmath 2 | m=complex(input()) 3 | print(abs(complex(m.real,m.imag)),'\n',cmath.phase(complex(m.real,m.imag))) 4 | -------------------------------------------------------------------------------- /Integers Come In All Sizes.py: -------------------------------------------------------------------------------- 1 | a = int(input("")) 2 | b = int(input("")) 3 | c = int(input("")) 4 | d = int(input("")) 5 | print(a**b+c**d) 6 | -------------------------------------------------------------------------------- /Tuples.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | integer_list = tuple(map(int, input().split())) 4 | print(hash(integer_list)) 5 | -------------------------------------------------------------------------------- /Triangle Quest 2.py: -------------------------------------------------------------------------------- 1 | for i in range(1,int(input())+1): 2 | print([0,1,121,12321,1234321,123454321,12345654321,1234567654321,123456787654321,12345678987654321][i]) 3 | -------------------------------------------------------------------------------- /Loops.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | for i in range(n):# 0<= i0 for i in n) and any(str(i)==str(i)[::-1] for i in n)):#if all the numbers is positive then it will return True 6 | print(bool(1)) 7 | else: 8 | print(bool(0)) 9 | -------------------------------------------------------------------------------- /Python If-Else.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | n = int(input().strip()) 9 | 10 | if n%2==1: 11 | print("Weird") 12 | elif n%2==0 and (n>= 2 and n<6): 13 | print("Not Weird") 14 | elif n%2==0 and (n>6 and n<21): 15 | print("Weird") 16 | else: 17 | print("Not Weird") 18 | -------------------------------------------------------------------------------- /itertools.permutations().py: -------------------------------------------------------------------------------- 1 | # Enter your code here. Read input from STDIN. Print output to STDOUT 2 | import itertools as it 3 | itere , n =input("").split(" ") 4 | lst1 =(list(i for i in itere)) 5 | str(lst1.sort()) 6 | n=int(n) 7 | lst = list( x for x in it.permutations(lst1 , n)) 8 | for i in lst: 9 | m = "" 10 | for j in i: 11 | m+=j 12 | print(m) 13 | 14 | -------------------------------------------------------------------------------- /Write a function.py: -------------------------------------------------------------------------------- 1 | def is_leap(year): 2 | leap = False 3 | if (year % 4) == 0: 4 | if (year % 100) == 0: 5 | if (year % 400) == 0: 6 | return True 7 | else: 8 | return leap 9 | else: 10 | return True 11 | else: 12 | return leap 13 | 14 | year = int(input()) 15 | print(is_leap(year)) 16 | -------------------------------------------------------------------------------- /itertools.combinations_with_replacement().py: -------------------------------------------------------------------------------- 1 | from itertools import combinations_with_replacement 2 | lst , n = input("").split(" ") 3 | n= int(n) 4 | lst1 = list(x for x in lst) 5 | lst1.sort() 6 | lst = '' 7 | for j in lst1: 8 | lst+=j 9 | final = list(m for m in combinations_with_replacement(lst,n)) 10 | for x in final: 11 | s='' 12 | for i in x: 13 | s+=i 14 | print(s) 15 | -------------------------------------------------------------------------------- /Set .discard(), .remove() & .pop().py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | s = set(map(int, input().split(" "))) 3 | m = int(input()) 4 | for i in range(0,m): 5 | x=list(input().split(" ")) 6 | if x[0]=="pop": 7 | s.pop() 8 | elif x[0]=="remove": 9 | j = int(x[1]) 10 | s.remove(j) 11 | elif x[0]=="discard": 12 | j = int(x[1]) 13 | s.discard(j) 14 | print(sum(s)) 15 | -------------------------------------------------------------------------------- /itertools.combinations().py: -------------------------------------------------------------------------------- 1 | import itertools as it 2 | iterr ,n = input().split(" ") 3 | lst1= list(i for i in iterr) 4 | str(lst1.sort()) 5 | result = [] 6 | for i in range(1,int(n)+1): 7 | x = list(m for m in it.combinations(lst1, i)) 8 | result.append(x) 9 | for m in range(len(result)): 10 | for j in result[m]: 11 | for k in j: 12 | print(k, end ="" ) 13 | print() 14 | -------------------------------------------------------------------------------- /No Idea!.py: -------------------------------------------------------------------------------- 1 | n , m = map(int , input("").split(" ")) 2 | n_list=list(map(int , input("").split(" "))) 3 | Set_A=set(int(x) for x in input("").split(" ")) 4 | Set_B = set(int(x) for x in input("").split(" ")) 5 | result=0 6 | for i in n_list: 7 | if i in Set_A: 8 | result+=1 9 | elif i in Set_B: 10 | result-=1 11 | elif i not in Set_B and i not in Set_A: 12 | pass 13 | print(result) 14 | -------------------------------------------------------------------------------- /Merge the Tools!.py: -------------------------------------------------------------------------------- 1 | def merge_the_tools(string, k): 2 | for i in range(len(string)//k): 3 | s=string[k*i:k*i+k] 4 | l=[i for i in s] 5 | a='' 6 | for i in l: 7 | if i not in a: 8 | a+= i 9 | print(a) 10 | # print(s) 11 | 12 | 13 | if __name__ == '__main__': 14 | string, k = input(), int(input()) 15 | merge_the_tools(string, k) 16 | -------------------------------------------------------------------------------- /List Comprehensions.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | x = int(input()) 3 | y = int(input()) 4 | z = int(input()) 5 | n = int(input()) 6 | final_list =[] 7 | for i in range(1+x): 8 | for j in range(y+1): 9 | for k in range(1+z): 10 | if i+j+k!=n: 11 | temp=[i,j,k] 12 | final_list.append(temp) 13 | else: 14 | continue 15 | print(final_list) 16 | -------------------------------------------------------------------------------- /Find a string.py: -------------------------------------------------------------------------------- 1 | def count_substring(string, sub_string): 2 | len_SubString= len(sub_string) 3 | result = 0 4 | for i in range(len(string)+1-len_SubString): 5 | if string[i:i+len_SubString]==sub_string: 6 | result+=1 7 | else: 8 | continue 9 | 10 | return result 11 | 12 | if __name__ == '__main__': 13 | string = input().strip() 14 | sub_string = input().strip() 15 | 16 | count = count_substring(string, sub_string) 17 | print(count) 18 | -------------------------------------------------------------------------------- /Check Subset.py: -------------------------------------------------------------------------------- 1 | def Subset(a,b): 2 | result = 0 3 | for i in a: 4 | if i in b: 5 | result = 1 6 | else: 7 | result = 0 8 | break 9 | return True if result == 1 else False# Using Ternary Operator 10 | 11 | test_case = int(input("")) 12 | for i in range(test_case): 13 | a= int(input("")) 14 | seta = set(int(x) for x in input().split(" ")) 15 | b =int(input("")) 16 | setb = set(int(x) for x in input().split(" ")) 17 | print(Subset(seta , setb)) 18 | -------------------------------------------------------------------------------- /Finding the percentage.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | student_marks = {} 4 | for _ in range(n): 5 | name, *line = input().split() 6 | scores = list(map(float, line)) 7 | student_marks[name] = scores 8 | query_name = input() 9 | for i in student_marks: 10 | j = student_marks.get(i) 11 | if i==query_name: 12 | result = 0 13 | for k in j: 14 | result+= float(k) 15 | print("{:.2f}".format((result/len(j)))) 16 | break 17 | else: 18 | continue 19 | -------------------------------------------------------------------------------- /Words Score.py: -------------------------------------------------------------------------------- 1 | def is_vowel(letter): 2 | return letter in ['a', 'e', 'i', 'o', 'u', 'y'] 3 | def score_words(arr): 4 | final=0 5 | for word in arr: 6 | s=0 7 | result =0#if s is odd then add 1 otherwise add 2 8 | for i in word: 9 | if is_vowel(i): 10 | s+=1 11 | else: 12 | pass 13 | if s&1==1: 14 | result+=1 15 | else: 16 | result+=2 17 | final+=result 18 | return final 19 | 20 | n = int(input()) 21 | words = input().split() 22 | print(score_words(words)) 23 | -------------------------------------------------------------------------------- /Nested Lists.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | final_list =[] 3 | marks=[] 4 | for _ in range(int(input())): 5 | l= list() 6 | l.append(input()) 7 | score = float(input()) 8 | l.append(score) 9 | marks.append(score) 10 | final_list.append(l) 11 | marks.sort() 12 | min_value = marks[0] 13 | marks.remove(min_value) 14 | for i in marks: 15 | if i>min_value: 16 | Result_value = i 17 | break 18 | Result_names=[] 19 | for i in range(len(final_list)): 20 | if Result_value in final_list[i]: 21 | Result_names.append(final_list[i][0]) 22 | Result_names.sort() 23 | for i in Result_names: 24 | print(i) 25 | -------------------------------------------------------------------------------- /ginortS.py: -------------------------------------------------------------------------------- 1 | string = input("") 2 | lower = list() 3 | lower1 =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] 4 | 5 | upper = list() 6 | upper1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] 7 | odd = list() 8 | even= list() 9 | number =['1','2','3','4','5','6','7','8','9','0'] 10 | for i in string: 11 | if i in lower1: 12 | lower.append(i) 13 | elif i in upper1: 14 | upper.append(i) 15 | elif i in number: 16 | even.append(i) if (int(i)%2==0) else odd.append(i) 17 | lower.sort() 18 | upper.sort() 19 | even.sort() 20 | odd.sort() 21 | final = lower + upper + odd+even 22 | for i in final: 23 | print(i,end = '') 24 | -------------------------------------------------------------------------------- /Capitalize!.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | # Complete the solve function below. 10 | def solve(s): 11 | sa="" 12 | #Method_2 13 | sa+=s[0].upper() 14 | for i in range(1,len(s)): 15 | if s[i]==" ": 16 | sa+=s[i] 17 | elif s[i-1]==" ": 18 | if s[i]==" ": 19 | sa+=s[i] 20 | else: 21 | sa+=s[i].upper() 22 | else: 23 | sa+=s[i] 24 | return sa 25 | 26 | 27 | 28 | 29 | if __name__ == '__main__': 30 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 31 | 32 | s = input() 33 | 34 | result = solve(s) 35 | 36 | fptr.write(result + '\n') 37 | 38 | fptr.close() 39 | -------------------------------------------------------------------------------- /Lists.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | lst = [] 3 | N = int(input()) 4 | for i in range(N): 5 | mn= list(input("").split(" ")) 6 | 7 | if mn[0]=="insert": 8 | a , b = map(int , (mn[1],mn[2])) 9 | lst.insert(a,b) 10 | 11 | elif mn[0]=="print": 12 | print(lst) 13 | 14 | elif mn[0]=="remove": 15 | lst.remove(int(mn[1])) 16 | 17 | elif mn[0]=="append": 18 | lst.append(int(mn[1])) 19 | 20 | elif mn[0]=="sort": 21 | lst.sort() 22 | 23 | elif mn[0]=="pop": 24 | 25 | lst.pop() 26 | elif mn[0]=="reverse": 27 | lst.reverse() 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Default Arguments.py: -------------------------------------------------------------------------------- 1 | class EvenStream(object): 2 | def __init__(self): 3 | self.current = 0 4 | 5 | def get_next(self): 6 | to_return = self.current 7 | self.current += 2 8 | return to_return 9 | 10 | class OddStream(object): 11 | def __init__(self): 12 | self.current = 1 13 | 14 | def get_next(self): 15 | to_return = self.current 16 | self.current += 2 17 | return to_return 18 | 19 | def print_from_stream(n, stream=EvenStream()): 20 | stream.__init__() 21 | for _ in range(n): 22 | print(stream.get_next()) 23 | 24 | 25 | queries = int(input()) 26 | for _ in range(queries): 27 | stream_name, n = input().split() 28 | n = int(n) 29 | if stream_name == "even": 30 | print_from_stream(n) 31 | else: 32 | print_from_stream(n, OddStream()) 33 | -------------------------------------------------------------------------------- /Set Mutations.py: -------------------------------------------------------------------------------- 1 | # Enter your code here. Read input from STDIN. Print output to STDOUT 2 | n = int(input("")) 3 | seta = set(map(int , input("").split(" "))) 4 | j = int(input("")) 5 | for i in range(j): 6 | ian = list(input().split()) 7 | if ian[0]== "intersection_update": 8 | fi = set(int(x) for x in input('').split(" ")) 9 | seta.intersection_update(fi) 10 | 11 | elif ian[0] == "symmetric_difference_update": 12 | fi = set(int(x) for x in input('').split(" ")) 13 | seta.symmetric_difference_update(fi) 14 | 15 | elif ian[0] == "update": 16 | fi = set(int(x) for x in input('').split(" ")) 17 | seta.update(fi) 18 | 19 | elif ian[0] == "difference_update": 20 | fi = set(int(x) for x in input('').split(" ")) 21 | seta.difference_update(fi) 22 | res = 0 23 | for m in seta: 24 | res+=m 25 | print(res) 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hello,
I'm happy to see you in my GitHub. 2 |
I hope this repo helped you. 3 |
If you feel this repo helped you, please endore me for Python on LinkedIn 4 | ### Steps for endorsement :- Open my [LinkedIn ID](https://www.linkedin.com/in/avisikta-majumdar/) --> Scroll Down to Skills --> Endorse for Python . 5 | 6 | 7 | ## About StrataScratch 8 | It is a platform which provides you the opportunity to improve your coding skills, prepare for interviews, and jump-start for your career as well. 9 | ### [Register Now & start improving yourself with StrataScratch](https://stratascratch.com/?via=AvisiktaMajumdar) 10 | 11 | 12 | ## Let's connect over [LinkedIn](https://www.linkedin.com/in/avisikta-majumdar/) 13 | 14 | ## If you are looking for Job Guarantee program in Data Science, I think this course will help you to achieve you dream job. 15 | ### [Almabetter Full Stack Data Science Program](https://grow.almabetter.com/auth/signup?referralCode=4M11C2&utm_source=referral) 16 | -------------------------------------------------------------------------------- /Alphabet Rangoli.py: -------------------------------------------------------------------------------- 1 | def print_rangoli(size): 2 | width= (size+(size-1)+2*(size-1)) 3 | n=size 4 | for i in range(n): 5 | s='' 6 | ch=96+n 7 | mid= ((2*i+1)//2) 8 | for j in range(2*i+1): 9 | s+=chr(ch) 10 | if j