“Beispiel Python” Code-Antworten

Python -Beispiel


import random
import time

computerwins = 0
playerwins = 0
ties = 0
end = 0

while True:

    choices = ["rock",
               "paper",
               "scissors"]

    userChoice = raw_input("Rock, Paper, Scissors, or End")

    computerChoice = (random.choice(choices))
    print(computerChoice)

    if userChoice == computerChoice:
        time.sleep(0.5)
        print("Tie!\n")
        ties += 1
        end += 1

    elif userChoice == "rock":
        if computerChoice == "paper":
            time.sleep(0.5)
            print("Computer Win!\n")
            computerwins +=1
            end += 1

        else:
            time.sleep(0.5)
            print("Player win!\n")
            playerwins += 1
            end += 1

    elif userChoice == "paper":
        if computerChoice == "rock":
            time.sleep(0.5)
            print("Player win!\n")
            playerwins += 1
            end += 1

        else:
            time.sleep(0.5)
            print("Computer win!\n")
            computerwins += 1
            end += 1

    elif userChoice == "scissors":
        if computerChoice == "rock":
            time.sleep(0.5)
            print("Computer win!\n")
            computerwins += 1
            end += 1

        else:
            time.sleep(0.5)
            print("Player win!\n")
            playerwins += 1
            end += 1

    elif userChoice == "end":
            choices.append("end")
            print("\nGreat game!\n")
            print("Total score for computer: ", computerwins, "wins!")
            print("Total score for player: ", playerwins, "wins!")
            print("Total ties: ", ties, "ties!")
            time.sleep(2)
            break
ayaan

Beispiel Python

from turtle import speed, goto
from math import cos, sin, pi

def c(n):
    speed('fastest')
    for i in range(n):
        goto(200*cos(2*pi*i/n), 200*sin(2*pi*i/n))
        goto(200*cos(2*pi*((2*i)%n)/n), 200*sin(2*pi*((2*i)%n)/n))

c(100)
Arrogant Anaconda

Python -Beispiel

# Program to generate a random number between 0 and 9

# importing the random module
import random

print(random.randint(0,9))
Spotless Skimmer

Ähnliche Antworten wie “Beispiel Python”

Fragen ähnlich wie “Beispiel Python”

Weitere verwandte Antworten zu “Beispiel Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen