This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 119701. |
Mention the difference between fetchone( ) and fetchmany( ) |
|
Answer» Displaying A record using fetchone( ) The fetchone( ) method returns the next row of a query result set or None in case there is no row left. Example import sqlite3 connection= sqlite3 ,connect(“Academy.db”) cursor = connection.cursor( ) cursor.execute(“SELECT * FROM student”) print(“\nfetch one:”) res = cursor. fetchone( ) print(res) OUTPUT fetch one: (1, ‘Akshay’ , ’B’ , ’M’ , 87.8, ‘2001-12-12’) Displayingusing fetchmany( ) Displaying specified number of records is done by using fetchmany( ).This method returns the next number of rows (n) of the result set. Example : Program to display the content of tuples using fetchmany( ) import sqlite3 connection = sqlite3.connect(” Academy, db”) cursor = connection. cursor( ) cursor.execute(“SELECT * FROM student”) print(“fetching first 3 records:”) result= cursor. fetchmany(3) print( result) OUTPUT fetching first 3 records: [ (1, ‘Akshay’ , ’B’ , ‘M’ , 87.8, ‘2001-12-12’), (2, ‘Aravind’ , ‘A’ , ’M’ , 92.5, ‘2000-08-17’), (3, ‘BASKAR’, ‘C, TVT, 75.2, ‘1998-05-17’)] |
|
| 119702. |
Which one of the following methods displays the specified number of records?(a) fetchone( )(b) fetchmany( )(c) fetchall( )(d) fetchsome( ) |
|
Answer» (b) fetchmany( ) |
|
| 119703. |
The two kinds Of placeholders in sqlite3 module are ……….. and …… |
|
Answer» qmarkstyle, namedstyle |
|
| 119704. |
Write a short note on fetchall( ), fetchone( ) and fetchmany( ) commands? |
|
Answer» cursor. fetchall( ) - fetchall ( )method is to fetch all rows from the database table cursor. fetchone( ) – The fetchone ( ) method returns the next row of a query result set or None in case there is no row left. cursor.fetchmany( ) method that returns the next number of rows (n) of the result set. |
|
| 119705. |
Any changes made in the values of the record should be saved by the command(a) Save(b) Save As(c) Commit(d) Oblige |
|
Answer» Answer (c) Commit |
|
| 119706. |
How will you use order by clause in SQL. Explain with sample program? |
|
Answer» The ORDER BY Clause can be used along with the SELECT statement to sort the data of specific fields in an ordered way. It is used to sort the result-set in ascending or descending order. In this example name and Rollno of the students are displayed in alphabetical order of names. Example import sqlite3 connection= sqlite3.connect(“Academy.db”) cursor = connection.cursor( ) cursor.execute(“SELECT Rollno,sname FROM student Order BY sname”) result = cursor.fetchall( ) print(*result,sep= ” \n”) OUTPUT (1, ‘Akshay’) (2, ‘Aravind’) (3, ‘BASKAR’) (6, ‘PRIYA’) (4, ‘SAJINI’) (7, ‘TARUN’) (5, ‘VARUN’) |
|
| 119707. |
List some aggregate functions in SQL? |
|
Answer» 1. COUNTO 2. SUM( ) 3. MIN( ) 4. AVG( ) 5. MAX( ) |
|
| 119708. |
Write the command to populate record in a table. Give an example? |
|
Answer» To populate (add record) the table “INSERT” command is passed to SQLite. “execute” method executes the SQL command to perform some action. In most cases, you will not literally insert data into a SQL table. You will rather have a lot of data inside of some Python data type e.g. a dictionary or a list, which has to be used as the input of the insert statement. |
|
| 119709. |
Write the Python script to display all the records of the following table using fetchmany( ) |
||||||||||||||||||
Answer»
import sqlite3 connectoin = sqlite3.connect(“company.db”) cursor = connection.cursor() cursor.execute(“Select * from product”) print(“Displaying Records”) result = cursor.fetchmany(5) print(*result, Sep = “\n”) Output: Displaying records (1003, ‘Scanner’ , 10500) (1004, ’Speaker’ , 3000) (1005, ‘Printer’ , 8000) (1008, ’Monitor’ , 15000) (1010, ‘Mouse’ , 700) |
|||||||||||||||||||
| 119710. |
Which command is used to accpet data during run time in python?(a) Insert( ) (b) input( ) (c) create( ) (d) update( ) |
|
Answer» input( ) is used to accpet data during run time in python. |
|
| 119711. |
Which command is used to display the records in asscending or descending order.(a) Group by(b) order by(c) group with(d) order with |
|
Answer» (b) order by |
|
| 119712. |
Write a Python script to create a table called ITEM with following specification? SUPPLIERSuppnoNameCityIcodeSuppQtyS001PrasadDelhi1008100S002AnuBangalore1010200S003ShahidBangalore1008175S004AkilaHydrabad1005195S005GirishHydrabad100325S006ShylajaChennai1008180S007LavanyaChennai10053251. Display Name, City and Itemname of suppliers who do not reside in Delhi.2. Increment the SuppQty of Akila by 40 |
|
Answer» 1. import sqlite3 connection = sqlite3.connect(“ABC.db”) cursor = connection,cursor( ) cursor.execute(“SELECT Supplier.Name, Supplier.city, Item.ItemName FROM Supplier, Item where Supplier.Icode = Item.Icode AND Supplier.city NOT IN ‘Delhi'”) co=[i[0] for i in cursor.description] print(co) result = cursor. fetchall( ) for r in result: print(r) Output: [‘Name’ , ‘City’ , ‘ItemName’] [‘Anu’ , ‘Bangalore’ , ‘Mouse’] [‘Shahid’ , ‘Bangalore’ , ‘Monitor’] [‘Akila’ , ‘Hydrabad’ , ‘Printer’] [‘Girish’ , ‘Hydrabad’ , ‘Scanner’] [‘Shylaja’ , ‘Chennai’ , ‘Monitor’] [‘Lavanya’ , ‘Mumbai’ , ‘Printer’] 2. Increment the suppQty of Akila by 40 import sqlite3 connection = sqlite3.connect(“ABC.db”) cursor = connection.cursor( ) cursor.execute(“UPDATE Supplier SET SuppQty = SuppQty + 40 where Name = ‘Akila'”) cursor.commit( ) result = cursor. fetchall( ) print(result) connection.close( ) Output: (S004, ‘Akila’ , ‘Hydrabad’ , 1005, 235) |
|
| 119713. |
What is the use of HAVING clause. Give an example python script? |
|
Answer» Having clause is used to filter data based on the group functions. This is similar to WHERE condition but can be used only with group functions. Group functions cannot be used in WHERE Clause but can be used in HAVING clause. Example import sqlite3 connection= sqlite3.connect(“Academy.db”) cursor = connection. cursor( ) cursor.execute(“SELECT GENDER,COUNT(GENDER) FROM Student GROUP BY GENDER HAVING COUNT(GENDER)>3 “) result = cursor. fetchall( ) co= [i[0] for i in cursor, description] print(co) print( result) OUTPUT [‘gender’ , ‘COUNT(GENDER)’] [(‘M’ , 5)] |
|
| 119714. |
Which function returns the smallest value of the selected columns(a) MIN( )(b) MINIMUM( )(c) SMALL( )(d) LEAST( ) |
|
Answer» MIN( ) function returns the smallest value of the selected columns |
|
| 119715. |
Which clause returns are record for each group?(a) Select(b) group in(c) group with(d) group by |
|
Answer» (d) group by |
|
| 119716. |
……… is used to display the field names of the table |
|
Answer» cursor description |
|
| 119717. |
What will be the result of fetchone( ) method if no row is left?(a) 1(b) 2(c) 3(d) none |
|
Answer» Answer is (d) none |
|
| 119718. |
Find the correct statement.(a) A record can be deleted using sql command(b) A record can be deleted with python(c) both are true |
|
Answer» (c) both are true |
|
| 119719. |
Which of the following executes the SQL command to perform some action?(a) Execute( )(b) Key( )(c) Cursor( )(d) run( ) |
|
Answer» (a) Execute( ) |
|
| 119720. |
Which method returns the next row of a query result set?(a) Fetch ne( )(b) fetch all( )(c) fetch next( )(d) fetch last( ) |
|
Answer» (a) Fetch ne( ) |
|
| 119721. |
A) Query result can be stored in csv file.R) To display the query output in a tabular form(a) R is the reason for A(b) R is wrong(c) A is wrong(d) both are not related |
|
Answer» (a) R is the reason for A |
|
| 119722. |
Considers the following tables appointments and students and write the python script to display the following output?RollnoSnameDutyAge1AkshayPrefect172AravindSecretary16 |
|
Answer» Given: Student → Table Rollno, Sname, grade, gender, average, birth-date Appointment → rollno, duty, age Example import sqlite3 connection = sqlite3.connect(“Academy.db”) cursor = connection.cursor( ) cursor.execute(“””DROP TABLE Appointment;”””) sql_command = “”” CREATE TABLE Appointment(rollnointprimarkey,Dutyvarchar(10),age int)””” cursor.execute(sqlcommand) sql command – ‘””INSERT INTO Appointment (Rollno,Duty ,age) VALUES (“1” , “Prefect” , “17”);””” cursor, execute(sql_command) sql_command = ”””INSERT INTO Appointment (Rollno,Duty, age) VALUES (“2” , “Secretary” , “16”);””” cursor.execute(sql_command) # never forget this, if you want the changes to be saved: connection.commit( ) cursor.execute(“SELECT student.rollno,student.sname,Appointment. Duty,Appointment.Age FROM student,Appointment where student. rollno= Appointment.rollno”) #print (cursor.description) to display the field names of the table co= [i[0] for i in cursor.description] print(co) # Field informations can be readfrom cursor.description. result = cursor. fetchall( ) for r in result: print(r) OUTPUT [‘Rollno’, ‘Sname’ , ‘Duty’ , ‘age’] (1, ‘Akshay’ , ‘Prefect’ , 17) (2, ’Aravind’ , ’Secretary’ , 16) |
|
| 119723. |
Write python program to accept 5 students names, their ages and ids during run time and display all the records from the table? |
|
Answer» In this example we are going to accept data using Python input() command during runtime and then going to write in the Table called “Person” Example # code for executing query using input data import sqlite3 #creates a database in RAM con =sqlite3.connect(“Academy,db”) cur =con.cursor( ) cur.execute(“DROP Table person”) cur.execute(“create table person (name, age, id)”) print(“Enter 5 students names:”) who =[input( ) for i in range(5)] print(“Enter their ages respectively:”) age =[int(input()) for i in range(5)] print(“Enter their ids respectively:”) p_d =[int(input( ))for i in range(5)] n =len(who) for i in range(n): #This is the q-mark style: cur.execute(“insert into person values(?,?,?)” , (who[i], age[i], p_id[i])) #And this is the named style: cur.execute(“select *from person”) #Fetches all entries from table print(“Displaying All the Records From Person Table”) print (*cur.fetchall(), sep= ’\n’) OUTPUT Enter 5 students names: RAM KEERTHANA KRISHNA HARISH GIRISH Enter their ages respectively: 28 12 21 18 16 Enter their ids respectively: 1 2 3 4 5 Displaying All the Records From Person Table (‘RAM’ , 28, 1) (‘KEERTHANA’ , 12, 2) (‘KRISHNA’ , 21, 3) (‘HARISH’ , 18,4) (‘GIRISH’ , 16, 5) |
|
| 119724. |
Mention the default modes of the File? |
|
Answer» You can specify the mode while opening a file. In mode, you can specify whether you want to read ‘r’ , write ‘w’ or append ‘a’ to the file. You can also specify “text or binary” in which the file is to be opened. The default is reading in text mode. In this mode, while reading from the file the data w’ould . be in the format of strings. |
|
| 119725. |
Which command in SQL is used to retrieve or fetch data from a table in the database?(a) Select (b) Fetch (c) retrieve (d) create |
|
Answer» Select SQL is used to retrieve or fetch data from a table in the database. |
|
| 119726. |
Which table holds the key information about the database tables?(a) page(b) select(c) primary(d) Master |
|
Answer» Answer is (d) Master |
|
| 119727. |
Which method is used to fetch all rows from the database table?(a) Fetch( )(b) fetchall( )(c) printall( )(d) retrieveall( ) |
|
Answer» (b) fetchall( ) |
|
| 119728. |
The ……….. is a software application for the interaction between users and the databases. |
|
Answer» Database Management System |
|
| 119729. |
Write a program to display list of tables created in a database? Example |
|
Answer» import sqlite3 con= sqlite3 .connect(‘Academy.db’) cursor = con.cursor( ) cursor.execute(“SELECT name FROM sqlitemaster WHERE type-table’;”) print(cursor. fetchall( )) OUTPUT [(‘Student’ ,), (‘Appointment’ ,), (‘Person’ ,)] |
|
| 119730. |
Mention the users who uses the Database? |
|
Answer» Users of database can be human users, other programs or applications. |
|
| 119731. |
In which mode of expression, the concentration of a solution remains independent of temperature?(a) Molarity(b) Normality(c) Formality(d) Molality |
|
Answer» Correct option is (d) Molality |
|
| 119732. |
What is cube root? |
|
Answer» The cube root of a number n is the number whose cube is n. It is denoted by \(\sqrt[3] {n}\), e.g., \(\sqrt[3]{8}\) = 2. |
|
| 119733. |
Total surface area of a cube is 864 sq.cm. Find its volume. |
|
Answer» Given: Total surface area of cube = 864 sq. cm To find: Volume of cube Solution: i. Total surface area of cube = 6l2 ∴ 864 = 6l2 ∴ l2 = \(\sqrt[864]6\) ∴ l2 = 144 ∴ l = \(\sqrt{144}\)… [Taking square root on both sides] = 12 cm ii. Volume of cube = l2 = 123 = 1728 cubic cm. ∴ The volume of cube is 1728 cubic cm. |
|
| 119734. |
How to find cube root? |
|
Answer» The cube root of a number can be found by resolving the number into prime factors, making groups of 3 equal factors, picking out one of the equal factors from each group and multiplying the factors so picked. 1728 = \(\underline{2\times2\times2}\) x \(\underline{2\times2\times2}\) x \(\underline{3\times3\times3}\) \(\sqrt[3] {1728}\) = 2 x 2 x 3 = 12 |
|
| 119735. |
What will be the cube root of a negative numbers? |
|
Answer» The cube root of a negative perfect cube is negative, e.g.,\(\sqrt[3] {-125}\) = -5 |
|
| 119736. |
For any integer a and b. |
|
Answer» For any integer a and b, we have (i) \(\sqrt[3] {a \times b}\) = \(\sqrt[3] {a} \times\sqrt[3]{b}\) (ii) \(\sqrt[3]{\frac{a}{b}}\) = \(\frac{\sqrt[3] {a}}{\sqrt[3]{b}}\) |
|
| 119737. |
\(\sqrt[3]{\sqrt{0.000064}}\) is equal to(a) 0.02(b) 0.2(c) 2(d) 0.4 |
|
Answer» (b) 0.2 \(\sqrt[3]{\sqrt{0.000064}}\) = \(\sqrt[3]{\sqrt\frac{64}{1000000}}\) \(\sqrt[3]{\frac{8}{1000}}\) = \(\frac{2}{10}\) = 0.2 |
|
| 119738. |
Cube root of a number when divided by 5 results in 25, what is the number ?(a) 5(b) 1253(c) 53(d) 125 |
|
Answer» (b) 1253 Let the number be x. Then, \(\frac{\sqrt[3]X}{5}\) = 25 \(\Rightarrow\) \(\sqrt[3]{X}\) = 125 \(\Rightarrow\) x = (125)3 |
|
| 119739. |
\(\sqrt[2] {\sqrt[3]{X \times 0.000001}}\) = 0.2. The value of x is(a) 8(b) 16(c) 32(d) 64 |
|
Answer» (d) 64 \(\sqrt[2]{\sqrt[3]{X\times0.000001}}\) = 0.2 \(\Rightarrow\) \(\sqrt[3]{X \times 0.000001}\) = (0.2)2 = 0.04 (Squaring both the sides) \(\Rightarrow\) x x 0.000001 = (0.04)3 = 0.000064 (on taking the cube of both the sides) \(\Rightarrow\) x = \(\frac{0.000064}{0.000001}\) = 64. |
|
| 119740. |
\(\sqrt[3]{\sqrt[3]{a^3}}\) is equal to(a) a(b) 1(c) \(a^\frac{1}{3}\)(d) a3 |
|
Answer» (c) \(a^{\frac{1}{3}}\) \(\sqrt[3]{\sqrt[3]{a^3}}\) = \(\big((a^3)^{\frac{1}{3}\big)^{\frac{1}{3}}}\) = \(a^{3\times\frac{1}{9}}\) = \(a^{\frac{1}{3}}\) |
|
| 119741. |
Suppose you have been to a strange place where people use a language which is different from yours/new to you. How will you communicate with them in that situation? Discuss with your friends. |
|
Answer» When we are in a strange place. Our body language comes to our help. We have to mime them and express what we feel or what we do, some situations require body gestures some times our actions reflect our inner strengths and our own personality. Sometimes we have to use signs and smybols with all these things we communicate. |
|
| 119742. |
What does the poet ask us not to let die? |
|
Answer» The poet asks us not to let die the thought. |
|
| 119743. |
“English is a game to play”. How does the poet Justify it? |
|
Answer» English plays an important role in communicating with any people throughout the world. Through it the world wide knowledge can be gained. It is a wonderful game in matching the words to the brightest thoughts in our head. So that they come out and true. They brush our wrong ideas and feed our thoughts to become the loveliest things. |
|
| 119744. |
Which one depresses brain activity?A. Sedatives and tranquillisersB. Opiate narcoticsC. Both A and BD. Hallucinogens |
| Answer» Correct Answer - C | |
| 119745. |
Psychotrophic drugsA. Are mood altering drugsB. Treat mental illnessC. Increase physical activityD. Decrese physical acitivity |
| Answer» Correct Answer - A | |
| 119746. |
Psychotrophic drugs includeA. Sedatives, tranquillisers and stimulantsB. Narcotics and hallucinogensC. Both A and BD. Vodka |
| Answer» Correct Answer - A | |
| 119747. |
Match te columns A. a-s, b-t, c-r, d-pB. a-t, b-q, c-r, d-pC. a-t, b-r, c-q, d-pD. a-t, b-r, c-p, d-q |
|
Answer» Correct Answer - D (i). Second - trademark for sedative hyponotic drug secobarbital (ii). Nembutal - trademark for pentobarbital (an adjunct to anaesthesia) |
|
| 119748. |
Which of the following is used in the treatment of cholera, acne vulgaris? (a) fluoro quinolone (b) aminoglycosides (c) tetracycline (d) macrolides |
|
Answer» (c) tetracycline |
|
| 119749. |
Narcotics includeA. PapaverB. NicotianaC. DaturaD. Rauwolfia |
|
Answer» Correct Answer - A Datura has also narcotic properties in its seeds, leaves and flowering tops |
|
| 119750. |
Narcotics areA. Amphetamine and caffeineB. Morphine and HeroineC. LSD and CocaineD. Barbiturate and benzodiazepine |
| Answer» Correct Answer - B | |