1. a). Which of the following are not valid strings in Python? [1]
(i) “Hello” (ii)’Hello’ (iii) “Hello’ (iv) ‘Hello” (v) {Hello}
b) What will be the output of following code [1]
x,y=4,8
x,y=y,x+2
print(x,y)
c) What is the use of interactive mode? [1]
d) What is the difference between an interpreter and a compiler? [2]
e) What will be the output of the following? [2]
(i) print(len(str(17//4)) )
(ii) print(len(str(17/4)) )
f) List the error in following Python code snippet. Suggest a solution. [2]
print(“The address is”, address)
g) Write a program to create a one dimensional array of size 8 with all elements as zero, but the fourth element should be 5. [3]
a) The valid strings are (c), (d) and (e)
b) The output will be: 8 6
c) Python’s interactive interpreter is suitable for testing code as this mode does not save commands in the form of program file.
d) An interpreter converts an High level language program into machine language line by line and simultaneously executes the converted line.
A compiler converts an HLL program in machine language in one go. If there are errors in the program, it gives the error list along with the line numbers.
e) When we create the dataframe object it get the row numbers and columns labels automatically but if we want to change the row numbers and column labels we can do so with help of reindexing.
The methods used in reindexing are:
Rename(),reindex() and reindex_like()
f) The above statement is trying to print the value of an undefined variable name. The solution to above problem is to define the variable name before using it.
Address= Parklane, Delhi
Print(“The address is”,Address)
g) import numpy as n
X=np.zeros(8)
X[3]=5
Print(X)
2 a) Write the syntax to delete a dictionary element. [2]
b) Give the output of the following statement. [2]
str="Group Discussion"
print str.lstrip("Gro")
c) Why can’t Lists be used as keys? [2]
d) What happens, if we try to access a key,which is not contained in the dictionary? [2]
e) Differentiate between append() and the extend() method. [3]
f) Predict the output of following code: [3]
1. x='I am the best'
print(x[:2],x[:-2],x[-2:])
print(x[:],x[:-9])
print(x[2:-3],x[-2:-5])
2. a="I"+"am"+"best"
for str in a:
b=str
print(b,':',end=' ')
3. a="python"
print (a[3:],a[:3])
print(a[-3:],a[:-3])
print(a[:-5]+a[-5:])
g) Consider the string str=”Global Warming”; [4]
Write statements in python to implement the following:
1) To display the last four characters.
2) To display the substring starting from index 4 and ending at index 8.
3) To check whether string has alphanumeric characters or not.
4) To trim the last four characters from the string.
a) del< dictionary >[< key >] OR
< dictionary >.pop(< key >)
b) The output will be : up Discussion.
c) sort_values function is used to arrange the data in ascending or descending order.
.sort_values(by,axis=0,ascending=True, inplace=false, kind=’quicksort’, na_position=’last’)
d) Lists cannot be used as keys in a dictionary because they are mutable. And a Python dictionary can have only keys of immutable types. The interpreter raises the Key Error exception, when a dictionary is accessed with either an undefined key or by a numeric index.
e) The append() method adds a single element to the end of the list and returns no value.
L1.append(‘d’) #L1=[‘a’,’b’,’c’,’d’]
The extend() method is used for adding more than one elements to a list. This method takes a list as an argument and appends all of the elements of the argument list to the list object on which this method is applied.
L2=[‘d’,’e’]
L1.extend(L2) # L1=[‘a’,’b’,’c’,’d’,’e’]
f)
1) I I am the be st
I am the best I am
am the b
2) I : a : m : b : e : s : t :
3) hon pyt
hon pyt
hon python
g)
1) print (str[-4:])
ming
2) print (str[4:8])
al W
3) str.isalpha()
False
4) print (str[:10])
Global War
3 a) What will happen if we apply describe() on a DataFrame object which has both numeric as well as string type? [1]
b) Write the function for the following tasks : [2]
(i) To retrieve top 5 rows
(ii) To retrieve bottom 5 rows
c) Differentiate between NumPy Arrays and Series Objects. [2]
d) Consider the DataFrame – dtf. [3]
Determine the output of following:-
1. print(dtf[dtf[“Marks”]>57])
2. print(dtf.head(2))
3. print(dtf.tail(2))
e) Write down the definition of each attribute. [3]
1. Series.size
2. Series.itemsize
3. Series.hasnans
f) Given a DataFrame namely data as shown [4]
Write code statement to:
1. Find all rows with the label “III”. Extract all columns.
2. List rows with marks more than 57.
3. List single True or False to signify if all marks are more than 60 or not.
4. List 2nd, 3rd, and 4th rows.
a) Pandas by default will show details about numeric column only.
b) i. head()
ii. tail()
c) The differences are given below:
Numpy arrays | Series Objects |
Indexes in NumPy arrays are always in numeric form, starting with zero onwards. | But the Series Object is more flexible as they can have any type of indexes like numbers, letters, labels, etc. |
ndarrays can perform vectorized operations only if the shapes of two ndarrays match. | The data of two series objects is aligned as per the matching indexes. NaN is returned for non-matching indexes. |
d) 1.
2.
3.
e)
f)
1. data.loc[‘III’, :]
2. data[data[‘marks’]> 75]
3. (data[‘marks’]>60).all()
4. data.iloc[0:3, :]
4 a). What is a database system? [1]
b) What is the syntax of create table in MYSQL? [1]
c) What is a primary key? [1]
d) What is the full form of CSV? [1]
e) Mention the constraints that can be applied on the table column? [2]
f) Write down the difference between DDL and DML commands. [3]
g) Given below is the table answer the question based on it. [3]
Employee
Emp_ID | E_Name | E_Address | E_Dept |
1 | SEEMA | SECTOR 77 NOIDA | COMPUTER |
2 | JYOTI | PREET VIHAR DELHI | PHYSICS |
3 | RIYA | MG ROAD GURGAON | CHEMISTRY |
4 | RUSHA | MOHAN NAGAR GHAZIABAD | BIOLOGY1. |
1. Write the query to insert in table the 5th emp_id with its details.
2. Write the query to display EMP_ID and E_Name of an employee.
3. Write the query to change the address of Emp_ID =2 from PREET VIHAR DELHI to FARIDABAD
h) What is a data type? Explain three commonly used data type in SQL. [3 ]
a) A database is a collection of interrelated data and a database system is basically a computer based recordkeeping system.
b) The syntax of CREATE TABLE is:
Create table
([()],
[()…..])
c) The set of one or more attribute which uniquely identify the tuple within the relation is known as primary key.
d) CSV stands for “comma-separated values”.
e) NOT NULL, DEFAULT, UNIQUE, CHECK, Primary key, Foreign Key are some of the constraints that are applied to table column.
f) DDL: data definition language is used to define the data structure. The statements included in DDL are: create, alter, drop, truncate, comment and rename.
DML : Data manipulation language is used to manage data within schema object. The statements included in it are: select, insert, update, delete and merge.
g)
1. INSERT INTO Employee VALUES ( 5, ‘TIA’, ‘Model Town ’ , ‘MATHS’);
2. select EMP_ID and E_Name from Employee;
3. UPDATE Employee SET E_Address= FARIDABAD where Emp_ID=2 ;
h) SQL Data type defines the value type that can be stored in a table column. For example if we want to store the number in a table we can store it as int data type.
The commonly used data types are:
5 a) What do you mean by Plagiarism? [1]
b) Describe why authentication is important for file protection. [2]
c) Mention any two preventive measures against viruses. [2]
d) What is Digital footprint? Why is it so important? [2]
e) Enlist three measures one should take to avoid loss of confidentiality of personal information. [3]
a) Plagiarism is stealing someone else’s work and representing it as our own work without giving credit to creator.
b) Authentication ensures that the individual is who he or she claims to be, but says nothing about the access right of the individual. It is used as a primary step for file protection from unauthorized users.
c) The preventive measures are:
d) A digital footprint is the information of data that we create while browsing internet.
It is important as it keeps the record and traces of activities that people do on internet so that this information can be tracked.
e) The three measures are:-
Take your CBSE board preparation to another level with AI based and rich media animation on Extramarks - The Learning App.
Features of Learning App