還記得我們上節(jié)課學(xué)習(xí)的print
函數(shù)嗎映屋?其實(shí)它還可以連續(xù)輸出幾個(gè)序列, 我們將在本節(jié)看到桐愉。
本節(jié)主要枚舉了Python中常用的數(shù)據(jù)類型(整點(diǎn)/浮點(diǎn)數(shù)字, 字符串, 布爾), 合理的變量命名規(guī)則(數(shù)字字母下劃線,且不以數(shù)字開頭)以及不常見的運(yùn)算符(布爾:and/or/not; 整除://渔欢; 取余:%; 乘方:**)赎瞎。
Syntax.py
# -*- coding: utf-8 -*-
# data-type
typelist = [
1, -1, 0, 1.23e5, -1.23e-5,
0xff00,
'abc', "I'm ok!", 'I\'m \"ok\"!', '''This is \
a multiline \
string''',
True, False, 0 and 1, 0 or 1, not 1,
None,
0 == None,
]
# variables
_numlist = typelist[:6]
strlist = typelist[7:10]
strlist_1 = strlist[1]
bool_list_all = typelist[11:12]
truetests = typelist[13:]
# Constants
PI = 3.141592653
# operators
a = 10
b = 3
print(
'a=', a,
'\nb=', b,
'\na/b=', a / b,
'\na//b=', a // b,
'\na%b=', a % b,
'\na**b=', a**b
)
print('All types of data:\n', typelist)
print('\tNumber types:\n', _numlist)
print('\tString types:\n', strlist)
print('\tSecond elements of string variable:\n', strlist_1)
print('\tBool types:\n', bool_list_all)
print('\tBool operator test:\n', truetests)
print('Constant Pi:\n', PI)