मराठी

Write the output of the code given below: a = 30 def call (x): global a if a%2==0: x+=a else: x−=a return x x=20 print (call (35), end="#") print (call (40), end="@") - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

Write the output of the code given below:

a = 30
def call (x):
          global a
          if a%2==0:
             x+=a
          else:
             x−=a
          return x 
x=20
print (call (35), end="#") 
print (call (40), end="@")
लघु उत्तर
Advertisements

उत्तर

Output:

65#70@ 

Explanation:

The call() method examines the value of the global variable a. Because a is 30 and 30 % 2 returns 0 in both function calls, the expression x+=a is executed, resulting in the numbers 30 + 35 and 30 + 40 in the respective calls.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2022-2023 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×