Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Python-Midsem-v2

python questions

Uploaded by

ARUN N K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python-Midsem-v2

python questions

Uploaded by

ARUN N K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NITC/EE/KMAN,EE05/23.09.2024 Name:...............................................................

Roll No:.............................................................
DEPARTMENT OF ELECTRICAL ENGINEERING
5th SEMESTER B. Tech (EEE) MID SEMESTER EXAMINATION - MONSOON SEMESTER 2024-‘25
EE2021E Python Programming and Applications
Time: 2 Hours Maximum: 30 Marks
(Answer all questions.)

1. Answer all short questions (a) – (f) together.


a. The full form of IDLE is_________________
b. An ordered set of instructions or commands to be executed by a computer is
called _____________
c. ____________ are reserved words.
d. Standard mapping data type in Python is called ___________________.
e. Python has many predefined functions called ___________functions
f. The process of identifying and removing logical errors and runtime errors is
called __________________
(6x0.5 = 3 marks)

2. List the advantages of Python over other programming languages. What module must
be imported to print random number in a given range? (1 mark)

3. Write a Python program that accepts a word from the user, reverses it, prints the
reverse word and indicates whether it is palindrome or not. (Use for loop and if
statement) (3 marks)

4. Write a Python program to check the validity of password input by users. The password
must be 8 characters long, must contain atleast one capital, one small, one special
character (!,@,#,$,&) and one number. If the criterion is met then output of the program
must be password saved successfully. If the criterion is not met then it must output
invalid password and ask a new password and repeat until criterion is met (6 marks)

5. Write a Python program (using while loop) that will calculate the binary representation
of a given number (3 marks)

6. Write the syntax for list comprehension and mention its advantage over for loop. Using
list comprehension print even numbers in a given range (3 marks)

7. What will be the output of the following Python code (1 mark)

word = "Python programming and applications"


vowels = "aeiou"
result = [char for char in word if char in vowels]
print(result)
8. Give the generator expression syntax, give one example and mention 4 advantages of
python generators (2 marks)

9. What will be the output of the following Python code and explain your answer in terms
of scope of variables (the code is free from indentation and syntax errors) (3 marks)

x=1
def func():
global x
x=11
y=12
print(f'local x is equal to {x}')
print(f'local y is equal to {y}')
def bar():
print(f'bar sees x equal to {x}')
bar()
func()
print(f'global x is equal to {x}')

10. a. Write the syntax for list, tuple and dictionary and give one example for each. Mention
their characteristics. (3 marks)
b.Give the difference between set and frozen sets along with necessary examples.
(2 marks)

You might also like