x 1 2 7 y 0 while lenx i 0 y y ninx y remove ninx xin
Solution
7) Output is nothing
Expalnation:
The program goes into an infinite loop as len(x) never to be 0. So condition in while loop will be always true and loop runs infinite times.
You have to use Ctrl+C to exit the program.
______________________________________________________________________________
8) Output is
False
True
Explanation:
The function test_word(string) checks whether given string is Palindrome
i) whe we pass string “hello”
first it calculates length of string in str_len = len(string)
then in for loop i = 0 to (str_len/2) i.e. i= 0 to 2
then it’s comparing string[0] with string[4]
if it’s not matching then loop stop otherwise it will continue for next iteration i.e. i=1.
Hence answer is False
______________________________________________________________________________
9) Output is
Start
End
Explanation :
Here we are creating array p but not adding any element in p
i.e. its an array of zero length i.e. Null array
so condition in while loop fails and loop stops and prints next statement i.e. End
______________________________________________________________________________
10) Output is
3489
Explanation:
The function is called as a(b(c(3)))
This is the case of nested functions so here order will be
c(d)->b(c(d))->a(b(c(d)))
so first c(3) is called and printed 3 with concatenation end=’ ’ and will return 4
now b(4) will get called and will print 4 after 3 i.e. 34
this function will return value 8.
Now a(8) got called and prints 348 on the screen and returns 9 to the caller
So finally print(a(b(c(d))))) called and prints a i.e. 9
So ans will be 3489
______________________________________________________________________________
11) Output is
-Done!
Explanation:
Here in for loop x range is 0 to len(list) = 6
We are comparing list element with ‘ ‘(space)
So if condition fails as its ASCII comparison(for space ascii value is 32 and q is 113) and loop breaks i.e. terminates and print the last statement i.e. -Done
______________________________________________________________________________
![x = [1, 2, 7, ] y = [0] while len(x) i = 0; y - y = [nin(x)] y - remove (nin(x)) x-insert(0, min(y)) print(x) def test_word (string): result - True sr_len -len x = [1, 2, 7, ] y = [0] while len(x) i = 0; y - y = [nin(x)] y - remove (nin(x)) x-insert(0, min(y)) print(x) def test_word (string): result - True sr_len -len](/WebImages/1/x-1-2-7-y-0-while-lenx-i-0-y-y-ninx-y-remove-ninx-xin-970003-1761495810-0.webp)
![x = [1, 2, 7, ] y = [0] while len(x) i = 0; y - y = [nin(x)] y - remove (nin(x)) x-insert(0, min(y)) print(x) def test_word (string): result - True sr_len -len x = [1, 2, 7, ] y = [0] while len(x) i = 0; y - y = [nin(x)] y - remove (nin(x)) x-insert(0, min(y)) print(x) def test_word (string): result - True sr_len -len](/WebImages/1/x-1-2-7-y-0-while-lenx-i-0-y-y-ninx-y-remove-ninx-xin-970003-1761495810-1.webp)