assignment of day four


1.Numeric type

(1)integer

Use

Is to show people's age;phone number ;id numbers etc.

Define

age_Nick=18 #nick is eighteen years old
print(id(age_Nick))#140733086069536
print(type(age_Nick#<class 'int'>
print(age_Nick)#18

How to use

plus minus,multiply,divide or some logical comparison > <

(2)float

Usefulness

Is to show height weight salary etc.

Define

salary = 2.1  # salary=float(2.1)

print(id(salary))#2188554482512
print(type(salary))#<class 'float'>
print(salary)#2.1

How to use

The same to int plus minus,multiply,divide or some logical comparison > <

2.string type

Use

To show the name ,hobby etc.

Define

name1 = 'Nick'
name2 = "Egg"
print(id(name1))#2039780276080
print(type(name1))#<class 'str'>
print(name1)#Nick
name3 = """Nick
Egg"""

print(name3)#Nick
            #Egg

How to use

string type can only plus multiply or logical comparison

3.list

Use

To store multiple value such as multiple girlfriend multiple hobbies .

Define

hobby = 'read'
hobby_list = [hobby, 'run', 'girl']
print(id(hobby_list))#3013323084360
print(type(hobby_list))#<class 'list'>
print(hobby_list)#['read', 'run', 'girl']

How to use

Our aim is not to store but to take I'll show the way to take value from list and plz remenber the start number is 0

4.Dictionary

Use

Is to store many many value from

key value

way ,and while taking can follow the key,key can describe value.

Define

user_info = {'name': 'nick', 'gender': 'male', 'age': 19,
             'company_info': ['oldboy', 'shanghai', 50]}

print(id(user_info))#1738629399160
print(type(user_info))#<class 'dict'>
print(user_info)#{'name': 'nick', 'gender': 'male', 'age': 19, 'company_info': ['oldboy', 'shanghai', 50]}

How to use

dictionary taking value is no more rely on indexes,but rely on the key ,though the [key],can get key's value.

4.Wordcloud

import jieba
import wordcloud
# import module



from imageio import imread
mk=imread('wujo.png')

s="蔡徐坤 把 唱 跳 手起刀落 rap 篮球 打成筛子 流量明星 口红 男扮女装 鸡你太美 随后 获得 出道后 首个 个人 音乐类 奖项 亚洲新歌榜 2018 年度盛典“ 最受欢迎 潜力 男歌手"
s_list=jieba.lcut(s)
print(s_list)
s=''.join(s_list)

w=wordcloud.WordCloud(font_path='C:\Windows\Fonts\simsun.ttc',mask=mk,background_color='white')
w.generate(s)
w.to_file('cxk1.png')
原文地址:https://www.cnblogs.com/jimGraymane/p/11413134.html