C:\Users\Jeffery1u>pythonPython 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32Warning:This Python interpreter is in a conda environment, but the environment hasnot been activated. Libraries may fail to load. To activate this environmentplease see https://conda.io/activationType "help", "copyright", "credits" or "license" for more information.>>> 23+730>>> 4**216>>> result=20>>> print(result)20>>> x=30>>> x+=70>>> x100>>> int(4.3)4>>> float(10)10.0>>> round(4.67)5>>> # i love u... x=30>>> x30>>> type(x)>>> str='i love u'>>> str'i love u'>>> # 使用双引号开始字符串,单引号开始内部字符串... str="i love 'u'">>> str"i love 'u'">>> print(str)i love 'u'>>> str='''i'm love "u" '''>>> print(str)i'm love "u">>> #上面也可以使用三引号... #使用加号字符串... pring("a"+"b")Traceback (most recent call last): File " ", line 3, in NameError: name 'pring' is not defined>>> print("a"+"b")ab>>> "a"+"b"
# list=[1,2.0,'3.0']# for i in list:# print(i)# print(list[-1])# print(list[0:])# print(list[1:-1])# list=[[1,2.0,'3.0'],[1,2.0,'3.0'],[1,2.0,'3.0']] #列表列表## print(list[0][0])from csv import readerapps_data=list(reader(open('AppleStore.csv')))print(apps_data[:5]) #前五行数据row_1 = ['Facebook', 0.0, 'USD', 2974676, 3.5]row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]row_4 = ['Temple Run', 0.0, 'USD', 1724546, 4.5]row_5 = ['Pandora - Music & Radio', 0.0, 'USD', 1126879, 4.0]rating_sum=0app_data_set = [row_1, row_2, row_3, row_4, row_5]# for rating in app_data_set:# rating_sum=rating[4]+rating_sum# print(float(rating_sum/len(app_data_set))) #小数尽可能用浮点型ratings=[]for row in app_data_set: ratings.append(row[-1])print(ratings)avg_rating =sum(ratings)/len(ratings)print(avg_rating)#列表求和 求个数content_ratings = {'4+': 4433, '9+': 987, '12+': 1155, '17+': 622}# dictionary_name[index] = value 修改 或 添加新值#判断是否存在键dic={}list=[]for l in list: if l in dic: dic[l]=1 else: dic[l] = 1#函数 返回值def freq_table(index): frequency_table = {} for row in apps_data[1:]: value = row[index] if value in frequency_table: frequency_table[value] += 1 else: frequency_table[value] = 1 return frequency_table