Need some code help!!

This is the place for queries that don't fit in any of the other categories.

Need some code help!!

Postby shift » Thu May 23, 2013 12:16 am

Hi guys i am very new with python and was seeing if anyone could help me out!!

I have to make a working code from this......

As a software developer, you have "inherited" an incomplete project.  Your predecessor has partially completed the development of a coin tossing game, and you have taken on the task of finishing it off...

You are to write a small application for a coin tossing game.  In this game, your code will simulate the tossing of 2 coins. 
Firstly, the user will be asked for their first name.
Then the user will be asked to predict the outcome of the toss:
Heads (that is two heads)
Tails (that is two tails)
Heads and tails (that is one head and one tail)
Lastly, the user will be asked for their bet on the outcome.  (The return on the bet will be that the users double their money for a win on 1 or 2 above, and for a win on 2 receives one and a half times their money.)
Sample input/output is given below:

Welcome to 2-Coin Toss!!!
Hi, what is your name? John
Well, John, it is good to meet you!
Here are your possible calls on the toss of two coins:
1. Two heads
2. Two tails
3. One head and one tail
What is your call, 1, 2 or 3? 1
You have called:  two heads
What is your bet? $10
The toss is: two heads
You have won:  $ 20
You are required to put range, type and existence data validation in place for the user’s call of 1 (to heads), 2(two tails) or 3 (head and tail).  The form must be a While loop that repeats a request for the call of 1, 2, or 3 until the user enters a 1 or 2 or 3 (that is, entries such as “hello” or “5” must be rejected by your code without crashing with a run-time error).
The user bet is subject to validation, according to the restrictions shown in the SRS.

1.1 Identification of the software product
This is a prototype gaming system suitable for a mobile telephone
The name of this gaming system is "2-Coin Toss"

1.2  Intended audience of this Software Requirements Specification
This audience for this document is software developers.

1.3  Purpose of the software product
This software product should take the user’s name, call of heads, tails, or head and tail, bet, and respond with a win or lose scenario.

2.   Scope

2.1 Items within Scope
Request for client’s name
Taking of call of heads, tails or head and tail
Validation of call input
Validation of bet
Calculation of toss
Informing user of win or loss
Display running total of user winner/loss total
All bets and results must be stored in an external text file
No single bet may exceed $10
No user can bet more than 20 times in a single session
Details of any settings i.e. maximum bet, maximum number of bets in a single session, bet to payout ratios must be stored in a separate external text file

2.2  Items not in Scope
Registration of each user is not in scope
Access to the settings files via a menu option is not in scope

2.3  Operating Environment
The application is intended for use on mobile phones.


The code i have been given so far is:

def 2_coin_toss():

import random

name = input("Hi, what is your name?")

print ("Well,", name, ",it is good to meet you!")


while not(counter<5):

print ("Here are your possible calls:")
print (" 1. Two heads")
print (" 2. Two tails")
print (" 3. One head and one tail")
call = input("What is your call, 1, 2 or 3? ")

print ("You have called ",)

if call==1:
print ("two heads")
if call==2:
print ("two tails")
if call==3:
print ("head and tail")

bet = input("what is your bet? $")

print ("The toss is:",)

if toss==1:
print ("two heads")
if toss==2:
print ("two tails")
if toss==3:
print ("head and tail")

if call==toss:
print ("You have won $", bet*2)
print ("You have lost you bet of $",bet)

Appreciate it if someone could help thanks!!
Last edited by Yoriz on Fri May 24, 2013 12:19 pm, edited 1 time in total.
Reason: Locked post
Posts: 1
Joined: Thu May 23, 2013 12:02 am

Re: Need some code help!!

Postby metulburr » Thu May 23, 2013 1:17 am

New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
User avatar
Posts: 1560
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 2 guests