What is the expected result of the following code?
1. import os
2.
3. os.mkdir('pictures')
4. os.chdir('pictures')
5.
6. print(os.getcwd())
You create a function to calculate the power of a number by using Python.
You need to ensure that the function is documented with comments
You create the following code. Line numbers are included for reference only.
1. 01 # The calc_power function calculates exponents
2. 02 # x is the base
3. 03 # y is the exponent
4. 04 # The value of x raised to the y power is returned
5. 05 def calc_power(x, y):
6. 06 comment = "# Return the value"
7. 07 return x ** y # raise x to the y power
Which of the following statements are true?
Choose two.
Is there a way to check if a class is a subclass of another class?
What is the expected output of the following code?
1. def func(x, y=2):
2. num = 1
3. for i in range(y):
4. num = num * x
5. return num
6.
7.
8. print(func(4))
9. print(func(4, 4))
What is the expected output of the following code?
1. import random
2.
3. random.seed(0)
4. x = random.choice([1, 2])
5. random.seed(0)
6. y = random.choice([1, 2])
7. print(x - y)
© Copyrights FreePDFQuestions 2026. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (FreePDFQuestions). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the FreePDFQuestions.