Passing Primitives as Function Parameters in Python

Let's look at the features of passing primitive data types (strings, numbers) to function parameters.

Let's say we have a function that takes a variable tst as a parameter and assigns it the value 2. After the function, we declare a variable num:

pythondef func(tst):
  tst = 2
  print(tst)

num = 3

Let's call the function and pass the variable num as its parameter and print its value to the console. Even though the function parameter specifies num, its value in the global scope has not changed:

pythonfunc(num) # 2 print(num) # 3
Задание 1

What will be the result of running the following code:

pythondef func(txt):
  txt = 'user2'
  return txt

name = 'user1'

res = func(name)
print(res)
print(name)
Задание 2

What will be the result of running the following code:

pythondef func(tst1, tst2):
  tst1 += 1
  tst2 *= 2
  return tst1 + tst2

num1 = 0
num2 = 2

res = func(num1, num2)
print(num1 + num2)
print(res)