---
# System prepended metadata

title: lesson17 リスト （授業練習用）
tags: [練習用]

---

# lesson17 リスト （授業練習用）
## 授業でスライドにあるコードを練習する。HackMDに書いたコードをコピーして、実行した結果をスクリーンショットして貼り付けてください。
###### tags: `練習用`
### 例：
:::info
Code:
```python=
r = float(input("Please input value r:"))
r_Round = r * 2 * 3.14
r_Area = r * r * 3.14
print("The round:", r_Round)
print("The area:", r_Area)
```
結果：
![](https://i.imgur.com/u7n9gvs.png)
:::

---
### 1.
:::info
Code:
```python=
list_empty = []
print(list_empty)
list_variable = [1,2,3,4,5,6,7,8,9]
print(list_variable)
languages=["python","c++","php"]
print(languages)
languages_ver = ["python",3,7,"java",14]
print(languages_ver)


```
結果：
[]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
['python', 'c++', 'php']
['python', 3, 7, 'java', 14]




:::

---

### 2.
:::info
Code:
```python=
range_list = range(1,10)
print(range_list)
print(type(range_list))

range_list =list( range(1,10))
print(range_list)
print(type(range_list))

strlist = list("python")
print(strlist)

```
結果：
range(1, 10)
<class 'range'>
[1, 2, 3, 4, 5, 6, 7, 8, 9]
<class 'list'>
['p', 'y', 't', 'h', 'o', 'n']



:::

---

### 3.
:::info
Code:
```python=
range_list = list(range(1,10))
print(range_list)
print(range_list[0])
print(range_list[4])
print(range_list[-3])
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled6.py', wdir='C:/Users/user/.spyder-py3/autosave')
[1, 2, 3, 4, 5, 6, 7, 8, 9]
1
5
7




:::

---

### 4.
:::info
Code:
```python=
languages=["python","c++","java","php"]
print(languages.index(("c++")))
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled7.py', wdir='C:/Users/user/.spyder-py3/autosave')
1


:::

---

### 5.

:::info
Code:
```python=
a=[1,2,3]
b=[4,5,6]
new_list= a+b
newlist_2=new_list+[7,8,9]
print(new_list)
print(newlist_2)
```
結果：

runfile('C:/Users/user/.spyder-py3/autosave/untitled8.py', wdir='C:/Users/user/.spyder-py3/autosave')
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7, 8, 9]

:::

---
### 6.
:::info
Code:
```python=
languages=["python","c++","java"]
print(languages)
languages.append("php")
print(languages)
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled9.py', wdir='C:/Users/user/.spyder-py3/autosave')
['python', 'c++', 'java']
['python', 'c++', 'java', 'php']

:::

---

### 7.
:::info
Code:
```python=

range_list=list(range(1,10))
for i in range_list:
    print(i,end = " ")
print()
for i in range(9):
    print(range_list[i],end = " ")
```
結果：
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
:::

---

### 8.
:::info
Code:
```python=

```
結果：

:::

---

### 9.
:::info
Code:
```python=

```
結果：

:::

---

### 10.

:::info
Code:
```python=

```
結果：

:::

---