PythonTest3.30pm
PythonTest3.30pm
PART - A MCQ
**Marking** In this Section each question contains 1 mark
A. Complex
B. Dictionary
C. Array
D. Tuple
A. name
B. first_name
C. last-name
D. _123
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
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")
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
del example[2]
print(example)
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
{
"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?
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'
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
OUPUT
maximum number is 90
total sum is 188
on a bill you have to add these taxes on billing amount to generate final bill
example
INPUT:
OUTPUT: