sa 12 cs chapter 5

8. Write a program that reads characters from the keyboard one by one. All lower case characters get stored inside the file LOWER, all upper case characters get stored inside the file UPPER and all other characters get stored inside file OTHERS.

# Code f1 = open(‘LOWER.txt’, ‘w’) f2 = open(‘UPPER.txt’, ‘w’) f3 = open(‘OTHERS.txt’, ‘w’) c = True while c: c = input(‘Enter a character to write or False to terminate the program : ‘) if c is False: break elif c.islower(): # checks for lower character f1.write(c) elif c.isupper() # checks for upper character f2.write(c) […]

8. Write a program that reads characters from the keyboard one by one. All lower case characters get stored inside the file LOWER, all upper case characters get stored inside the file UPPER and all other characters get stored inside file OTHERS. Read More »

9. Write a function in Python to count and display the number of lines starting with alphabet ‘A’ present in a text file ” LINES.TXT”. e.g., the file “LINES.TXT” contains the following lines :

A boy is playing there. There is a playground. An aeroplane is in the sky. Alphabets & numbers are allowed in password. the function should display the output as 3. # Code def func(l): # function to count lines starting with ‘A’ c = 0 # c is the count of such lines for line

9. Write a function in Python to count and display the number of lines starting with alphabet ‘A’ present in a text file ” LINES.TXT”. e.g., the file “LINES.TXT” contains the following lines : Read More »