#!/usr/bin/env python # coding: utf-8 # In[1]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot'] type(medical_list) # In[2]: list('123') # In[3]: list(123) # In[4]: print('Length of list\t:', len(medical_list)) print('[0]\t\t:', medical_list[0]) print('[1:5:3]\t\t:', medical_list[1:5:3]) # In[5]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot'] medical_list.append('headache') medical_list.append('nausea') medical_list.append('vomitting') medical_list # In[6]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot'] recent_illness = ['headache', 'nausea', 'vomitting'] medical_list.extend(recent_illness) medical_list # In[7]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot'] recent_illness = ['headache', 'nausea', 'vomitting'] medical_list = medical_list + recent_illness medical_list # In[8]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot'] recent_illness = ['headache', 'nausea', 'vomitting'] medical_list += recent_illness # 我改了這行 medical_list # In[9]: 底數 = 2 對數 = 10 底數 **= 對數 底數 # 已經不是底數的底數 # In[10]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot', 'headache', 'nausea', 'vomitting'] print('vomitting 的位置:', medical_list.index('vomitting')) medical_list[(medical_list.index('vomitting'))] = 'vomiting' print('拼字正確的清單', medical_list) # In[11]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot', 'headache', 'nausea', 'vomiting'] print('2. 給你看', medical_list.pop()) print('1. 拿出來', medical_list) # In[12]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot', 'headache', 'nausea', 'vomiting'] print('pimple的位置', medical_list.index('pimple')) print('拿出來給你看', medical_list.pop(medical_list.index('pimple'))) print(medical_list) # In[13]: medical_tuple = ('toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot', 'headache', 'nausea', 'vomitting') type(medical_tuple) # In[14]: medical_list = ['toothache', 'pimple', 'myopia', 'astigmatism', 'asthma', 'flatfloot', 'headache', 'nausea', 'vomitting'] medical_tuple = tuple(medical_list) medical_tuple # In[15]: medical_tuple[-1] # In[16]: medical_tuple[-1] = 'vomiting'