├── 3.12.2022 ├── .TodayPrograms.txt └── rockPaperScissor. │ └── rockPaperScissorPrakash.py └── LabExercises ├── exNo2(a).py ├── exno1(a).py ├── exno1(b).py ├── exno10(a).py ├── exno10(b).py ├── exno11(a).py ├── exno11(b).py ├── exno12(a).py ├── exno12(b).py ├── exno13(a).py ├── exno13(b).py ├── exno14(a).py ├── exno14(b).py ├── exno15(a).py ├── exno15(b).py ├── exno16(a).py ├── exno16(b).py ├── exno2(b).py ├── exno3(a).py ├── exno3(b).py ├── exno4(a).py ├── exno4(b).py ├── exno5(a).py ├── exno5(b).py ├── exno6(b).py ├── exno7(a).py ├── exno7(b).py ├── exno8(a).py ├── exno8(b).py ├── exno9(a).py └── exno9(b).py /3.12.2022/.TodayPrograms.txt: -------------------------------------------------------------------------------- 1 | 2 | Dec 3 Problems list 3 | 4 | 1.Rock,Paper, Scissor 5 | -------------------------------------------------------------------------------- /3.12.2022/rockPaperScissor./rockPaperScissorPrakash.py: -------------------------------------------------------------------------------- 1 | import random 2 | n=input("enter your choise: ") 3 | ist1=['rock', 'paper', 'sissor'] 4 | x=random.choice(ist1) 5 | print("computer's choise:",x) 6 | chos=x 7 | if n==chos and chos==n: 8 | print("draw") 9 | elif n=='rock' and chos=='sissor': 10 | print("you win") 11 | elif n=='rock'and chos=='paper' : 12 | print("you lose") 13 | elif n=='paper' and chos=='sissor': 14 | print("you lose") 15 | elif n=='paper' and chos=='rock': 16 | print("you win") 17 | elif n=='sissor' and chos=='rock': 18 | print("you fail") 19 | elif n=='sissor' and chos=='paper': 20 | print("you win") 21 | else: 22 | print("enter valid input") 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /LabExercises/exNo2(a).py: -------------------------------------------------------------------------------- 1 | #Arithmetic Expression 2 | #Addition 3 | print("Addition de two numbers") 4 | a = int (input ("Enter the first value : ")) 5 | b = int(input("Enter the second Value : ")) 6 | print("the sum of a and b is %d" %(a+b)) 7 | #Subtraction 8 | print("Subtraction de two numbers") 9 | c = int(input ("Enter the first value : ")) 10 | d = int(input("Enter the second Value : ")) 11 | print("the sum of a and b is %d" %(c-d)) 12 | #multiplication 13 | print("Multiplication de two numbers") 14 | e = int (input ("Enter the first value : ")) 15 | f = int(input("Enter the second Value : ")) 16 | print("the sum of a and b is %d" %(e*f)) 17 | #division 18 | print("Division de two numbers") 19 | g = int (input ("Enter the first value : ")) 20 | h = int(input("Enter the second Value : ")) 21 | print("the sum of a and b is %d" %(g/h)) -------------------------------------------------------------------------------- /LabExercises/exno1(a).py: -------------------------------------------------------------------------------- 1 | print("helllo world") 2 | name = input("enter your name : ") 3 | print("hi %s.Nice to meet you! "%name) -------------------------------------------------------------------------------- /LabExercises/exno1(b).py: -------------------------------------------------------------------------------- 1 | #write a python program to get the length and breadth as input and print the area of triangle 2 | 3 | a =int(input("Enter the value of length: ")) 4 | b =int(input("Enter the value of breadth: ")) 5 | print("The area of Rectangle is : %d"%(a*b)) -------------------------------------------------------------------------------- /LabExercises/exno10(a).py: -------------------------------------------------------------------------------- 1 | def binary(n, arr, num): 2 | low=1 3 | high=n 4 | while low<=high: 5 | mid=(low+high)//2 6 | if arr[mid]==num: 7 | return mid 8 | elif numarr[j+1]: 5 | temp=arr[j] 6 | arr[j]=arr[j+1] 7 | arr[j+1]=temp 8 | print("Enter the size of the array") 9 | size=int(input()) 10 | pos=-1 11 | array=[0 for x in range(size)] 12 | print("Enter the array elements") 13 | for i in range(size): 14 | array[i]=int(input()) 15 | bubble(size,array) 16 | print("The sorted array is") 17 | for i in range(size): 18 | print(array[i]) -------------------------------------------------------------------------------- /LabExercises/exno11(b).py: -------------------------------------------------------------------------------- 1 | def InsertionSort(a): 2 | 3 | # traversing the array from 1 to length of the array(a) 4 | for i in range(1, len(a)): 5 | 6 | temp = a[i] 7 | 8 | # Shift elements of array[0 to i-1], that are 9 | # greater than temp, to one position ahead 10 | # of their current position 11 | j = i-1 12 | while j >=0 and temp < a[j] : 13 | a[j+1] = a[j] 14 | j -= 1 15 | a[j+1] = temp 16 | 17 | # array to be sorted 18 | a = [10, 5, 13, 8, 2] 19 | InsertionSort(a) 20 | print("Array after sorting:") 21 | print(a) -------------------------------------------------------------------------------- /LabExercises/exno12(a).py: -------------------------------------------------------------------------------- 1 | print('Enter the sentence') 2 | sentence=input() 3 | d={} 4 | l=sentence.split(" ") 5 | temp=[] 6 | for i in range(len(l)): 7 | if l[i] in temp: 8 | d[l[i]]+=1 9 | else: 10 | temp.append(l[i]) 11 | d[l[i]]=1 12 | index=0 13 | word='' 14 | for key,value in d.items(): 15 | if value>index: 16 | index=value 17 | word=key 18 | print("The word '",word,"' is the most repeated with count",index) -------------------------------------------------------------------------------- /LabExercises/exno12(b).py: -------------------------------------------------------------------------------- 1 | dict = {} 2 | n=int(input("enter how many values you want to store : ")) 3 | for i in range(n): 4 | key = input("EnterKey value: ") 5 | Value = input("Enter the Value for key: ") 6 | dict[key]=Value 7 | print(dict) 8 | -------------------------------------------------------------------------------- /LabExercises/exno13(a).py: -------------------------------------------------------------------------------- 1 | a=open("student.txt","w") 2 | print("Enter the student name: ") 3 | name=input() 4 | print("Enter the student enrollment number: ") 5 | eno=int(input()) 6 | print("Enter the department") 7 | dept=input() 8 | a.write("Name: "+name) 9 | a.write("\nEnrollment no:"+str(eno)) 10 | a.write("\nDepartment:"+dept) 11 | a.close() 12 | a=open("student.txt","r") 13 | print(a.read()) 14 | -------------------------------------------------------------------------------- /LabExercises/exno13(b).py: -------------------------------------------------------------------------------- 1 | file=open("demo.txt",'r') 2 | file2=open("demo2.txt",'w') 3 | 4 | num=file.readline() 5 | num=int(num) 6 | print(num) 7 | fact=1 8 | for i in range(1,num+1): 9 | fact=fact*i 10 | print(fact) 11 | 12 | 13 | file2.write(str(fact)) 14 | -------------------------------------------------------------------------------- /LabExercises/exno14(a).py: -------------------------------------------------------------------------------- 1 | try: 2 | print("Enter the first number") 3 | a=int(input()) 4 | print("Enter the second number") 5 | b=int(input()) 6 | c=a/b 7 | except ValueError as e: 8 | print(e) 9 | except ZeroDivisionError as e: 10 | print(e) 11 | except Exception as e: 12 | print(e) 13 | -------------------------------------------------------------------------------- /LabExercises/exno14(b).py: -------------------------------------------------------------------------------- 1 | try: 2 | a = 10/0 3 | print (a) 4 | except ArithmeticError: 5 | print ("This statement is raising an arithmetic exception.") 6 | else: 7 | print ("Success.") 8 | try: 9 | a = [1, 2, 3] 10 | print (a[3]) 11 | except LookupError: 12 | print ("Index out of bound error.") 13 | else: 14 | print ("Success") 15 | 16 | -------------------------------------------------------------------------------- /LabExercises/exno15(a).py: -------------------------------------------------------------------------------- 1 | # file name ---package.py 2 | def prime(a,b): 3 | for i in range(a,b+1,1): 4 | flag=0 5 | for j in range(2,(i//2)+1,1): 6 | if i%j==0: 7 | flag=1 8 | break 9 | if flag==0 and i!=1: 10 | print(i) 11 | 12 | # in second file import this 13 | usepack.py 14 | from package import prime 15 | print("Enter the starting range") 16 | a=int(input()) 17 | print("Enter the ending range") 18 | b=int(input()) 19 | prime(a,b) -------------------------------------------------------------------------------- /LabExercises/exno15(b).py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter a number")) 2 | 3 | for x in range(0,n): 4 | 5 | sum = 0 6 | 7 | for i in range(1, x): 8 | if x%i == 0: 9 | sum += i 10 | 11 | if x == sum: 12 | print(f"{x} is a Perfect number") 13 | else: 14 | print(f"{x} is not a Perfect number") -------------------------------------------------------------------------------- /LabExercises/exno16(a).py: -------------------------------------------------------------------------------- 1 | import random 2 | player1=0 3 | player2=0 4 | p1=0 5 | p2=0 6 | while(1): 7 | print("Do you want to roll the dice (Y/N)") 8 | ch=input() 9 | if ch=='N': 10 | break 11 | else: 12 | print("Player 1 is rolling the dice: ",end=" ") 13 | p1=random.randint(1,6) 14 | player1+=p1 15 | print(p1) 16 | print("Player 2 is rolling the dice: ",end=" ") 17 | p2=random.randint(1,6) 18 | player2+=p2 19 | print(p2) 20 | print() 21 | print() 22 | if player1>player2: 23 | print("Player 1 has won!!!") 24 | elif player2>player1: 25 | print("Player 2 has won!!!") 26 | else: 27 | print("The game ended in a tie!!!") -------------------------------------------------------------------------------- /LabExercises/exno16(b).py: -------------------------------------------------------------------------------- 1 | '''num=['zero','one','two','three','four','five','six','seven','eight','nine'] 2 | n=int(input("enter a number: ")) 3 | if n < 10: 4 | print(num[n]) 5 | elif n>9 and n<99: 6 | newn=n//10 7 | newn2=n%10 8 | print(num[newn],num[newn2],end="") 9 | elif n>99: 10 | newn=n%10 11 | n=n//10 12 | newn2=n%10 13 | n=n//10 14 | newn3=n%10 15 | print(num[newn],num[newn2],num[newn3], end="") 16 | ''' 17 | 18 | # Python program to print a given number in 19 | # words. The program handles numbers 20 | # from 0 to 9999 21 | 22 | # A function that prints 23 | # given number in words 24 | 25 | 26 | def convert_to_words(num): 27 | 28 | # Get number of digits 29 | # in given number 30 | l = len(num) 31 | 32 | # Base cases 33 | if (l == 0): 34 | print("empty string") 35 | return 36 | 37 | if (l > 4): 38 | print("Length more than 4 is not supported") 39 | return 40 | 41 | # The first string is not used, 42 | # it is to make array indexing simple 43 | single_digits = ["zero", "one", "two", "three", 44 | "four", "five", "six", "seven", 45 | "eight", "nine"] 46 | 47 | # The first string is not used, 48 | # it is to make array indexing simple 49 | two_digits = ["", "ten", "eleven", "twelve", 50 | "thirteen", "fourteen", "fifteen", 51 | "sixteen", "seventeen", "eighteen", 52 | "nineteen"] 53 | 54 | # The first two string are not used, 55 | # they are to make array indexing simple 56 | tens_multiple = ["", "", "twenty", "thirty", "forty", 57 | "fifty", "sixty", "seventy", "eighty", 58 | "ninety"] 59 | 60 | tens_power = ["hundred", "thousand"] 61 | 62 | # Used for debugging purpose only 63 | print(num, ":", end=" ") 64 | 65 | # For single digit number 66 | if (l == 1): 67 | print(single_digits[ord(num[0]) - 48]) 68 | return 69 | 70 | # Iterate while num is not '\0' 71 | x = 0 72 | while (x < len(num)): 73 | 74 | # Code path for first 2 digits 75 | if (l >= 3): 76 | if (ord(num[x]) - 48 != 0): 77 | print(single_digits[ord(num[x]) - 48], 78 | end=" ") 79 | print(tens_power[l - 3], end=" ") 80 | # here len can be 3 or 4 81 | 82 | l -= 1 83 | 84 | # Code path for last 2 digits 85 | else: 86 | 87 | # Need to explicitly handle 88 | # 10-19. Sum of the two digits 89 | # is used as index of "two_digits" 90 | # array of strings 91 | if (ord(num[x]) - 48 == 1): 92 | sum = (ord(num[x]) - 48 + 93 | ord(num[x+1]) - 48) 94 | print(two_digits[sum]) 95 | return 96 | 97 | # Need to explicitly handle 20 98 | elif (ord(num[x]) - 48 == 2 and 99 | ord(num[x + 1]) - 48 == 0): 100 | print("twenty") 101 | return 102 | 103 | # Rest of the two digit 104 | # numbers i.e., 21 to 99 105 | else: 106 | i = ord(num[x]) - 48 107 | if(i > 0): 108 | print(tens_multiple[i], end=" ") 109 | else: 110 | print("", end="") 111 | x += 1 112 | if(ord(num[x]) - 48 != 0): 113 | print(single_digits[ord(num[x]) - 48]) 114 | x += 1 115 | 116 | 117 | # Driver Code 118 | convert_to_words("9923") # Four Digits 119 | convert_to_words("523") # Three Digits 120 | convert_to_words("89") # Two Digits 121 | convert_to_words("8") # One Digits 122 | 123 | # This code is contributed 124 | # by Mithun Kumar 125 | -------------------------------------------------------------------------------- /LabExercises/exno2(b).py: -------------------------------------------------------------------------------- 1 | #Write a program to find the diameter , circumference and area of a circle 2 | #area = pi*r^2 3 | #circumference = 2*pi*r 4 | # diameter = 2*r 5 | 6 | pi = 3.14 7 | r = int(input("Enter the radius of the circle : ")) 8 | print("The area of the circle is %s " %(pi*r**2)) 9 | print("The Circumference of the circle is %s" %(2*pi*r)) 10 | print("the diameter of the Circle is %s " %(2*r)) -------------------------------------------------------------------------------- /LabExercises/exno3(a).py: -------------------------------------------------------------------------------- 1 | # String Operators 2 | 3 | s='im a good boy :)' 4 | a='str' 5 | b="ww" 6 | print(type(s)) 7 | print(s.capitalize()) #capitalize the first letter 8 | print(a.center(10,"f")) #adds the string in center of characters 9 | print(a.ljust(10,"f"))#adds the string in left of characters 10 | print(a.rjust(10,"f"))#adds the string in right of characters 11 | print(a,"\t",b) #\t adds tab (white space) 12 | print(a.expandtabs(8))#expand tabs increases the tab space 13 | print(s.isnumeric()) 14 | print(s.isdigit) 15 | print(s.isdecimal) 16 | print(s.swapcase())#if the letter is notcapitslized it capitalizes vce versa 17 | print(b.isupper()) 18 | print(b.islower()) 19 | print(len(a)) 20 | print(a.lstrip()) 21 | print(max(a)) 22 | print(min(s))#last character 23 | print(s.rfind("a")) -------------------------------------------------------------------------------- /LabExercises/exno3(b).py: -------------------------------------------------------------------------------- 1 | a = input("enter a word: ") 2 | b=(a[::-1]) 3 | if a==b: 4 | print("the given word is a palindrom") 5 | else: 6 | print("the given word is not a palindrom") -------------------------------------------------------------------------------- /LabExercises/exno4(a).py: -------------------------------------------------------------------------------- 1 | # greatest of three numbers 2 | 3 | a = int(input("enter num 1 : ")) 4 | b = int(input("\nenter num2 :")) 5 | c = int(input("\nenter num3 :")) 6 | if a>b & a>c : 7 | print("a ",a,"is the bigger number ") 8 | elif b>a &b>c : 9 | print("b",b," is bigget number ") 10 | else: 11 | print("c ",c,"is the biggest number ") -------------------------------------------------------------------------------- /LabExercises/exno4(b).py: -------------------------------------------------------------------------------- 1 | a = int(input("enter a number : ")) 2 | if a%2 ==0: 3 | print("The given number is even") 4 | else : 5 | print("the given number is odd") 6 | 7 | -------------------------------------------------------------------------------- /LabExercises/exno5(a).py: -------------------------------------------------------------------------------- 1 | # program to check pass or fail (35marks = fail) 2 | 3 | mark = int(input("enter your mark : ")) 4 | if mark>35: 5 | print("congratulations you have passed ") 6 | else: 7 | print("better luck next time ") -------------------------------------------------------------------------------- /LabExercises/exno5(b).py: -------------------------------------------------------------------------------- 1 | a=int(input("enter digit:")) 2 | b=[0,1,2,3,4,5,6,7,8,9] 3 | c=['zero','one','two','three','four','five','six','seven','eight','nine'] 4 | for i in b: 5 | if a==i: 6 | print(c[i]) 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LabExercises/exno6(b).py: -------------------------------------------------------------------------------- 1 | print("Enter Marks Obtained in 5 Subjects: ") 2 | avg = int(input("enter your mark out of 100 : ")) 3 | 4 | 5 | if avg>=91 and avg<=100: 6 | print("Your Grade is A1") 7 | elif avg>=81 and avg<91: 8 | print("Your Grade is A2") 9 | elif avg>=71 and avg<81: 10 | print("Your Grade is B1") 11 | elif avg>=61 and avg<71: 12 | print("Your Grade is B2") 13 | elif avg>=51 and avg<61: 14 | print("Your Grade is C1") 15 | elif avg>=41 and avg<51: 16 | print("Your Grade is C2") 17 | elif avg>=33 and avg<41: 18 | print("Your Grade is D") 19 | elif avg>=21 and avg<33: 20 | print("Your Grade is E1") 21 | elif avg>=0 and avg<21: 22 | print("Your Grade is E2") 23 | else: 24 | print("Invalid Input!") -------------------------------------------------------------------------------- /LabExercises/exno7(a).py: -------------------------------------------------------------------------------- 1 | #functions \ 2 | '''def factorialfinder(a): 3 | a=int(input('enter the number')) 4 | b=1 5 | for i in range (1,a+1): 6 | b=b*i 7 | print(b) 8 | 9 | 10 | factorialfinder() 11 | ''' 12 | #factorial of a given number using function 13 | a=int(input('enter the number: ')) 14 | def factorialfinder(a): 15 | 16 | #a=int(input('enter the number')) 17 | b=1 18 | for i in range (1,a+1): 19 | b=b*i 20 | print("the factorial of the given number is : ",b) 21 | 22 | 23 | factorialfinder(a) 24 | 25 | -------------------------------------------------------------------------------- /LabExercises/exno7(b).py: -------------------------------------------------------------------------------- 1 | #fibbionaci series using recursion 2 | n= int(input("range : ")) 3 | 4 | 5 | 6 | def fibonacci(n): 7 | count=0 8 | a=0 9 | b=1 10 | if n<=0: 11 | print('invalid number') 12 | elif n==1 : 13 | print(a) 14 | 15 | else: 16 | while(count