0% found this document useful (0 votes)
3 views2 pages

Python Programming Question Bank

Uploaded by

fadin6575
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)
3 views2 pages

Python Programming Question Bank

Uploaded by

fadin6575
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

Semester 3

Python Programming
Question Bank
Module I
Section A
1. What is a byte code? (Nov 2020)
2. What are identifiers in Python? (Nov 2020)
3. Give the membership operators in python with examples. (Nov 2020)
4. Explain output statements in Python. (Nov 2020)
5. What are Keywords or reserved words in Python? (Nov 2021)
6. What are different Identity operators in Python with examples. (Nov 2021)
7. Explain input statements in Python. (Nov 2021)
8. Give the rules for naming an identifier in Python (Nov 2022)
9. What is the purpose of ‘not in ‘operator in Python? (Nov 2022)
10. What is the use of eval() function in Python? (Nov 2022)
Section B
1. Explain the different relational operators in Python with examples (Nov 2020)
2. Find the area and circumference of a circle. Prompt user for input. (Nov 2020)
3. Explain different arithmetic operators used in Python with examples. (Nov 2021) &
(Nov 2022)
4. Discuss the int(),float(), str(), complex() and list() type conversion functions with
examples.
5. List out the operator precedence in Python. (Nov 2022)
Section C
1. Explain different data types used in Python with examples. (Nov 2020)
2. a. Explain the salient features of Python Programming Language.
b. Describe the different ways of writing and executing of python program. (Nov 2022)
Module 2
Section A
1. Write the syntax of for loop statements. (Nov 2020)
2. What are loop control statements? (Nov 2020)
3. Explain range() function. (Nov 2020)
4. Write the syntax of while loop. (Nov 2021)
5. What are infinite loops ? (Nov 2021)
6. What do you mean by indentation? (Nov 2021)
7. What is the difference between break and continue statements in Python. (Nov 2022)
8. How will you create an infinite loop in Python? (Nov 2022)
Section B
1. Write a program to find the sum of all odd and even numbers up to a number specified
by the user. (Nov 2020)
2. Write a program to check whether a number is prime or not. Prompt user for input.
(Nov 2020)
3. Write python code to solve the quadratic equation ax2+bx+c=0 getting the input
coefficient from the user. (Nov 2021)
4. Write python program to find the LCM of two numbers. (Nov 2021) & (Nov 2022)
5. Explain various decision-making statements in python. (Nov 2022)
6. Explain while loop and while loop with else case with examples. (Nov 2022)
Section C
1. Write a program to find the sum of the following series: 1+1/2+1/3+1/4+ …….+1/n
(Nov 2020)
2. Write a python program to reverse a number and find the sum of digits in the reversed
number. Prompt the user for input. (Nov 2021)
3. Illustrate the decision control statements in python with flow charts. (Nov 2021)
Module 3
Section A
1. What are the advantages of function? (Nov 2020)
2. Define positional arguments in a function. (Nov 2020)
3. How function call is done in Python? (Nov 2020)
4. What are local variables? (Nov 2020)
5. What are lambda functions? (Nov 2022)
6. Difference between built-in functions and user defined functions in Python. (Nov 2022)
7. What are keyword arguments in functions? (Nov 2022)
Section B
1. Describe the syntax for the following function and explain with an example: (Nov
2020)
a) abs() b) max() c) pow() d) len() e) sort()
2. Write a program to add two numbers using function. (Nov 2020)
3. Discuss zip() function with an example. (Nov 2021)
4. Explain nested function with an example. (Nov 2021)
Section C
1. Write a python program using function to find the value of nPr=n!/(n-r)! without
using in built factorial() function (Nov 2020)
2. Write a python program using function to find the sum and average of the elements in a
list without using in built functions. (Nov 2021)
3. Discuss different argument passing mechanism in Python with suitable examples. (Nov
2022)
Module 4
Section A
1. What are the different ways to create strings in Python? (Nov 2020)
2. What are Lists? (Nov 2020)
3. What are the rules for creating keys in a dictionary? (Nov 2020)
4. How the elements in a string can be accessed using for loop? (Nov 2020)
5. Define mutable and immutable objects. Give examples. (Nov 2021)
6. How strings are sliced? (Nov 2021)
7. How lists can be accessed using while loop? (Nov 2021)
8. What is a set? (Nov 2021)
9. What are sets in Python? (Nov 2022)
10. How will you reverse a list in Python? (Nov 2022)
11. What do you mean by Python dictionary? (Nov 2022)
Section B
1. Write a python code to find the mean and variance from a list of numbers (Nov 2020)
2. Describe the syntax for the following function and explain with example. (Nov 2020)
3. a) replace() b) rstrip c) reverse() d) count() d) join()
4. Describe the syntax for the following function and explain with example. (Nov 2021)
a) upper() b) pop() c) title() d) index() e) split()
5. Distinguish between list, tuple and dictionary. . (Nov 2021)
6. List the functions and syntax of any five string formatting functions in python. . (Nov
2022)
Section C
1. Write a python program to check for the presence of a key in the dictionary and sum all
its values. (Nov 2020)
2. Write a python program that accepts a sentence and calculate the number of words,
digits, uppercase letter and lowercase letters. (Nov 2021)
3. What are mutable and immutable objects in python? Explain any two data types in each
of this category and its associated methods with examples. (Nov 2022)
********************

Common questions

Powered by AI

Mutable objects in Python, such as lists and dictionaries, can be changed after creation, allowing for dynamic data structures where elements can be added, removed, or altered. They are typically used in cases where collections need to be modified, like appending data to a list. Immutable objects, such as strings and tuples, cannot be altered once defined, ideal for maintaining integrity where data should remain unchanged. This immutability is useful in scenarios demanding hash keys or environments where thread safety is a concern .

Indentation in Python is crucial because it is used to define the scope of loops, functions, classes, and other blocks of code. Unlike many other programming languages that use braces or keywords, Python uses indentation to signal a block of code. Correct indentation is essential because Python will raise an IndentationError if the code is not indented consistently. This requirement for indentation promotes readability and reduces the likelihood of errors associated with block definition .

The eval() function in Python parses the expression passed to it and evaluates it as a Python expression. It is often used to dynamically evaluate Python expressions from user input or strings at runtime. For example, eval('3 + 4') would return 7. However, using eval() can pose significant security risks if the input is not properly sanitized, as it can execute arbitrary code. Thus, it should be used cautiously .

Identifiers in Python are names used to identify variables, functions, classes, modules, or other objects. The rules for naming an identifier are: it must start with a letter (A-Z or a-z) or an underscore (_), followed by letters, digits, or underscores. Python identifiers are case-sensitive, meaning 'Var' and 'var' would be considered distinct identifiers. Keywords are not allowed as identifiers .

Membership operators 'in' and 'not in' are used to test for membership in sequences such as strings, lists, or tuples. The 'in' operator returns True if the specified element is found in the sequence. For example, 'x in [1, 2, 3]' returns True if x is one of the elements in the list. Conversely, 'not in' returns True if the specified element is not present in the sequence, e.g., 'x not in [1, 2, 3]' returns True if x is not in the list .

Relational operators in Python are used to compare values, producing boolean outcomes. They include greater than (>), less than (<), equal to (==), not equal to (!=), greater than or equal to (>=), and less than or equal to (<=). Practical applications involve decision-making within code, such as conditionals and loops, where different outcomes depend on comparisons of variables or expressions, such as filtering data in a list based on a threshold .

Lists in Python are mutable, meaning their contents can be changed after creation, such as adding, removing, or updating elements. Tuples are immutable; once created, their contents cannot be altered. This makes tuples suitable for scenarios where fixed and read-only data is required. Dictionaries, meanwhile, are mutable and are composed of key-value pairs. Keys must be immutable types, like strings or numbers. Dictionaries are ideal for fast lookups based on keys rather than positions .

Operator precedence in Python dictates the order in which operations are performed in expressions, with certain operators binding more tightly and getting executed before others. For example, multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-), meaning in the expression '3 + 4 * 5', the multiplication is performed first, resulting in '3 + 20 = 23'. Understanding operator precedence is crucial to writing correct and expected expressions, especially in complex statements without explicit parentheses .

Lambda functions in Python are anonymous functions defined using the lambda keyword. They can have any number of input parameters, but only one expression, which is evaluated and returned. Unlike regular functions defined with 'def', lambda functions are used for simple operations that are short-lived and require less formal structure. They are often used in scenarios requiring a function for a short-term purpose like filtering or sorting data using functions like sort or map. For example, using 'sorted(list, key=lambda x: x[1])' sorts a list of tuples based on the second element .

'Break' and 'continue' are loop control statements in Python that alter the flow of a loop. 'Break' immediately terminates the loop, transferring control to the first statement following the loop's end. Conversely, 'continue' skips the rest of the code inside the loop for the current iteration and resumes at the loop's next iteration. Both are useful in controlling loop execution paths, yet they differ in application as 'break' ends loop execution, while 'continue' only interrupts a single iteration .

You might also like