10. what is the output for y?\ny = 0\nfor i in range(0, 8, 2):\n y += i\nprint(y)\n20\n7\n12\n8\nthis…

10. what is the output for y?\ny = 0\nfor i in range(0, 8, 2):\n y += i\nprint(y)\n20\n7\n12\n8\nthis program computes the sum of the even numbers from 0 to 7 and then prints out the sum at the end. in this case, the program computes 0+2+4+6 which equals 12. this sum does not include 8 because the range function stops at the last valid integer less than the given stop argument.\n11. suppose d = {\peter\:33, \john\:36}, to obtain the number of entries in dictionary, use \n d.size()\n size(d)\n len(d)\n d.len()\n12. nested loops are loops inside of other loops.\n true\n false
Answer
10.
Explanation:
Step1: Analyze range function
The range(0, 8, 2) generates a sequence of numbers starting from 0, incrementing by 2, and stopping before 8. So the sequence is 0, 2, 4, 6.
Step2: Calculate sum
We start with y = 0 and then add each number from the sequence to y. So $y=0 + 0+2+4+6=12$.
Answer:
12
11.
Explanation:
In Python, to get the number of key - value pairs (entries) in a dictionary, we use the built - in len() function. We pass the dictionary as an argument to it. For a dictionary d, we write len(d). There is no size() method for dictionaries in Python, and d.len() is not a valid syntax.
Answer:
C. len(d)
12.
Explanation:
By definition, nested loops are loops where one loop is placed inside another loop. For example, a for loop inside another for loop or a while loop inside a for loop etc.
Answer:
A. True