QB Mod1

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

K.V.G. College of Engineering, Sullia, D.K.

,574327
Affiliated to Visvesvaraya Technological University, Belagavi
Approved By AICTE, New Delhi & Recognized by Govt. of Karnataka
Phone: 08257231141 Email: [email protected] Website: www.kvgengg.com

Module 1-Question Bank


Sl.no Introduction to Python Programming(BPLCK105B)
1. List the features of Python Programming Language
2. What is the need for role of precedence? Illustrate the rules of precedence in python with
example.
3. Explain the math operators in Python from highest to lowest Precedence with an example CO1
for each. Write the steps how Python is evaluating the expression (5 - 1) * ((7 + 1) / (3 -
1)) and reduces it to a single value.
4. Write a python program to find the sum of all odd and even numbers of n elements. Here CO1
skip the numbers which are divisible by 3.
5. Define a Python function with suitable parameters to generate prime numbers between CO1
two integer values.
6. Explain Local and Global Scope in Python programs. What are local and global CO1
variables? How can you force a variable in a function to refer to the global variable?
7. Write a Python program which accepts two integer values m and n (note: m>0, n>0 and
m < n) as inputs and pass these values to the function. Suitable error messages should be
displayed if the conditions for input values are not followed.
8. What are Comparison and Boolean operators? List all the Comparison and Boolean CO1
operators in Python and explain the use of these operators with suitable examples.
9. Predict the output and justify the answer
i) -11%9 ii) 7.7//7 iii) (200-70) *10/5 iv) not “False” v) 5*1**2
10. Define a Python function with suitable parameters to generate first N Fibonacci numbers. CO1
The first two Fibonacci numbers are 0 and 1 and the Fibonacci sequence is defined as a
function F as Fn = Fn-1 + Fn-2.
11. Write a Python program which accepts a value for N (where N >0) as input and pass this
value to the function. Display suitable error message if the condition for input value is
not followed.
12. Write a python program to find the area of square, rectangle and circle. Print the results. CO1
Take input from user.
13. List and explain the syntax of all flow control statements with example. CO1
14. What is Exception Handling? How exceptions are handled in Python? Write a Python CO1
program with exception handling code to solve divide-by-zero error situation.
15. Illustrate the use of break and continue with a code snippet. CO1
16. What is user defined functions? How can we pass parameters in user defined functions? CO1
Explain with suitable example.
17. Explain global statement with example. CO1
18. Write a python program to demonstrate counting, summing and average of elements
using loops
19. Write a function that computes and returns addition, subtraction, multiplication, division CO1
of two integers. Take input from user.
20. Explain the concept of conditional execution, alternate execution and chained execution CO1
with suitable examples
21. Explain the concept of type conversion functions and math conversions in python with CO1
suitable examples

DEPARTMENT OF CIVIL ENGINEERING, SULLIA, D. K


K.V.G. College of Engineering, Sullia, D.K.,574327
Affiliated to Visvesvaraya Technological University, Belagavi
Approved By AICTE, New Delhi & Recognized by Govt. of Karnataka
Phone: 08257231141 Email: [email protected] Website: www.kvgengg.com

22. Briefly explain the working of range() function CO1


23. Briefly Explain the usage of keyword import and global statement in python CO1
24. What is a function? How to define a function in python? Write a program using function CO1
to find out the given string is palindrome or not.
25. Write a python program to create a function called collatz() which reads as parameter CO1
named number. If the number is even, it should print and return number//2 and if the
number is odd then it should print and return 3*number+1. The function should keep
calling on that number until the function returns a value 1
26. Write a python program to calculate the area and circumference of a circle input the value CO1
of radius and print the results.
27. Demonstrate the working of print (), input () and string replication. CO1
28. Write a python program to check whether a given number is even or odd. CO1
29. Explain can we pass parameters in user defined functions? Explain with suitable CO1
example.
30. Demonstrate the concept of exception. Implement a code which prompts the user for CO1
Celsius temperature, convert the temperature to Fahrenheit and print out the converted
temperature by handling the exception
31. Discus local and global scope of variables in python. Illustrate different scenarios, with CO1
an example.
32. List and define the use of comparison operators in python. Write the output for the CO1
following expression I python
i. 2**3
ii. 20%6
iii. 20//6
33. Design a Python program to find the average of best two marks out of three marks taken CO1
as input.
34. Write a python program using try and except, so that your program handles non-numeric CO1
input gracefully by printing a message and exiting the program. The following shows
two executions of the program. he following shows two executions of the program:
Enter Hours: 20
Enter Rate: nine
Error, please enter numeric input
Enter Hours: forty
Error, please enter numeric input
35. Write a single user-defined function called Solve that returns remember and quotient on CO1
the division of two numbers accepted from the user. Print reminder and quotient
separately on the console.
36. Write a python program that uses input to prompt a user for their name and then CO1
welcomes them.
37. Write a program with a function computer grade that takes a score as its parameter and CO1
returns a grade as string.

DEPARTMENT OF CIVIL ENGINEERING, SULLIA, D. K

You might also like