#字符串——大小写
def str():
s="abcde"
print(s.title()) # title : 每一个单词首字母大写,其他全小写
print(s.upper()) # upper : 全部大写
print(s.lower()) # lower : 全部小写
#str()
#-------------------------------------------------------------
def _nt():
print("hello world\n\thello world") # \t 's function
print("Languages:\n\tPython\n\tJava\n\tC\C++") # \n\t 's function
#_nt()
#-------------------------------------------------------------
#字符串——删除空白
def _remove():
s=" hello world "
print(s)
print(s.lstrip()) # (开头)首空格
print(s.rstrip()) # 末尾空格
print(s.strip()) # 首、尾空格
#_remove()
#--------------------------------------------------------------
#列表——插入元素
def list_append():
list=["I","LOVE","YOU"]
list.append("yh") #list.append(what) 列表末尾添加数据
print(list)
list.insert(0,"yh")
print(list) #list.insert(num,what) 列表具体位置,添加数据其他往后挪一位
list.insert(-1,"ZY")
print(list)
#list_append()
#--------------------------------------------------------------
#列表——删除元素
def list_del():
s=["I","LOVE","YOU","ZY"]
del s[-1] #del s[i] 删除已知位置的列表值
print(s)
s=["I","LOVE","YOU","ZY"]
print(s.pop()) #s.pop() 删除并得到末尾的列表值
print(s)
s=["I","LOVE","YOU","ZY"]
s.remove("ZY") #s.remove("ZY") 删除列表已知值
print(s)
#list_del()
#--------------------------------------------------------------
#列表——由小到大排序 / len()确定元素个数
def list_sort():
s=['a','d','c','e','b']
s.sort() # s.sort() 由小到大排序: 数字按数字 英文按字母表 abcde
print(s)
s.reverse()
print(s)
s.reverse() # s.reserve() 逆序排列,再逆序一次就可以返回原来的
print(s)
x=len(s)
print(x)
#list_sort()
#--------------------------------------------------------------
#列表——数字列表找最大最小值等
def MAX_AND_MIN():
num=[1,2,3,4,5,6,7,8,9,0]
print(max(num)) # max(self) : 找最大值
print(min(num)) # min(self) : 找最小值
print(sum(num)) # sum(self) : 求和
#MAX_AND_MIN()
#--------------------------------------------------------------
#列表——元组
def another_list():
s=(200,100)
print(s[0])
# print(s[-1]) #元组是无法改变的列表 这里改变s【0】=50 is wrong!
# s[0]=50
# print(s[0])
#another_list()
#--------------------------------------------------------------
#If语句——列表
def _if():
s=["zy","yh","lx","cj"]
a="zy"
if a in s:
print("YES") # if 中直接not in 或者 in 来判断是否在列表中
if a not in s:
print("NO")
#_if()
#-------------------------------------------------------------
#函数——import(模块)
import pizza as zy #from pizza import print.one 两种调用方法 as是别名,把pizza叫做zy
#zy.print_one()
#--------------------------------------------------------------
#类——class XX():
class Restaurant():
def __init__(self,name,type):
self.name=name
self.type=type
def describe_restaurant(self):
print(self.name+"and"+self.type)
def open(self):
print("The restaurant is open")
retstaurant=Restaurant("AI BOAT","chinese food") #具体内容看书的简介 P140
#retstaurant.describe_restaurant()
#retstaurant.open()
#--------------------------------------------------------------
def str():
s="abcde"
print(s.title()) # title : 每一个单词首字母大写,其他全小写
print(s.upper()) # upper : 全部大写
print(s.lower()) # lower : 全部小写
#str()
#-------------------------------------------------------------
def _nt():
print("hello world\n\thello world") # \t 's function
print("Languages:\n\tPython\n\tJava\n\tC\C++") # \n\t 's function
#_nt()
#-------------------------------------------------------------
#字符串——删除空白
def _remove():
s=" hello world "
print(s)
print(s.lstrip()) # (开头)首空格
print(s.rstrip()) # 末尾空格
print(s.strip()) # 首、尾空格
#_remove()
#--------------------------------------------------------------
#列表——插入元素
def list_append():
list=["I","LOVE","YOU"]
list.append("yh") #list.append(what) 列表末尾添加数据
print(list)
list.insert(0,"yh")
print(list) #list.insert(num,what) 列表具体位置,添加数据其他往后挪一位
list.insert(-1,"ZY")
print(list)
#list_append()
#--------------------------------------------------------------
#列表——删除元素
def list_del():
s=["I","LOVE","YOU","ZY"]
del s[-1] #del s[i] 删除已知位置的列表值
print(s)
s=["I","LOVE","YOU","ZY"]
print(s.pop()) #s.pop() 删除并得到末尾的列表值
print(s)
s=["I","LOVE","YOU","ZY"]
s.remove("ZY") #s.remove("ZY") 删除列表已知值
print(s)
#list_del()
#--------------------------------------------------------------
#列表——由小到大排序 / len()确定元素个数
def list_sort():
s=['a','d','c','e','b']
s.sort() # s.sort() 由小到大排序: 数字按数字 英文按字母表 abcde
print(s)
s.reverse()
print(s)
s.reverse() # s.reserve() 逆序排列,再逆序一次就可以返回原来的
print(s)
x=len(s)
print(x)
#list_sort()
#--------------------------------------------------------------
#列表——数字列表找最大最小值等
def MAX_AND_MIN():
num=[1,2,3,4,5,6,7,8,9,0]
print(max(num)) # max(self) : 找最大值
print(min(num)) # min(self) : 找最小值
print(sum(num)) # sum(self) : 求和
#MAX_AND_MIN()
#--------------------------------------------------------------
#列表——元组
def another_list():
s=(200,100)
print(s[0])
# print(s[-1]) #元组是无法改变的列表 这里改变s【0】=50 is wrong!
# s[0]=50
# print(s[0])
#another_list()
#--------------------------------------------------------------
#If语句——列表
def _if():
s=["zy","yh","lx","cj"]
a="zy"
if a in s:
print("YES") # if 中直接not in 或者 in 来判断是否在列表中
if a not in s:
print("NO")
#_if()
#-------------------------------------------------------------
#函数——import(模块)
import pizza as zy #from pizza import print.one 两种调用方法 as是别名,把pizza叫做zy
#zy.print_one()
#--------------------------------------------------------------
#类——class XX():
class Restaurant():
def __init__(self,name,type):
self.name=name
self.type=type
def describe_restaurant(self):
print(self.name+"and"+self.type)
def open(self):
print("The restaurant is open")
retstaurant=Restaurant("AI BOAT","chinese food") #具体内容看书的简介 P140
#retstaurant.describe_restaurant()
#retstaurant.open()
#--------------------------------------------------------------