0% found this document useful (0 votes)
63 views14 pages

Ge3151-Python-Unit 1,2 QB

Unit 1 and 2 python important questions

Uploaded by

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

Ge3151-Python-Unit 1,2 QB

Unit 1 and 2 python important questions

Uploaded by

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

GE3151 - PROBLEM SOLVING AND PYTHON PROGRAMMING

SYLLABUS
UNIT I COMPUTATIONAL THINKING AND PROBLEM SOLVING
Fundamentals of Computing – Identification of Computational Problems -Algorithms, building blocks of
algorithms ( statements, state, control flow, functions), notation (pseudo code, flow chart, programming
language), algorithmic problem solving, simple strategies for developing algorithms (iteration, recursion).
Illustrative problems: find minimum in a list, insert a card in a list of sorted cards, guess an integer number
in a range, Towers of Hanoi.
UNIT II DATA TYPES, EXPRESSIONS, STATEMENTS
Python interpreter and interactive mode, debugging; values and types: int, float, boolean, string
and list; variables, expressions, statements, tuple assignment, precedence of operators, comments;
Illustrative programs: exchange the values of two variables, circulate the values of n variables, distance
between two points.
UNIT III CONTROL FLOW, FUNCTIONS, STRINGS
Conditionals: Boolean values and operators, conditional (if), alternative (if-else), chained conditional (if-
elif- else); Iteration: state, while, for, break, continue, pass; Fruitful functions: return values, parameters,
local and global scope, function composition, recursion; Strings:string slices, immutability, string
functions and methods, string module; Lists as arrays. Illustrative programs: square root, gcd,
exponentiation, sum an array of numbers, linear search, binary search.
UNIT IV LISTS, TUPLES, DICTIONARIES 9
Lists: list operations, list slices, list methods, list loop, mutability, aliasing, cloning lists, list parameters;
Tuples: tuple assignment, tuple as return value; Dictionaries: operations and methods;advanced list
processing
- list comprehension; Illustrative programs: simple sorting, histogram, Students marks statement, Retail
bill preparation.
UNIT V FILES, MODULES, PACKAGES 9
Files and exceptions: text files, reading and writing files, format operator; command line arguments,
errors and exceptions, handling exceptions, modules, packages; Illustrative programs: word count, copy
file, Voter’s age validation, Marks range validation (0-100).
TOTAL : 45
PERIODS
TEXT BOOKS:
1. 1. Allen B. Downey, “Think Python: How to Think like a Computer Scientist”, 2nd Edition,
O’Reilly
Publishers, 2016.
2. Karl Beecher, “Computational Thinking: A Beginner's Guide to Problem Solving and
Programming”,
1st Edition, BCS Learning & Development Limited, 2017.
REFERENCES:
1. Paul Deitel and Harvey Deitel, “Python for Programmers”, Pearson Education, 1st Edition, 2021.
2. G Venkatesh and Madhavan Mukund, “Computational Thinking: A Primer for Programmers and
Data
Scientists”, 1st Edition, Notion Press, 2021.
3. John V Guttag, "Introduction to Computation and Programming Using Python: With Applications 4
to Computational Modeling and Understanding Data”, Third Edition, MIT Press, 2021
4. Eric Matthes, “Python Crash Course, A Hands - on Project Based Introduction to Programming”,
2nd Edition, No Starch Press, 2019.
5. Martin C. Brown, “Python: The Complete Reference”, 4th Edition, Mc-Graw Hill, 2018.

5
UNIT I - ALGORITHMIC PROBLEM SOLVING

PART- A (2 Marks)
1. What is an algorithm?(Jan-2018)
Algorithm is an ordered sequence of finite, well defined, unambiguous instructions for completing a task.
It is an English-like representation of the logic which is used to solve the problem. It is a step-by-step
procedure for solving a task or a problem. The steps must be ordered, unambiguous and finite in number.

2. Write an algorithm to find minimum of three


numbers. ALGORITHM : Find Minimum of three
numbers
Step 1: Start
Step 2: Read the three numbers A, B, C
Step 3: Compare A,B and A,C. If A is minimum, perform step 4 else perform step 5.
Step 4:Compare B and C. If B is minimum, output “B is minimum” else output “C is minimum”.
Step 5: Stop

3. List the building blocks of algorithm.


The building blocks of an algorithm are
 Statements
 Sequence
 Selection or Conditional
 Repetition or Control flow
 Functions
An action is one or more instructions that the computer performs in sequential order (from first to last). A
decision is making a choice among several actions. A loop is one or more instructions that the computer
performs repeatedly.

4. Define statement. List its types.


The instructions in Python, or indeed in any high-level language, are designed as components for
algorithmic problem solving, rather than as one-to-one translations of the underlying machine language
instruction set of the computer. Three types of high-level programming language statements. Input/output
statements make up one type of statement. An input statement collects a specific value from the user for a
variable within the program. An output statement writes a message or the value of a program variable to
the user’s screen.

5. Write the pseudocode to calculate the sum and product of two numbers and display it.
INITIALIZE variables sum, product, number1, number2 of type real
PRINT “Input two numbers”
READ number1, number2
COMPUTE sum = number1 + number2
PRINT “The sum is", sum
COMPUTE product = number1 * number2
PRINT “The Product is", product
END program

6. How does flow of control work?


Control flow (or flow of control) is the order in which individual statements, instructions or function calls
of an imperative program are executed or evaluated. A control flow statement is a statement in which
execution results in a choice being made as to which of two or more paths to follow.

6
7. Write the algorithm to calculate the average of three numbers and display it.

7
Step 1: Start
Step 2: Read values of X,Y,Z
Step 3: S = X+Y+Z
Step 4: A = S/3
Step 5: Write value of A
Step 6: Stop
8. Give the rules for writing Pseudocode.
 Write one statement per line.
 Capitalize initial keywords.
 Indent to show hierarchy.
 End multiline structure.
 Keep statements language independent.

9. What is a function?
Functions are named sequence of statements that accomplish a specific task. Functions usually "take in"
data, process it, and "return" a result. Once a function is written, it can be used over and over and over
again. Functions can be "called" from the inside of other functions.

10. Give the difference between flowchart and pseudocode.


Flowchart Pseudocode
 A flowchart is a diagram showing an  Pseudocode is a means of expressing the
overview of the problem. stepwise instructions for solving a
 It is a pictorial representation of how problem without worrying about the
the program will work, and it syntax of a particular programming
follows a standard format. language.
 It uses different kinds of shapes to  Unlike a flowchart, it uses a written
signify different processes involved format which requires no absolute
in the problem rules for writing.
 It can be written in ordinary English,
and we can use some keywords in it too.
11. Define a flowchart.
 A flowchart is a diagrammatic representation of the logic for solving a task.
 A flowchart is drawn using boxes of different shapes with lines connecting them to show the flow of
control.
 The purpose of drawing a flowchart is to make the logic of the program clearer in a visual form.

12. Give an example of iteration.


a=0
for i in range(4): # i takes the value 0,1,2,3
a=a+i
print(a) #number 6 is printed (0+0;0+1;1+2;3+3)

13. Write down the rules for preparing a flowchart.


While drawing a flowchart, some rules need to be followed:
 A flowchart should have a start and end.
 The direction of flow in a flowchart must be from top to bottom and left to right.
 The relevant symbols must be used while drawing a flowchart.

14. List the categories of Programming languages.

8
Programming Languages are divided into the following categories:
 Interpreted
 Functional
 Compiled
 Procedural
 Scripting
 Markup
 Logic-Based
 Concurrent
 Object-Oriented Programming Languages.
15. Mention the characteristics of algorithm.
 Algorithm should be precise and unambiguous.
 Instruction in an algorithm should not be repeated infinitely.
 Ensure that the algorithm will ultimately terminate.
 Algorithm should be written in sequence.
 Algorithm should be written in normal English.
 Desired result should be obtained only after the algorithm terminates

16. List out the simple strategies to develop an algorithm.


Algorithm development process consists of five major steps.
Step 1: Obtain a description of the problem.
Step 2: Analyze the problem.
Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more detail.
Step 5: Review the algorithm.

17. Compare machine language, assembly language and high-level language.


Machine Language Assembly Language High-Level Language

 The language of 0s and 1s  It is low level  High level languages are


is called as machine programming language English like statements
language. in which the sequence of and programs .
 The machine language is 0s and 1s are replaced by  Written in these languages
system independent mnemonic (ni-monic) are needed to be translated
because there are different codes. into machine language before
set of binary instruction for  Typical instruction for to their execution using a
different types of computer addition and system
systems subtraction software compiler.
18. Describe algorithmic problem solving.
Algorithmic Problem Solving deals with the implementation and application of algorithms to a variety of
problems. When solving a problem, choosing the right approach is often the key to arriving at the best
solution.

19. Give the difference between recursion and iteration.


Recursion Iteration
Function calls itself until the base condition is Repetition of process until the condition fails.
reached.
In recursive function, base case (terminate Iterative approach involves four steps:
condition) and recursive case are specified. initialization, condition, execution and
updation.

9
Recursion is slower than iteration due to overhead Iteration is faster.
of maintaining stack.
Recursion takes more memory than iteration due Iteration takes less memory.
to overhead of maintaining stack.
20. What are advantages and disadvantages of recursion?
Advantages Disadvantages
Recursive functions make the code look clean Sometimes the logic behind recursion is hard to
and elegant. follow through.
A complex task can be broken down into simpler Recursive calls are expensive (inefficient) as
sub-problems using recursion. they take up a lot of memory and time.
Sequence generation is easier with recursion Recursive functions are hard to debug.
than using some nested iteration.

21. Write an algorithm to accept two numbers, compute the sum and print the result.(Jan-2018)
Step1: Read the two numbers a and b.
Step 2: Calculate sum = a+b
Step 3: Display the sum
22. Write an algorithm to find the sum of digits of a number and display
it. Step 1:Start
Step 2: Read value of N
Step 3: Sum = 0
Step 4: While (N != 0)
Rem = N % 10
Sum = Sum + Rem
N = N / 10
Step 5: Print Sum
Step 6: Stop

23. Write an algorithm to find the square and cube and display
it. Step 1: Start
Step 2: Read value of N
Step 3: S =N*N
Step 4: C =S*N
Step 5: Write values of S,C
Step 6: Stop

24. Explain Tower of Hanoi.


The Tower of Hanoi is a mathematical game. It consists of three rods and a number of disks of different
sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order
of size on one rod, the smallest at the top, thus making a conical shape.
The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:
 Only one disk can be moved at a time.
 Each move consists of taking the upper disk from one of the stacks and placing it on top of
another stack.
 No disk may be placed on top of a smaller disk.
With 3 disks, the puzzle can be solved in 7 moves. The minimal number of moves required to solve a
Tower of Hanoi puzzle is 2n − 1, where n is the number of disks.
25. What is recursion?

10
Recursion is a method of solving problems that involves breaking a problem down into smaller and
smaller subproblems until you get to a small enough problem that it can be solved trivially. Usually
recursion involves a function calling itself. While it may not seem like much on the surface, recursion
allows us to write elegant solutions to problems that may otherwise be very difficult to program.
Example:
defcalc_factorial(x):
if x == 1:
return 1
else:
return (x * calc_factorial(x-1))
num = 4
print("The factorial of", num, "is", calc_factorial(num))
26. Write an algorithm to find minimum in a list. (Jan-2019)
ALGORITHM : To find minimum in a list
Step 1: Start
Step 2: Read the list
Step 3: Assume the first element as minimum
Step 4: Compare every element with minimum. If the value is less than minimum, reassign that value as
minimum.
Step 5: Print the value of minimum.
Step 6: Stop
27. Distinguish between algorithm and program. (Jan-2019)
Algorithm Program

Algorithm is the approach / idea to solve some A program is a set of instructions for the computer
problem. to follow.

It does not have a specific syntax like any of the It is exact code written for problem following all
programming languages the rules (syntax) of the programming language.

It cannot be executed on a computer. It can be executed on a computer

28. List the Symbols used in drawing the flowcart. (May 2019)
Flowcharts are usually drawn using some standard symbols
 Terminator
 Process
 Decision
 Connector
 Data
 Delay
 Arrow
29. Give the python code to find the minimum among the list of 10 numbers. (May 2019)
numList = []
n=int(raw_input('Enter The Number of Elements in List :'))
for i in range(0, n):
x = raw_input('Enter the Element %d :' %(i+1))
numList.append(x)
maxNum = numList[0]
for i in numList:

11
if i > maxNum:
maxNum = i
print('Maximum Element of the Given List is %d' %(int(maxNum)))

30. How will you analysis the efficiency of an algorithm? (Nov / Dec 2019)
Time efficiency, indicating how fast the algorithm runs.
Space efficiency, indicating how much extra memory it uses

31. How do algorithm, flowchart and pseudo code use for problem solving? (Nov / Dec 2019)
Algorithm: A process or set of rules to be followed in calculations or other problem – solving operations,
especially by a computer
Flowchart: Flowchart is diagrammatic representation of the algorithm.
Pseudo code: In Pseudo code normal English language is translated into the programming languages to be
worked on.
All are tools for problem solving independent of programming language. Difference is only in the way of
representing the solution.

PART B (16 MARKS)


1. What are the building blocks of an algorithm? Explain in detail.
2. Briefly describe iteration and recursion. Explain with algorithm.
3. Explain Algorithmic problem solving.
4. Write an algorithm and draw a flowchart to calculate 24.
5. Illustrate Algorithm, Psuedocode and Flowchart with an example.
6. a) Describe Psuedocode with its guidelines.
b) Give an example for psuedocode.
c) Write the pseudocode for Towers of Hanoi.
7. a) What is flowchart?
b) List down symbols and rules for writing flowchart.
c) Draw a flowchart to count and print from1 to 10.
8. a) Write a program to find the net salary of an employee.
b) Write a program to guess an integer number in a range.
9. a) Write a program to insert a card in a list of sorted cards.(Jan-2019)
b) Write a program to find the minimum number in a list.
10. a) Draw a flow chart to accept three distinct numbers, find the greatest and print the result. (8) (Jan-2018)
b) Draw a flow chart to find the sum of the series 1+2+3+……+100. (8)(Jan-2018)
11. Outline the Towers of Hanoi problem. Suggest a solution to the Towers of Hanoi problem with relevant
diagrams. (16) (Jan-2018)
12. Identify simple strategies for developing an algorithm. (Jan-2019)
13. Mention the different types of iterative structures allowed in python. Explain the use of continue and break
statements with an example. (May 2019)
14. (a) What is an algorithm? Summarise the characteristics of a good algorithm.(8) (May 2019)
(b) Outline the algorithm for displaying the first n odd numbers. (May 2019)
15. (a) What is a programming language? What are its types? Explain them in detail with their advantages
and disadvantages. (8) (Nov / Dec 2019)
(b) Write a function find_index( ), which returns the index of a number in the Fibonacci sequence, if the
number is an element of this sequence and returns -1, if the number is not contained in it, call this function
using user input and display the result. (8) (Nov / Dec 2019)
16. (a) What is recursive function? What are its advantages and disadvantages? Compare it with
iterative function. (6) (Nov / Dec 2019)
(b) Implement a recursive function in python for the sieve of Eratosthenes. The sieve of Eratosthenes is a
simple algorithm for finding all prime numbers up to a specified integer. It was created by the ancient

12
Greek mathematician Eratosthenes. The algorithm to find all the prime numbers less than or equal to a
given integer n: (10) (Nov / Dec 2019)
1) Create a list of integers from two to n: 2,3,4,…, n
2) Start with a counter i set to 2, i.e. the first prime number
3) Starting from i+1, count up by I and remove those numbers from the list, i.e. 2*i,3*i, 4*i,..
4) Find the first number of the list following i. This is the next prime number.
5) Set i to the number found in the previous step.
6) Repeat steps 3 and 4 until i is greater than n. (As an improvement: It’s enough to go to the square root
of n)
7) All the numbers, which are still in the list, are prime numbers.

UNIT II – DATA TYPES, EXPRESSIONS,


STATEMENTS PART- A (2 Marks)
1. What is meant by interpreter?
An interpreter is a computer program that executes instructions written in a programming language. It can
either execute the source code directly or translate the source code in a first step into a more efficient
representation and executes this code.
2. How will you invoke the python interactive interpreter?
The Python interpreter can be invoked by typing the command "python" without any parameter followed
by the "return" key at the shell prompt.
3. What are the commands that are used to exit from the python interpreter in UNIX and windows?
CTRL+D is used to exit from the python interpreter in UNIX and CTRL+Z is used to exit from the python
interpreter in windows.
4. Define a variable and write down the rules for naming a variable.
A name that refers to a value is a variable . Variable names can be arbitrarily long. They can contain both
letters and numbers, but they have to begin with a letter. It is legal to use uppercase letters, but it is good
to begin variable names with a lowercase letter.
5. Write a snippet to display “Hello World” in python interpreter.
In script mode:
>>>print("Hello World")
Hello World
In Interactive Mode:
>>> "Hello World"
'Hello World'
6. List down the basic data types in Python.
 Numbers
 String
 List
 Tuple
 Dictionary
7. Define keyword and enumerate some of the keywords in Python. (Jan-2019)
A keyword is a reserved word that is used by the compiler to parse a program. Keywords cannot be used as
variable names. Some of the keywords used in python are:
 and
 del
 from
 not
 while
 is
 continue

13
8. What do you mean by an operand and an operator? Illustrate your answer with relevant example.
An operator is a symbol that specifies an operation to be performed on the operands. The data items that
an operator acts upon are called operands. The operators +, -, *, / and ** perform addition,
subtraction, multiplication, division and exponentiation.
Example: 20+32.In this example, 20 and 32 are operands and + is an operator.
9. Explain the concept of floor division.
The operation that divides two numbers and chops off the fraction part is known as floor division.
Example:>>> 5//2= 2
10. Define an expression with example.
An expression is a combination of values, variables, and operators. An expression is evaluated using
assignment operator. Example:Y= X + 17
11. Define statement and mention the difference between statement and an expression.
A statement is a unit of code that the Python interpreter can execute. The important difference is that an
expression has a value but a statement does not have a value.
12. What is meant by rule of precedence? Give the order of precedence.
The set of rules that govern the order in which expressions involving multiple operators and operands are
evaluated is known as rule of precedence. Parentheses have the highest precedence followed by
exponentiation. Multiplication and division have the next highest precedence followed by addition and
subtraction.
13. Illustrate the use of * and + operators in string with example.
The * operator performs repetition on strings and the + operator performs concatenation on strings.
Example:>>> ‘Hello*3’
Output:HelloHelloHello
>>>’Hello+World’
Output:HelloWorld
14. What is function call?
A function is a named sequence of statements that performs a computation. When you define a function,
you specify the name and the sequence of statements. Later, you can “call” the function by name is called
function call.
Example:
sum() //sum is the function name
15. What is a local variable?
A variable defined inside a function. A local variable can only be used inside its function.
Example:
deff():
s = "Me too." // local
variable print(s)
a = "I hate spam."
f()
print (a)
16. Define arguments and parameter.
A value provided to a function when the function is called. This value is assigned to the corresponding
parameter in the function. Inside the function, the arguments are assigned to variables called parameters.
17. What do you mean by flow of execution?
 In order to ensure that a function is defined before its first use, you have to know the order in which
statements are executed, which is called the flow of execution.
 Execution always begins at the first statement of the program. Statements are executed one at a time,
in order from top to bottom.
18. What is the use of parentheses?

14
Parentheses have the highest precedence and can be used to force an expression to evaluate in the order you
want. It also makes an expression easier to read.
Example: 2 + (3*4) * 7
19. What do you meant by an assignment statement?
An assignment statement creates new variables and gives them values:
>>> Message = 'And now for something completely different'
>>> n = 17
This example makes two assignments. The first assigns a string to a new variable namedMessage; the
second gives the integer 17 to n.
20. What is tuple? (or) What is a tuple? How literals of type tuples are written? Give example(Jan-
2018) A tuple is a sequence of immutable Python objects. Tuples are sequences, like lists. The differences
between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas
lists use square brackets. Creating a tuple is as simple as putting different comma-separated values.
Comma-
separated values between parentheses can also be used.
Example: tup1 = ('physics', 'chemistry', 1997, 2000); tup2= ();
21. Define module.
A module allows to logically organizing the Python code. Grouping related code into a module
makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes
that can bind and reference.A module is a file consisting of Python code. A module can define functions,
classes and variables. A module can also include runnable code.
22. Name the four types of scalar objects Python has. (Jan-2018)
 int
 float
 bool
 None
23. List down the different types of operator.
Python language supports the following types of operators:
 Arithmetic operator
 Relational operator
 Assignment operator
 Logical operator
 Bitwise operator
 Membership operator
 Identity operator
24. What is a global variable?
Global variables are the one that are defined and declared outside a function and we need to use them
inside a function.
Example:#This function uses global variable s
def f():
print(s)
# Global scope
s = "I love India"
f()

25. Define function.


A function in Python is defined by a def statement. The general syntax looks like this:
def function-name(Parameter list):
statements # the function body

15
The parameter list consists of zero or more parameters. Parameters are called arguments, if the function is
called. The function body consists of indented statements. The function body gets executed every time the
function is called. Parameter can be mandatory or optional. The optional parameters (zero or more) must
follow the mandatory parameters.
26. What is the purpose of using comment in python program?
Comments indicate information in a program that is meant for other programmers (or anyone reading the
source code) and has no effect on the execution of the program. In Python, we use the hash (#) symbol to
start writing a comment.
Example: #This is a comment
27. State the reasons to divide programs into functions. (Jan-2019)
Creating a new function gives the opportunity to name a group of statements, which makes program easier
to read and debug. Functions can make a program smaller by eliminating repetitive code. Dividing a long
program into functions allows to debug the parts one at a time and then assemble them into a working
whole. Well designed functions are often useful for many programs.
28. Outline the logic to swap the content of two identifiers without using third variable. (May 2019)
a=10
b=20
a=a+b
b=a-b
a=a-b
print(“After Swapping a=”a,” b=”,b)

29. State about Logical operators available in python language with example. (May 2019)
Logical operators are the and, or, not operators.
Operator Meaning Example
And True if both the operands are true x and y
Or True if either of the operands is true x or y
Not True if operand is false (complements the operand) not x
30. Compare Interpreter and Compiler (Nov / Dec 2019)
Compiler: A Compiler is a program which translates the source code written in a high level language in
to object code which is in machine language program. Compiler reads the whole program written in high
level language and translates it to machine language. If any error is found, it display error message on
the screen.
Interpreter: Interpreter translates the high level language program in line by line manner. The interpreter
translates a high level language statement in a source program to a machine code and executes it
immediately before translating the next statement. When an error is found the execution of the program is
halted and error message is displayed on the screen

31. Write a python program to circulate the values of n variables (Nov / Dec 2019)
no_of_terms = int(input("Enter number of values : "))
list1 = []
for val in range(0,no_of_terms,1):
ele = int(input("Enter integer : "))
list1.append(ele)
print("Circulating the elements of list ", list1)
for val in range(0,no_of_terms,1):
ele = list1.pop(0)
list1.append(ele)

16
print(list1)
PART B (16 MARKS)
1. What is the role of an interpreter? Give a detailed note on python interpreter and interactive mode of
operation. (or) Sketch the structures of interpreter and compiler. Detail the differences between
them. Explain how Python works in interactive mode and script mode with examples. (Jan 2019)
2. Illustrate values and different standard data types with relevant examples.
3. Define variables. List down the rules for naming the variable with example.
4. List down the different types of operators and their function with suitable example.
5. What are the two modes of operation in python? Analyze the differences between them.
6. What do you mean by rule of precedence? List out the order of precedence and demonstrate in detail with
example.
7. Elaborate on tuple assignment.
8. What is the use of function? Explain the role of function call and function definition with example. (or)
Outline about function definition and call with example. Why are function needed? (May 2019)
9. Describe flow of execution of function with an example.
10. Write a Python program to circulate the values of n variables.
11. Write a python program to swap two variables.
12. Write a python program to check whether a given year is a leap year or not.
13. Write a python program to convert celsius to fahrenheit
. (Formula: celsius * 1.8 = fahrenheit –32).
14. a) What is a numeric literal? Give examples. (4) (Jan-2018)
b) Appraise the arithmetic operators in Python with an example. (12) (Jan-2018)
15. a) Outline the operator precedence of arithmetic operators in Python. (6) (Jan-2018)
b) Write a Python program to exchange the value of two variables. (4) (Jan-2018)
c) Write a Python program using function to find a sum of first ‘N’even numbers and print the
result.(6)(Jan 2018)
16. a) Mention the list of keywords available in Python. Compare it with variable name. (8)(May 2019)
b) What are Statement? How are they constructed from variable and expression in Python. (8) (May 2019)
17. (a) Write a python program to rotate a list by right n times with and without slicing technique (4 + 4)
(Nov / Dec 2019)
(b) Discuss about keyword arguments and default arguments in python with example. (4 + 4) (Nov / Dec
2019)
18. (a) Write a python program to print the maximum among ‘n’ randomly generate ‘d’ numbers by storing
them in a list (10) (Nov / Dec 2019)
19. (b) Evaluate the following expressions in python (6) (Nov / Dec 2019)
i) 24 // 6 % 3
ii) float(4 + int(2.39) % 2)
iii) 2 ** 2 ** 3

17

You might also like