---
# System prepended metadata

title: 'Lesson15:Random授業練習用 宿南版'
tags: [Python]

---

# Lesson15:Random授業練習用 宿南版
###### tags: `Python`


## スライド練習１
:::info
code：
```python=
import random
print(list(range(10)))
rand_num=random.randrange(10)
print(rand_num)

print(list(range(1,10)))
rand_num=random.randrange(1,10)
print(rand_num)

print(list(range(1,10,2)))
rand_num=random.randrange(1,10,2)
print(rand_num)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled0.py', wdir='C:/Users/user/.spyder-py3/autosave')
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
7
[1, 2, 3, 4, 5, 6, 7, 8, 9]
1
[1, 3, 5, 7, 9]
7
:::

## スライド練習２
:::info
code：
```python=
import random
rand_number=random.randint(1,100)
print(rand_number)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled1.py', wdir='C:/Users/user/.spyder-py3/autosave')
95
:::

## スライド練習３
:::info
code：
```python=
import random
rand_number=random.random()
print(rand_number)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled2.py', wdir='C:/Users/user/.spyder-py3/autosave')
0.5057425678160209

runfile('C:/Users/user/.spyder-py3/autosave/untitled2.py', wdir='C:/Users/user/.spyder-py3/autosave')
0.55476388528811

:::

## スライド練習４
:::info
code：
```python=
import random

r = random.random()
print(r)
r = int(random.random()*99)
print(r)
r = int(random.random()*99)+1
print(r)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled3.py', wdir='C:/Users/user/.spyder-py3/autosave')
0.4170254707493868
5
18
:::

## スライド練習５
:::info
code：
```python=
import random
rand_number=random.uniform(2.5,5.0)
print(rand_number)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled4.py', wdir='C:/Users/user/.spyder-py3/autosave')
3.446496547495709
:::

## スライド練習５
:::info
code：
`
結果

:::
