Question Bank - Pap
Question Bank - Pap
Question Bank-1
1. a. Discuss with example and diagrams, Why Should you learn to write Programs?
b. Define Program. Differentiate between Compiler and Interpreter. Give Examples.
c. With a neat diagram explain the High level definition of the parts of Hardware Architecture.
Explain the role/Job of Programmer.
2. a. With examples explain the following Six Building blocks of Programs: Input, Output, Sequential
Execution, Conditional Execution, Repeated Execution and Reuse.
b. Explain the following different types of errors: Syntax errors, Semantic errors and Logic Errors.
3. Define the following with example : Values and Types , Variables , Expressions , Keywords ,
Statements , Operators and Operands, Order of Operations , Modulus Operators , String operations
and Comments.
4. Explain how to read the input from the user with example.
5. Explain the following with examples
a. Boolean Expression
b. Logical Operators
c. Conditional Execution : if
d. Alternative Execution: if else
e. Chained Conditionals : if elif else
f. Nested Conditionals : if else if else
g. Catching exception using try and except
h. Short circuit evaluation of logical circuits
6. Explain the following with example
a. Functions
b. Function Call
c. Built in Function
d. Type Conversion Functions
e. Random Numbers
f. Math Functions
g. Adding new Functions
h. Defining and using the new functions
i. Flow of execution
j. Parameter and Arguments
k. Fruitful and void Functions
l. Advantages of Functions
7. Write a program that uses input to prompt a user for their name and then welcomes them.
8. Write a program to prompt the user for hours and rate per hour to compute gross pay.
Subject: Python Application Programming Code: 15CS664
9. Write a program to read the following input from user and display
a. Name :
b. USN :
c. Roll NO:
d. Mobile No:
e. E-Mail id :
f. Percentage of Marks :
10. To find the simple interest for a given value P,T and R. The program must take the input from the
user.
11. To read two integers and find the sum , diff , mult and div .
12. To check whether the number is positive using simple if .
13. To check whether the given number is even or odd using simple if else.
14. Write a program to prompt the user for hours and rate per hour to compute gross pay. Also to give
the employee 1.5 times the hourly rate for hours worked above 40 hours.
15. Define Iteration and Loop. With Syntax and Programming example explain the working and flow
execution of 1. While Loop and 2. For Loop in Python. Explain what are Minimum and Maximum
Loops.
16. Define String? Explain how the strings are accessed , traversed, sliced and why Strings are called
immutable. Explain at least 5 String functions with examples. (concatenation, len, upper, lower, etc).
17. What are Files? Explain with syntax how the following file operations are done in Python :
a. Opening a File (existing)
b. Reading a File (existing)
c. Closing a File
d. Writing a File (existing)
e. Checking a current position
f. Reposition a pointer to the beginning
g. Creating and writing a new file
18. Write a python program to generate first n Fibonacci number and factorial of n using functions
19. Write a python program to count the number of Characters in a given string and hence to display the
characters of string in reverse order.
20. Write a python program to
a. To create two new files f1 and f2
b. To read and display the contents , count the number of lines and find the word whose count is
more in f1 and f2 respectively.
c. To create and display the file f3 which is a combination of f1 and f2.
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH 206 (B.H. Road), Gubbi, Tumkur – 572 216. Karnataka
Question Bank-2
1. What are Lists? Explain with examples the different ways to create a list. Why lists are called
Mutable. Discuss the following List operations and functions with examples :
1. Accessing ,Traversing and Slicing the List Elements 2. + (concatenation) and * (Repetition)
3. append , extend , sort , remove and delete
4. len , sum, min and max
5. split and join
2. Write a program to compute an average : 1) without using list and 2) using list
3. Compare String and List with examples. With example illustrate how the list can be passed as
arguments. What are objects and Aliasing?
4. What are Dictionaries? Explain with examples how the dictionaries are created. Differentiate
between Key and value of the Dictionary element. Mention the properties of Key . Discuss the
following Dictionary operations and functions with examples
1. Accessing , Traversing , Updating , Deleting
2. Traversing a Dictionary using looping
5. With example program illustrate how the Dictionary can be used to count the occurrence of words in
a file.
6. What are Tuples ? Explain with examples how tuples are created. Compare Tuple with list. Discuss
the following Dictionary operations and functions with examples
3. Accessing , Updating , Deleting , Traversing (Iteration) , Comparing
4. len ,(in) membership + (concatenation) and * (Repetition)
5. DSU (Decorate , Sort and UnDecorate ) pattern
7. Discuss the Tuple Assignment with example .Explain how swapping can be done using tuple
assignment. Write a Python program to input two integers a and b , and swap those numbers . Print
both input and swapped numbers.
8. With example explain how dictionary can be converted into tuple.
9. Write python program to find the common word in a given file. Accept the file name from the user.
10. What are Regular Expressions? What are the two types of characters used in regular expression?
Give example. What are the common uses of regular expression?
11. Explain the intention/meaning of the following Regular expressions
1. ^From .* ([0-9][0-9]):
2. ^Details:.*rev=([0-9.]+
3. ^X\S*: ([0-9.]+)
4. ^X\S*: [0-9.]+
5. ^X\S*: [0-9.]+
6. [a-zA-Z0-9]\S+@\S+[a-zA-Z]
7. \S+@\S+
8. ^From:.+@
9. r"([a-zA-Z]+) (\d+)"
10. r"(\w+) World"
11. r'(.*) are (.*?) .*'
Subject: Python Application Programming Code: 15CS664
12. Explain the following methods of python regular expression library with programming examples.
a. re.match()
b. re.search()
c. re.findall()
d. re.split()
13. Explain with example the significance of Escape character in Regular Expression.
14. Briefly describe the methods of regular expression
15. What is list in Python? Demonstrate use of any three methods of list.
16. Give the output of following Python code: l=[(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] print l
17. Give the output of following Python code: str1 = ‘This is Pyhton’
print( "Slice of String : ", str1[1 : 4 : 1] ) print("Slice of String : ", str1[0 : -1 : 2])
18. Is tuple mutable? Demonstrate any two methods of tuple.
19. What is dictionary in Python? Explain with an example
20. What is Lambda function give example.
21. Write a Python program to sum all the items in a list.
22. Write a Python program to get the largest and smallest number from a list.
23. Write a Python program to count the number of strings where the string length is 2 or more and the
first and last character are same from a given list of strings. Sample List : ['abc', 'xyz', 'aba', '1221']
Expected Result : 2
24. Write a Python program to convert a list of characters into a string.
25. Write a Python program to find the index of an item in a specified list.
26. Write a Python program to get the frequency of the elements in a list.
27. Write a Python program to create a list by concatenating a given list which range goes from 1 to n.
Sample list : ['p', 'q'] n =5
Sample Output : ['p1', 'q1', 'p2', 'q2', 'p3', 'q3', 'p4', 'q4', 'p5', 'q5']
28. Write a Python program to convert list to list of dictionaries. Go to the editor Sample lists: ["Black",
"Red", "Maroon", "Yellow"], ["#000000", "#FF0000", "#800000", "#FFFF00"]
Expected Output: [{'color_name': 'Black', 'color_code': '#000000'}, {'color_name': 'Red', 'color_code':
'#FF0000'}, {'color_name': 'Maroon', 'color_code': '#800000'},
{'color_name': 'Yellow', 'color_code': '#FFFF00'}] Click me to see the sample solution
29. Write a Python program to create a list of empty dictionaries.
30. Write a Python script to concatenate following dictionaries to create a new one. Sample Dictionary :
dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50,
6: 60}
31. Write a Python program to create a tuple with different data types
32. Write a Python program to convert a tuple to a string
33. Write a Python program to convert a list of tuples into a dictionary
34. Write a Python program to convert a tuple to a dictionary.
35. Write a Python program to find the length of a tuple.
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH 206 (B.H. Road), Gubbi, Tumkur – 572 216. Karnataka
Question Bank-3