Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- def greet():
- print("Hello, I'm chatbot. Ask me a question!")
- def hangman():
- wordChosen = input("Write a word for someone to guess. ")
- list = []
- wrong = []
- tries = 6
- end = 1
- for i in range(len(wordChosen)):
- list.append("_")
- print(list)
- while(tries > 0):
- if(end == len(wordChosen)):
- break
- else:
- guess = input("choose a letter: ")
- if(guess in wordChosen):
- for i in range((len(wordChosen))):
- # if the letter at i = guess replace list num with guess
- if(guess == wordChosen[i]):
- list[i] = guess
- print(list)
- end = end + 1
- else:
- print("try again")
- wrong.append(guess)
- tries = tries - 1
- print("tries: ", tries)
- if(tries == 0):
- print("game over")
- if(end == len(wordChosen) and tries > 0):
- print("you won!")
- def default():
- print("That's cool!")
- def guessNum():
- random = randint(1,100)
- guess = input("Guess a number 1-100 inc ")
- for i in range(10):
- if not guess.isnumeric():
- print("thats not a pos num")
- guess = input("Guess a number 1-100 inc ")
- else:
- guess = int(guess)
- if (guess > random):
- print("too high")
- guess = input("Guess a number 1-100 inc ")
- elif(guess < random):
- print("too low")
- guess = input("Guess a number 1-100 inc ")
- elif(guess == random):
- print("you got it!")
- break
- else:
- print("try again")
- guess = input("Guess a number 1-100 inc ")
- def calc():
- num1 = input("What is your first number? ")
- num2 = input("What is you second number? ")
- num1 = int(num1)
- num2 = int(num2)
- math = 0
- mathfunc = input("What would you like to do? (multiply, add, subtract, divide) ")
- if(mathfunc == "add"):
- math = num1 + num2
- print(num1, " + ", num2, " = ", math)
- elif(mathfunc == "multiply"):
- math = num1 * num2
- print(num1, " * ", num2, " = ", math)
- elif(mathfunc == "divide"):
- math = num1 / num2
- print(num1, " / ", num2, " = ", math)
- elif(mathfunc == "subtract"):
- math = num1 - num2
- print(num1, " - ", num2, " = ", math)
- else:
- while (mathfunc != "add" and mathfunc != "subtract" and mathfunc != "multiply" and mathfunc != "divide"):
- print("That choice is not valid")
- mathfunc = input("What would you like to do? (multiply, add, subtract, divide) ")
- if(mathfunc == "add"):
- math = num1 + num2
- print(num1, " + ", num2, " = ", math)
- elif(mathfunc == "multiply"):
- math = num1 * num2
- print(num1, " * ", num2, " = ", math)
- elif(mathfunc == "divide"):
- math = num1 / num2
- print(num1, " / ", num2, " = ", math)
- elif(mathfunc == "subtract"):
- math = num1 - num2
- print(num1, " - ", num2, " = ", math)
- def rps():
- #rockPaperScissors = ["rock", "paper", "scissors"] len(rockPaperScissors)
- rpsPlayer = input("What do you choose? (rock, paper, scissors) ")
- randomRPS = randint(0, 2)
- if(rpsPlayer == "rock" or rpsPlayer == "scissors" or rpsPlayer == "paper"):
- if(randomRPS == 0):
- if(rpsPlayer == "rock"):
- print("draw. My play: rock")
- elif(rpsPlayer == "scissors"):
- print("I win! My play: rock")
- elif(rpsPlayer == "paper"):
- print("You win! My play: rock")
- elif(randomRPS == 1):
- if(rpsPlayer == "paper"):
- print("draw. My play: paper")
- elif(rpsPlayer == "rock"):
- print("I win! My play: paper")
- elif(rpsPlayer == "scissors"):
- print("You win! My play: paper")
- elif(randomRPS == 2):
- if(rpsPlayer == "scissors"):
- print("draw. My play: scissors")
- elif(rpsPlayer == "paper"):
- print("I win! My play: scissors")
- elif(rpsPlayer == "rock"):
- print("You win! My play: scissors")
- else:
- while(rpsPlayer != "rock" and rpsPlayer != "scissors" and rpsPlayer != "paper"):
- print("That choice is not valid.")
- rpsPlayer = input("What do you choose? (rock, paper, scissors) ")
- if(randomRPS == 0):
- if(rpsPlayer == "rock"):
- print("draw. My play: rock")
- elif(rpsPlayer == "scissors"):
- print("I win! My play: rock")
- elif(rpsPlayer == "paper"):
- print("You win! My play: rock")
- elif(randomRPS == 1):
- if(rpsPlayer == "paper"):
- print("draw. My play: paper")
- elif(rpsPlayer == "rock"):
- print("I win! My play: paper")
- elif(rpsPlayer == "scissors"):
- print("You win! My play: paper")
- elif(randomRPS == 2):
- if(rpsPlayer == "scissors"):
- print("draw. My play: scissors")
- elif(rpsPlayer == "paper"):
- print("I win! My play: scissors")
- elif(rpsPlayer == "rock"):
- print("You win! My play: scissors")
- def name():
- Letter1 = ["B", "S", "T", "L", "W"]
- Letter2 = ["a", "e", "i", "o", "u"]
- Letter3 = ["v", "n", "m", "r", "d"]
- Letter4 = ["a", "e", "i", "o", "u"]
- Letter5 = ["g", "h", "l", "f", "p"]
- random1 = randint(0, (len(Letter1)-1))
- random2 = randint(0, (len(Letter2)-1))
- random3 = randint(0, (len(Letter3)-1))
- random4 = randint(0, (len(Letter4)-1))
- random5 = randint(0, (len(Letter5)-1))
- word = Letter1[random1] + Letter2[random2] + Letter3[random3] + Letter4[random4] + Letter5[random5]
- Letter6 = ["K", "G", "R", "Z", "M"]
- Letter7 = ["a", "e", "i", "o", "u"]
- Letter8 = ["y", "s", "t", "f", "g"]
- Letter9 = ["a", "e", "i", "o", "u"]
- Letter10 = ["d", "b", "j", "r", "z"]
- Letter11 = ["a", "e", "i", "o", "u"]
- random6 = randint(0, (len(Letter6)-1))
- random7 = randint(0, (len(Letter7)-1))
- random8 = randint(0, (len(Letter8)-1))
- random9 = randint(0, (len(Letter9)-1))
- random10 = randint(0, (len(Letter10)-1))
- random11 = randint(0, (len(Letter11)-1))
- word2 = Letter6[random6] + Letter7[random7] + Letter8[random8] + Letter9[random9]+ Letter10[random10] + Letter11[random11]
- full = word + " " + word2
- print(full)
- def convo():
- jokes = ["What do you call a fish without eyes? Fsh. ", "What do you call an alligator detective? An investi-gator. ",
- "Why did the Clydesdale give the pony a glass of water?", "Why did the scarecrow win an award? Because he was outstanding in his field.",
- "There are two muffins baking in the oven. One muffin says to the other, “Phew, is it getting hot in here or is it just me?” The other muffin says, “AAAAHHH!! A TALKING MUFFIN!” ",
- "What lights up a soccer stadium? A soccer match.", "Why shouldn’t you write with a broken pencil? Because it’s pointless. ",
- "What’s the difference between the bird flu and the swine flu? One requires tweetment and the other an oinkment."]
- greeting = input("How are you doing today? I am doing good! ")
- if("good" in greeting or "great" in greeting):
- next = input("im happy you are well. Whats up? ")
- if("nothing" in next):
- print("Thats ok! I love doing nothing too")
- then = input("would you like to tell me a joke? ")
- if("yes" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- else:
- print("That sounds cool!")
- then = input("would you like to tell me a joke? ")
- if("yes" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- elif("bad" in greeting or "depressed" in greeting):
- next = input("I'm sorry you are not feeling well. Whats up? ")
- if("nothing" in next):
- print("Thats ok! I love doing nothing too")
- then = input("would you like to tell me a joke? ")
- if("yes" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- else:
- print("That sounds cool!")
- then = input("would you like to tell me a joke? ")
- if("yes" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- else:
- next = input("Thats cool. Whats up? ")
- if("nothing" in next):
- print("Thats ok! I love doing nothing too")
- then = input("would you like to tell me a joke? ")
- if("yes" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- else:
- print("That sounds cool!")
- then = input("would you like to tell me a joke?")
- if("yes" in then or "yeah" in then):
- print(jokes[randint(0, len(jokes))])
- return 0
- else:
- print("Thats ok. Bye!")
- return 0
- functionsAvailable = ["hangman", "guess a number", "calculator", "rock paper scissors", "name generator", "conversation", "exit"]
- def processInput(answer):
- if(answer == "hangman"):
- hangman()
- elif(validInput(answer, ["guess a number", "guess"])):
- guessNum()
- elif(answer == "calculator"):
- calc()
- elif(validInput(answer, ["rock paper scissors", "rps"])):
- rps()
- elif(validInput(answer, ["name generator", "name"])):
- name()
- elif(validInput(answer, ["lets have a conversation", "convo", "conversation", "How are you?"])):
- convo()
- else:
- default()
- def validInput(ui, valid):
- for i in range(len(valid)):
- if(ui == valid[i]):
- return True
- return False
- def main():
- greet()
- while True:
- print("Here are the games available to you: ")
- for i in functionsAvailable:
- print(i)
- answer = input("(What will you say?) ")
- if(answer == "exit"):
- print("goodbye!")
- break
- else:
- print("_____________________________________")
- processInput(answer)
- print("_____________________________________")
- # DON'T TOUCH! Setup code that runs your main() function.
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment