diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-25 17:10:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-25 17:10:49 +0200 |
| commit | d6c61d988bfa4255baf9cdae42db59ebee38363f (patch) | |
| tree | 118ff3c2424e735149c145524965a4a337e50beb /src/Lecture4/live/live4.py | |
| parent | 46eef66b1e1571c77dc828d7e950b129b4c8bfd0 (diff) | |
| download | mathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.tar.gz mathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.zip | |
Added files
Diffstat (limited to 'src/Lecture4/live/live4.py')
| -rw-r--r-- | src/Lecture4/live/live4.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Lecture4/live/live4.py b/src/Lecture4/live/live4.py new file mode 100644 index 0000000..b011675 --- /dev/null +++ b/src/Lecture4/live/live4.py | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | |||
| 2 | def fun(a, b): | ||
| 3 | print("This is function fun") | ||
| 4 | print("I am executing!") | ||
| 5 | print("Your parameter a:", a) | ||
| 6 | z = a + b | ||
| 7 | if z > 10: | ||
| 8 | print("Your sum is large!", z) | ||
| 9 | while z > 5: | ||
| 10 | print("Decreasing sum:", z-1) | ||
| 11 | z = z - 1 | ||
| 12 | |||
| 13 | #fun(2, 11) | ||
| 14 | #print("..") | ||
| 15 | #fun(0, 7) | ||
| 16 | |||
| 17 | def g(x, y): | ||
| 18 | #print("This is function g") | ||
| 19 | return (x**2 +1)*y | ||
| 20 | |||
| 21 | print(g(10,2)-100) | ||
| 22 | |||
| 23 | |||
| 24 | def fibo(n): | ||
| 25 | if n == 0: | ||
| 26 | return 0 | ||
| 27 | if n == 1: | ||
| 28 | return 1 | ||
| 29 | return fibo(n-1) + fibo(n-2) | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | print(fibo(5)) | ||
| 34 | F = [fibo(x) for x in range(6)] | ||
| 35 | print(F) | ||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
