Posts

Showing posts from May, 2023

Write a random number generator that generates random numbers between 1 and 6 (simulates a dice).

Image
 Write a random number generator that generates random numbers between 1 and 6 (simulates a dice).

Write a Python program to create a simple calculator using user defined functions.

Image
 

Create a binary file with roll number, name and marks. Input a roll number and update the marks.

Image
Create a binary file with roll number, name and marks. Input a roll number and update the marks.

Read lines from a text file India.txt to findand display the occurrence of the word "India"

 #read lines from a text file India.txt to findand display the occurrence of the word "India" def disp():     count=0     f=open("India.txt","r")     for line in f:         word=line.split()         for w in word:             if w=="India":                 count=count+1     print("Total occurrence of the word 'India':",count) disp()

Write a Python program to implement a stack using list.

Image
  Write a Python program to implement a stack using list. Output:

Read a text file and display the number of vowels/consonants/uppercase/lowercase letters.

#Read a text file and display the number of #vowels/consonants/uppercase/lowercase letters. f=open('vowel.txt', 'r') l=f.readlines() vow=con=uc=lc=0 print(l) for i in l:     for j in i:         if j.isupper()==True:             uc+=1         elif j.islower()==True:             lc+=1         if j in 'aeiouAEIOU':             vow+=1         elif j!=' ':             con+=1 print('No. of vowels:',vow) print('No. of cosonants:',con) print('No. of uppercase letters:',uc) print('No. of lowercase letters:',lc) 

Create a binary file with name and roll number. Search for a given roll number and display the name, if not found display appropriate message.

Image
Create a binary file with name and roll number. Search for a given roll number and display the name, if not found display appropriate message.