def callon(b=20, a=10):
b = b + a
a = b - a
print(b, "#", a)
return b
x = 100
y = 200
x = callon(x, y)
print(x, "@", y)
y = callon(y)
print(x, "@", y)
Initial state: x = 100, y = 200.
Call 1: callon(100, 200)
b = 100 + 200 = 300
a = 300 - 200 = 100
Print: 300 # 100
Return: 300
Update x to 300.
Print: x, "@", y → 300 @ 200
Call 2: callon(200) (default a = 10)
b = 200 + 10 = 210
a = 210 - 10 = 200
Print: 210 # 200
Return: 210
Update y to 210.
Print: x, "@", y → 300 @ 210
Final Output:
300 # 100
300 @ 200
210 # 200
300 @ 210
Explanation:
The function callon accepts two parameters, b and a, with default values of b=20 and a=10.
Function logic:
- b is updated: b = b + a.
- a is updated: a = b - a.
- The current values of b and a are printed, separated by "#".
- The updated value of b is returned.
The initial call to callon modifies the variable x. The second call modifies y.
The concluding output reflects the state of x and y after these operations.
Our parents told us that we must eat vegetables to be healthy. And it turns out, our parents were right! So, what else did our parents tell?
Our parents told us that we must eat vegetables to be healthy.
And it turns out, our parents were right!
So, what else did our parents tell?
A tuple named subject stores the names of different subjects. Write the Python commands to convert the given tuple to a list and thereafter delete the last element of the list.
Write a user-defined function in Python named showGrades(S) which takes the dictionary S as an argument. The dictionary S contains Name: [Eng, Math, Science] as key:value pairs.
The function displays the corresponding grade obtained by the students according to the following grading rules:
\[ \begin{array}{|c|c|} \hline \textbf{Average of Eng, Math, Science} & \textbf{Grade} \\ \hline \geq 90 & A \\ \hline < 90 \text{ but } \geq 60 & B \\ \hline < 60 & C \\ \hline \end{array} \]
Example: Consider the following dictionary: \[ S = \{\text{"AMIT"}: [92, 86, 64], \text{"NAGMA"}: [65, 42, 43], \text{"DAVID"}: [92, 90, 88]\} \] The output should be: \[ \text{AMIT} - B \\ \text{NAGMA} - C \\ \text{DAVID} - A \]