Write a program to perform Stack Operation.
Class 12th CBSE CS Write a Program to Perform Stack Operation in Python Solution: –Â Fun & Easy to follow Works on all devices Your own Pace Super Affordable Popular Videos https://www.youtube.com/watch?v=9uOETcuFjbE UX for Teams Learn the basics and a bit beyond to improve your backend dev skills. Chris Matthews Designer https://www.youtube.com/watch?v=9uOETcuFjbE SEO & Instagram […]
Write a program to search a record using its roll number and display the name of student. If record not found then display appropriate message.
Class 12th CBSE CS Write a program to search a record using its roll number and display the name of student. If record not found then display appropriate message. Solution: –Â import pickle roll = input(‘Enter roll number that you want to search in binary file :’) file = open(“student.dat”, “rb”) list = pickle.load(file) file.close( […]
Create a binary file with name and roll number of student and display the data by reading the file.
Class 12th CBSE Create a binary file with name and roll number of student and display the data by reading the file. Solution: –Â import pickle def writedata( ): list =[ ] while True: roll = input(“Enter student Roll No:”) sname = input(“Enter student Name :”) student = {“roll”:roll,”name”:sname} list.append(student) choice= input(“Want to add more […]
Write a program to count the number of times the occurrence of ‘is’ word in a text file.
Class 12th CBSE CS Write a program to count the number of times the occurrence of ‘is’ word in a text file. Solution: –Â fin=open(“D:\python programs\Book.txt”,’r’) str=fin.read( ) L=str.split( ) count=0 for i in L: if i==’is’: count=count+1 print(count) fin.close( ) Fun & Easy to follow Works on all devices Your own Pace Super Affordable […]
Write a program to count number of words in a file.
Class 12th CBSE CS Write a program to count number of words in a file. Solution: –Â fin=open(“D:\python programs\Story.txt”,’r’) str=fin.read( ) L=str.split() count_words=0 for i in L: count_words=count_words+1 print(count_words) Fun & Easy to follow Works on all devices Your own Pace Super Affordable Popular Videos https://www.youtube.com/watch?v=9uOETcuFjbE UX for Teams Learn the basics and a bit […]
Write a program to count the number of vowels present in a text file.
Class 12th CBSE CS Write a program to count the number of vowels present in a text file. Solution: –Â fin=open(“D:\python programs\MyBook.txt”,’r’) str=fin.read( ) count=0 for i in str: if i==’a’ or i==’e’ or i==’i’ or i==’o’ or i==’u’: count=count+1 print(count) Fun & Easy to follow Works on all devices Your own Pace Super Affordable […]
Write a program to display ASCII code of a character and vice versa.
Class 12th CBSE CS Write a program to display ASCII code of a character and vice versa. Solution: –Â var=True while var: choice=int(input(“Press-1 to find the ordinal value of a character nPress-2 to find a character of a valuen”)) if choice==1: ch=input(“Enter a character : “) print(ord(ch)) elif choice==2: val=int(input(“Enter an integer value: “)) print(chr(val)) […]
Write a program to check a number whether it is palindrome or not.
Class 12th CBSE CS Write a program to check a number whether it is palindrome or not. Solution: –Â num=int(input(“Enter a number : “)) n=num res=0 while num>0: rem=num%10 res=rem+res*10 num=num//10 if res==n: print(“Number is Palindrome”) else: print(“Number is not Palindrome”) Fun & Easy to follow Works on all devices Your own Pace Super Affordable […]
Write a Program to generate random number between 1 to 6 and check whether a user guess a number or not.
Class 12th CBSE CS Write a Program to generate random number between 1 to 6 and check whether a user guess a number or not. Solution: –Â import random while True: n = random.randint(1,6) guess = int(input(“Enter a number between 1 to 6 :- “)) if n == guess: print(“You won the game …..”) break […]
Write a Program to create a result in Python and Display it accordingly.
Class 12th CBSE CS Write a Program to create a result in Python and Display it accordingly.. Solution: –Â rno = int(input(“Enter your roll no :- “)) name = input(“Enter your name :- “) s1 = int(input(“Enter the mark of Subject 1 :- “)) s2 = int(input(“Enter the mark of Subject 2 :- “)) s3 […]