0% found this document useful (0 votes)
1 views6 pages

Python

Uploaded by

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

Python

Uploaded by

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

Question Bank

23CST283 - Python for Machine Learning

Course Type Course Nature CA Conduct System L T P Credits CA Total CA Pass SEE Total SEE Pass Total Pass

Theory 1 End Semester Mark 3 1 0 4 50 0 100 40 75

Question Bank Summary

Sect. Part A Sect. Part B Easy Med. Chall. Th. Appli.

45 39 22 52 10 38 46 5 28 23 10 1 0

Part A

# Unit Question COS Categorized

Easy -
1 1.1 List the advantages of using the Python interactive shell for debugging. CO1 Understanding
-T

Easy -
2 1.1 What is the difference between using the interactive shell and writing a Python script. CO1 Understanding
-T

Medium -
3 1.10 Explain how the [Link]() and [Link]() functions work with examples. CO1 Understanding
-T

Medium -
4 1.10 Write a Python code snippet that calculates the area of a circle using [Link] constant from the math module. CO1
Applying - A

Easy -
5 1.2 Differentiate between IDLE's interactive shell and the script editor. CO1 Understanding
-T

Easy -
In Python, keywords have specific meanings and cannot be used as variable names. Explain why this restriction exists, and give
6 1.5 CO1 Understanding
three examples of keywords that could cause errors if mistakenly used as variable names
-T

What will be the value of variables x, y & z after execution of following python program. Assume that user Medium -
7 1.5 CO1
enters a value 5. temp=input("enter a number") x=temp*5 y=int(temp)*5 z=bool(temp*0) Applying - T

Explain why comments are used in Python programs. How do they help both the original programmer and others who may read Easy -
8 1.6 or maintain the code? CO1 Understanding
-T

You are building a program that calculates the total cost of items in an online shopping cart. The item prices are stored as
Medium -
9 1.6,9 strings (e.g., '19.99'). Write a Python code to convert these prices to a numeric type to calculate the total cost, and explain why CO1
Applying - T
type conversion is necessary in this context.

Easy -
Create a Python program that takes a city name and current temperature from the user, then displays a message like "In [City],
10 1.7 CO1 Understanding
it’s currently [Temperature]°C."
-T

Easy -
Write a Python program that asks the user for their name and age, then displays a message like "Hello, [Name]! You are [Age]
11 1.7 CO1 Understanding
years old today".
-T

Easy -
12 1.7 What is format() method in Python CO1 Remembering
-T

Medium -
13 1.9 How do you access the math module and use its built-in functions? Provide an example. CO1 Understanding
-T

Medium -
14 2.2 Compare the for loop and the while loop in Python. Discuss their syntax and key differences. CO2 Understanding
-T
Easy -
15 2.2 Illustrate the usage of break and continue statements with proper examples. CO2 Understanding
-T

Easy -
16 2.4 Describe the concept of local and global scope with respect to functions. CO2 Understanding
-T

Write a Python program that accepts a user's full name as input and then outputs the name in uppercase, lowercase, and title Medium -
17 2.7 CO2
case. Applying - A

Medium -
18 2.7 Given s = 'medium' , what is the output of : a) print(s[:4]) b) print(s[-4:4]) c) print(s[Link]) CO2
Evaluating - A

Medium -
19 2.7 Write a Python program that takes a string as input and prints the reverse of the string. Explain your approach. CO2 Applying - A

Easy -
20 2.8 Explain how Python handles decimal to binary number systems and conversions between them. CO2 Understanding
-T

Easy -
21 3.1 What are the basic operations you can perform on a list in Python? Give two examples. CO3 Understanding
-T

Medium -
22 3.1 Create a list of lists to represent a 3x3 matrix in Python. CO3
Applying - A

Easy -
23 3.1 Write a Python statement to find the length of a list. Explain why this operation is useful. CO3
Applying - A

Medium -
24 3.2,4 How does slicing differ between lists and tuples? Provide a brief explanation. CO3
Analysing - T

Medium -
25 3.3 What is list comprehension? Write a one-line example to create a list of even numbers from 1 to 10 using list comprehension. CO3
Applying - A

Medium -
26 3.4 Differentiate between Python sets and lists. Why would you use a set over a list? CO3 Understanding
-T

Medium -
27 3.4 Describe how you would use a set to remove duplicate values from a list in Python. Write a code segment to demonstrate this. CO3
Analysing - A

Easy -
28 3.5 Identify the Python module used to handle dates and times, and explain how you can get the current date and time. CO3 Remembering
-T

Medium -
29 3.5 Explain how to add a number of days to a specific date in Python. Provide a short example showing how this can be done. CO3 Understanding
-T

Medium -
30 3.6 Demonstrate how to update the value of a specific key in a Python dictionary. Provide a brief example. CO3
Applying - A

Easy -
Describe the purpose of the get() function in Python dictionaries. Explain how it can prevent potential errors when accessing
31 3.6 CO3 Understanding
keys.
-T

Easy -
32 4.1 Define a class and an object in Python. Give one example of each. CO4 Remembering
-A

Medium -
33 4.2 What is a constructor in Python? Why is it useful? Give a simple example of a class with a constructor. CO4 Understanding
-T

Medium -
34 4.2 Explain the purpose of accessors and mutators in a class. Provide an example of each. CO4 Understanding
-T

Medium -
35 4.2 Define an instance variable and a class variable in Python. CO4 Understanding
-T

Easy -
36 4.3 What is inheritance in object-oriented programming? Give one example of how inheritance can be used in Python. CO4 Understanding
-T

Medium -
37 4.4 Explain polymorphism in object-oriented programming with an example. CO4 Understanding
-T

Easy -
38 5.1 What are the purposes of the os and sys modules in Python? Provide one example of a function from each module. CO5 Remembering
-T

Medium -
39 5.10 How can a basic plot be created from a Pandas DataFrame? Provide an example. CO5 Understanding
-A
Easy -
40 5.2 Describe how to open a text file in Python for reading and writing. Explain the difference between read and write modes. CO5 Understanding
-T

Easy -
41 5.3 Explain the difference between text files and binary files. Why might you choose to use a binary file? CO5 Understanding
-T

Easy -
42 5.4 What is NumPy, and how is it useful in Python programming? Provide an example of creating a NumPy array. CO5 Understanding
-T

Medium -
43 5.5 Demonstrate one matrix operation available in NumPy. Explain the purpose of the [Link] module. CO5 Understanding
-T

Medium -
44 5.6 Explain how to create a basic line plot in Matplotlib. Provide an example. CO5
Applying - A

Medium -
45 5.7 What is the purpose of ticks, labels, and legends in a Matplotlib plot? Provide an example to demonstrate each. CO5
Applying - A

Part B

# Unit Question COS Categorized

Easy -
What is the software development process? Describe the main phases of the Waterfall Model, and include a clear
1 1.4 CO1 Remembering
diagram to illustrate its flow
-T

2 1.5 A. What are operators in Python? Explain different types of operators with examples.(7 marks) CO1,CO1 Medium - - T
B. How do expressions work in Python? Explain with examples of numeric and Boolean expressions.(7 marks)

3 1.5,6 A. What are the different data types in Python? Explain the properties of numeric and string data types.(7 marks) CO1,CO1 Medium - - T
B. How variables are assigned with values in Python? What are the rules for naming variables?(7 marks)

A. Discuss the purpose of comments in a Python program. Write a short program that demonstrates the use of single-
line and multi-line comments to explain each step. Explain how comments help improve readability and maintainability of
4 1.6 code. (7 marks) CO1,CO1 Medium - - A
B. Develop a Python program that asks the user to input a temperature in Celsius and converts it to Fahrenheit. Include
9
type conversion if necessary, and display both the Celsius and Fahrenheit temperatures. (Formula: F = C x + 32 )
5
(7 marks)

A. Apizza in a circular shape of 8 inches diameter is placed in a square box


whose side length is 10 inches. write the Python program to find how much of
the box is “empty”? (7 marks) Medium -
5 1.7 CO1,CO1 Understanding
B. Consider the person ‘X’ has some amount in his hand and the person ‘Y’ has -A
some amount in his hand. If they wish to exchange the amount among them,
how can they exchange it by using the third party ‘Z’. Prompt necessary
data from the user (7 marks)

6 1.8 A. Explain how Python processes a program, from source code to output. What happens in the background?(7 marks) CO1,CO1 Medium - - T
B. What are syntax errors in Python? How can you detect and correct them?(7 marks)

A. Write a Python program that asks the user to enter a number and then uses anif-else structure to check if it is
7 2.1 positive, negative, or zero. (7 marks) CO2,CO1 Medium - - A
B. g (7 marks)

A. Write a Python program using if, elif, and else to determine a student’s grade based on their score. Assign different
grades to students based on their scores.

1. If a student scores above 90, assign grade A


2. If a student scores above 75, assign grade B
8 2.1 CO2,CO2 Medium - - A
3. If a student scores above 65, assign grade C
4. If a student scores below 65, assign grade F

(7 marks)
B. Write a Python program for a simple calculator that takes two numbers and an operator to perform basic arithmetic
using control statements. (7 marks)
A. Write a Python program that takes a number from the user and prints the multiplication table for that number (up to
9 2.2 10). (7 marks) CO2,CO2 Medium - - A
B. Write a Python program that calculates the sum of all integers from 1 to a number entered by the user. Use a loop to
implement the solution. (7 marks)

10 2.2 A. Write a Python program to use for loop to find the factorial of a given number. (7 marks) CO2,CO2 Medium - - A
B. Write a Python prohram using a for loop to iterate from 0 to 100 and print only even numbers(7 marks)

A. Four People A,B,C,D are sitting in a Circular arrangement. In how many ways
their seating can be arranged. write a python program to find the number of
11 2.2
ways to arrange the seats.[ Hint: The number of arrangements is given by CO2,CO2
Medium -
Applying - A
(n−1)! ] (7 marks)
B. Write the python program to display a pattern like a right angle triangle

using an asterisk. The pattern like : * ** *** **** (7 marks)

A. Explain the concept of a function in Python and its significance in programming. Provide the
12 2.3 syntax for defining a function, including how parameters and return statements are used. CO2,CO2 Medium - - T
Illustrate your explanation with a simple example. (7 marks)
B. Write a function that calculates the area of a circle given its radius.(7 marks)

13 2.5 A. Define a Python function that accepts both positional and named arguments. Demonstrate its use with a practical CO2,CO2 Medium - - T
example. (7 marks)
B. Explain why returning values from functions is useful for reusability and modular programming.(7 marks)

Medium -
14 2.6 Write a python program to display Fibonacci sequence using recursion. CO2
Applying - A

Medium -
15 2.6 A. Write a Python program for finding the factorial of a number using recursion(7 marks) CO2,CO2
Applying - A
B. Design a Python function that calculates the power of a number (x^y) using recursion(7 marks)

Write a Python program to reverse a string without using built-in functions. Explain how slicing can be applied to Medium -
16 2.7 CO2
manipulate strings in various ways. Applying - A

Write a Python program that takes a string input and counts the number of vowels and consonants. Explain how string Medium -
17 2.7 CO2
functions and loops can be used to achieve this result. Analysing - A

A. Write a Python function that accepts a string and returns the number of vowels in it.(6 marks)
B. Write a Python program that takes a string as input and:

18 2.7 Counts the number of uppercase and lowercase letters. CO2,CO2 Medium - - A
Replaces all uppercase letters with lowercase and all lowercase letters with uppercase.
Prints the modified string.

(8 marks)

A. Write a Python program that initializes a set with unique numbers, adds new elements,
removes any one element, and attempts to add a duplicate element. Display the contents Medium -
19 3.4 CO3,CO3
of the set at each stage of modification. (7 marks) Applying - A
B. Write a Python program to demonstrate the use of union, intersection and difference on
two sets, set1 and set2. Display the results of each operation. (7 marks)

20 3.4 A. Write a Python program that sorts a list of integers in descending order.(7 marks) CO3,CO3 Medium - - A
B. Explain how sorting is applied to lists in Python and how you can modify the sort order.(7 marks)

A. Write a Python program to display the current date and time in the format "YYYY-MM-DD HH:MM". Then, using
Medium -
21 3.5 strftime, display the date as "Month Date, Year" (e.g., "October 25, 2023"). (7 marks) CO3,CO3
Applying - A
B. Write a program that calculates the number of days between two dates entered by the user in "YYYY-MM-DD"
format. If the end date is before the start date, the program should instead display an appropriate message. (7 marks)

A. Write a program that creates a dictionary with information on three students (names as keys and their ages as
values). Demonstrate how to add a new student and update the age of a particular student. Display the dictionary after Medium -
22 3.7,8 each modification. (7 marks) CO3,CO3 Applying - A
B. Design a function reverse_lookup that takes a dictionary and a value as parameters and returns the key associated
with that value. If the value is not found, it should return None. Demonstrate the function with a sample dictionary (7
marks)

A. Write a program that allows the user to add product names and their prices to a dictionary. The user should be able to
23 3.7 add multiple products until they choose to stop. Display the final dictionary. (7 marks) CO3,CO3 Medium - - A
B. Create a dictionary that maps course codes to course names. Write a program to allow a user to input a course code
and retrieve the corresponding course name if it exists. (7 marks)
A. Write a Python program that iterates through a dictionary of items with prices and prints only those items with prices
Challenging - -
24 3.8 above a user-specified threshold. (7 marks) CO3,CO3
A
B. Describe how to filter the data in a dictionary through the process of comprehension by means of a practical example.
(7 marks)

A. Define a class Car that includes instance variables for company, model, and year. Write a method display_info that
Medium -
25 4.1 prints the car's details. (7 marks) CO4,CO4
Applying - A
B. Create an object of the Car class and call display_info to demonstrate the output. Explain how instance variables and
methods work within the class. (7 marks)

A. Define a class Student with instance variables name and grade. Implement a constructor to initialize these values,
Challenging -
26 4.2 and add accessor and mutator methods for each attribute. (7 marks) CO4,CO4
Applying - A
B. Create an instance of the Student class, modify the grade using a mutator method, and retrieve the name using an
accessor. Explain the benefits of using accessors and mutators in classes. (7 marks)

A. Define a parent class called Person with attributes name and age. Then, define a subclass Employee that inherits
Challenging -
27 4.3 from Person and adds an attribute salary. Write a method in Employee to display all details. (7 marks) CO4,CO4
Analysing - A
B. Create an instance of Employee and demonstrate calling the display method. Explain how inheritance helps in code
reuse and organization. (7 marks)

A. Define two classes, Dog and Cat, each with a speak method that returns a string with the animal sound ("Woof" for
Challenging -
28 4.4 Dog, "Meow" for Cat). Demonstrate polymorphism by calling speak on instances of both classes. (7 marks) CO4,CO4
Analysing - A
B. Explain how polymorphism is implemented here and describe its advantages in object-oriented programming.(7
marks)

A. Write a program to input a number and find its square root using [Link](). Write code to catch the exception thrown Medium -
29 4.7 CO4,CO4
if a negative number is entered. (7 marks) Applying - A
B. List three exceptions that Python can throw and give one example each for triggering those exceptions(7 marks)

A. Write a program that performs arithmetic division using two variables, handling both ZeroDivisionError and
Challenging -
30 4.8 ValueError (7 marks) CO4,CO4
Analysing - A
B. Explain how multiple exceptions are handled in Python with the program from the first part and the benefits of
managing each exception separately (7 marks)

A. Write a program that lists all files in a directory using the os module. Include code to handle the case where the
Challenging -
31 5.1 directory may not exist. (7 marks) CO5,CO5
Analysing - A
B. How can the [Link] list be used to handle command-line arguments in Python? Provide an example program that
accepts two arguments from the command line and prints them. (7 marks)

A. Write a program to load a dataset into a Pandas DataFrame and create a bar plot of one of the columns.(7 marks) Challenging - -
32 5.6,7,10 CO5,CO5
B. Explain how Pandas can be used with Matplotlib for data visualization. Show one example of this integration.(7 A
marks)

A. Write a program that opens a text file, writes a list of names to it, then reads and displays the names.(7 marks) Challenging -
33 5.2 CO5,CO5
B. What is the importance of handling file exceptions in Python, such as FileNotFoundError and IOError. Provide Analysing - A
example code showing exception handling for reading a file. (7 marks)

A. Write a Python program to copy the contents of one text file into another text file, line by line.(7 marks)
34 5.2 CO5,CO5 Medium - - A
B. Write a Python program to append a list of strings to an existing text file named "[Link]." Each string should be
written on a new line. (7 marks)

A. Write a Python program that reads a file in binary mode and writes its contents to a new file. Explain each step of the
Medium -
35 5.3 program. (7 marks) CO5,CO5
Analysing - A
B. Write a Python program that compares two binary files byte by byte to check if they are identical. If they are not, the
program should output the byte position of the first mismatch. (7 marks)

A. Write a program to create a 3x3 NumPy array with values ranging from 1 to 9. Demonstrate how to retrieve any one
Medium -
36 5.4 row and any one column. (7 marks) CO5,CO5
Analysing - A
B. Explain the advantages of using NumPy arrays over Python lists for mathematical operations. Provide an example of
a dot product of two vectors using NumPy arrays. (7 marks)

A. Write a program using numpy that generates two 3x3 matrices using random numbers and performs matrix addition,
Medium -
37 5.5 subtraction, and multiplication on them. Display the results. (7 marks) CO5,CO5
Applying - A
B. Explain how [Link] can be used to generate random integers and decimals. Provide an example of
generating ten decimal numbers between 0 and 1. (7 marks)

A. Write a program using Matplotlib that creates a line plot with labels for the x-axis, y-axis, and a title. Display the plot. Challenging -
38 5.6 CO5,CO5
(7 marks) Applying - A
B. Explain how to adjust the figure size and add gridlines to a Matplotlib plot. Provide an example.(7 marks)

A. Write a program to load a CSV file into a Pandas DataFrame, then demonstrate adding a new column to the Challenging - -
39 5.9 CO5,CO5
DataFrame. (7 marks) A
B. Explain how Pandas simplifies data cleaning. Provide an example of filling missing values in a DataFrame.(7 marks)

You might also like