GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-code/command-line-interface/get_random_nmbr.py at master · theFest/python-code

Expand file tree

/

get_random_nmbr.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
24 lines (21 loc) · 1.6 KB
/

get_random_nmbr.py

Copy path

File metadata and controls

24 lines (21 loc) · 1.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
""" The code imports the random module, which provides functions for generating random numbers.
It defines a function generate_numbers that generates count number of random integers between 0 and 100, inclusive.
The function takes two parameters:
count: The number of random numbers to generate
pseudo: A flag indicating whether or not to use a pseudo-random number generator. If pseudo is set to True, the function seeds the random number generator with the value 0.
The function uses a for loop to generate count random integers and store them in a list called numbers. The random.randint function is used to generate each random integer.
If pseudo is set to True, the random.seed function is called first to seed the random number generator with the value 0.
Finally, the generate_numbers function returns the list of generated numbers.
The code then calls the generate_numbers function twice, once with pseudo=True and once with pseudo=False, and prints the resulting lists.
If pseudo is set to True, the random number generator will always generate the same sequence of numbers, because it is seeded with the same value (0) each time the function is called.
If pseudo is set to False, the random number generator will generate a different sequence of numbers each time the function is called, because it is not seeded with a specific value. """
import random
def generate_numbers(count, pseudo=False):
numbers = []
if pseudo:
random.seed(0)
for i in range(count):
numbers.append(random.randint(0, 100))
return numbers
print(generate_numbers(5, pseudo=True))
print(generate_numbers(5, pseudo=False))
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.