Informatics Practices
What will be the output of the following code?
for k in range(-10, 0, 2):
print(k)
Python Control Flow
3 Likes
Answer
-10
-8
-6
-4
-2
Working
The for
loop generates a sequence of numbers starting from -10, stopping before 0 (i.e., 2), and incrementing by 2 each time, resulting in the sequence -10, -8, -6, -4, -2.
Answered By
2 Likes
Related Questions
For a given list
L = [1, 2, 3, 4, 5, 6]
the index of element 4 will be:
Assertion (A): The index of element 4 will be 3 or -3.
Reasoning (R): Python list supports forward and backward indexing with -1 to given to left most and 0 to right most element.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Evaluate the following expression:
(i) 12/3+4**2-6/3
(ii) not True or False and True
Differentiate between Cloud Computing and Grid Computing with suitable examples.
Write a Python program to calculate and display the square and cube of an inputted number.