私のコンピュータ科学のクラスfinalについては、私たちはPythonで独自のゲームを作るように指示されています。"Horse" Mathのゲーム
要件:
1ニーズ「whileループ」の両方を使用すると
2.必要な情報を追跡または
3を獲得するためにいずれかのリストを使用するように「Yループにおけるxの。」ゲームプレイ、スコアを追跡するための関数を使用する必要があります。
4.開始時、終了時、または終了間のいずれかにいくつかの芸術を表示します。
5.マルチプレーヤーまたはシングルプレーヤーが可能です。
6.最終プロジェクトに見合った複雑さを持たなければなりません。
とにかく、私はバスケットボールで馬に似たゲームを作ることに決めました。ゲームの目的は、時間がなくなる前に数学問題の答えを見つけることです。あなたがしなければ、あなたは馬の手紙を受け取ります。あなたが馬のすべての手紙を取得したら、あなたのゲームは終わった。ここで
は、私がこれまで持っているものです。
import random
import time
from timeit import default_timer
print("welcome to Jared's Math Horse game!")
time.sleep(1)
print("You will have to do some basic geometry and algebra problem,and some brain teasers...")
time.sleep(1)
print("For each you get wrong, you get a letter, and it will spell 'HORSE'. Once you get all letters, you lose. ROUND TO THE NEAREST INTEGER!!!!!!!!")
time.sleep(1)
###BEgin actual stuff
how_long = int(input("How many times(problems) do you want to play? (above or equal 5)"))
score = 0
##Problems
problems = ["A cylinder has a radius of 5. It's height is 6. What is the volume?471","A boy buys two shirts. One costs $15 and he pays $27 for both shirts. How much was the 2nd shirt?12","dat boi costs $12 after a 15% discount. What was the original price?14.12","A square pyramid with a height 12 and a side length 5. What is the volume?20","What is the square root of 36?", "What is the roman numeral for 500? QUICK USE GOOGLE!!!D","On a scale of 100-100 how cool is jared?100" ]
#######End of variables
####Func time
def horse(score,problem,speed):
b = input("You have {} seconds. Press enter to begin. Round answers to nearest integer.".format(speed))
begin = default_timer()
howfast = default_timer() - begin
print(random.problem[0,7])
##Check answer
answer = input("What is your answer?:")
## Give score
##loops
for x in how_long:
while True:
if score !=5:
a = random.randint(0,7)
problem = problems[a]
##Speed
speed = int(input("How fast do you want to play?? 1=slow 2=medium 3=FAST"))
if speed == (1):
speed = random.randint(30,60)
if speed == 2:
speed = random.randint(20,40)
if speed == 3:
print("spicy!")
speed = random.randint(10,30)
score = horse(score,problem,speed)
if score == 0:
print("You have a perfect score. Good work.")
if score == 1:
print("You have an H")
if score == 2:
print("You have Ho")
if score == 3:
print("You have Hor")
if score == 4:
print("You have Hors")
if score == 5:
print("You have Horse. Game over, loser.")
break
は馬()
Soがあなたが正しい答えをタイプすれば、それを作る方法がわかりません。あなたは手紙を手に入れずに移動します。私は 'if and'ステートメントを使ってみました。それはそれです。ところで、問題の答えは終わりです。ヘルプはVERYと高く評価されています。申し訳ありませんが、私はこれをうまく説明していない場合、私はこれでノブです。ハハ
「number_wrong」を作成したことがない変数を使用しているのはなぜですか? – Keatinge
'number_wrong == 1'ならば、あなたのコードは合計5回印刷されます...それはあなたが欲しいものですか? –
笑、number_wrongは「スコア」にする必要があります。ありがとう – jrod