Module-3 python important questions
1)Write a python program to count number of lines in a file.?
2) Explain the following functions with example :
i) makedirs( ) ii) getcwd( ) iii) velpath( ) iv) listdir( ) v) sub( )?
3). What are three “mode” arguments that can be passed to open( ) function with example.?
4)With code snippet, explain saving variables using the shelve module and print pformat( )
functions.?
5)Write a python program that accepts a sentence and find the number of words, digits,
upper case letters and lower case letters.?
6)Write a program to make a new string with all the consonant eliminated from the string
read from the user [Hint – For example Input: Hello, have a
good day. Output : HII, hv gd dy]?
7)Explain the following methods with suitable examples : i) upper ( ) ii) lower ( ) iii) is_upper (
) iv) is_lower ( )?
8) Illustrate with example opening of a file with open ( ) function, reading the contents of the
file with read ( ) and writing to files with write ( ).?
9)Explain the steps involved in adding bullets to Wiki
– Markup. Support with appropriate code.?
10). Develop a program to sort the contents of a text file and write the sorted contents into a
separate text file. [Use strip ( ) , len ( ) , list methods sort ( ) , append and file methods open (
) , readlines ( ) and write ( )].?
11)Read multidigit number from console. Develop a program to print frequency of
occurrence of each digit with suitable message.?
12)Describe the Python string handling methods with examples : Split ( ), endswith ( ), ljust (
), center ( ), lstrip ( ).?
13)Summarize the process of input validation in python programming.
14)Explain Python string handling methods with examples : join ( ), startswith ( ), rjust ( ),
strip ( ), rstrip ( ).?
15) Demonstrate the process of copying and pasting strings with pyperclip module.
16)Explain the following string methods with examples.
i) isalpha( ) ii) isalnum( ) iii) isdecimal( ) iv) isspace( ) v) istitle( ).?
17)Explain about in and not in operators in string?