Python Question Bank
Python Question Bank
QUESTION BANK
1.Define algorithm.
Properties of Algorithms
COMPILER INTERPRETER
The compiler saves the The Interpreter does
Machine Language in form not save the Machine
of Machine Code on disks. Language.
Compiled codes run faster Interpreted codes run
than Interpreter. slower than Compiler.
Linking-Loading Model is The Interpretation
the basic working model of Model is the basic
the Compiler. working model of the
Interpreter.
Errors occurring in programming are called as bugs. The process of tracking these
bugs is called as debugging.
There are three types of errors that can occur while coding: Syntax Error,
Runtime Error and Semantic Error.
4. What are the features and applications of Python?
Features of python.
Applications of python:
Python is commonly used for developing websites and software, task
automation, data analysis, and data visualization.
5.Define list:
Python Lists are similar to arrays in C. However, the list can contain data of
different types.
* The items stored in the list are separated with a comma (,) and enclosed
6.Define tuples.
Len()
Max()
Min()
Tuple()
8.Define dictionary.
*Dictionaries are used to store data values in key:value pairs.
Dictionaries are written with curly brackets, and have keys and values:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
9.Define flowchart.
A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume). Rules for Python variables:
TYPES:
Local variable.
Global variable.
Functions in Python are first-class objects.This broadly means, that functions in Python:
have types
A function is a block of code which only runs when it is called. You can pass data,
known as parameters, into a function. A function can return data as a result.
Creating a Function:
for n in x:
print(n)
output:(3,5,7,9,11,13,15,17,19)
the 0th, 2nd and 4th elements. Sample List: [“Red”, “Green”,
“Black”, “Pink”, “Yellow”]
Output:[“Green”,”Pink”]
Type Casting is the method to convert the Python variable datatype into a certain data type in
order to perform the required operation by users. In this article, we will see the various
techniques for typecasting. There can be two types of Type Casting in Python:
Python Implicit Type Conversion
Python Explicit Type Conversion
OUTPUT: {{“brand”:”ford”,”year”:1964}
17.Illustrate PYTEST:
Pytest is a python based testing framework, which is used to write and execute test codes. In the
present days of REST services, pytest is mainly used for API testing even though we can use
pytest to write simple to complex tests, i.e., we can write codes to test API, database, UI, etc.
Advantages of Pytest
Pytest can run multiple tests in parallel, which reduces the execution time of the test
suite.
Pytest allows us to skip a subset of the tests during execution.
Pytest allows us to run a subset of the entire test suite.
Pytest is free and open source.
QUESTIONS (13MARKS&15MARKS)
its syntax and suitable example program. (if, elif and else)
2.Write a python program to calculate grade of students
obtained in 5 Subjects.
Subjects.
6.Implement a python program to check weather given number is positive or negative or zero
and draw the flowchart for the program.
7.Design a python program to print the star pattern in right angle triangle using while loop.
8. Discuss the different types of errors in python and give your suggestion to achieve debugging
in python.
program which performs the following operation without using built-in methods.
10. Discuss in detail about local scope and global scope with example program.
3.append ()
4.insert ()
15. Write a program to find Sum of N natural numbers using with and without while loop & for
loop and draw the flowchart.
a) argument behavior
b) Parameterized PYTEST
18.Write an algorithm, pseudocode and draw the flowchart for the following program: