---
# System prepended metadata

title: 'lesson21: リスト3（授業練習用）'
tags: [練習用]

---

# lesson21: リスト3（授業練習用）
###### tags: `練習用`
:::warning
## スライドにあるコードを練習しよう。自分が書いたコードをコピーし、実行した結果をスクリーンショットしてHackMDに貼り付けてください。

:::

runfile('C:/Users/user/.spyder-py3/autosave/untitled28.py', wdir='C:/Users/user/.spyder-py3/autosave')
a=[1, 2, 3],b=[1, 2, 3]
a=[1, 2, 3],b=[1, 7, 3]

---
## 1.
:::info
Code:
```python=
intlist=[-7,8,3,-5,-3,2,10,6,-23,-5,34,55,6]
print(intlist)
intlist.sort()
print("up{}".format(intlist))
intlist.sort(reverse=True)
print("down{}".format(intlist))
```
結果：
In [111]: runfile('C:/Users/user/.spyder-py3/autosave/untitled24.py', wdir='C:/Users/user/.spyder-py3/autosave')
[-7, 8, 3, -5, -3, 2, 10, 6, -23, -5, 34, 55, 6]
up[-23, -7, -5, -5, -3, 2, 3, 6, 6, 8, 10, 34, 55]
down[55, 34, 10, 8, 6, 6, 3, 2, -3, -5, -5, -7, -23]






:::

---

## 2.
:::info
Code:
```python=
languages=["python","c++","java"]
print(languages)
languages.insert(1,"php")
print(languages)
```
結果：
['python', 'c++', 'java']
['python', 'php', 'c++', 'java']




:::

---

## 3.
:::info
Code:
```python=
languages=['python', 'php', 'c++', 'java']
print(languages)
copy_languages=languages.copy()
print(" copy from languages {}",format(copy_languages))
languages.append("php")
print(languages)
```
結果：
['python', 'php', 'c++', 'java']
 copy from languages {} ['python', 'php', 'c++', 'java']
['python', 'php', 'c++', 'java', 'php']




:::

---

## 4.
:::info
Code:
```python=
a=[1,2,3]
c=[1,2,3]
b=a
print("a={},b={},c={},".format(a,b,c))
```
結果：
a=[1, 2, 3],b=[1, 2, 3],c=[1, 2, 3],


:::

---

## 5.

:::info
Code:
```python=
a=[1,2,3]
c=[1,2,3]
b=a
print("a={},b={},c={},".format(a,b,c))

c[1]=7
print("a={},b={},c={},".format(a,b,c))
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled27.py', wdir='C:/Users/user/.spyder-py3/autosave')
a=[1, 2, 3],b=[1, 2, 3],c=[1, 2, 3],
a=[1, 2, 3],b=[1, 2, 3],c=[1, 7, 3],


:::

---
## 6.
:::info
Code:
```python=
a=[1,2,3]
c=[1,2,3]
b=a
print("a={},b={},c={},".format(a,b,c))

b[1]=5
print("a={},b={},c={},".format(a,b,c))
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled27.py', wdir='C:/Users/user/.spyder-py3/autosave')
a=[1, 2, 3],b=[1, 2, 3],c=[1, 2, 3],
a=[1, 5, 3],b=[1, 5, 3],c=[1, 2, 3],

:::

---

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

```
結果：

:::

---

## 8.
:::info
Code:
```python=
a=[1,2,3]
b=[]
for x in a:
    b.append(x)
print("a={},b={}".format(a,b))
b[1]=7
print("a={},b={}".format(a,b))
```
結果：

:::

---

## 9.
:::info
Code:
```python=
a=[1, 2, 3],b=[1, 2, 3]
a=[1, 2, 3],b=[1, 7, 3]
```
結果：

:::

---

## 10.

:::info
Code:
```python=
a=[1,2,3]
b=a.copy()

print("a={},b={}".format(a,b))
b[1]=7
print("a={},b={}".format(a,b))
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled28.py', wdir='C:/Users/user/.spyder-py3/autosave')
a=[1, 2, 3],b=[1, 2, 3]
a=[1, 2, 3],b=[1, 7, 3]

:::
# 11.
:::info
Code:
```python=
languages=['python', 'c++', 'java']
str=input("input str:")

if str in languages:
    print("{} is  not in the list".format(str))
else:
    print("{} is  not in the list".format(str))
```
結果：
runfile('C:/Users/user/.spyder-py3/autosave/untitled29.py', wdir='C:/Users/user/.spyder-py3/autosave')
input str:c++
c++ is  not in the list



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

```
結果：


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

```
結果：
---# 14.
:::info
Code:
```python=

```
結果：