Write a Python program that meets the following specifications: In bowling, the player starts with 10 pins in a row at t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a Python program that meets the following specifications: In bowling, the player starts with 10 pins in a row at t

Post by answerhappygod »

Write a Python program that meets the followingspecifications:
In bowling, the player starts with 10 pins in a row at the farend of a lane. The goal is to knock all the pins down. For thisassignment, the number of pins and balls will vary. Given thenumber of pins N and then the number ofballs K to be rolled, followedby K pairs of numbers (one for each ballrolled), determine which pins remain standing after all the ballshave been rolled.
The balls are numbered from 1 to N for thissituation. The subsequent number pairs, one foreach K represent the first and last (inclusive)positions of the pins that were knocked down with each roll. Printa sequence of N characters,where "I" represents a pin left standingand "." represents a pin knocked down.
You must use the code below as a base:def update_bowling_configuration(pins, first, last): '''Changes the pins configuration according to thefallen pins from first to last'''n, k = [int(str_numbers) for str_numbers ininput().split()] pins = ['I'] * n # All pins are standing at the start of thegamefor rolls in range(k): first, last = [int(s) for s in input().split()] #collection of strike data #call your function below #print pins below
Example input:10 3
8 10
2 5
3 6
Example output: I.....I...
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply