Purchase Solution

Python program for a limited over cricket match

Not what you're looking for?

Ask Custom Question

In a limited over cricket match Team A is taking on Team B. Team A is batting first.

Write a Python program that will first ask the number of overs each team will bat. The program then will continue to ask the score board people to input the runs for every ball for Team A until the team gets all out or they run out of overs. Do NOT prompt a message like "Enter runs :" for each ball.

Each over has just six balls, and you do not need to worry about extra balls due to No Balls, Wide etc in this program. Also you do not need to worry about multiple things happening for a ball. For example, you do not need to consider cases where a team gets runs and at the same time loses a wicket for the same ball. For one ball only one thing will be happening.
The program should display a running total score for the team. When the loop finishes the program should display the total score, number of wickets lost, and the number of overs played by Team A.

The program then should do the same for Team B. When the loop finishes for Team B the program should display the total scores, number of wickets lost and number of overs played by both teams. An extra termination condition of the loop for Team B will be if the running total score of Team B exceeds the total score of Team A.

The program will also display the winning team and the result. That is, if Team A wins then it will display the result in terms of runs. For example, Team A wins by 54 runs, which is the difference between the total runs scored by the teams. However, if Team B wins then the program will display the result in terms of wickets. For example, Team B wins by 3 wickets.

The program will need to keep track of number of balls played, and number of wickets lost by a team. Use multiple functions, instead of using only one function to do everything. Make a good design of the functions to make the best use of the code and avoid duplicate calculations.

Purchase this Solution

Solution Summary

Python code is reasonably easy to follow. Solution provides two versions of the program for Python v2.7.2 and v3.2.3 as there have been some changes between series 2 and series 3 of Python.

Solution Preview

Please go through the attached program versions and modify/tune them as per your requirement.

The attached program versions have been tested working fine with python version 2.7.2 (tested on Ubuntu 11.10 Linux distribution) and ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.