-2
我想問用戶的名字。兩個遊戲之間的選擇
在給出它們的名字後,它將打印在一個句子中。
我想問用戶在兩個遊戲之間進行選擇,我想在if語句中調用正確的函數。
# coding=utf-8
import time
import calendar
from random import randint
def mygame():
"""
Guessing game!
"""
playing = True
num = randint(1, 100)
guesses = 0
print("Welcome to my Game")
print("Would you like to play?")
print("Yes or No")
Yes = "Yes"
No = "No"
x = input()
if x == Yes:
print("Welcome to my game!")
while playing:
print("Guess a number between 1 and 100")
guess = int(input("What is your guess?!"))
if guess > 100 or guess < 1:
invalid = True
while invalid:
print("Invalid number guessed, Enter a new NUMBER, between 1 and 100")
guess = int(input("What is your guess?!"))
guesses += 1
if 100 >= guess >= 1:
invalid = False
guesses -= 1
guesses += 1
print(guess)
if guess == num:
print("You Guessed the number correctly, it only took you " + str(guesses))
playing = False
elif guess > num:
print("Your guess was too high!, TRY AGAIN!")
else:
print("Your guess was too low, TRY AGAIN!")
if x == No:
print("Goodbye!")
quit()
def calendar1():
"""
This prints out calendar for November of 2016
"""
cal = calendar.month(2016, 11)
print("What is your name?")
name = input()
print("Hello %s, I have two options for you today!" % name)
localTime = time.asctime(time.localtime(time.time())) # This is formatted time!
print(localTime)
你好。請重新格式化以提出具體問題。你試過什麼,什麼是/沒有工作? – SummerEla
我是一個初學者在Python和編程本身!基本上我試圖做的是,有2個功能,並且可以說它們都包含遊戲,猜謎遊戲,數字遊戲!我想要求用戶輸入在兩個功能之間進行選擇!當選擇一個選擇運行該功能,如果其他運行其他功能,你可以給我發電子郵件[email protected] –
對不起,Edwin,這不是如何StackExchange的工作原理。我們都在這裏幫助對方學習..不是代碼給你。你爲什麼不自己嘗試一下,讓我們知道你卡在哪裏? – SummerEla