Answer to Question #195349 in Python for Dinesh kumar R

Question #195349

It is the final of the world’s most prestigious cricket tournament, the Indian Premier League. In the final, the Chennai Super Kings (CSK) are playing against the Mumbai Indians (MI). There is one over left for the match to end and CSK require R runs to win with W wickets remaining.


An over consists of 6 balls. Each ball can result in any one of the following possibilities:-


  • 6 Runs
  • 4 Runs
  • 7 Runs (3 Runs + Overthrows)
  • 2 Runs
  • 1 Run
  • Wicket

If a ball results in a wicket, CSK’s remaining wickets will decrease by one. If a ball results in runs (either 6, 4, 7, 2 or 1), these runs are added to the runs that CSK have already scored.


The match ends when one of the following happens:-


* If CSK scores R runs, the match ends and CSK wins.


* If the match ends with CSK scoring exactly one run less than the required runs, then the match is a tie.



1
Expert's answer
2021-05-19T15:51:39-0400
winningRuns=int(input("Enter the required run for CSK to win match (enter integer value)?"))
wicket=int(input("wicket :"))
score=int(input('Enter the current score:'))
requiredScore=score
print('Run requires to win the match',winningRuns)
print('wicket fall:',wicket)
print('Current score is:',score)


for run in range(6):
    runs=int(input('Enter the runs in ball'))
    if(runs==6):
        score+6
    else:
        if(runs==4):
            score+4
        else:
            if(runs==3):
                score+3
            else:
                if(runs==7):
                    score+7
                else:
                    if(runs==2):
                        score+2
                    else:
                        if(runs==1):
                            score+1
                        else:
                            if(runs==0):
                                score+0
                            else:
                                wicket+1

if(requiredScore>score):
    print('CSK lost the match by',(requiredScore-score),'runs')
else:
    if(requiredScore==score):
        print('Match draw')
    else:
        if(requiredScore<score):
            print('CSK won the match by',(11-wicket))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS