done/1. Write a python program to find largest element in the list. list1=[3,7,9,1,5,4,8,2]-------> given large=list1[0] for item in list1: if item>large: large=item print(“The largest element in the given list1 is {}”.format(large)) done/2. Write a python program to find smallest element in the list. list2=[3,7,9,1,5,4,8,2]-------> given small=list2[0] for item in list2: if itemlist1[i]: a=list1[i] list1[i]=list1[j] list1[j]=a print(list1) 7.Write the program to find the value corresponds to the given key of the dictionary. dict1={1:'a',2:'b',3:'c'} given_key=2 value=dict1[given_key] print(value) 8.Write the program to find the key corresponds to the given value of the dictionary. dict1={1:'a',2:'b',3:'c'} given_value='c' for key in dict1.keys(): if dict1[key]==given_value: print(key) done/9.Write a program to add the two given tuple to get the third tuple. t1=(1,5,7,8) t2=(9,) t3=t1+t2 print(t3) 10.Write the program to sort the given dictionary wrt key. dict1={'b':'sumith','c':'shetty','a':'span','d':'idea'} print(dict(sorted(dict1.items()))) done/ 11. Write a program to remove duplicate elements from the list. list1=[1,1,2,2,2,3,3,3,3,3,4,5,6,7,8,9,9,9,9,9,9,9,9,9] print(list(set(list1))) 12.Write a program to find whether the given string exist using the regular expression. import re str1='how are you man?' regx='man' print(re.search(regx,str1)) 13. Find all the occurance of the given string pattern in the original string. import re str1='4ABaaagaga7YZbashsh' regx='[0-9][A-Z]{2}...' print(re.findall(regx,str1)) 14.Write a regx to validate the email. import re list1=['sumith@gmail.com','sumith@spanidea.com','sumith.com','sumith@google.in'] regx='[0-9][A-Za-z]+@[A-Za-z]+\.[A-Za-z]{2,3}' for item in list1: if re.findall(regx,item): print("The email address {} is valid".format(item)) else: print("The email address {} is invalid".format(item)) done/ 15.Write a program to find a substring inside the given string. str1='sumith shetty' print(str1.find('shetty')) done/ 16.Write a program to find and replace a word in a given string. str1='Where do you live' print(str1) str1=str1.replace('live','stay') print(str1) done/ 17.Write a program to slpit the given string into each word. str1='Where do you live' print(str1.split(' ')) done/ 18.Write a program to join the given list of words into single string. list1=['Where','do','you','live'] str1=' '.join(list1) print(str1) done/19.Write a python program to find the square of a number usnig lambda function. n=6 x=lambda a: a*a print(x(n)) done/20.Write a python program to find the cube of a number usnig lambda function. n=9 x=lambda a: a**3 print(x(n)) 21.Write a program to extract the each letter of the string. str1='sumith' list1=list(enumerate(str1)) print(list1) done/ 22. Write a program to remove duplicates from the list (without using set). list1=[1,1,22,2,76,34,89,99,76,22,2,34,89,34,89,99,1] list2=[] for item in list1: if item not in list2: list2.append(item) print(list2) done/ 23. Write a program to remove duplicate from the list(without using set and another list). list1=[1,1,22,2,76,34,89,99,76,22,2,34,89,34,89,99,1] for item in list1: if list1.count(item)>1: for _ in range(list1.count(item)-1): list1.remove(item) print(list1) done/ 24.Write a program to retain only even numbers in the given list. list1=[2,4,5,6,7,9,66,5,7,77,760,980,999,100] list2=[] for item in list1: if item%2==0: list2.append(item) print(list2) done/ 25.Write a program to retain only odd numbers in the given list. list1=[2,4,5,6,7,9,66,5,7,77,760,980,999,100] list2=[] for item in list1: if item%2!=0: list2.append(item) print(list2) done/ 26.Write a program to generate a list of odd numbers using list comprehension. list1=[i for i in range(1,22,2)] print(list1) list1=[i for i in range(1,22) if i%2!=0] print(list1) 27.Write a program to demonstrate dictionary comprehension dict1={i:i**2 for i in range(1,10)} print(dict1) 28.Write a program to generate fibonacci series. def fib(n): a,b=0,1 print(a) print(b) for i in range(n-2): sum=a+b print(sum) a,b=b,sum fib(21) currently i m doing py practice que. which was shared by sushmita done/ 29.Write a program to concatenate two strings into one. str1='Sumith' str2='Shetty' print(str1+' '+str2) done/ 30.Write a program to add in string using f mode print in print statement. str1='Sumith' str2='Shetty' print(f'My first name is {str1} and my last name is {str2}') done/ 31. Write a program to add in string using .format method in print statement. str1='Sumith' str2='Shetty' print('My first name is {} and my last name is {}'.format(str1,str2)) done/ 32. Write a program to reverse a string. str1='Sumith' print('The given string is {}'.format(str1)) print('The reversed string is {}'.format(str1[::-1])) 33. Write a program to count the occurrences of a particular element in the list. def counting(list_given,search_element): count=0 for item in list_given: if item==search_element: count+=1 return count list1=[1,2,2,1,4,99,99,76,67,88,8,8,8,8,76,67,76,67,99,99,4,4,4,4,4,2,2,1,1,1,1,1,100,999] element=1 print(counting(list1,element)) done/ 34.Write a program to convert the list into set. list1=[1,2,2,1,4,99,99,76,67,88,8,8,8,8,76,67,76,67,99,99,4,4,4,4,4,2,2,1,1,1,1,1,100,999] print(set(list1)) done/ 35. Write a program to convert the list into a tuple. list1=[1,2,2,1,4,99,99,76,67,88,8,8,8,8,76,67,76,67,99,99,4,4,4,4,4,2,2,1,1,1,1,1,100,999] print(tuple(list1)) done/ 36. Write a program to convert the list into a string. list1=['S','u','m','i','t','h'] str1='' for item in list1: str1+=item print(str1) 37. Write a program to yield multiple values from a generator function. def gen(): yield 1 yield 2 yield 3 yield 4 a=gen() for _ in range(4): print(next(a)) 38. Write a program to demonstrate inheritance oops concept. class Dog: def __init__(self,breed): self.breed=breed def get_breed(self): return self.breed class Shefered(Dog): def __init__(self,breed,name,age): super().__init__(breed) self.name=name self.age=age def get_name(self): return self.name def get_age(self): return self.age dog1=Dog('german') print(dog1.get_breed()) dog2=Dog('american') print(dog2.get_breed()) child_dog=Shefered('indian','rocky',9) print(child_dog.get_breed()) print(child_dog.get_name()) print(child_dog.get_age()) 39. Write a program to demonstrate base class and derived class. class Parent: def __init__(self,name,sname): self.name=name self.sname=sname def get_name(self): return self.name def get_sname(self): return self.sname class Child(Parent): def __init__(self,name,sname): super().__init__(name,sname) p1=Parent('Karunakar','Shetty') print(p1.get_name()) print(p1.get_sname()) c1=Child('Sumith','Shetty') print(c1.get_name()) print(c1.get_sname()) --------------------Another method 2 class Parent: def __init__(self,name,sname): self.name=name self.sname=sname def get_name(self): return self.name def get_sname(self): return self.sname class Child(Parent): def __init__(self,name,sname): Parent.__init__(self,name,sname) p1=Parent('Karunakar','Shetty') print(p1.get_name()) print(p1.get_sname()) c1=Child('Sumith','Shetty') print(c1.get_name()) print(c1.get_sname()) -----------------------------Another method 3 class Parent: def __init__(self,name): self.name=name self.sname='Shetty' def get_name(self): return self.name def get_sname(self): return self.sname class Child(Parent): def __init__(self,name): Parent.__init__(self,name) p1=Parent('Karunakar') print(p1.get_name()) print(p1.get_sname()) c1=Child('Sumith') print(c1.get_name()) print(c1.get_sname()) c2=Child('Rithesh') print(c2.get_name()) print(c2.get_sname()) ----------------------Another Method 4 class Birds: def __init__(self): print('All birds will fly') def height(self): return 'Height of flying varies from bird to bird' class Ostrich(Birds): def __init__(self): print('Ostrich can not fly high') def height(self): return 'Ostrich usually cant fly high because of its weight' class Sparrow(Birds): def __init__(self): print('Sparrow can fly high like other birds') def height(self): return 'Sparrow flies very high when compared to other bird' b1=Birds() print(b1.height()) o1=Ostrich() print(o1.height()) s1=Sparrow() print(s1.height()) 40. Write a program to modify the string in the python. str1='Hello zorld' str2=str1.replace('z','W') print(str2) ------------------> other method str1='Hello zorld' list1=list(str1) list1[6]='W' str1="".join(list1) print(str1) 41.Write a program to convert a string to int. str1='9' a=int(str1)*3 print(a) 42.Write a program to convert a string to float. str1='9' a=float(str1)*3 print(a) 43. Write a program to demonstrate append and extend methods in a list. --------------->list append list1=[1,2,3] list1.append(4) print(list1) -------------->list extend list1=[1,2,3] list2=[4,5,6,7,8,9] list1.extend(list2) print(list1) 44. Write a program to use **kwargs in the method. def func1(**kwargs): for k,v in kwargs.items(): print('The key is {} and the value is {}'.format(k,v)) func1('a':'apple','b':'ball') 45. Write a program to check whether given string is palindrome or not. def palindrome(string): str2=string[::-1] if str2.lower()==string.lower(): print(string+' is a palindrome') else: print(string+' is not a palindrome') palindrome(input('Enter the string to be checked for palindrome or not:')) 46. Write a program to generate a complex numbers. def complex_gen(real,imaginary): print('The complex number is:',end='') print(real+'+i'+imaginary) real=input('Enter the real part of the complex number:') imaginary=input('Enter the imaginary part of the complex number:') complex_gen(real,imaginary) 47. Write a program to generate complex number using the inbuilt function. import cmath x=int(input("Enter the real part of complex number:")) y=int(input("Enter the imaginary part of complex number:")) z=complex(x,y) print(z) 48. Write a program to demonstrate decorator. def decor1(func): #decorator def inner1(*args): # wrapper print('inside the wrapper function of decorator') a=func(*args) a=a**2 print('about to exit the wrpper function of decorator') return a return inner1 @decor1 def adding(a,b):# Main function print('inside the main function') return a+b print(adding(2,7)) #Driver code 49. Write a program to generate factorial of the given number. def fact(n): a=1 for i in range(1,n+1): a*=i return a print(fact(int(input('Enter the number whose factorial has to be found: ')))) 50. Write a program to find the multiplication table of the given number upto 10th multiple. def multiplication_table(n): #Methods print('The multiplication table of {} is :'.format(n)) for i in range(1,11): print('{}{}{}{}{}'.format(n,'x',i,'=',n*i)) #print(str(n)+'x'+str(i)+'='+str(n*i)) multiplication_table(int(input('Enter the number to display its multiplication table:'))) # Driver code 51. Write a program to demontrate iterator. str1='Sumith' a=iter(str1) for _ in range(len(str1)): print(next(a)) 52. Write a program to demonstrate the dictionary comprehension. dict1={i:i**2 for i in range(21) if i%2!=0} print(dict1) 53. Write a program to reverse a given ineger number. n=int(input('Enter the integer number to be reversed: ')) print('The number before reversing is {}'.format(n)) m=str(n)[::-1] n=int(m) print('The number after reversing is {}'.format(n)) 54. Write a program to check whether given number is a Armstrong number or not. n=int(input('Enter the number to check whether it is Armstrong number or not:')) temp=n m=str(n) result=0 for i in range(len(m)): result+=int(m[i])**3 if temp==result: print('The number {} is an Armstrong number'.format(n)) else: print('The number {} is a not an Armstrong number'.format(n)) 55. Write a program to swap two numbers using third variable. a=int(input('Enter the value of a:')) b=int(input('Enter the value of b:')) temp=a a=b b=temp print('The value of a is {} and the value of b is {}'.format(a,b)) 56. Write a program to swap two numbers without using third variable. Method 1 a=int(input('Enter the value of a:')) b=int(input('Enter the value of b:')) a,b=b,a print('The value of a is {} and the value of b is {}'.format(a,b)) 57. Write a program to swap two numbers without using third variable. Method 2 a=int(input('Enter the value of a:')) b=int(input('Enter the value of b:')) a=a+b b=a-b a=a-b print('The value of a is {} and the value of b is {}'.format(a,b)) 58. Write a program to generate fibonacci series using recursive method. a=int(input('Enter the number of elements to be generated in the fobbonacci series:')) def fibo(n): if n==0: return 0 elif n==1: return 1 else: return fibo(n-1)+fibo(n-2) print('The fibonacci series are:') for i in range(a): print(fibo(i)) 59. Write a program to find the sum of digits of the given number. a=int(input('Enter the number whose sum of the digits should be found:')) b=str(a) digit_sum=0 for item in b: digit_sum+=int(item) print('The sum of the digits of the given number is {}'.format(digit_sum)) 60. Write a program to print the each digit of the given number. a=87531 for i in range(len(str(a))): sum=(a//10) print(a%10) a=sum 61. Write a program to check whether the given number is prime or not. n=int(input('Enter the number to check whether prime or not:')) temp=0 for i in range(2,n//2+1): if n%i==0: temp=1 break if temp==1: print('The given number {} is not a prime number'.format(n)) else: print('The given number {} is a prime number'.format(n)) 62. Write a program to check whether a given number is palindrome or not. n=int(input('Enter the number to check whether it is palindrome or not:')) a=str(n) b=a[::-1] if a==b: print('The given number {} is a palindrome'.format(n)) else: print('The given number {} is not a palindrome'.format(n)) 63. Write a program to find the greatest among three integer. n1=int(input('Enter the value of n1:')) n2=int(input('Enter the value of n2:')) n3=int(input('Enter the value of n3:')) if n1>n2 and n1>n3: print('n1 is greatest among the three with a value {}'.format(n1)) elif n2>n1 and n2>n3: print('n2 is greatest among the three with a value {}'.format(n2)) elif n3>n1 and n3>n2: print('n3 is greatest among the three with a value {}'.format(n3)) else: print('There is a matching values or missing values found please re-run and provide the valid values') 64. Write a program to check whether the given number is in binary representation form or not. n=int(input('Enter the value to be checked for binary:')) num=n while(num>0): a=num%10 if a!=0 and a!=1: print('The given number {} is not a binary number'.format(n)) break num=num//10 if num==0: print('The given number {} is a binary number'.format(n)) 65. Write a program to find average of the numbers. size=int(input('Enter the size of the list to store the numbers:')) list1=[] for i in range(size): value=int(input('Enter the value for the index '+str(i) +':')) list1.append(value) print(list1) avg=sum(list1)/size print('The average value is {}'.format(avg)) 66. Write a program to check whether the given no is even or odd. n=int(input('Enter the number here: ')) if n%2==0: print('The given number {} is an even number'.format(n)) else: print('The given number {} is an odd number'.format(n)) done/ 67. Write a program to find the smallest number among the given three numbers. n1=int(input('Enter the number n1: ')) n2=int(input('Enter the number n2: ')) n3=int(input('Enter the number n3: ')) if n1item: small=item print(f'The smallest among all the values is found to be {small}') done/ 69. Write a program to find the largest value in the given list and display the same. n=int(input('Enter the size of the list to be created: ')) list1=[] for i in range(n): list1.append(int(input('Enter the element of the list for index value '+str(i)+' : '))) large=list1[0] for item in list1: if largelarge_value: large_value=v large_key=k print(f'The character {large_key} has repeated max with a count of {large_value}') 91. Write a program to count the number of alphabets, digits and special character in the given string. while(True): str1=input('Enter the string here : ') if str1=='-1': break alpha_count=0 digit_count=0 special_count=0 for item in str1: if item.isalpha(): alpha_count+=1 elif item.isdigit(): digit_count+=1 else: special_count+=1 print(f'In the given string the number of alphabets are {alpha_count}\nnumber of digits are {digit_count}\nnumber of the special characteers are {special_count}') 92. Write a program to replace all the blank spaces in the given string without using the inbuilt function. while(True): str1=input('Enter the string here : ') if str1=='-1': break str2='' for item in str1: if item!=' ': str2+=item print(f'The string after removing the blank space is :{str2}') 93. Write a program to replace all the blank spaces in the given string using the inbuilt function. while(True): str1=input('Enter the string here : ') if str1=='-1': break str2=str1.replace(' ','') print(f'The string after removing the blank space is :{str2}') 94. Write a program to split the given string into the individual word using the delimeter. while(True): str1=input('Enter the string here : ') if str1=='-1': break print(str1.split(' ')) 95. Write a program to concatenate two strings into one strings using + operator. while(True): str1=input('Enter the string1 here : ') if str1=='-1': break str2=input('Enter the string2 here : ') if str2=='-1': break print(str1+str2) 96. Write a program to concatenate two strings into one strings using .join operator. while(True): str1=input('Enter the string1 here : ') if str1=='-1': break str2=input('Enter the string2 here : ') if str2=='-1': break str3=" ".join([str1,str2]) print(str3) 97. Write a program to remove repeated character from the string. while(True): str1=input('Enter the string here : ') if str1=='-1': break str2='' for item in str1: if item not in str2: str2+=item print(str2) 98. Write a program to find the sum of all integers present in the given string. while(True): str1=input('Enter the string here : ') if str1=='-1': break sum=0 for item in str1: if item.isdigit(): sum+=int(item) print(sum) 99. Write a program to print all non repeating character in the string. while(True): str1=input('\nEnter the string here : ') if str1=='-1': break str2='' for item in str1: if item not in str2: str2+=item print(item,end='') done/ 100. Write a program to sort string character in ascending order. while(True): str1=input('\nEnter the string here : ') if str1=='-1': break list1=list(str1) print(''.join(sorted(list1))) done/ 101. Write a program to sort string character in descending order. while(True): str1=input('\nEnter the string here : ') if str1=='-1': break list1=list(str1) list1.sort(reverse=True) print(''.join(list1)) 102. Write a program to import re regx='[A-z0-9]+' user_str=input('Enter the password here : ') while(user_str!='1'): #Method for password validation def password_validation(regx,user_str): if len(user_str)>7 and len(user_str)<17: if re.search(regx,user_str): print('Logged in succesfully') else: print('Password is not matching with the required security conditions') else: print('Kindly enter the password of length 8 to 16 only') #Driver Code password_validation(regx,user_str) user_str=input('Enter the password here : ') from flask import request from flask import jsonify valdation_flask=ip @app.route("https://www.whatismyip.com/ip-whois-lookup/",methods[GET]) def get_my_ip(): return jsonify{ip:147.28.19.0} if __name__=="__main__": app.run(debug=false,host='0.0.0.0',port=80.threaded=True)