Question 1
Q1-def square(x):
return x * x
result = square(3)
What is the value of result after executing the code?
Question 2
Q2-def add_numbers(a, b):
return a + b
result = add_numbers(4, 7)
What is the value of result after executing the code?
Question 3
Q3-import random
num_list = [1, 2, 3, 4, 5]
selected_num = random.choice(num_list)
What does the above code do?
Question 4
Q4-from math import sqrt
result = sqrt(16)
What is the value of result after executing the code?
Question 5
Q5-class Car:
def __init__(self, make, model):
self.make = make
self.model = model
car1 = Car("Toyota", "Camry")
What is car1 in the above code?
Question 6
Q6-class Circle:
def __init__(self, radius):
self.radius = radius
def calculate_area(self):
return 3.14 * self.radius * self.radius
circle1 = Circle(5)
area = circle1.calculate_area()
What does the area variable represent in the above code?
Question 8
Q8-import datetime
current_time = datetime.datetime.now()
What is current_time in the above code?
Question 9
Q9-from math import pi
class Circle:
def __init__(self, radius):
self.radius = radius
def calculate_area(self):
return pi * self.radius * self.radius
circle1 = Circle(6)
area = circle1.calculate_area()
What is the area variable in the above code?
Question 10
Q10-import random
class Dice:
def __init__(self):
self.value = None
def roll(self):
self.value = random.randint(1, 6)
my_dice = Dice()
my_dice.roll()
What does the roll method in the above code do?
There are 10 questions to complete.