分享一些Python的语句给大家

1.选择一个变量,给变量赋值,然后 进行运行如下:

name='老王’

print('name')

2. input是一个内建函数(系统自带的函数/方法)

如name=input()

   age=input()

print('我的名字是'+name',我的年龄是'+age)

3.字符串拼接

name='张三’

found='喝酒’

print(name+'喜欢‘+found)

4.变量命名有两种方式;

  1.大驼峰   每一个单词首字母大写如MyName

    小驼峰    第一个单词字母小写后面的单词字母大写如 myName

  2 下划线命名法   my_name   coding_man

5. 1.条件判断式

score=81

if  score>=60:

    print('')

  2.  if  else结构

salary=1000

if salary>=10000:

   print('')

else:

   print('')

 3.   if   elif  结构

price=2800

if price<300:

   print('')

elif  price<1000:

   print('')

else:

    print('')

6.将字符串转化为数字  如

count=int(count)



猜你喜欢

转载自blog.csdn.net/qq_42543314/article/details/80820059