๐Ÿง  Unit I: Computational Thinking and Programming โ€“ 2 Functions & Python Basics Which of the following is a valid Python function definition? a) function add(x, y): b) def add(x, y): c) func add(x, y): d) def add(x, y): return x + y Answer: b) def add(x, y): What will be the output of the following Python code? def func(x=5, y=10): return x + y print(func()) a) 15 b) 5 c) 10 d) Error Answer: a) 15 Which of the following is the correct syntax to define a function in Python? a) function myFunc(): b) def myFunc(): c) func myFunc[]: d) function: myFunc() Answer: b) def myFunc(): File Handling Which function is used to open a file in Python? a) openfile() b) fileopen() c) open() d) file() Answer: c) open() What does the readlines() method do in Python? a) Reads the entire file b) Reads a single line c) Reads all lines and returns them as a list d) Reads the first n lines Answer: c) Reads all lines and returns them as a list Which of the following file modes is used to append data to an existing file? a) 'r' b) 'w' c) 'a' d) 'x' Answer: c) 'a' Data Structures: Stack Which list method can be used to perform the Pop operation in a stack implemented by a list? a) pop() b) pop(1) c) remove() d) pop(0) Answer: a) pop() Which list method can be used to perform the Push operation in a stack implemented by a list? a) append() b) extend() c) push() d) insert() Answer: a) append() ๐ŸŒ Unit II: Computer Networks Which of the following is a wired communication medium? a) Radio waves b) Co-axial cable c) Micro waves d) Infrared waves Answer: b) Co-axial cable Which network topology connects all devices to a central device? a) Bus b) Star c) Tree d) Ring Answer: b) Star Which protocol is used for secure communication over the internet? a) HTTP b) FTP c) HTTPS d) SMTP Answer: c) HTTPS Which device is used to connect multiple networks? a) Hub b) Switch c) Router d) Repeater Answer: c) Router ๐Ÿ—„๏ธ Unit III: Database Management Which SQL command is used to retrieve data from a database? a) SELECT b) INSERT c) UPDATE d) DELETE Answer: a) SELECT Which SQL clause is used to sort the result set in ascending or descending order? a) ORDER BY b) GROUP BY c) SORT BY d) FILTER BY Answer: a) ORDER BY Which of the following is a valid data type in SQL? a) integer b) float c) varchar d) All of the above Answer: d) All of the above Which SQL clause is used to filter records? a) WHERE b) HAVING c) GROUP BY d) FILTER Answer: a) WHERE Which function is used to count the number of rows in a SQL query? a) COUNT() b) SUM() c) AVG() d) MAX() Answer: a) COUNT() Which Python module is used to interact with SQL databases? a) mysql.connector b) sqlite3 c) mysql d) database Answer: (a)mysql.connector and (b) sqlite3 ๐Ÿง  Python Programming & Functions Which of the following is a valid Python identifier? a) 123abc b) _abc123 c) @abc d) abc@123 Answer: b) _abc123 What will be the output of the following Python code? python Copy Edit def func(x=5, y=10): return x + y print(func()) a) 15 b) 5 c) 10 d) Error Answer: a) 15 Which of the following is NOT a valid file mode in Python? a) 'r' b) 'w+' c) 'rw' d) 'a' Answer: c) 'rw' What does the readlines() method do in Python? a) Reads the entire file b) Reads a single line c) Reads all lines and returns them as a list d) Reads the first n lines Answer: c) Reads all lines and returns them as a list Which of the following is the correct syntax to define a function in Python? a) function myFunc(): b) def myFunc(): c) func myFunc[]: d) function: myFunc() Answer: b) def myFunc(): ๐Ÿ—„๏ธ File Handling Which function is used to open a file in Python? a) openfile() b) fileopen() c) open() d) file() Answer: c) open() What does the write() method do in Python? a) Reads data from a file b) Writes data to a file c) Closes a file d) Appends data to a file Answer: b) Writes data to a file Which of the following file modes is used to append data to an existing file? a) 'r' b) 'w' c) 'a' d) 'x' Answer: c) 'a' ๐Ÿ“Š Data Structures & Algorithms Which of the following is an immutable data type in Python? a) List b) Dictionary c) Set d) Tuple Answer: d) Tuple What will be the output of the following Python code? python Copy Edit lst = [1, 2, 3, 4] lst.append([5, 6]) print(len(lst)) a) 4 b) 5 c) 6 d) 7 Answer: b) 5 ๐Ÿงพ SQL & Database Management Which SQL command is used to retrieve data from a database? a) SELECT b) INSERT c) UPDATE d) DELETE Answer: a) SELECT Which SQL clause is used to sort the result set in ascending or descending order? a) ORDER BY b) GROUP BY c) SORT BY d) FILTER BY Answer: a) ORDER BY ---------------------------------------------------- ๐Ÿ”น Python Basics & Functions What is the output of print(2 ** 3 ** 2)? A) 512 B) 64 C) 256 D) 36 Answer: A Which of the following is not a keyword in Python? A) pass B) eval C) assert D) nonlocal Answer: B What will type([]) return? A) B) C) D) Answer: C Which function is used to find the length of a string in Python? A) count() B) len() C) length() D) str_len() Answer: B ๐Ÿ”น Data Structures (Lists, Tuples, Dictionaries) Which of the following is mutable? A) Tuple B) List C) String D) Integer Answer: B Which method is used to add an element to the end of a list? A) append() B) add() C) insert() D) push() Answer: A What will be the output of len({'a':1, 'b':2, 'c':3})? A) 2 B) 3 C) 6 D) Error Answer: B Which of the following methods is used to remove all items from a dictionary? A) del() B) remove() C) clear() D) pop() Answer: C ๐Ÿ”น File Handling Which file mode is used for reading and writing a file in binary format? A) r+ B) rb+ C) w+ D) a+ Answer: B Which method is used to read a single line from a text file? A) read() B) readline() C) readlines() D) input() Answer: B Which of the following statements closes a file in Python? A) file.end() B) file.close() C) close(file) D) file.finish() Answer: B ๐Ÿ”น SQL & Databases Which SQL keyword is used to retrieve data from a database? A) GET B) SELECT C) EXTRACT D) FETCH Answer: B Which of the following is not a valid SQL command? A) SELECT B) INSERT C) UPDATE D) JOIN INTO Answer: D What is the result of the query: SELECT COUNT(*) FROM Students;? A) The sum of marks B) Number of students C) Maximum roll number D) Average of marks Answer: B ๐Ÿ”น Networking & Cyber Safety What does URL stand for? A) Universal Resource Locator B) Uniform Resource Locator C) Universal Routing Link D) Uniform Routing Locator Answer: B Which of the following is an example of a web browser? A) Google B) Yahoo C) Chrome D) Bing Answer: C Which of the following protocols is used for sending emails? A) FTP B) SMTP C) HTTP D) POP Answer: B Which of the following is a strong password? A) 123456 B) password C) Qw!8@zY#1 D) abcdef Answer: C Which of the following is an IP address? A) www.google.com B) 256.1.1.1 C) 192.168.0.1 D) http://server Answer: C What is the full form of Wi-Fi? A) Wireless Fidelity B) Wired Fiber C) Web Interface D) Wide Frequency Answer: A