Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ myemoji.py """
- emojis = dict(
- sadface="\U0001F61E",
- grinningface="\U0001F600",
- wavinghand="\U0001F44B",
- thumbsup="\U0001F44D",
- thumbsdown="\U0001F44E",
- handshake="\U0001F91D",
- )
- """ main.py """
- import os
- from myemoji import emojis
- def yesno(question):
- while True:
- prompt = f"{question} [y/n]: "
- ans = input(prompt).strip().lower()[:1]
- if ans not in ["y", "n"]:
- continue
- if ans == "y":
- return True
- return False
- def main():
- os.system('cls' if os.name == 'nt' else 'clear')
- myName = input("\n\n\tWhat is your name? ")
- if len(myName) > 0:
- myName = myName.title()
- print(f"\tHello, {myName}. I'm Python, glad to meet you! {emojis['handshake']}")
- if yesno("\tDo you have a pet?"):
- print(f"\tThat's great! {emojis['thumbsup']} ", end=" ")
- petName = input("What's your pet's name? ")
- if len(petName) > 0:
- petName = petName.title()
- petAge = input(f"\tHow old is \"{petName}\"? ")
- units = "year"
- if int(petAge) > 1:
- units += "s"
- print(f"\t{myName} has a pet named \"{petName}\". {petName} is {petAge} {units} old.\n\n")
- else:
- print(f"\t{myName.title()} doesn't have a pet... how sad! {emojis['sadface']}\n\n")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement