CT-3 QB
CT-3 QB
CT-3 QB
How do you access the first element of a tuple t = (10, 20, 30)?
a) t[1] b) t.first() c) t[0] d) t.get(1)
You said:
need more
ChatGPT said:
ChatGPT
Here are more MCQs on the remaining topics to meet your requirements:
What will dict1 = {'a': 10, 'b': 20} return for dict1['a']?
a) 10
b) 'a'
c) Error
d) None
Answer: a) 10
Which library is best suited for working with structured data (tables)?
a) NumPy
b) Pandas
c) Scikit-learn
d) TensorFlow
Answer: b) Pandas
How do you query a DataFrame for rows where a column is greater than a value?
a) df.column > value
b) df[df['column'] > value]
c) df.query(column > value)
d) None of the above
Answer: b) df[df['column'] > value]
1) Write about Python, and why is it widely used in fields such as data
science and web development? List its key features.
2) Write a program to accept a list of numbers from the user. Sort the list into
ascending order and remove any duplicates.
3) Differentiate list from tuples with appropriate examples.
4) Brief the key attributes of a NumPy array? Explain the purpose of ndim,
shape, and dtype.
5) You have a DataFrame representing student grades. Write a function to
classify students as "Pass" or "Fail" based on their grades and apply it to
the DataFrame.
6) Explain the differences between a Pandas Series and a Pandas DataFrame.
Provide examples of when each would be used.
7) Describe the concept of sets in Python. How do you create and manipulate
sets, and what makes them different from lists and tuples?
8) Discuss the key differences between NumPy and Pandas, focusing on their
structures, functionalities, and performance. Include the following aspects
in your answer:
(i)Describe the fundamental concepts behind NumPy and Pandas libraries
in Python.
(ii)Explain the process of creating a NumPy array and a Pandas DataFrame.
Provide examples of syntax.
(iii)Provide examples of slicing in both libraries and explain when each
method is preferred.
(iv) Discuss the speed performance of NumPy and Pandas in handling
large datasets.
9) Explain the differences between a WHILE loop and a FOR loop in python.
When would you choose one over the other?
10) Write a Python program to find the union, intersection, and
difference between two sets of student names.
11) Brief dictionary and it’s any 5 operations with examples.
12) What is a percentile? How can it be calculated using NumPy’s
percentile() function?
13) How does slicing in NumPy differ from slicing in Python lists? Explain
with examples.
14) Create a DataFrame to represent sales data for a store (Product
Name, Quantity, Price). Display the first five rows of the DataFrame.
15) Compare the following Python data structures: Set, List, Tuple, and
Dictionary. Your answer should include:
16) 1.Definition and a brief description of each data structure.
17) 2.At least two unique features of each data structure with example.
• Adding elements (if applicable).
• Accessing elements (if applicable).
18) Explain some popular Python libraries for data analysis and
visualization. Describe their use cases briefly.