Passage d'une variable d'une fonction a une autre|TP_3.9|ADD sendtofunction.py

This commit is contained in:
Fred Z 2018-02-11 08:49:05 +01:00
parent 07e4c39586
commit bde50f38f9
1 changed files with 23 additions and 0 deletions

23
sendtofucntion.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#https://stackoverflow.com/questions/48729156/how-to-share-values-between-functions-in-python
from random import randrange
a = 20
b = 45
def function1():
coin = randrange(0, 100)
a2 = a + coin
return a2
def function2(coin):
b2 = b + coin
return b2
coin = function1() - a
f2 = function2(coin)
print("coin: {}".format(coin))
print("f2: {}".format(f2))