END TERM EXAMINATION | |
First Semester[BTech] | |
Paper Code: BAI-101 | Subject : Programming With Python |
Time:3 Hours | Maximum Marks:60 |
Note: Q1 is compulsory. Attempt one question each from the Units I, II, III & IV | |
Q1 Discuss : (2.5*8=20) | |
(a) Write a Python program to print the prime numbers of up to a given number, accept the number from the user. | |
(b) Write a Python program to accepts a string and calculates the number of digits and letters. | |
(c) Write a program to check if the word ‘open’ is present in the “This is open source software”. | |
(d) Write a Python Program that reads n numbers separated by a space in one line and displays distinct numbers. For example Input : 1 1 1 1 1 2 2 2 2 Output : 1 2 | |
(e) Write a Python function to calculate the factorial of a number (a non-negative number). The function accepts the number as an argument. | |
(f) Write a Python Program to handle that exception that occurs when accessing an index out of range in a list. | |
(g) Given a numpy array, write a function to sort it in descending order. | |
(h) Use regular expression to check if the string ends with “World!”. If a match is found , it prints “Match Found!” otherwise, it prints “Match not found”. | |
UNIT I | |
Q2.a) Explain the difference between break and continue with suitable example.
b). Write a program to print all prime numbers that fall between two numbers. (Accept 2 numbers from the user) |
|
Q3. a) Write the Python program to print the given series 53,53,40,40,27,27 (from 53 to 0)
b) Print the pattern using the for loop : |
|
UNIT II | |
Q4. a) State the difference between lists and dictionary with examples.
b) Write a Python script to merge two Python Dictionaries. |
|
Q5. a) Define tuple and show it is immutable with an example.
b) Write a program to find maximum and minimum element of tuple. |
|
UNIT III | |
Q6. a) Define scope of a variable in a function. Differentiate between local and global variable with examples.
b) Write a Python program to reverse a string. |
|
Q7. a) Write a Python function to check whether a string is a panagram or not.
b) Write a Python function that takes a list as an argument and returns the sum of all the elements in the list. |
|
UNIT IV | |
Q.8 a) Differentiate between class attributes and instance attributes with examples.
b) Create a base class Animal with a method sound. Create a derived class Dog that overrides the sound method to print “Bark”. |
|
Q9. Write a python programming to create a Pie chart with a title of the popularity of programming languages :
Sample Data : Programming Languages : Java, Python, PHP, JavaScript, C#, C++ Popularity : 22.7, 17.6, 8.8, 8, 7.7, 6.7 |