码迷,mamicode.com
首页 > 编程语言 > 详细

python数据类型

时间:2019-09-30 13:01:22      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:import   second   oat   pytho   min   print   pow   table   version   

致敬hello world!

print("hello world!")

print("hello again")

print("this is the 3rd line, \n",

        "and this is also the 3rd line")

print("this is the 3rd line, \

         and this is also the 3rd line")

expression-> number

operator _> +-*/

print(4-5)

print(8+)

110/12.97

naming

number_of_cars = 34

x = 8  if x < 7:

  print(x)

if(x < 7):

print("x is smaller than 7")

Semantics

x = 8 

if x < 7:

  print("x is smaller tahn 7")

  print("x is bigger than 7")

variable names, and objects

variable and value

speed_of_liuxiang = 110/12.97

distance = 1000

time = distance/speed_of_liuxiang

print(time)

print(time/60)

assign new value, Mutable

speed_of_ydj= 110/10

time = distance/speed_of_ydj

print(time)

time = time -1

print(time)

data type

interger   + - * / % //   how big is an int?    0b10 0o10 ox10

float   98.5  type(a)     import math   math.pi math.e math.floor(98.6)  math.ceil(98.6) math.pow(2,3)  math.sqrt(25)

Boolean    1 < 2    (2< 1) or(1<2)   not(2<1)    type(a)

Strings  s = ‘this is a string‘  type(s)   print(s)   ‘’‘this is the first line

    this is the second line’‘’

type  conversions

a = str(98.6)

a

type(a)

float(‘98.6‘)

int(‘-123‘)

1 + 2.0 

True + 3

3.88 +"28"

 

combine & duplicate

template = "my name is "

name = "ydj"

greeting = template + ‘‘ " + name+" ."

print(greeting)

 

python数据类型

标签:import   second   oat   pytho   min   print   pow   table   version   

原文地址:https://www.cnblogs.com/ydjmail/p/11611942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!