Name the device used to convert images, printed text or an object into digital image.
Answer
Scanner
Give any two features of Python.
Answer
Two features of Python are:
- Python is an interpreted, interactive, directly executed language with a pre-compiled code.
- It is free, open-source and portable language having a large repository of libraries.
If the value of a = 10 and b = 15, then a *= b will assign ............... to the variable a.
- 25
- 150
- 100
- 225
Answer
150
Reason — The operator *=
is a shorthand for multiplying and assigning a value. So, a *= b
means a = a * b
. Given a = 10 and b = 15, the expression evaluates to a = 10 * 15, which results in a = 150.
Define Sequence data type in Python? Give two examples.
Answer
A sequence data type is a data structure that holds an ordered collection of items. These items can be of any type, and the sequence maintains their order.
For example — list, string.
The software which is freely available for use but source code may not be available comes under —
- Open-Source
- Firmware Software
- Freeware Software
- Proprietary Software
Answer
Freeware Software
Reason — Freeware software is freely available for use but source code is not available to the public.
Which of the following is a valid variable name?
- 1name
- na*me
- name
- name one
Answer
name
Reason — A valid variable name in Python can only contain letters (a-z, A-Z), digits (0-9), and underscores (_). It cannot start with a digit, contain special characters like *, or include spaces. Therefore, "name" is a valid variable name.
Anu wants to change the width of a column Author in a Table Library from Varchar(20) to Varchar(30). Which command should she use?
Answer
Anu should use MODIFY
clause with ALTER TABLE
command to modify the data type size for the Author column from 20 to 30 characters. The command is as follows:
ALTER TABLE Library
MODIFY Author VARCHAR(30);
The superimposition of computer-generated perceptual information over the existing physical surrounding is called ............... .
Answer
Augmented Reality
Seema is collecting data for her science project from science blogs, e-newspapers and various websites this process is known as ............... .
- Data Capturing
- Data Retrieval
- Data Storage
- All of these
Answer
Data Retrieval
Reason — Data retrieval involves obtaining and collecting data from various sources, such as science blogs, e-newspapers, and websites.
What will be the correct output of the following code:
a, b = '30', '5'
c = a+b
print(c)
- 19
- 305
- ValueError
- TypeError
Answer
305
Reason — In the above code, a
and b
are strings as they are enclosed in quotes. When using the + operator with strings, it performs concatenation rather than arithmetic addition. Therefore, a + b
results in the concatenation of '30' and '5', producing '305'.
If you add a new column in a table using the Alter Table command, which value is inserted in the new column for the existing rows?
Answer
If we add a new column in a table using the Alter Table command, the new column will be filled with NULL for all existing rows.
If a < b and a < c then
- a is the greatest number
- a is the smallest number
- b is the greatest number
- c is the greatest number
Answer
a is the smallest number
Reason — If a < b and a < c
, it means a
is less than both b
and c
. Therefore, a
is the smallest number among a
, b
, and c
.
Mismatched redundant copies of data is known as Data ............... .
- Dependence
- Redundancy
- Inconsistency
- Isolation
Answer
Inconsistency
Reason — Mismatched redundant copies of data is known as Data Inconsistency.
............... is a subfield of linguistics, Computer Science and Artificial Intelligence concerned with the interaction between computer and human language.
Answer
NLP (Natural Language Processing)
Convert 1 GB to 1 Kilobytes.
Answer
1 GB = 1024 megabytes (MB) and 1 MB = 1024 kilobytes (KB).
Therefore:
1 GB = 1024 MB * 1024 KB/MB = 1,048,576 KB
So, 1 GB is equal to 1,048,576 KB.
Shikha has written the following SQL statement:
Select Name, Dept, Salary*12 as "Annual Salary" from EMP;
What is "Annual Salary" in the above statement?
Answer
In the given SQL statement, "Annual Salary" is an alias for the calculated column Salary*12
. An alias is a temporary name given to a column or table in an SQL query, making it easier to reference and display the results.
Consider the following dictionary
Book = {1 : "Informatics Practices",
2 : "Computer Science ",
3 : "Information Technology"}
Jaya executes statement: 2 in Book
Assertion (A): For the above dictionary Book, the output of the statement 2 in Book
is True.
Reasoning (R): For Dictionary, the ‘in’ and ‘not in’ operators return True or False.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
The statement 2 in Book
checks if the key 2 exists in the dictionary Book
. Since 2 is a key in the dictionary with the value "Computer Science ", the statement returns True. The in
and not in
operators in Python dictionaries return True or False depending on whether the specified key exists in the dictionary or not.
For a given list
L = [1, 2, 3, 4, 5, 6]
the index of element 4 will be:
Assertion (A): The index of element 4 will be 3 or -3.
Reasoning (R): Python list supports forward and backward indexing with -1 to given to left most and 0 to right most element.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Answer
A is true but R is false.
Explanation
The index of element 4 in the list L = [1, 2, 3, 4, 5, 6] is 3. Additionally, the index -3 refers to the element 4 when counting from the end of the list. Python lists support both forward (positive) and backward (negative) indexing with -1 referring to the rightmost element and 0 referring to the leftmost element.
Evaluate the following expression:
(i) 12/3+4**2-6/3
(ii) not True or False and True
Answer
(i) 12 / 3 + 4**2 - 6 / 3
= 12 / 3 + 16 - 6 / 3
= 4 + 16 - 2
= 20 - 2
= 18
(ii) not True or False and True
= False or False and True
= False or False
= False
What will be the output of the following code?
for k in range(-10, 0, 2):
print(k)
Answer
-10
-8
-6
-4
-2
The for
loop generates a sequence of numbers starting from -10, stopping before 0 (i.e., 2), and incrementing by 2 each time, resulting in the sequence -10, -8, -6, -4, -2.
Differentiate between cloud computing and grid computing?
Answer
Cloud Computing | Grid Computing |
---|---|
Cloud computing is used for virtualization of servers, where one server computes several tasks or services concurrently. | Grid computing allocates multiple servers onto a single application. |
It supports long-running services (Service Oriented). | It is typically used for job execution, where a program runs for a limited time (Application-Oriented). |
Cloud computing is used for multiple services. | Grid computing is used for a single application. |
Its computation service is on-demand. | Its computation service provides maximum computing power for one application. |
It involves virtualization of hardware, software, and storage platforms. | It involves virtualization of data and computing resources. |
Examples : GoogleDrive, OneDrive, Mobile Office Applications (e.g., Office 365, Google Docs), SharePoint, Microsoft Azure, iCloud, AWS etc. | Examples : GridGain, JPPF, JBossCache, EhCache etc. |
Write a Python program to calculate and display the square and cube of an inputted number.
num = int(input("Enter a number"))
s = num ** 2
c = num ** 3
print("Square of", num, "is:", s)
print("Cube of", num, "is:", c)
Enter a number4
Square of 4 is: 16
Cube of 4 is: 64
What will be the output of the following code?
Country=["India", "Australia", "USA", "China", "Russia", "Ukraine" ]
print(Country[2:5])
print(Country[-5:-2])
Answer
['USA', 'China', 'Russia']
['Australia', 'USA', 'China']
In the given Python code, Country[2:5]
returns ["USA", "China", "Russia"], slicing from index 2 up to index 4. Then, Country[-5:-2]
retrieves a sublist starting from index -5 up to index -3. This results in ["Australia", "USA", "China"].
The indexing table is:
Element | Positive Index | Negative Index |
---|---|---|
"India" | 0 | -6 |
"Australia" | 1 | -5 |
"USA" | 2 | -4 |
"China" | 3 | -3 |
"Russia" | 4 | -2 |
"Ukraine" | 5 | -1 |
Define Relation between IOT and WOT?
Answer
The relationship between IoT (Internet of Things) and WoT (Web of Things) is that both are frameworks for connecting and managing smart devices, but they operate at different levels:
IoT allows us to interact with different devices through internet with the help of smartphones or computers, thus creating a personal network.
WoT allows the use of web services to connect anything in the physical world on the web.
Create a list containing 10 marks the scored by the students—
(i) Write a command to insert the marks of the student at index position 4.
(ii) Write a command to know the length of the list.
Answer
The list containing 10 marks scored by the students is as follows:
marks = [85, 92, 78, 90, 88, 76, 95, 89, 84, 91]
(i)
marks.insert(4, 87)
(ii)
l = len(marks)
What is MySQL?
Answer
MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). MySQL provides us with a rich set of features that support a secure environment for storing, maintaining and accessing data.
Match the followings:
Column 1 | Column 2 |
---|---|
(a) Alternate Key | (A) Number of tuples in a relation |
(b) Relation | (B) Used to specify rules for the data in a table |
(c) Cardinality | (C) A table in a relational database |
(d) Constraint | (D) A candidate key that is not a Primary Key |
Answer
Column 1 | Column 2 |
---|---|
(a) Alternate Key | (D) A candidate key that is not a Primary Key |
(b) Relation | (C) A table in a relational database |
(c) Cardinality | (A) Number of tuples in a relation |
(d) Constraint | (B) Used to specify rules for the data in a table |
Five friends plan to start a new business. However, they have a limited budget and limited computer infrastructure. Which benefits of cloud services they can avail to launch their startup?
Answer
The five friends can benefit from cloud services through the following advantages:
It provides cost efficiency by only paying for the resources they use.
It offers scalability, enabling them to adjust resources based on demand and access advanced technologies without significant infrastructure investment.
It facilitates remote accessibility, allowing team members to collaborate from anywhere, while reducing IT management as the provider handles maintenance and security.
What is a server?
Answer
A server is a computer that has server software loaded on it. Its main job is to manage network resources and share resources for clients.
Write the output for the following print statements in Python.
Sub_Teacher = {"English":"Mr. Gill", "Maths": "Mr. R.N. Pandey", "IP":"Ms. Renu Ahuja", "Physics": "Ms. Meenu Lal", "Chemistry":"Ms. Mamta Goel"}
print(Sub_Teacher['Chemistry']) #Line1
print(Sub_Teacher.keys()) #Line2
print(len(Sub_Teacher)) #Line3
Answer
Ms. Mamta Goel
dict_keys(['English', 'Maths', 'IP', ' Physics', 'Chemistry'])
5
print(Sub_Teacher['Chemistry'])
— This line retrieves the value associated with the key 'Chemistry' from the dictionary, which is "Ms. Mamta Goel".print(Sub_Teacher.keys())
— This line lists all the keys in theSub_Teacher
dictionary. Thekeys()
method returns a list of dictionary’s keys.print(len(Sub_Teacher))
— This line calculates the number of key-value pairs in theSub_Teacher
dictionary using thelen()
function. It returns 5, indicating the total number of key-value pairs in the dictionary.
Rohit, a Librarian has created a Table Book with the following fields:
Bookid, Bookname, Author and Price. He has entered 20 records in the table.
Which command should he use to do the following:
(i) To change the price of Computer Science book from 450 to 500.
(ii) To insert Primary Key in the table.
(iii) What is the difference between delete and drop command.
Answer
(i)
UPDATE Book
SET Price = 500
WHERE Bookname = 'Computer Science' AND Price = 450;
(ii)
ALTER TABLE Book
ADD CONSTRAINT pk_Bookid PRIMARY KEY (Bookid);
(iii) DELETE command is used to remove all the contents from the table, leaving it empty. On the other hand, the DROP command is used to delete the table from the database along with all its data and structure.
The data type list is an ordered sequence which is mutable and made up of one or more elements. Unlike a string which consists of only characters, a list can have elements of different data types such as integer, float, string, tuple or even another list. A list is very useful to group elements of mixed data types. Elements of a list are enclosed in square brackets and are separated by comma.
(i) How is a list different from a dictionary?
(ii) Find the values of y and z after execution:
x=[2, 3]
y=[30, 40]
z=[88, 99]
y.extend(x)
z.append(x)
print (y)
print (z)
Answer
(i) A list in Python is an ordered collection of elements that can be accessed by their index. In contrast, a dictionary is an unordered collection of key-value pairs, where values are accessed using unique keys. Elements of a list are enclosed in square brackets and are separated by comma while dictionaries are enclosed in curly brackets, with keys and values separated by colons and key-value pairs separated by commas.
(ii)
[30, 40, 2, 3]
[88, 99, [2, 3]]
y.extend(x)
modifies the listy
by adding the elements ofx
to the end ofy
. So,y
becomes [30, 40, 2, 3].z.append(x)
adds the entire listx
as a single element to the end ofz
. So,z
becomes [88, 99, [2, 3]].
Write a program in Python to input elements in an empty list. Also delete an element from the list which a user will input.
m = []
n = int(input("Enter the number of elements in list: "))
for i in range(n):
element = input("Enter an element to add to the list: ")
m.append(element)
print("List before deletion:", m)
e = input("Enter the element to delete from the list: ")
m.remove(e)
print("List after deletion:", m)
Enter the number of elements in list: 5
Enter an element to add to the list: 3
Enter an element to add to the list: 6
Enter an element to add to the list: 9
Enter an element to add to the list: 12
Enter an element to add to the list: 15
List before deletion: ['3', '6', '9', '12', '15']
Enter the element to delete from the list: 12
List after deletion: ['3', '6', '9', '15']
Consider the following list.
emp=["Aditya", 40000, "Deepak",50000, "Yashmit", 60000, "Bhavya", 80000]
(i) To Insert the value "Ramit" at index number 4.
(ii) To check whether element 50000 is present in the list or not.
(iii) To display the first 3 elements from the list.
(iv) To remove the fifth element from the list.
Answer
(i)
emp.insert(4, "Ramit")
(ii)
50000 in emp
(iii)
print(emp[:3])
(iv)
del emp[4]
An organization wants to create a table EMPLOYEE, DEPENDENT to maintain the following details about its employees and their dependents.
EMPLOYEE (EmployeeID, AadhaarNumber, Name, Address, Department) DEPENDENT (EmployeeId, DependentName, Relationship).
There are 10 records each in both tables.
(i) Name the attributes of the Employee, which can be used as candidate keys.
(ii) What is the degree of the Employee Table?
(iii) What is the Cardinality of a Dependent Table?
(iv) Which is the Primary key of Dependent Table?
Answer
(i) In the EMPLOYEE table, the attributes AadhaarNumber and EmployeeID can be used as candidate keys. This means that either AadhaarNumber or EmployeeID can uniquely identify each record in the EMPLOYEE table.
(ii) In the EMPLOYEE relation, there are five attributes, resulting in a degree of 5.
(iii) The cardinality of a table is the number of rows (records) it contains. The DEPENDENT table has 10 records. Hence, the cardinality of the DEPENDENT table is 10.
(iv) For the DEPENDENT table, the combination of EmployeeID and DependentName can be used as the primary key because each dependent is uniquely associated with an employee.
Find out the errors in the following code snippet and rewrite the code by underlining the corrections made.
30=y
for i in range (2, 6)
print (true)
else:
print ("Loop over")
Answer
30=y #Error 1
for i in range (2, 6) #Error 2
print(true) #Error 3
else:
print ("Loop over") #Error 4
Error 1 — This is an invalid assignment statement. The variable should be on the left side.
Error 2 — The for
loop header is missing a colon at the end.
Error 3 — 'true' should be 'True' to be a valid boolean value in Python.
Error 4 — The else block is not properly indented.
The corrected code is:
y = 30
for i in range(2, 6):
print(True)
else:
print("Loop over")
Consider the following dictionary and write the answers of the following:
DAYS={"day1": "Sunday", "day2": "Monday", "day3":"Tuesday", 'day5':" Thursday"}
(a) Add 'Wednesday' to the dictionary DAYS as a key 'day4'.
(b) Remove 'day5' item from the dictionary.
(c) Given the Dictionary metal, what is the output generated by the following code:
metal={"first":"gold", "second":"silver", "first":"copper"}
print(metal)
Answer
(a)
DAYS['day4'] = 'Wednesday'
(b)
del DAYS['day5']
(c)
{'first': 'copper', 'second': 'silver'}
Write a program to accept a number from the user and check whether it is a prime number or not.
n = int(input("Enter a number: "))
if n <= 1:
print(n, "is not a prime number.")
else:
factors = 0
for i in range(1, n + 1):
if n % i == 0:
factors += 1
if factors == 2:
print(n, "is a prime number.")
else:
print(n, "is not a prime number.")
Enter a number: 11
11 is a prime number.
Enter a number: 24
24 is not a prime number.
Consider the following table BANK. Write commands of SQL for (i) to (v):
Table: BANK
Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
---|---|---|---|---|
11001 | Atul | Saving | 5000 | 9216245833 |
11002 | Mansha | Current | 10000 | 9466615675 |
11003 | Rahul | Current | 2000 | 9416822012 |
11004 | Mehak | Saving | NULL | 7805634056 |
11005 | Akshay | Fixed Deposit | 50000 | 8732216155 |
(i) Show the details of AccountHolders who have opened a Current Account.
(ii) Display the Account Holder and Contact No. of those who have not deposited any opening balance.
(iii) Display the unique Account type available in the table Bank.
(iv) Display all the details of those Accounts whose Account Holder name’s 2nd character is "a".
(v) Add a new record with the following data.
11006, "Tamanna", "Fixed", 70000, 9255617800
Answer
(i)
SELECT *
FROM BANK
WHERE ACCT_TYPE = 'CURRENT';
+---------+-------------+-----------+-------------+------------+
| Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
+---------+-------------+-----------+-------------+------------+
| 11002 | Mansha | Current | 10000.00 | 9466615675 |
| 11003 | Rahul | Current | 2000.00 | 9416822012 |
+---------+-------------+-----------+-------------+------------+
(ii)
SELECT ACCT_HOLDER, CONTACT_NO
FROM BANK
WHERE OPENING_BAL IS NULL;
+-------------+------------+
| ACCT_HOLDER | CONTACT_NO |
+-------------+------------+
| Mehak | 7805634056 |
+-------------+------------+
(iii)
SELECT DISTINCT Acct_type
FROM BANK;
+---------------+
| Acct_type |
+---------------+
| Saving |
| Current |
| Fixed Deposit |
+---------------+
(iv)
SELECT *
FROM BANK
WHERE Acct_Holder LIKE '_a%';
+---------+-------------+-----------+-------------+------------+
| Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
+---------+-------------+-----------+-------------+------------+
| 11002 | Mansha | Current | 10000.00 | 9466615675 |
| 11003 | Rahul | Current | 2000.00 | 9416822012 |
+---------+-------------+-----------+-------------+------------+
(v)
INSERT INTO BANK
VALUES (11006, 'Tamanna', 'Fixed', 70000, 9255617800);
Mr. Malhotra is working on a MySQL table named Stud with the following table schema:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
regno | int | NO | PRI | NULL | |
name | varchar(30) | YES | NULL | ||
marks | int | YES | 0 | ||
dob | date | NO | NULL |
(i) Which command is used to get the given table schema as output?
(ii) Write the query to create table Stud.
(iii) Write a command to add a column address varchar(20) in table Stud.
(iv) Write a command to delete the column dob from the table Stud.
(v) Can Mr. Malhotra create more than one table in a database?
Answer
(i)
DESCRIBE Stud;
(ii)
CREATE TABLE Stud (
regno int NOT NULL PRIMARY KEY,
name varchar(30) DEFAULT NULL,
marks int DEFAULT 0,
dob date NOT NULL
);
(iii)
ALTER TABLE Stud
ADD address varchar(20);
(iv)
ALTER TABLE Stud
DROP COLUMN dob;
(v) Yes, Mr. Malhotra can create more than one table in a database. In fact, a database can have multiple tables, each with its own schema and data. There is no limit to the number of tables that can be created in a database.