MODULE 1 Previous University Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

PROGRAMMING IN PYTHON MODULE 1

PART A

1. What is the output of the following print statement in Python?


(a) print (9//2) (b) print (9/2)
2. Write a Python program to count number of even numbers and odd numbers in a given
set of n numbers.
3. What is the output of the following Python code. Justify your answer.
x = 'abcd'
for i in range(len(x)):
print(i)
4. Write the syntax and semantics of the multiway-if statement.
5. Jack says that he will not bother with analysis and design but proceed directly to coding
his programs. Why is that not a good idea?
6. Write the output of the following python statements :
i) round(12.57) ii) 5//2 iii) int(6.5)
7. Explain type conversion with example.
8. Write a program that accepts the lengths of three sides of a triangle as inputs and outputs
whether or not the triangle is a right triangle.
9. Write a Python program to reverse a number and also find the sum of digits of the
number.Prompt the user for input.
10. Explain the concept of scope and lifetime of variables in Python programming language,
with a suitable example.

PART B

1. Write a python program to generate the following type of pattern for the given N
rows .
1
12
123
1234

2. Mention the different types of loop and control statements allowed in Python
and explain each type with suitable examples.
3. Write the python program to print all prime numbers less than 1000.
4. Write a Python program to find distance between two points (x1,y1) and (x2,y2).
5. Write a Python program to find the roots of a quadratic equation, ax2+ bx + c =0 .
Consider the cases of both real and imaginary roots.
6. Write a Python program to check whether a number is Armstrong number or not.
7. Write a Python program to display the sum of odd numbers between a programmer
specified upper and lower limit.
Given the value of x, write a Python program to evaluate the following series upto n
terms:
𝑥2 𝑥 3
1+𝑥+ + +…
2! 3!
8. Write a python program to find the sum of the cosine series 1 - x^2/2! + x^4/4!-
.......:

9. Write a python program to find X^Y or pow(X,Y) without using standard function.
10. Write a python program to generate the following type of pattern for the given N
rows where N <= 26.
A
AB
ABCD
ABCDE

11. Write a python program to generate prime numbers within a certain range.
12. Discuss the steps involved in the waterfall model of software development process
with the help of a neat diagram.
13. Write a Python program to print all numbers between 100 and 1000 whose sum of
digits is divisible by 9.
14. Illustrate the use of range() in Python.
15. Write a Python program to print all prime factors of a given number.
16. Write a Python code to check whether a given year is a leap year or not
[An year is a leap year if it’s divisible by 4 but not divisible by 100 except for those
divisible by 400].
17. What are the possible errors in a Python program. Write a Python program to print the
value of 22n+n+5 for n provided by the user.
18. Write a Python program to find the value for sin(x) up to n terms using the series
where x is in degrees
𝑥 𝑥3
sin(𝑥) = 1!- 3!
19. Write a Python code to determine whether the given string is a Palindrome or not
using slicing. Do not use any string function.

You might also like