-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
130 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
import turtle | ||
|
||
t = turtle.Turtle() | ||
turtle.title("I Love You") | ||
screen = turtle.Screen() | ||
screen.bgcolor("white") | ||
t.color("red") | ||
t.begin_fill() | ||
t.fillcolor("black") | ||
|
||
t.left(140) | ||
t.forward(180) | ||
t.circle(-90, 200) | ||
|
||
t.setheading(60) # t.left | ||
t.circle(-90, 200) | ||
t.forward(180) | ||
|
||
t.end_fill() | ||
t.hideturtle() | ||
|
||
def heart_red(): | ||
t = turtle.Turtle() | ||
turtle.title("I Love You") | ||
screen = turtle.Screen() | ||
screen.bgcolor("white") | ||
t.color("red") | ||
t.begin_fill() | ||
t.fillcolor("red") | ||
|
||
t.left(140) | ||
t.forward(180) | ||
t.circle(-90, 200) | ||
|
||
t.setheading(60) # t.left | ||
t.circle(-90, 200) | ||
t.forward(180) | ||
|
||
t.end_fill() | ||
t.hideturtle() | ||
|
||
turtle.done() | ||
|
||
|
||
if __name__ == "__main__": | ||
heart_red() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,63 @@ | ||
import random | ||
from colorama import Fore, Style | ||
import inquirer | ||
|
||
responses = [ | ||
"It is certain", | ||
"It is decidedly so", | ||
"Without a doubt", | ||
"Yes definitely ", | ||
"Yes definitely", | ||
"You may rely on it", | ||
"As I see it, yes", | ||
"Most likely ", | ||
"Most likely", | ||
"Outlook good", | ||
"Yes", | ||
"Signs point to yes", | ||
"Do not count on it", | ||
"My reply is no", | ||
" My sources say no", | ||
" Outlook not so good", | ||
"My sources say no", | ||
"Outlook not so good", | ||
"Very doubtful", | ||
"Reply hazy try again", | ||
"Ask again later", | ||
"Better not tell you now ", | ||
"Cannot predict now ", | ||
"Better not tell you now", | ||
"Cannot predict now", | ||
"Concentrate and ask again", | ||
] | ||
print("Hi! I am the magic 8 ball, what's your name?") | ||
name = input() | ||
print("Hello!" + name) | ||
|
||
|
||
def magic8Ball(): | ||
print("Whay's your question? ") | ||
question = input() | ||
answer = responses[random.randint(0, len(responses) - 1)] | ||
print(answer) | ||
tryAgain() | ||
|
||
|
||
def tryAgain(): | ||
print( | ||
"Do you wanna ask any more questions? press Y for yes and any other key to exit " | ||
) | ||
x = input() | ||
if x in ["Y", "y"]: | ||
magic8Ball() | ||
|
||
|
||
# Will use a class on it. | ||
# Will try to make it much more better. | ||
def get_user_name(): | ||
return inquirer.text( | ||
message="Hi! I am the magic 8 ball, what's your name?" | ||
).execute() | ||
|
||
|
||
def display_greeting(name): | ||
print(f"Hello, {name}!") | ||
|
||
|
||
def magic_8_ball(): | ||
question = inquirer.text(message="What's your question?").execute() | ||
answer = random.choice(responses) | ||
print(Fore.BLUE + Style.BRIGHT + answer + Style.RESET_ALL) | ||
try_again() | ||
|
||
|
||
def try_again(): | ||
response = inquirer.list_input( | ||
message="Do you want to ask more questions?", | ||
choices=["Yes", "No"], | ||
).execute() | ||
|
||
if response.lower() == "yes": | ||
magic_8_ball() | ||
else: | ||
exit() | ||
|
||
|
||
magic8Ball() | ||
if __name__ == "__main__": | ||
user_name = get_user_name() | ||
display_greeting(user_name) | ||
magic_8_ball() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import random | ||
from colorama import Fore, Style | ||
import inquirer | ||
|
||
responses = [ | ||
"It is certain", | ||
"It is decidedly so", | ||
"Without a doubt", | ||
"Yes definitely", | ||
"You may rely on it", | ||
"As I see it, yes", | ||
"Most likely", | ||
"Outlook good", | ||
"Yes", | ||
"Signs point to yes", | ||
"Do not count on it", | ||
"My reply is no", | ||
"My sources say no", | ||
"Outlook not so good", | ||
"Very doubtful", | ||
"Reply hazy try again", | ||
"Ask again later", | ||
"Better not tell you now", | ||
"Cannot predict now", | ||
"Concentrate and ask again", | ||
] | ||
|
||
|
||
# Will use a class on it. | ||
# Will try to make it much more better. | ||
def get_user_name(): | ||
return inquirer.text( | ||
message="Hi! I am the magic 8 ball, what's your name?" | ||
).execute() | ||
|
||
|
||
def display_greeting(name): | ||
print(f"Hello, {name}!") | ||
|
||
|
||
def magic_8_ball(): | ||
question = inquirer.text(message="What's your question?").execute() | ||
answer = random.choice(responses) | ||
print(Fore.BLUE + Style.BRIGHT + answer + Style.RESET_ALL) | ||
try_again() | ||
|
||
|
||
def try_again(): | ||
response = inquirer.list_input( | ||
message="Do you want to ask more questions?", | ||
choices=["Yes", "No"], | ||
).execute() | ||
|
||
if response.lower() == "yes": | ||
magic_8_ball() | ||
else: | ||
exit() | ||
|
||
|
||
if __name__ == "__main__": | ||
user_name = get_user_name() | ||
display_greeting(user_name) | ||
magic_8_ball() |