Skip to content

Commit

Permalink
update: add good features
Browse files Browse the repository at this point in the history
More good features were added.
  • Loading branch information
NitkarshChourasia committed Jan 8, 2024
1 parent dd0534c commit 641e756
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 45 deletions.
44 changes: 26 additions & 18 deletions love_turtle.py
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()
68 changes: 41 additions & 27 deletions magic8ball.py
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()
63 changes: 63 additions & 0 deletions magic_8_ball.py
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()

0 comments on commit 641e756

Please sign in to comment.