[go: up one dir, main page]

0% found this document useful (0 votes)
20 views11 pages

PP Final Questions

The document outlines a comprehensive curriculum for Python programming, covering topics such as the programming cycle, conditionals, loops, functions, strings, data structures, file I/O, and exception handling. Each chapter includes specific questions and tasks aimed at reinforcing the concepts, such as writing functions, understanding algorithms, and manipulating data. The curriculum is structured to progressively build skills in Python through practical examples and exercises.

Uploaded by

madhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views11 pages

PP Final Questions

The document outlines a comprehensive curriculum for Python programming, covering topics such as the programming cycle, conditionals, loops, functions, strings, data structures, file I/O, and exception handling. Each chapter includes specific questions and tasks aimed at reinforcing the concepts, such as writing functions, understanding algorithms, and manipulating data. The curriculum is structured to progressively build skills in Python through practical examples and exercises.

Uploaded by

madhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

PYTHON PROGRAMMING

Chapter 1: Introduction and Basics


• Topic: The Programming Cycle for Python, Python IDE, Interacting with
Python Programs, Elements of Python, Type Conversion
• 20-21(1.a): What is the use of “raise” statement? Describe with an
example.
• 21-22(1.a): Explain the Programming Cycle for Python in detail.
• 22-23(1.a): Explain the Programming Cycle for Python in detail.
• 23-24(1.f): Explain why the program generates an error.
x = [‘12’, ’hello’, 456] x[0] *= 3 x[1][1]=’bye’
• 23-24(1.e): Describe the difference between linspace and argspace.
• 20-21(1.g): How do you read an input from a user in Python to be
used as an integer in the rest of the program? Explain with an
example.
• 21-22(2.a): What do you mean by Python IDE? Explain in detail.
• 23-24(1.b): Differentiate between / and // operator with an example
• 23-24(1.g): Describe about different functions of matplotlib and
pandas.
• Topic: Basics: Expressions, Assignment Statement, Arithmetic Operators,
Operator Precedence, Boolean Expression
• 20-21(1.e): Which of the following statements produce an error in
Python? x, y, z = 1,2,3 # s1 a, b = 4,5,6 # s2 u = 7,8,9 # s3 (List all the
statements that have error.)
• 20-21(1.f): Explain the role of precedence with an example.
• 21-22(1.b): What will be the output of the following Python code?
i=0
while i< 3:
print(i)
i += 1
else:
print(0)
• 21-22(1.c): What will be the output of the following Python code?
• 23-24(1.c): Compute the output of the following python code:
def count(s):
for str in string.split():
s = “&”.join(str)
return s
print(count(“Python is fun to learn.”))
• 20-21(1.h): Consider the program:
x,y,z = 1,2,3 #s1
a,b = 4,5,6 #s2
u = 7,8,9 #s3 Explain why this program generates an error.
• 20-21(1.i): What is the output of the following program?
• 20-21(5.b): What is short circuit evaluation? What is printed by the
following Python program? a = 0 b = 2 c = 3 x = c or a print(x)
Chapter 2: Conditionals and Loops
• Topic: Conditional statement in Python (if-else statement, its working and
execution), Nested-if statement and Elif statement in Python, Expression
Evaluation & Float Representation
• 22-23(2.b): Explain the following loops with a flow diagram, syntax,
and suitable examples. I) For II) while
• 23-24(4.b): Explore the working of while, and for loop with examples.
• Topic: Loops: Purpose and working of loops, While loop including its
working, For Loop, Nested Loops, Break and Continue
• 20-21(1.c): Describe the behavior of “range (s, e)" in Python.
• 22-23(2.c): Explain the continue, break, and pass statements with a
suitable example.
• 21-22(4.a): Write a Python program to construct the following
pattern, using a nested for loop.
• *
• **
• ***
• ****
• *****
• ****
• ***
• **
• *
Chapter 3: Function and Strings
• Topic: Function: Parts of A Function, Execution Of A Function, Keyword and
Default Arguments, Scope Rules
• 20-21(1.b): Write a recursive Python function “rprint" to print all
elements in a list in reverse.
• 20-21(4.b): Show an example where both Keyword arguments and
Default arguments are used for the same function in a call. Show both
the definition of the function and its call.
• 22-23(4.a): Discuss the different types of argument-passing methods
in python. Explain the variable length argument with any suitable
example.
• 22-23(2.a): Demonstrate five different built in functions used in the
string. Write a program to check whether a string is a palindrome or
not.
• 23-24(1.d): How to use the functions defined in library.py in main.py
• 23-24(2.c): Construct a function perfect_square(number) that
returns a number if it is a perfect square otherwise it returns -1. For
example: perfect_square(1) returns 1 perfect_square (2) returns -1
• 23-24(2.d): Construct a program to change the contents of the file by
reversing each character separated by comma: Hello!! Output
H,e,l,l,o,!,!
• 23-24(5.a): Construct a function ret smaller(1) that returns smallest
list from a nested list. If two lists have same length then return the
first list that is encountered. For example: ret smaller([ [ -2, -1, 0, 0.12,
1, 2], [3, 4, 5], [6 , 7, 8, 9, 10], [11, 12, 13, 14, 15]]) returns [3,4,5] ret
smaller([ [ -2, -1, 0, 0.12, 1, 2], [‘a’, ’b’, ’c’, ’d’, 3, 4, 5], [6 , 7, 8, 9, 10],
[11, 12, 13, 14, 15]]) returns [6 , 7, 8, 9, 10]
• Topic: Strings: Length of the string and perform Concatenation and Repeat
operations in it, Indexing and Slicing of Strings
• 20-21(2.a): Write a Python function removekth(s, k) that takes as
input a string s and an integer k>=0 and removes the character at
index k. If k is beyond the length of s, the whole of s is returned. For
example,
removekth(“PYTHON”, 1) returns “PTHON”
removekth(“PYTHON”, 3) returns “PYTON”
removekth(“PYTHON”, 0) returns “YTHON”
removekth(“PYTHON”, 20) returns “PYTHON”
• 22-23(1.b): Describe the concept of List Slicing with a suitable
example.
• 22-23(3.a): Illustrate Unpacking tuples, mutable sequences, and
string concatenation with examples
• 23-24(2.b): Illustrate different list slicing constructs for the following
operations on the following list:
L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
1. Return a list of numbers starting from the last to second item of
the list
2. Return a list that start from 3rd item to second last item.
3. Return a list that has only even position elements of list L to list M.
4. Return a list that starts from the middle of the list L.
5. Return a list that reverses all the elements starting from element
at index 0 to middle index only and return the entire list.
Divide each element of the list by 2 and replace it with the
remainder.
• 21-22(5.a): Write a Python program to change a given string to a new
string where the first and last chars have been exchanged.
• Topic: Python Data Structure : Tuples, Unpacking Sequences, Lists, Mutable
Sequences, List Comprehension, Sets, Dictionaries
• 21-22(2.c): Explain Tuples and Unpacking Sequences in Python Data
Structure.
• 22-23(1.g): What is a dictionary in Python?
• 22-23(2.e): Explain the list Comprehension with any suitable
example.
• 23-24(1.a): Describe the concept of list comprehension with a
suitable example
• Topic: Higher Order Functions: Treat functions as first class Objects, Lambda
Expressions
• 22-23(3.b): Explain the lambda function. How it is helpful in the
higher order function. Explain map() function with a suitable
example.
• 20-21(1.i): What is the output of the following program?
Chapter 4: Sieve of Eratosthenes & File I/O
• Topic: Sieve of Eratosthenes: generate prime numbers with the help of an
algorithm given by the Greek Mathematician named Eratosthenes, whose
algorithm is known as Sieve of Eratosthenes
• 21-22(6.b): Explain the algorithm Sieve of Eratosthene used in Python
Programming.
• 22-23(5.b): Demonstrate the ‘Sieve of Eratosthenes’theorem and
write the python function to print prime numbers between 1 to 100.
• Topic: File I/O: File input and output operations in Python Programming,
Exceptions and Assertions Modules : Introduction, Importing Modules
• 20-21(1.d): Explain the use of “with” construct in Python with an
example program.
• 21-22(2.d): What are File input and output operations in Python
Programming?
• 21-22(6.a): How to create and import a module in Python?
• 22-23(1.c): Show the way to import the module in python.
• 20-21(3.a): How can you create Python file that can be imported as a
library as well as run as a standalone script?
• 20-21(3.b): Describe the difference between import library and from
library import * when used in a python program. Here library is some
python library.
• 22-23(5.a): Demonstrate the file handling procedure in detail. Write
a python code to create a file with 'P.txt' name and write your name
and father's name in this file and then read this file to print it.
• 23-24(6.a): Change all the numbers in the file to text. Construct a
program for the same. Example: Given 2 integer numbers, return
their product only if the product is equal to or lower than 10. And the
result should be: Given two integer numbers, return their product
only if the product is equal to or lower than one zero
• 23-24(6.b): Construct a program which accepts a sequence of words
separated by whitespace as file input. Print the words composed of
digits only.
• Topic: Abstract Data Types : Abstract data types and ADT interface in Python
Programming
• 21-22(1.d): How do we define an Interface for an ADT?
• 21-22(1.e): How do you perform a search in Python?
Chapter 5: Iterators & Recursion
• Topic: Iterators & Recursion: Recursive Fibonacci, Tower Of Hanoi
• 21-22(2.e): Solve the Tower of Hanoi problem for n= 3 disk and show
all the steps.
• 22-23(7.b): Summarize the 'Tower of Hanoi' puzzle and write its
recursive function to implement it.
• 21-22(7.a): Write a Recursive function in python
BinarySearch(Arr,1,R,X) to search the given element X to be searched
from the List Arr having R elements, where 1 represent slower bound
and R represents the upper bound.
• Topic: Search : Simple Search and Estimating Search Time, Binary Search
and Estimating Binary Search Time
• 20-21(2.c): Describe the differences between a linear search and a
binary search?
• 22-23(6.b): Explain Binary search with its python code and
complexity.
• Topic: Sorting & Merging : Selection Sort, Merge List, Merge Sort, Higher
Order Sort
• 21-22(3.a): Write a program in Python to execute the Selection sort
algorithm.
• 22-23(6.a): Develop and write the python code of selection sort to
sort 41,65,43,91,12,14,62 elements. Also, explain its complexity.
• 21-22(7.b): Explain the terms Merge List and Merge Sort in Python
Programming.
• Topic: String Manipulation
• 23-24(3.a): Determine a python function removenth(s,n) that takes
an input a string and an integer n>=0 and removes a character at
index n. If n is beyond the length of s then whole s is returned. For
example:
removenth(“MANGO”,1) returns MNGO
removenth(“MANGO”,3) returns MANO
• 23-24(3.b): Construct a program that accepts a comma separated
sequence of words as input and prints the words in a comma-
separated sequence after sorting them alphabetically. Suppose the
following input is supplied to the program: without, hello, bag, world
Then, the output should be: bag, hello, without, world
• Topic: Exception Handling
• 20-21(2.b): Write a Python function average to compute the average
of a list of numbers. The function must use try-except to handle the
case where the input list is empty. Further, in that case the average
for the empty list should be set to 0.0 using the except block.
• 22-23(7.a): Explain the importance of Exception handling in any
object-oriented programming language. Explain try exceptions and
finally block with any suitable example.
• Topic: List Manipulation
• 20-21(2.d): Write a function lessthan(lst, k) to return list of numbers
less than k from a list 1st. The function must use list comprehension.
• 20-21(2.e): Write a program factors(N) that returns a list of all
positive divisors of N (N>=1). For example:
factors(6) returns [1,2,3,6]
factors(1) returns [1]
factors(13) returns [1,13]
• 20-21(4.a): Write a function makePairs that takes as input two lists of
equal length and returns a single list of same length where k-th
element is the pair of k-th elements from the input lists. For example,
makePairs([1,3,5,7],[2,4,6,8])
returns [(1,2),(3,4),(5,6),(7,8)]
makePairs([],[])
returns []
• 23-24(5.b): Construct following filters: 1. Filter all the numbers 2.
Filter all the strings starting with a vowel 3. Filter all the strings that
contains any of the following noun: Agra, Ramesh, Tomato, Patna.
Create a program that implements these filters to clean the text.
• 21-22(5.b): Write a Python program to add an item in a tuple.
• 23-24(2.e): Construct a plot for following dataset using matplotlib :
Refer question
• 23-24(7.a): Construct a program to read cities.csv dataset, remove
last column and save it in an array. Save the last column to another
array. Plot the first two columns.
• 23-24(7.b): Design a calculator with the following buttons and
functionalities like addition, subtraction, multiplication, division and
clear.

Missing question
• 23-24(4.a): A website requires the users to input username and password
to register. Construct a program to check the validity of password input by
users. Following are the criteria for checking the password:
1. At least 1 letter between [a-z]
2. At least 1 number between [0-9]
3. At least 1 letter between [A-Z]
4. At least 1 character from [$#@]
5. Minimum length of transaction password: 6
6. Maximum length of transaction password: 12 Your program should
accept a sequence of comma separated passwords and will check them
according to the above criteria. Passwords that match the criteria are to be
printed, each separated by a comma

• 22-23(4.b): Write short notes on the following with a suitable example I) Encapsulation II)
Inheritance

• 22-23(1.d): Differentiate between Python Arrays and lists?


• 22-23(1.e): Define floor division with an example

• 22-23(1.f): Explain the difference between ‘append’ and ‘extend’ in Python?


• 22-23(1.h): what is object -oriented programming (OOP) in python? Give an example
• 22-23(1.i): what will be the output of the following python code
Def count(s):
vowels =”AEIOUaeiou”
count =0
For c in s :
If c in vowels:
count += 1
return count
print(count(“I Love India”))
• 22-23(1.j): what will be the output of the following code ?
List1 = ['M', 'o', 'n', 'k', 'y']
print("@".join(list1))

• 21-22(2.b): How can you randomize the items of a list in place in Python?
• 20-21(5.a),21-22(3.b): Explain why python is considered an interpreted language.

You might also like