0% found this document useful (0 votes)
51 views

ITC Lab Quiz

The document appears to be a quiz or test covering introductory concepts in computing and data science. It contains 20 multiple choice questions testing knowledge of topics like Python commenting, loops, functions, files, Tkinter, NumPy, and basic data structures.

Uploaded by

Abraiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

ITC Lab Quiz

The document appears to be a quiz or test covering introductory concepts in computing and data science. It contains 20 multiple choice questions testing knowledge of topics like Python commenting, loops, functions, files, Tkinter, NumPy, and basic data structures.

Uploaded by

Abraiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of Electrical, Electronics & Telecom Engineering

UET (Lahore) Faisalabad Campus


Reg. No. _____________

EE132L- Introduction to Computing and Data Science Time: 30 minutes

FALL 2023, Session 2023 ( 01st Semester) Marks=20

1. Which of the following is the correct way to comment out multiple lines of code in Python?

a) # This is a comment

b) /* This is a comment */

c) <!-- This is a comment -->

d) ''' This is a comment '''

2. What is the purpose of the continue statement in Python?

a) Terminates the current loop

b) Skips the current iteration of the loop

c) Continues to the next iteration of the loop

d) Exits the entire program

3. What is the output of following code:

my_list = [1, 2, 3, 4, 5]

print(my_list[2:4])

a) [1, 2]
b) [2, 3]
c) [3, 4]
d) [4, 5]

4. What is the purpose of the following Python code?

with open('example.txt', 'r') as file:

content = file.read()

words = content.split()

w = set(words)

print(len(w))

a) Counts the number of characters in the file

b) Counts the number of lines in the file

c) Counts the number of unique words in the file

d) Prints the content of the file


5. What is the output of the following Python code?

numbers = [1, 2, 3, 4, 5]

new_numbers = [x**2 for x in numbers if x % 2 == 0]

print(new_numbers)

a) [1, 4, 9, 16, 25]

b) [4, 16]

c) [2, 4]

d) [1, 3, 5]

6. Find the error in the following code:

def add_numbers(a, b):

return a + b

result = add_numbers(5, 7, 2)

print(result)

a) The function is missing a return statement

b) Too many arguments passed to the function

c) Incorrect function name

d) No error in the code

7. What is the error in the following Python code?

for i in range(5)

print(i)

------for loop colon missing------------

8. Identify the correct way to open a file in binary mode for writing:

a) file = open("output.txt", "w")

b) file = open("output.txt", "r+")

c) file = open("output.txt", "wb")

d) file = open("output.txt", "br")

9. How can you bind a function my_function to a button click event in Tkinter?

a) button.bind(my_function)

b) button.onClick(my_function)

c) button.configure(command=my_function)

d) bind(button, my_function)

10. How can you create a button with the label "Click Me" in Tkinter?

a) Button("Click Me")

b) Button(text="Click Me")

c) Button(label="Click Me")
d) create_button("Click Me")

11. How can you plot a line graph in Matplotlib with x-values [1, 2, 3] and y-values [4, 5, 6]?

a) line([1, 2, 3], [4, 5, 6])

b) plot([1, 2, 3], [4, 5, 6])

c) scatter([1, 2, 3], [4, 5, 6])

d) bar([1, 2, 3], [4, 5, 6])

12. How can you find the index of the maximum value in a NumPy array arr?

a) index(max(arr))

b) max(arr).index()

c) argmax(arr)

d) find_max_index(arr)

13. What does the NumPy function "np.concatenate" do?

a) Adds two arrays element-wise

b) Joins arrays along an existing axis

c) Finds the common elements between two arrays

d) Multiplies corresponding elements of two arrays

14. How can you create an infinite loop in Python?

a) for i in range(10):

b) while True:

c) for i in range(5):

d) while False:

15. How can you check if a value is in a list using an if statement?

a) if value in list:

b) if list.contains(value):

c) if value.contains(list):

d) if list in value:

16. What is the output of the following code?

text = "This is a sample text."

result = text.count('is')

print(result)

a) 1

b) 2

c) 3

d) 4
17. Identify and correct the error in the following code:

def greet(name):

return f"Hello, {name}!"

result = greet("John")

print(result)

a) Add a colon after def greet(name)

b) Remove the return statement in the greet function

c) Add parentheses after print(result)

d) No error in the code

18. What will be the output of the following code snippet?

a = [1, 2, 3]

a = tuple(a)

a[0] = 2

print(a)

a) [2, 2, 3]

b) (2,2,3)

c) Error

d) (1,2,3)

19. What will be the output of the following code snippet?

example = ["Sunday", "Monday", "Tuesday", "Wednesday"];

print(example[-3:-1])

a) ["Monday", "Tuesday "]

b) ["Sunday", "Monday "]

c) ["Tuesday", "Wednesday"]

d) [“Wednesday", "Monday"]

20. What will be the output of the following code snippet?

a = [1, 2, 3, 4]

b = [3, 4, 5, 6]

c = [x for x in a if x not in b]

print(c)

a) [1,2]

b) [5,6]

c) [1,2,5,6]

d) [3,4]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy