Skip to content

Commit a85cf02

Browse files
authored
Add files via upload
1 parent 55e8eb1 commit a85cf02

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

magic8Ball.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def getAnswer(answerNumber):
1919
elif answerNumber == 9:
2020
return 'Very doubtful'
2121

22-
r = random.randint(1,9)
23-
fortune = getAnswer(r)
24-
print(fortune)
25-
22+
#r = random.randint(1,9)
23+
#fortune = getAnswer(r)
24+
#print(fortune)
25+
26+
print (getAnswer(random.randint(1,9)))
2627

sameName.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def spam():
2+
eggs = 'spam local'
3+
print(eggs) #prints 'spam local'
4+
def bacon():
5+
6+
eggs = 'bacon local'
7+
print(eggs) #prints 'bacon local'
8+
spam()
9+
print(eggs) #prints 'bacon local'
10+
11+
eggs = 'global'
12+
bacon()
13+
print(eggs) #prints 'global'

sameName2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def spam():
2+
global eggs
3+
eggs = 'spam'
4+
5+
eggs = 'global'
6+
spam()
7+
print(eggs)

sameName3.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def spam():
2+
global eggs
3+
eggs = 'spam' #this is global
4+
5+
def bacon():
6+
eggs = 'bacon' #this is local
7+
def ham():
8+
print(eggs) #this is global
9+
10+
eggs = 42 #this is global
11+
spam()
12+
print(eggs)

sameName4.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def spam():
2+
print(eggs) #ERROR!
3+
eggs = 'spam local'
4+
5+
eggs = 'global'
6+
spam()

zeroDivide.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def spam(divideBy):
2+
return 42 / divideBy
3+
4+
print(spam(2))
5+
print(spam(12))
6+
print(spam(0))
7+
print(spam(1))

0 commit comments

Comments
 (0)