Autumn Break Assignment I
Autumn Break Assignment I
Autumn Break Assignment I
1. What is a literal in Python? How many types of literals are allowed in Python?
2. What is None in Python?
3. What are Python’s built-in core data types?
4. Out of the following, find the invalid identifiers –
Price*Qty, class, For, do, 3rdcol, totally, Row31, _Amount
5. Predict the output of the following programs :
a. count = 0
while count<10:
print (‘Hello’)
count += 1
b. keepgoing = True
x = 100
while keepgoing:
print(x)
x = x-10
if x<50:
keepgoing = false
c. for z in range(-500, 500, 100):
print(z)
d. for x in ‘lamp’:
print(str.upper(x))
6. Find the error in the following code. Correct the code and write the output.
s1 = ‘must’
s2 = try
n1 = 10
n2 = 3
print(s1+s2)
print(s2*n2)
print(s1+n1)
print(s2*s1)
7. Consider the following code:
inp = input(“Please enter a string”)
while len(inp) < = 4:
if inp[-1] == ‘z’ :
inp = inp[0:3] + ‘c’
elif ‘a’ in inp:
inp = inp[0] + ‘bb’
elif not int(inp[0]):
inp = ‘1’+inp[1:] + ‘z’
else:
inp = inp + ‘*’
print(inp)
What will be the output produced if the input is i) ‘1bzz’ ii) ‘1a’ iii) ‘abc’ iv) ‘0xy’
v) ‘xyz’
8. Write a program that reads a string and checks whether it is a palindrome or not.
9. How are lists different from strings when both are sequences?
10. What is sorting? Write a program that uses bubble sort to sort a list of integers.
11. Write a method to display the elements of list thrice if it is a number and display the
element terminated with '#' if it is not a number.
For example, if the content of list is as follows
Lst = [‘41’,’DROND’,’GIRIRAJ’,’13’,’ZARA’]
The output should be
414141
DROND#
GIRIRAJ#
131313
ZARA#
12. What is the difference between the formal parameters and actual parameters? What
are their alternative names?
13. Following code intends to swap the values of two variables through a function, but
upon running the code, the output shows that the values are swapped inside the
switch() function but back again in the main program, the variables remain un-
swapped. What could be the reason? Suggest a fix.
def switch(x, y):
x, y=y, x
print(“inside switch:”, end=’ ‘)
print(“x = ”, x, “y = ”, y)
x=5
y=7
print(“x = ”, x, “y = ”, y)
switch(x, y)
print(“x = ”, x, “y = ”, y)
14. Write a function that takes a positive integer and returns the one’s position digit of
the integer.
15. Find the error. Correct the code and predict output.
def Tot(Number)
Sum =0
for c in Range(1, Number+1)
Sum +=c
RETURN Sum
print(Tot[3])
print(Tot[6])
16. Consider the code below and answer the questions that follow:
def multiply(number1, number2):
ans = number1*number2
return(ans)
print(number1, ‘times’, number2, ‘ = ’, ans)
output = multiply(5,5)
i) When the code above is executed, what prints out?
ii) What is the value of variable output after code is excecuted?
17. Write a function namely nth Root () that receives two parameters x and n and
returns nth root of x. The default value of n is 2.
18. What is the utility of built-in function help()?
19. What are the possible outcome(s) of the following code? Also specify the maximum
and minimum values that can be assigned to variable NUMBER.
STR = “CBSEONLINE”
NUMBER = random.randint(0, 3)
N=9
while STR[N] != ‘L’:
print(STR[N] + STR[NUMBER]+’#’, end=’ ‘)
NUMBER += 1
N = N-1
i) ES#NE#IO#
ii) LE#NO#ON#
iii) NS#IE#LO#
iv) EC#NB#IS#
20. What is the difference between read() and readlines() function?
21. The file new.txt contains the following
Considering the given file what output will be produced by the following code-
( 0
+-) 1
unary - * / 2
^ 4
33. Write a program to implement a stack for book-details i.e. book-no and book-name.
That is, now each item node of the stack contains two types of information – a book-
no and its name. Implement Push and display operations using a menu driven
program.
34. Write the full form of the following –
a. NIC
b. MAC
c. FTP
d. TCP/IP
e. OSI
f. VoIP
g. SSH
h. HTTPS
i. RFID
j. IoT
k. NFC
l. URI
m. POP
n. IMAP
o. SMTP
35. What is the difference between hub, switch and router?
36. What are the security concerns related to IoT?
37. What is a collision in a network? How does it impact the performance of a network?
38. What are the steps followed in checksum generator?
39. What is a tracert or traceroute command?
40. What is HTTPS? How does it work?
41. What are ACK, CTS and RTS signals?
42. What is the use of Whois networking command?
43. Consider the following network map showing how routers of various networks are
connected.
B C
F
A
D E