Program 1:

Exit :
24
Explanation: In the above program, r and s are lambda functions or anonymous functions, and q is an argument to both functions. In the first step, we initialized x as 2. In the second step, we passed x as an argument to the lambda function r, this will return x * 2, which is stored in x. That is, x = 4 now. Similarly, in the third step, we passed x to the lambda function s, so x = 4 * 3.i.e. x = 12 now. Again, in the last step, x is multiplied by 2, passing it to r. Therefore, x = 24.
Program 2:

Exit:
2.0
Explanation: This type of division is called
b
=
False
c
=
False
if
a
or
b
and
c:
print
"GEEKSFORGEEKS"
else
:
print
"pythonengineering"
Exit:
GEEKSFORGEEKS
Explanation: In Python, the AND operator takes precedence over the OR operator. So this is evaluated first. those. (b and c) evaluates to false. The OR operator is now evaluated. Here (True or False) evaluates to True. Thus, the if condition becomes True and GEEKSFORGEEKS is outputted as output.
Program 4:

Output:
3
Explanation: In Python, the priority order is — first NOT, and then AND and in the last OR. Thus, the if condition and the second elif condition evaluates to False, while the third elif condition evaluates to True, which results in 3 as output.
Program 5:
count
=
1
def
doThis ():
global
count
for
i
in
(
1
,
2 < / code> ,
3
):
count
+
=
1
doThis ()
print
count
Output:
4
Explanation: the count variable outside the function is a global variable, and the count variable that the function refers to is the same global variable defined outside the function. This way, changes made to the variable in the function are reflected in the original variable. So, the output of the program — 4.
This article courtesy of Harsh Agarwal . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.
Vincent Bumgarner has been designing software for nearly 20 years, working in many languages on nearly as many platforms. He started using Splunk in 2007 and has enjoyed watching the product evolve ov...
10/07/2020
Grokking Deep Learning teaches you to build deep learning neural networks from scratch! In his immersive style, deep learning expert Andrew Trask shows you the hidden science so you can uncover every ...
05/09/2021
Automate the Boring Stuff with Python PDF, 2nd Edition: Practical Programming for Total Beginners Illustrated Edition. The second edition of this Python bestseller (over 100,000 copies sold in prin...
22/08/2021
Computer Age Statistical Inference: Algorithms, Evidence, and Data Science (Institute of Mathematical Statistics Monographs, Series Number 6). The twentyfirst century has seen a breathtaking expan...
28/08/2021