0% found this document useful (0 votes)
218 views4 pages

Python Programming Concepts Overview

Uploaded by

ethernallamp
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)
218 views4 pages

Python Programming Concepts Overview

Uploaded by

ethernallamp
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

Module 1

1. Define Python. List the salient features of python.


2. Define Flowchart. Draw the Flowchart to check whether the input number is odd or even.
3. Explain Membership and Identity operators in Python
4. Write a python program to find roots of a quadratic equation ax2+bx+c . Use input() to
enter a, b and c and print root1 and root2
5. Define an Algorithm. Write an algorithm to find the greatest number among the given two
numbers
6. Explain the operator precedence and order of evaluation for arithmetic operators in Python
7. Write a Python program to find GCD and LCM of two given numbers.
8. Write a python program to find the factorial of a number
9. Computes the expressions 1. 3+(4-(11//5))**2%2 2. (1+2)**(5-2) 3. 3*2**2. Define
PEDMAS.
10. Explain the rules to define a variable in python. Give examples for assigning multiple
values to multiple variables.
11. Define Keyword. Explain any six keywords in python.
12. Explain type casting and its usage with an example
13. Classify the different operators in Python with an example.

Module 2
1. Explain the higher-order functions reduce () and filter () with an example

2. Explain the working of the ‘for’ and ‘while’ loop with an example

3. Write a Python program for user defined function to find the reverse of a number using
loop.
4. Explain any five built in functions in Python

5 .Describe the working of the if, else and elif block in Python with an example

6 .Write a Python program to print Pascal triangle

7 .Write a Python program to check whether the given year is a leap year or not.

8 .With syntax and examples, Explain while, Nested while and while else loop statements.

9 .Explain the recursive function along with example.

10. Explain the for, Nested for and for else loop statements along with examples.
11 .Write the algorithm to find the sum of n natural numbers using recursion.
12. Explain the working of LAMBDA and MAP filter functions along with examples.

13. with syntax and examples, Explain REDUCE and FILTER functions

14. Explain the string indexing and slicing with an example.

15. Evaluate the working of continue, break and pass function.

16. Explain the types of function arguments with example.

17. Calculate the total marks, percentage and grade of a student. Marks obtained in each of
the three subjects are to be input by the user. Assign grades according to the following
criteria: Grade A:
Percentage >=80, Grade B: Percentage >=70 and <80 Grade C: Percentage >=60 and <70
Grade D: Percentage >=50 and <60 Fail: Percentage<50.
18. Write a python program to find the factorial of a number using recursion.

19. Explain the concept of recursion. Mention its advantages and disadvantages over iteration
with an example program.
20. Write a python program to print 5th multiplication table.

Module 3
1. Explain the below functions in Python – read (), write (), append (), open ()

2. With examples, Illustrate the difference between string indexing and string slicing.

3. Explain the string operations of concatenation and repetition with an example

4. Write a Python program that accepts a hyphen separated sequence of words as input and
prints the words in hyphen-separated sequence after sorting them alphabetically
5. With an example show how to import modules in Python

6. Explain Deleting/Updating in a string with an example

7. Write a Python program to count number of uppercase letters, lowercase letters and spaces
in a string and toggle case the given string
8. With suitable examples, Explain read mode in file handling in python.

9. Explain the string slicing and splitting along with examples.

10. With suitable examples, Explain write and append mode in file handling.

11. Write a python program to count the number of words, characters and lines in a specified
file.
12. Classify the index and Find function with an example.

13. Explain the difference between single string and multiline string with an example

14. Examine the reassigning of string with an example.

15. Illustrate the working of replace and Case fold function with an example.

16. Discuss string indexing and slicing in Python. Illustrate your answer with examples
showing how to access individual characters.
17. Describe the various string operators available in Python. Provide examples of string
concatenation, repetition, and membership testing using the in operator.
18. Explain the concept of exception handling in Python. Define the purpose of try, except,
raise, and finally blocks with examples.
19. What are assertions in Python, and how are they used? Discuss their purpose in debugging
and testing code, along with the syntax for using assertions.
20. Explain how to create strings in Python. Provide examples of string creation using single
quotes, double quotes, and triple quotes.

Module 4
1. Difference between List and Dictionary in Python with example program for each.
2. Difference between List and Tuple in Python with example program for each.
3. Convert list of tuple into dictionary using iterative method with example program.
4. Which is better list or tuple in Python? Justify you answer with example program?
5. Difference Between ‘+’ and ‘append’ in Python with example.
6. How to Split Elements of a List? Explain the different methods.
7. Give any two ways to create a list in Python and reverse a list.
8. Explain the different list methods in Python for Python lists and give example program
for any five.
9. What is Immutable in Tuples? Justify your answer with example program.
10. Explain the append() and extend() in Python with suitable program for each.
11. Given a list of lists, write a Python program to extract the last element of each sublist
in the given list of lists.
12. List out the Different Operations Related to Tuples. Explain any five with example
program for each.
13. Explain the different tuple methods in Python for Python tuples and give example
program for each.
14. Advantages of tuple over list with example.
15. List out the Different Operations Related to sets. Explain with example program.
16. Explain the different set methods in Python for Python tuples and give example
program for each.
17. Create a dictionary and explain the properties of keys and values.
18. Explain any 5 ways to iterate through a dictionary with suitable example for each.
19. Write a python program to removing dictionary from list of dictionaries with output.

What are the built-in methods that you can use on dictionaries? Explain any five with
example program
Module 5
1. Explain the file reading operation with an example
2. Describe the processing of writing a character into a file using suitable example
3. Analyse the format operators in python
4. Discuss the details of command line arguments
5. Evaluate the use of modules and packages for efficient programming
6. Explain the governing principles of object-oriented programming
7. Illustrate with a python program to create a class and objects
8. Discuss the implementation of various types of inheritance using suitable examples
9. Write a python program to read line by line from a given files file1 & file2 and write
into file3.
10. Read a text file in Python and print no. of lines and no. of unique words.
11. Write a Python program to read a text file and do following:
1. Print no. of words
2. Print no. Statements
12. How operator overloading can be implemented in Python?
13. Write a Python program to overload + operator.
14. Explain built-in class attributes in a python class.
15. Create a class Employee with data members: name, department and salary. Create
suitable methods for reading and printing employee information.
16. Create a class Employee with data members: name, department and salary. Create
suitable methods for reading and printing employee information.
17. Create a class student with following member attributes: roll no, name, age and total
marks.
18. Create suitable methods for reading and printing member variables. Write a python
program to overload ‘==’ operator to print the details of students having same marks.
19. Write about class constructor(_init_()),self-variable
20. Compare method overloading and overriding

Common questions

Powered by AI

Python is known for its simplicity and readability, which makes it an excellent choice for beginners. It is an interpreted language, which means it can execute code line by line and has dynamic typing, allowing more flexibility in coding. Python is also versatile, supporting multiple paradigms such as procedural, object-oriented, and functional programming. It has a robust standard library that supports a wide array of modules and tools for various tasks. Additionally, Python is open-source with a strong community support, ensuring frequent updates and a plethora of libraries .

Membership operators in Python, 'in' and 'not in', are used to test whether a specific value is found within a sequence such as a list, tuple, or string. For example, 'a in [1, 2, 3]' evaluates to False. Identity operators, 'is' and 'is not', check whether two references point to the same object, i.e., they have the same identity in memory. For instance, 'a is b' returns True if both variables point to the same object .

Recursion is a programming technique where a function calls itself to solve smaller instances of a problem, typically until a base condition is met. It is significant for problems that can naturally be divided into similar subproblems, such as factorial calculation or Fibonacci sequence. The advantages include cleaner, more intuitive code for certain problems and reduced code size. However, recursion can lead to performance costs due to function call overhead and is limited by Python’s stack depth, leading to possible stack overflow on very deep recursions. Iteration, in contrast, is often more efficient in terms of execution speed and memory usage since it does not have the overhead of multiple function calls .

The key difference between lists and tuples is that lists are mutable, allowing modifications like item addition, deletion, or updates, whereas tuples are immutable, meaning once set, their elements cannot be changed. Tuples are faster than lists due to their immutability and can be used as keys in dictionaries, which require immutable types. Lists are more suitable when data needs frequently to be modified. Example: list: ['a', 'b', 'c']; tuple: ('a', 'b', 'c').

Python has several types of function arguments: positional, allowing arguments to be passed in order, keyword, enabling explicit naming, and default, specifying default values for parameters if none are provided. Variable-length arguments *args and **kwargs capture additional positional and keyword arguments, respectively. For example, def func(a, b=2, *args, **kwargs) can accept func(1, 3, 45, x=5). This flexibility supports a wide range of function signature needs .

Modules and packages in Python enable modular programming, allowing functions, classes, and variables to be grouped in separate files, improving code organization and reusability. They enhance project maintainability, as individual modules can be modified independently. Modules aid in the prevention of name conflicts with different file namespaces. Additionally, packages, which are directories of modules, allow for hierarchical structuring of code for complex applications. Usage encourages logical code separation and easier debugging .

Higher-order functions, such as reduce() and filter(), operate on collections and return new results. The filter(function, iterable) construct is used to filter elements of an iterable based on a function that returns a boolean value. For example, filter(lambda x: x % 2 == 0, [1, 2, 3, 4]) results in [2, 4]. Reduce(function, iterable) cumulatively applies a function to the elements in a sequence, reducing it to a single value, e.g., reduce(lambda x, y: x + y, [1, 2, 3, 4]) sums up to 10 .

Mutable data types, like lists, can have their state or contents modified after creation, which means changes made to them inside a function affect the original object. Immutable types, like tuples, cannot be changed after creation, so if a tuple is passed to a function, any modification attempts will result in errors or unchanged output. This behavior affects function design, where mutable data types are suitable for in-place modifications, whereas immutable types ensure data consistency and predictability across functions .

Operator precedence defines the order in which operations are evaluated in expressions. Python follows the standard mathematical precedence, prioritizing parentheses first, followed by exponentiation, multiplication and division, and finally addition and subtraction (PEDMAS/BODMAS rule). For example, in the expression '3 + 4 * 2', multiplication is performed before addition, resulting in 11. Order of evaluation determines the sequence in which these operations are computed from left to right .

Python uses the try-except block to manage exceptions. Code that might raise an exception is placed in the try block, while except block handles the error. The code in the finally block runs regardless of whether an exception occurred, useful for cleanup actions. The raise statement manually triggers an exception. For instance, consider a try block that attempts to open a file. If the file isn’t found, the except block can handle the FileNotFoundError by printing an error message or taking alternative action. The finally block could close the file if it was opened successfully .

You might also like