0% found this document useful (0 votes)
21 views4 pages

PPS CT 3 QB

The document contains a question bank for CT 3 covering topics from UNIT IV and UNIT V, including Python programming, data structures, and Pandas library operations. It consists of multiple-choice questions, programming tasks, and theoretical questions related to lists, tuples, sets, DataFrames, and NumPy. Additionally, it includes practical exercises for coding and data manipulation using Python.

Uploaded by

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

PPS CT 3 QB

The document contains a question bank for CT 3 covering topics from UNIT IV and UNIT V, including Python programming, data structures, and Pandas library operations. It consists of multiple-choice questions, programming tasks, and theoretical questions related to lists, tuples, sets, DataFrames, and NumPy. Additionally, it includes practical exercises for coding and data manipulation using Python.

Uploaded by

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

CT 3 Question Bank

UNIT IV and UNIT V


1. Which of the following would produce same output
tuple = (5,3,1,9,0)
(i)print(tuple[:-1] (ii) print(tuple[0:5]
(iii) print(tuple[0:4] (iv) print(tuple[-4:]
a. i,ii b. ii,iv
c. i,iv d. i,iii
2. In the following what are the values? {‘name’:’Pooja’,’age’:’22’,’courses’:
[‘calculus’,’Maths’]}
a. Pooja,22,calculus,Maths b.{},:,’’,[] c.name,age,couse
d.calculus,Maths
3. What would be the output
Numbers=tuple(“45678”)
print(Numbers)
a. 45678 b.(‘4’,’5’,’6’,’7’,’8’) c.(45678) d.”45678”
4. What will be the result of below Python code?
A={0,2,4,6,8};B={1,2,3,4,5}
A&B
a. {0,1,2,3,4,5,6,8} b. {0,1,3,5,6,8}
c. {2,4} d.{0,8,6}
5. What is the output of the following code
Tuple1=(5,1,7,6,2)
Tuple1=pop(2)
print(Tuple1)
a) 5,1,6,2 b. 5,1,7,6 c.5,1,7,6,2 d. Error
6. Which of the following will change data type of a column named column in data
frame df to string datatype
a. df.column.astype(str) b. df.column.type(str)
c.str(df.column) d. df.str(column)
7. The following data code will create a dataframe named ‘df1’ with ______columns
df1=pd.DataFrame([1,2,3])
a.1 b.2 3.3 4.4
8. Add a new row to a dataframe using __________ method
a.rloc() b.loc() c.iloc() d.eloc()
9. What will be the output of the following code?
import pandas as pd
pd.Series([1,2]),index=[‘a’,’b’,’c’])
a.Syntax error b.Index error c.Value error d.type error
10.How many rows is the following numpy array:
A=np.array([[1,2],[3,4],[5,6],[7,8]])

a. 1 b.2 c. 3 d.4
11.Which of the following takes a dict of dicts or a dict of array-like sequences and
returns a DataFrame?
a. DataFrame.from_items c. DataFrame.from_values
b. DataFrame.from_records d. DataFrame.from_dict
12.Which of the following would complete val = to set val to 20 by slicing a Tuple.
aTuple = ("Orange", (10, 20, 30), (5, 15, 25))
val =
a. val = aTuple[1:2][1] b. val = aTuple[2][1]
c. val = aTuple[1:2](1) d. val = aTuple[1][1]
13.Comparing a dictionary to Python to a dictionary for words, ____________ is each
word we look up_______ is definition of the word
a. value, key b.key, attribute c.method, value d.key, value
14.What would be the output
a = [9, 8, 7, 6, 5, 4]
print(a[:-3])
a. [9,8,7] b.[6,5,4] c.[9,7,6] d.[9,7,4]
15.What will be the result of below Python code?
set1={1,2,3}
set1.add(4)
set1.add(4)
print(set1)
a. {1,2,3,4} b. {1,2,3} c. {1,2,3,4,4}
d. It will throw an error as same element is added twice
16.What is the function used to convert a tuple into a list?
a) list_tuple() b. tuple() c.list() d. cannot convert
17.Which of the following will show an error when creating a tuple?
I. T1= "ram", "hello"," include help"
II. T1=("ram",)
III. T1=("ram")
IV. Three of them are correct
a. I b.II c.III d.IV
18.What is the syntax of slicing the list?
a. List (start index, stop index, step)
b. List (start index: stop index: step)
c. List [start index, stop index, step]
d. List [Start index: stop index: step]
19.What is the output of the below code?
np.arange(2,8)

a. array([2, 3, 4, 5, 6, 7]) b. array([1,2,3,4,5,6,7,8])


c. array([2,3,4,5,6,7,8]) d.array([3,4,5,6,7])
20._________ is the python library that primarily works with complex data and machine
learning
a.Numpy b. Scikit-learn c. SciPy d.Matplotlib
21.import pandas as pd
series1 = pd.Series([10,20,30,40])
print(series1*2)
what will be the output?
a. print the values that are divisible by 2
b. print the values that are product by 2
c. print the values that are modulus by 2
d. print the values that are divisible by 4
22.Which of the following takes a dict of dicts or a dict of array-like sequences and
returns a DataFrame?
a. DataFrame.from_items c. DataFrame.from_values
b. DataFrame.from_records d. DataFrame.from_dict

PART-B(8marks)
UNIT IV
1. Write the basic operations that can be performed in List.
2. Write a python program to print the Fibonacci series
3. Write a python program to print the following Floyd triangle
1
2 3
4 5 6
4. Write the basic operations that can be performed in Tuple.
5. What is meant by set? Write the various functions used in set with
suitable example.
6. Write a sample code for subtraction of two arrays in numpy.

UNIT V
7. Explain DataFrame in Pandas with a suitable example and mention its applications.
8. Lakshmi writes a sentence in her notebook. She wants to count the number of
uppercase, lowercase, digits, special symbols in her sentence.
9. Distinguish between Pandas with Numpy using different comparison parameters in
Python Programming Language.
10. Explain the various methods of creating DataFrames in Pandas with examples
11. Explain the different types of functions available in Pandas for data manipulation.
Discuss with suitable examples.
12. (i)Write a Pandas program to select the 'name' and age and designation columns from
the following Data
data = [['Anuj',21],['Rama',25],['Kapil',22]]
(ii) Enumerate the use of query function in pandas with an sample dataset.

Part – C ( 01 x 15 = 15 Marks)

1. Consider the list lst=[9,8,7,6,5,4,3]. Write the Python program which performs the
following operation
(i) Insert element 10 at beginning of the list.
(ii) Insert element 2 at end of the list.
(iii) Delete the element at index position 5.
(iv) Print all elements in reverse order.
2. (i)Write a python program to verify the list is sorted and to print True if list is sorted
else print False.
(ii)Write a python program to create a Numpy array with all zeros and ones.
3. Apply the NumPy library in Python to analyze the following dataset of marks scored
by 12 students in a Mathematics examination out of 100:
Dataset:Marks = [56, 78, 45, 89, 66, 90, 74, 82, 55, 69, 77, 88]
Determine the Maximum, Minimum, Mean, Median, Standard deviation, Variance
and 25th, 50th and 75th percentile of the marks.
4. Write a Pandas program to perform the following operations using the following
dataset:'Maths': [80, 90, 85, 70, 80], 'Science': [75, 88, 92, 75, 82], 'English': [70, 85,
80, 90, 84]. Create a dataframe and perform following
a) Display the first and last 2 rows of the DataFrame.
b) Add a new index title for each row as Student 1, Student 2 and
Student 3
c) Display the row total and column total.
d) Display the number of rows and columns in the DataFrame.
e) Perform statistical operations using pandas function.

You might also like