mirror of
https://github.com/RustyRaptor/CS278.git
synced 2026-12-03 20:15:16 -07:00
FInished lab 9
This commit is contained in:
1 parent
03afd42f6f
commit
4983b7ea1a
3 files changed
+104
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# CS 278 Lab 9
|
||||
|
||||
Done in python
|
||||
|
||||
## How to Run on CS Machines
|
||||
|
||||
|
||||
```
|
||||
cd <source folder>
|
||||
python3 lab9.py
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
def sum1(n):
|
||||
# base case
|
||||
if n == 0:
|
||||
return 2 ** 0
|
||||
|
||||
# recursive case
|
||||
return 2 ** n + sum1(n - 1)
|
||||
|
||||
|
||||
def sum2(n):
|
||||
# base case
|
||||
if n == 1:
|
||||
return 2
|
||||
|
||||
# recursive case
|
||||
return (n * (n + 1)) + (sum2(n - 1))
|
||||
|
||||
|
||||
user_n = int(input("Please enter the value of n: "))
|
||||
|
||||
print("The value of the 1st summation is", sum1(user_n))
|
||||
print("The value of the 2nd summation is", sum2(user_n))
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
from turtle import *
|
||||
rt(90)
|
||||
rt(-90)
|
||||
rt(-90)
|
||||
rt(300)
|
||||
rt(-300)
|
||||
fd(300)
|
||||
rt(-180)
|
||||
fd(300)
|
||||
rt(90)
|
||||
fd(300)
|
||||
bk(300*(25/100))
|
||||
rt(90)
|
||||
bk(300*(50/100))
|
||||
fd(300*(50/100))
|
||||
fd(300*(50/100))
|
||||
bk(300*(50/100))
|
||||
rt(90)
|
||||
bk(300*(25/100))
|
||||
fd(300*(25/100))
|
||||
fd(300*(25/100))
|
||||
rt(90)
|
||||
fd(300*(50/100))
|
||||
bk(300*(50/100))
|
||||
rt(90)
|
||||
rt(90)
|
||||
rt(90)
|
||||
fd(300*(50/100))
|
||||
fd(300*(50/100))
|
||||
rt(90)
|
||||
fd(300*(40/100))
|
||||
rt(90)
|
||||
fd(300*(23/100))
|
||||
bk(300*(23/100))
|
||||
rt(90)
|
||||
rt(90)
|
||||
fd(300*(50/100))
|
||||
bk(300*(50/100))
|
||||
rt(90)
|
||||
rt(90)
|
||||
rt(90)
|
||||
fd(300*(40/100))
|
||||
rt(90)
|
||||
fd(300*(50/100))
|
||||
bk(300*(23/100))
|
||||
rt(90)
|
||||
bk(300*(20/100))
|
||||
fd(300*(20/100))
|
||||
rt(90)
|
||||
fd(300*(20/100))
|
||||
bk(300*(20/100))
|
||||
fd(300*(23/100))
|
||||
bk(300*(23/100))
|
||||
fd(300*(25/100))
|
||||
fd(10)
|
||||
bk(1)
|
||||
bk(1)
|
||||
bk(1)
|
||||
bk(1)
|
||||
rt(90)
|
||||
fd(300*(25/100))
|
||||
fd(300*(5/100))
|
||||
bk(300*(5/100))
|
||||
bk(300*(25/100))
|
||||
rt(-90)
|
||||
fd(300*(25/100))
|
||||
fd(300*(25/100))
|
||||
rt(-90)
|
||||
fd(300)
|
||||
done()
|
||||
Reference in new issue
Block a user