Python: numpy def serial_numbers(num_players): """ QUESTION 2 - You are going to assign each player a serial number in the game. - In order to make the players feel that the game is very popular with a large player base, you don't want the serial numbers to be consecutive. - Instead, the serial numbers of the players must be equally spaced, starting from 1 and going all the way up to 100 (inclusive). - Given the number of players in the system, return a 1D numpy array of the serial numbers for the players. - THIS MUST BE DONE IN ONE LINE Args: num_players (int) Returns: np.array >> serial_numbers(10) array([1. 12. 23. 34. 45. 56. 67. 78. 89. 100.]) >> serial_numbers(12) array([1. 10. 19. 28. 37. 46. 55. 64. 73. 82. 91. 100.]) """ # print(serial_numbers(10)) # print(serial_numbers(12))
Python: numpy def serial_numbers(num_players): """ QUESTION 2 - You are going to assign each player a serial number in the game. - In order to make the players feel that the game is very popular with a large player base, you don't want the serial numbers to be consecutive. - Instead, the serial numbers of the players must be equally spaced, starting from 1 and going all the way up to 100 (inclusive). - Given the number of players in the system, return a 1D numpy array of the serial numbers for the players. - THIS MUST BE DONE IN ONE LINE Args: num_players (int) Returns: np.array >> serial_numbers(10) array([1. 12. 23. 34. 45. 56. 67. 78. 89. 100.]) >> serial_numbers(12) array([1. 10. 19. 28. 37. 46. 55. 64. 73. 82. 91. 100.]) """ # print(serial_numbers(10)) # print(serial_numbers(12))
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Python: numpy
def serial_numbers(num_players):
"""
QUESTION 2
- You are going to assign each player a serial number in the game.
- In order to make the players feel that the game is very popular with a large
player base,
you don't want the serial numbers to be consecutive.
"""
QUESTION 2
- You are going to assign each player a serial number in the game.
- In order to make the players feel that the game is very popular with a large
player base,
you don't want the serial numbers to be consecutive.
- Instead, the serial numbers of the players must be equally spaced, starting
from 1 and going all the way up to 100 (inclusive).
- Given the number of players in the system, return a 1D numpy array of the
serial numbers for the players.
- THIS MUST BE DONE IN ONE LINE
Args:
num_players (int)
Returns:
np.array
>> serial_numbers(10)
array([1. 12. 23. 34. 45. 56. 67. 78. 89. 100.])
>> serial_numbers(12)
array([1. 10. 19. 28. 37. 46. 55. 64. 73. 82. 91. 100.])
"""
from 1 and going all the way up to 100 (inclusive).
- Given the number of players in the system, return a 1D numpy array of the
serial numbers for the players.
- THIS MUST BE DONE IN ONE LINE
Args:
num_players (int)
Returns:
np.array
>> serial_numbers(10)
array([1. 12. 23. 34. 45. 56. 67. 78. 89. 100.])
>> serial_numbers(12)
array([1. 10. 19. 28. 37. 46. 55. 64. 73. 82. 91. 100.])
"""
# print(serial_numbers(10))
# print(serial_numbers(12))
Expert Solution
Step 1
python program to print the player serial number with equal space using numpy
use the linspace() method , it returns the evenly separated values over the specified period.
syntax.
numpy.linspace(start, stop, num, endpoint, retstep, dtype)
where,
start: It represents the starting value of interval
stop: stopping value of interval
num: amount of evenly spaced sample over interval to be generated
endpoint: true value indicated the stopping value is included in interval
retstep: this is a Boolean value, represents the steps and sample between consecutive numbers
dtype: it represents the data type of array item.
* this program use only three parameters start , stop and num. see the below code
Step by step
Solved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education