19. (i) Expand the terms: POP3 , URL
Ans: POP3 - Post Office Protocol 3
URL - Uniform Resource Locator
(ii) Give one difference between XML and HTML.
Ans:
| HTML (Hyper Text Markup Language) |
XML (Extensible Markup Language) |
| We use pre-defined tags |
We can define our own tags and use them |
| Static web development language – only focuses on how data looks |
Dynamic web development language – used for transporting and storing data |
| Used only for displaying data, cannot transport data |
Used for transporting and storing data |
OR
(i) Define the term bandwidth with respect to networks.
Ans: Bandwidth is the maximum rate of data transfer over a given transmission medium. / The amount of information that can be transmitted over a network.
(ii) How is http different from https?
Ans: https (Hyper Text Transfer Protocol Secure) is the protocol that uses SSL (Secure Socket Layer) to encrypt data being transmitted over the Internet. Therefore, https helps in secure browsing while http does not.
20. The code given below accepts a number as an argument and returns the reverse number. Observe the following code carefully and rewrite it after removing all syntax and logical errors. Underline all the corrections made.
define revNumber(num):
rev = 0
rem = 0
While num > 0:
rem = = num % 10
rev = rev * 10 + rem
num = num // 10
return rev
print(revNumber(1234))
Ans:
def revNumber(num):
rev = 0
rem = 0
while num > 0:
rem = num % 10
rev = rev * 10 + rem
num = num // 10
return rev
print(revNumber(1234))
21. Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an argument and displays the names (in uppercase)of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be:
LONDON
NEW YORK
Ans:
PLACES = {1:"Delhi", 2:"London", 3:"Paris", 4:"New York", 5:"Dubai"}
def countNow(PLACES):
for place in PLACES.values():
if len(place) > 5:
print(place.upper())
countNow(PLACES)
OR
Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
Ans:
def lenWords(STRING):
T = ()
L = STRING.split()
for word in L:
length = len(word)
T = T + (length,)
return T
22. Predict the output of the following code:
S = "LOST"
L = [10, 21, 33, 4]
D = {}
for I in range(len(S)):
if I % 2 == 0:
D[L.pop()] = S[I]
else:
D[L.pop()] = I + 3
for K, V in D.items():
print(K, V, sep="*")
Ans:
23. Write the Python statement for each of the following tasks using BUILT-IN functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
Ans: L1.insert(2,200)
(ii) To check whether a string named, message ends with a full stop / period or not.
Ans: message.endswith('.')
OR
A list named studentAge stores age of students of a class. Write the Python command to import the required module and (using built-in function) to display the most common age value from the given list.
Ans:
import statistics
print(statistics.mode(studentAge))
24. Ms. Shalini has just created a table named “Employee” containing columns Ename, Department and Salary.
After creating the table, she realized that she has forgotten to add a primary key column in the table. Help her in writing an SQL command to add a primary key column EmpId of integer type to the table Employee.
Thereafter, write the command to insert the following record in the table:
EmpId: 999
Ename: Shweta
Department: Production
Salary: 26900
Ans: SQL Command to add primary key:
ALTER TABLE Employee ADD EmpId INTEGER PRIMARY KEY;
As the primary key is added as the last field, the command for inserting data will be:
INSERT INTO Employee VALUES("Shweta","Production",26900,999);
Alternative answer to insert data:
INSERT INTO Employee(EmpId,Ename,Department,Salary) VALUES (999,"Shweta","Production",26900);
OR
Zack is working in a database named SPORT, in which he has created a table named “Sports” containing columns SportId, SportName, no_of_players, and category.
After creating the table, he realized that the attribute, category has to be deleted from the table and a new attribute TypeSport of data type string has to be added. This attribute TypeSport cannot be left blank. Help Zack write the commands to complete both the tasks.
Ans: To delete the attribute, category:
ALTER TABLE Sports DROP category;
To add the attribute, TypeSport
ALTER TABLE Sports ADD TypeSport char(10) NOT NULL;
25. Predict the output of the following code:
def Changer(P, Q=10):
P = P / Q
Q = P % Q
return P
A = 200
B = 20
A = Changer(A, B)
print(A, B, sep='$')
B = Changer(B)
print(A, B, sep='$', end='###')