0% found this document useful (0 votes)
163 views6 pages

Python Subjective Question Set

The document contains a collection of Python subjective questions organized under different topics like problem solving, data types, operators, strings, lists, tuples, dictionaries, modules, functions and files. The questions are meant to test conceptual understanding of Python programming concepts.

Uploaded by

anilgahlawat1987
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)
163 views6 pages

Python Subjective Question Set

The document contains a collection of Python subjective questions organized under different topics like problem solving, data types, operators, strings, lists, tuples, dictionaries, modules, functions and files. The questions are meant to test conceptual understanding of Python programming concepts.

Uploaded by

anilgahlawat1987
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

Python Subjective Question Set

Topic: Introduction to Problem Solving


Reference Videos: CS Academy-> Python -> Videos -> Introduction of Python
Questions:
1. What are the steps for problem solving? Explain the steps in detail
2. What is an algorithm? What are the characteristics of a good algorithm?
How are algorithms represented?
3. Write an algorithm to find the square of a number.
4. Write an algorithm to calculate area and perimeter of a rectangle, using
both pseudocode and flowchart.
5. What are conditionals? When they are required in a program?
6. What is decomposition of a problem?
Topic: Familiarization with the basics of Python programming
Reference Videos: CS Academy-> Python -> Videos -> Introduction of Python
Questions:
1. Explain the execution modes of Python.
2. Explain the features of Python.
3. Explain Tokens in Python.
4. What is the significance of comments in Python?
Topic: Knowledge of Data Types & Operators
Reference Videos: CS Academy-> Python -> Videos -> Data Types & Operators
Questions:
1. What are the different data types in Python?
2. What are the different operators in Python?
3. Write a program to enter two integers and perform all arithmetic
operations on them.
4. Which data type will be used to represent the following data values and
why? a) Number of months in a year b) Resident of Delhi or not c)
Mobile number d) Pocket money e) Volume of a sphere f) Perimeter of a
square g) Name of the student h) Address of the student
5. Write a program to swap two numbers i. using a third variable ii. Without
using a third variable
6. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here
‘n’ is an integer entered by the user
7. The formula E = mc2 states that the equivalent energy (E) can be
calculated as the mass (m) multiplied by the speed of light (c = about
3×108 m/s) squared. Write a program that accepts the mass of an object
and determines its energy.
8. Write a program that asks the user to enter their name and age. Print a
message addressed to the user that tells the user the year in which they
will turn 100 years old.
Topic: Expressions, type conversion & input/output
Reference Videos: CS Academy-> Python -> Videos -> Data Types & Operators
CS Academy-> Python -> Videos -> Statements & Flow of Control
Questions:
1. What are expressions? Explain precedence of operators in an expression.
2. Explain Type conversion in Python
3. What are the different types of errors in Python? Explain
4. Explain input and output in Python.
5. Write a program in python to show accepting data as input from the
console and displaying output
Topic: Statements, Conditional Statements, Iterative statements and Flow of
Control
Reference Videos: CS Academy-> Python -> Videos -> Statements & Flow of
Control
Questions:
1. Explain the significance of indentation in Python.
2. What is the difference between else and elif construct of if statement?
3. Differentiate between break and continue statements using examples
4. What is an infinite loop? Give one example.
5. Differentiate and explain sequential flow, conditional and iterative flow
of control
6. Write a program to find out the absolute value of a number n,
7. Write a program to sort 3 numbers
8. Write a program to find out divisibility of a number n by another number
m, where m and n are integers input by the user
9. Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto
n, where n is an integer input by the user
10. Write a program that checks whether an input number is a palindrome
or not.
[Link] a program to print the following patterns

[Link] a program to find the sum of 1+ 1/8 + 1/27......1/n3, where n is the


number input by the user. (Summation of a series)
[Link] a program to calculate the factorial of a given number.
Topic: Strings and Lists
Reference Videos: CS Academy-> Python -> Videos -> Strings and List Part 1
CS Academy-> Python -> Videos -> Strings and List Part 2
Questions:
1. Explain operations on a string in python.
2. Explain indexing in a string in python
3. Give a brief about built in functions on strings in python
4. Explain operations on a list in python.
5. Explain indexing in a list in python
6. Give a brief about built in functions on lists in python
7. Input a string having some digits. Write a program to return the sum of
digits present in this string
8. Write a program to input line(s) of text from the user until enter is
pressed. Count the total number of characters in the text (including
white spaces),total number of alphabets, total number of digits, total
number of special symbols and total number of words in the given text.
(Assume that each word is separated by one space)
9. Write a program that takes a sentence as an input parameter where each
word in the sentence is separated by a space. The function should
replace each blank with a hyphen and then return the modified
sentence.
10. Write a program for finding the maximum, minimum and mean of
numeric values stored in a list
11. Write a program to implement linear search on list of numbers
12. Write a program for counting the frequency of elements in a list
13. Write a program to read a list of elements. Modify this list so that it does
not contain any duplicate elements, i.e., all elements occurring multiple
times in the list should appear only once
Topic: Tuples and Dictionaries
Reference Videos: CS Academy-> Python -> Videos -> Strings and List Part 2
Questions:
1. Explain operations on a tuple in python.
2. Explain indexing in a tuple in python
3. Give a brief about built in functions on tuples in python
4. Write a program for finding the maximum, minimum and mean of
numeric values stored in a tuple
5. Write a program to implement linear search on tuple of numbers
6. Write a program for counting the frequency of elements in a tuple
7. Explain operations on a dictionary in python.
8. Write short notes on creating dictionary and accessing items in a
dictionary in python
9. Give a brief about dictionary methods and built in functions in python
10. Write a program to count the number of times a character appears in a
given string using a dictionary
11. Write a program to create a dictionary with names of employees, their
salary and access them
12. Write a Python program to find the highest 2 values in a dictionary.
13. Write a program to read email IDs of n number of students and store
them in a tuple. Create two new tuples, one to store only the usernames
from the email IDs and second to store domain names from the email
IDs. Print all three tuples at the end of the program. Use the function
split()
14. Write a Python program to create a dictionary from a string. Note: Track
the count of the letters from the string.
Sample string : 'w3resource'
Expected output : {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1}

Topic: Modules
Reference Videos: CS Academy-> Python -> Videos -> Modules and Interfacing
Questions:
1. Explain importing of a module in python
2. Write short notes on math module in python
3. Write short notes on statistics module in python
4. Write short notes on random module in python
Topic: Functions and files
Reference Videos: CS Academy-> Python -> Videos -> Modules and Interfacing
Questions:
1. What are functions and what are its advantages in python?
2. Explain user defined functions.
3. Write a user defined function to add 2 numbers and display their sum.
4. Write a short notes on arguments and parameters in python
5. Differentiate between local scope and global scope of a variable
6. What are the different types of functions in Python?
7. What are the different types of files supported in Python? Explain the
operations, modes and methods of those files.

Common questions

Powered by AI

Python supports several execution modes: the interactive mode and script mode. Interactive mode is used for quick testing and debugging as it executes commands immediately. Script mode, on the other hand, involves writing code in a file and running it as a script, which is beneficial for developing larger programs. The implications of these modes are significant; interactive mode allows for iterative development and rapid prototyping, whereas script mode is more suited for production-level code as it provides better structure and maintainability .

Python handles type conversion through implicit and explicit mechanisms. Implicit conversion is automatically performed by Python, such as converting an int to a float during arithmetic operations. Explicit conversion, or casting, uses functions like int(), float(), and str() to convert types manually. Type conversion is significant in data processing because it ensures that operations involving different data types can be performed efficiently and accurately. This flexibility allows for handling diverse data inputs and outputs seamlessly, a necessity in dynamic programming environments .

The 'break' and 'continue' statements are used to alter the flow of loops in Python. The 'break' statement exits a loop completely, terminating it early when a certain condition is met. For instance, it can be used to stop processing once an item is found in a search. In contrast, 'continue' skips the current iteration of the loop and proceeds to the next, useful in scenarios like ignoring select items in a list processing operation. While 'break' ends a loop, 'continue' provides more nuanced control by enabling selective processing within repetitive structures .

Operator precedence in Python determines the order in which operations are evaluated in expressions. For instance, in the expression '3 + 4 * 5', multiplication has higher precedence than addition, so '4 * 5' is evaluated first, resulting in 20, then added to 3, resulting in 23. Parentheses can alter the default precedence, as '(3 + 4) * 5' evaluates '3 + 4' first, yielding 7, which is then multiplied by 5 to result in 35. Understanding precedence is crucial to ensure expressions yield correct results and is pivotal in avoiding logical errors in code .

A good algorithm is characterized by its finiteness, definiteness, input, output, and effectiveness. Finiteness ensures that the algorithm will terminate after a finite amount of steps. Definiteness dictates that each step is precisely defined. It should allow for specific inputs and produce outputs that are directly related to the problem statement. Effectiveness requires that each step is elementary enough to be carried out in practice. These characteristics influence the effectiveness of an algorithm by ensuring it is reliable, predictable, and usable in practical scenarios, essential for implementation in programming .

Python's built-in modules, like 'math', 'statistics', and 'random', simplify complex programming tasks by encapsulating advanced functionality in accessible functions. The 'math' module provides functions for mathematical operations beyond basic arithmetic, 'statistics' offers tools for computing mathematical statistics functions, and the 'random' module aids in generating pseudo-random numbers. These modules reduce the need to manually implement complex algorithms, thus enhancing productivity and ensuring the use of well-tested and performant solutions in applications .

In Python, data types are chosen based on the nature of the data being handled. For instance, integers are used for whole numbers, such as the number of months in a year. Booleans represent binary conditions like 'Resident of Delhi or not'. Strings are used for text, like the name or address of a student. Floats are chosen for real numbers, e.g., the volume of a sphere. Each data type is selected to best suit the operations required for its associated data, ensuring accuracy and efficiency in processing .

Conditionals play a critical role in programming by enabling decision-making within code. They allow programs to execute different logic or computations based on varying conditions. For example, in programs involving user input validation, conditionals are used to ensure that inputs meet specific criteria before processing further. They are essential in iterative processes, also known as loops, where the continuation of a loop may depend on a specific condition being true or false. They are fundamental to control flow and are used extensively to create flexible and dynamic solutions in programs .

Effective problem solving involves several steps: 1) Define the problem clearly to understand what needs to be achieved. 2) Analyze the problem by identifying inputs, outputs, and constraints. 3) Develop a plan or an algorithm by breaking down the problem into smaller sub-problems. 4) Implement the plan by translating the algorithm into a programming language. 5) Test the solution with various inputs and refine as necessary. These steps can be applied in programming tasks by ensuring each stage is meticulously completed, from defining the problem to testing the solution, to ensure efficient and accurate code .

Sequential flow involves executing instructions one after the other without branching. For example, a series of statements like variable initializations follow this mode. Conditional flow, such as using if-else statements, allows making decisions that alter execution paths based on specific conditions. Iterative flow, encompassing loops like for and while, repeats a block of statements multiple times, controlled by a condition. Each type of flow is essential in programming, providing different mechanisms to process, test, and iterate over data and logic .

You might also like