Q. 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.
You can understand by Watching video :-
Answer :-
upper = open("UPPER.txt","w") lower = open("LOWER.txt" , "w" ) other = open ("OTHER.txt" , "w") while True : user = input("Enter a charracter (for exit enter quit ): ") if user == "quit" or user == "Quit" : break elif user.isupper() : upper.write( user + " " ) elif user.islower( ) : lower.write( user + " " ) else : other.write( user + " " ) upper.close() lower.close() other.close() print("Thankyou")
Output :-
Enter a charracter (for exit enter quit ): T
Enter a charracter (for exit enter quit ): h
Enter a charracter (for exit enter quit ): i
Enter a charracter (for exit enter quit ): s
Enter a charracter (for exit enter quit ):
Enter a charracter (for exit enter quit ): i
Enter a charracter (for exit enter quit ): s
Enter a charracter (for exit enter quit ):
Enter a charracter (for exit enter quit ): P
Enter a charracter (for exit enter quit ): a
Enter a charracter (for exit enter quit ): t
Enter a charracter (for exit enter quit ): h
Enter a charracter (for exit enter quit ):
Enter a charracter (for exit enter quit ): W
Enter a charracter (for exit enter quit ): a
Enter a charracter (for exit enter quit ): l
Enter a charracter (for exit enter quit ): l
Enter a charracter (for exit enter quit ):
Enter a charracter (for exit enter quit ): @
Enter a charracter (for exit enter quit ): P
Enter a charracter (for exit enter quit ): t
Enter a charracter (for exit enter quit ): o
Enter a charracter (for exit enter quit ): n
Enter a charracter (for exit enter quit ): 3
Enter a charracter (for exit enter quit ): .
Enter a charracter (for exit enter quit ): 9
Enter a charracter (for exit enter quit ): .
Enter a charracter (for exit enter quit ): 5
Enter a charracter (for exit enter quit ): quit
Thankyou
>>>
UPPER.txt Contains :-
T P W P
LOWER.txt Contain :-
h i s i s a t h a l l t o n
OTHER.txt Contains :-
@ 3 . 9 . 5
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )