Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I NEED HELP!!!
#1
I'm a year 11 student doing one of those stupid OCR Programming tasks. It's my first year with programming so I'm not the best and therefore I need help. The task is:

The players roll two 6-sided dice and get points depending on what they roll. There are 5 rounds in a game. In each game, each player rolls the two dice.
The rules are:
• The point rolled on each player’s dice are added to their score.
• If the total is an even number, an additional 10 points are added to their score.
• If the total is an odd number, 5 points are subtracted from their score.
• If they roll a double, they get to roll one extra die and get the number of points rolled added to their score.
• The score of a player cannot go below 0 at any point.
• The person with the highest score at the end of the 5 rounds wins.
• If both players have the same score at the end of the 5 rounds, they each roll 1 die and whoever gets the highest score wins (this repeats until someone wins).
Only authorized players are allowed to play the game.
Where appropriate, input from the user should be validated.

Design, develop, test and evaluate a program that:

1. Allows two players to enter their details, which are then authenticated to ensure that they are authorized players.
2. Allows each player to roll a 6-sided dice.
3. Calculates and outputs the points for each round and each player’s total score.
4. Allows the players to play 5 rounds.
5. If both players have the same score after 5 rounds, allows each player to roll 1 die each until someone wins.
6. Outputs who has won at the end of the 5 rounds.
7. Stores the winner’s score, and their name, in an external file.
8. Displays the score and player name of the top 5 winning scores from the external life.

I can't figure out how to add and subtract from their scores according to whether they land and even or an odd number.
PLEASE PLEASE SEND ME AN ANSWER TO THIS OR OFFER SOME HELP! THE DEADLINE IS MONDAY!!!
Reply
#2
Please post a minimal code sample (in python code tags) for the specific part your stuck on, explain what you expect to happen and what is actually happening and any errors received in error tags.
Reply
#3
(Mar-29-2019, 11:53 AM)polloila Wrote: I can't figure out how to add and subtract from their scores according to whether they land and even or an odd number.

Please write some code and I am pretty sure there are people willing to help you.

I observed that actually you have only one problem (quoted above). Simplest way to determine whether number is even or odd is to use modulus (divides and returns the value of the remainder):

>>> 4 % 2
0
>>> 5 % 2
1
>>> if 5 % 2 == 0:
...     print('even')
... else:
...     print('odd')
...
odd
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#4
(Mar-29-2019, 02:51 PM)perfringo Wrote:
(Mar-29-2019, 11:53 AM)polloila Wrote: I can't figure out how to add and subtract from their scores according to whether they land and even or an odd number.
Please write some code and I am pretty sure there are people willing to help you. I observed that actually you have only one problem (quoted above). Simplest way to determine whether number is even or odd is to use modulus (divides and returns the value of the remainder):
 >>> 4 % 2 0 >>> 5 % 2 1 >>> if 5 % 2 == 0: ... print('even') ... else: ... print('odd') ... odd 

Thank you, I have all of my coding done except for the bit I have stated I need help on and I can show you it if it would help. I have also already done a piece of code that determines wether or not it's an odd or even number. My biggest concern is having to change my entire coding just to include that little piece of code that adds or subtracts from the players scores.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020