0% found this document useful (0 votes)
2 views

PythonTest3.30pm

The document is a Python test paper consisting of multiple-choice questions (MCQs) and practical coding questions. It covers various topics including data types, identifiers, code output, and practical programming tasks such as manipulating dictionaries and tuples. Each section has specified marking criteria, with MCQs worth 1 mark each and practical questions worth 5 marks each.

Uploaded by

Vrinda Kumawat
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)
2 views

PythonTest3.30pm

The document is a Python test paper consisting of multiple-choice questions (MCQs) and practical coding questions. It covers various topics including data types, identifiers, code output, and practical programming tasks such as manipulating dictionaries and tuples. Each section has specified marking criteria, with MCQs worth 1 mark each and practical questions worth 5 marks each.

Uploaded by

Vrinda Kumawat
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

PYTHON TEST PAPER

PART - A MCQ
**Marking** In this Section each question contains 1 mark

Q1. Which is not a built-in data type in python ?

A. Complex
B. Dictionary
C. Array
D. Tuple

Q2. Which is not a valid python identifier ?

A. name
B. first_name
C. last-name
D. _123

Q3. what will be the output of following code ?

print(2**3 + (5 + 6)**(1 + 1))

A. 129
B. 8
C. 121
D. None of the above

Q4. What is the structure generated after the Python source code is compiled?

A. .ini
B. .pyc
C. exe file
D. .bin
Q5. What will be the output of the following code ?

a = [1, 2, 3]
a = tuple(a)
a[0] = 2
print(a)

A. [2, 2, 3]
B. (2, 2, 3)
C. (1, 2, 3)
D. Error

Q6. Which of the following statement prints hello\example\test.txt ?

A. print("hello\example\test.txt")
B. print("hello\\example\\test.txt")
C. print("hello\"example\"test.txt")
D. print("hello"\example"\test.txt")
E: print("hello\example\test.txt")

Q7. What will be the ouput of following code ?

a=3
b=1
print(a, b)
a, b = b, a
print(a, b)

A. 3 1 13
B. 3 1 31
C. 1 3 13
D. 1 3 31

Q8. What will be the output of the following code ?

example = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]


print(example[-3::-2])

A. ["Sunday", "Tuesday", "Thursday"]


B. ["Saturday", "Thursday", "Tuesday"]
C. ["Thursday", "Tuesday", "Sunday"]
D. ["Tuesday", "Thursday", "Saturday"]
E. ["Sunday", "Friday", "Saturday"]
Q9. What will be the output of the following code ?

example = ["Sunday", "Monday", "Tuesday", "Wednesday"]

del example[2]

print(example)

A. ["Sunday", "Monday", "Tuesday", "Wednesday"]


B. ["Sunday", "Monday", "Wednesday"]
C. ["Sunday", "Tuesday", "Wednesday"]
D. ["Sunday", "Monday", "Tuesday"]

Q10. Which built-in function is used to get all methods name of a class ?

A. len
B. type
C. dir
D. help
PART-B Practical Questions
**Marking** In this Section each question contains mark 5

Q11. Solve the following questions using the data below:

{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55, "batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
A. Write code to get the type of id '5005'?
B. Write code to add the new batter with id 1005 and type Strawberry?
C. Write code to modify the type of batter as Evil's Food of id 1004?

Q12. Write a Python program to remove an item from a tuple.

Q13. Write a Python program to multiply all the items in a dictionary.

my_dict = {'data1':100,'data2':-54,'data3':247}

Output = 293
Q14. Write a Python program to get the last part of a string after a specified character.

string = 'https://www.grras.com/internship/python'
specified_character = '/' output = 'python'

Explanation -> Last part is 'python' after /

Q15. Write a Python program to map two lists into a dictionary.

keys = ['red', 'green', 'blue']


values = ['#FF0000','#008000', '#0000FF']

Output = {'red': '#FF0000', 'green': '#008000', 'blue': '#0000FF'}

Q16. Write a Python script to concatenate following dictionaries to create a new one. Go to the editor

Sample Dictionary :
dic1={1:10, 2:20} dic2={3:30,
4:40} dic3={5:50,6:60}
Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}

Q17. Suppose you are hired to build a bank application in python. Client have give data records as below
?
How will you store this data in python program ?

Data

Account Number Name Balance DOB Email Phone Number Password

PYBNK234512 Rahul 25000 01/01/1993 [email protected] 1233214565 luhaR


PYBNK123456 Siya 12500.25 15/08/1990 [email protected] 3455431243 ayiS
PYBNK100121 Ram 90000 10/08/1996 [email protected] 9877899988 naR
PYBNK110011 Sita 45000 12/12/1997 [email protected] 1234567890 atiS

Q18. Write a program to generate output from given input string ?

INPUT " -----.......Hello-can-you-solve-me-?........---- "


OUTPUT "Hello can you solve me.
Q19. Write a python program to take 5 number input and print maximum and sum of all number ?
INPUT
23
17
28
90
30

OUPUT
maximum number is 90
total sum is 188

Q20. Write a python code to calculate final price

on a bill you have to add these taxes on billing amount to generate final bill

GST RATE = 20%


SGST RATE = 10%
SURCHARGE = 2%

example

INPUT:

Product Name: T-Shirt


Product Price: 2000
Discount Rate: 50%

OUTPUT:

After Discount Product Price is 1000.00 ₹


TAX AMOUNT = 200.00 ₹
SGST AMOUNT = 100.00 ₹
SURCHARGE AMOUNT = 20.00 ₹

To purchase T-Shirt you have to pay 1320.00 ₹

You might also like