import random
rock,paper,scissors = 1,2,3
choice = int(input("Please choose 1 2 or 3: "))
computer = random.randint(1,3)
player_won = False
draw = False
if choice == computer:
draw = True
elif choice == 1 and computer == 3:
player_won = True
elif choice == 2 and computer == 1:
player_won = True
elif choice == 3 and computer == 2:
player_won = True
if player_won:
print("You won!")
elif not player_won and not draw:
print("The computer won!")
else:
print("It's a draw!")
First, I recommend importing at the beginning of your program. Also, you can combine all your same datatype variables in one line. You also need to cast your user choice to an integer so you can compare it with the computer's choice. I wrote the if, elif, and else statements using a boolean variable. I simply wrote all the possibilities that would result in the player winning and this would result in the player_won variable being true. If this is the case, we print to the console, "You won!"
Answer:
Option d is the correct answer for the above question.
Explanation:
- The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
- The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
- Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
- The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
- So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
- Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
C. Provides an interface between user and OS.
The GUI, or Graphical User Interface, is just about everything you generally see with a common computer or smartphone. You rarely run an application or program from the command itself, as clicking an icon in the GUI runs the software for you.
Answer:
prefix comes first
Explanation:
pre means before, and post means after.
UTF-16 does this. One of the Chinese dialects has 28,000+ characters.