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

python基础

时间:2018-09-01 20:38:17      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:分享图片   世界   code   eof   控制语句   交互   lag   +=   one   

#第一个python程序
技术分享图片
#第一个python程序
# print(‘hello world‘)
# print(‘你好,世界‘)
View Code
#变量的命名
技术分享图片
#变量的命名
# AgeOfAlex=18#驼峰体
# age_of_alex=18#下划线
View Code
#内存空间
技术分享图片
#内存空间
# a=20
# b=a
# a=10
# print(a,b)
View Code
#引号的使用
技术分享图片
#引号的使用
# print(‘I am a student‘)
# print("I‘m a student")
# msg="""
# 会当凌绝顶,
# 一览众山小。
# """
# print(msg)
View Code
#字符串的拼接
技术分享图片
#字符串的拼接
# print(‘alex‘+‘wusir‘)
# print(‘alex‘*4)
View Code
#input 用户交互  得到的是字符串
技术分享图片
#input 用户交互  得到的是字符串
# name=input("name:")
# password=input("password:")
# print(name,password)
# print(type(name),type(password))
View Code
#条件控制语句 if elif else
技术分享图片
#条件控制语句 if elif else
# score=int(input("请输入成绩:"))
# if score>=90:
#     print(‘A‘)
# elif score>=80:
#     print(‘B‘)
# elif score>=70:
#     print(‘C‘)
# else:
#     print(‘D‘)

#嵌套使用
# name=input("name:")
# age=int(input("age:"))
# if name==‘alex‘:
#     if age==18:
#         print(‘welcome‘)
#     else:
#         print(‘age error‘)
# else:
#     print(‘name error‘)
View Code
# while循环
技术分享图片
# while循环

# 死循环
# while True:
#     print(‘hello‘)

#输出1-100
# count=1
# while count<=100:
#     print(count)
#     count+=1

#计算1-100的和
# s=0
# count=1
# while count<=100:
#     s+=count
#     count+=1
# print(s)
View Code
#break跳出循环
#continue跳出本次循环 继续下一次循环
#else循环正常执行完毕才执行
技术分享图片
#break跳出循环
#continue跳出本次循环 继续下一次循环
#else循环正常执行完毕才执行
# count=1
# while True:
#     print(count)
#     count+=1
#     if count>100:
#         break
# else:
#     print(‘循环正常执行完了才执行‘)
# print(‘--------end--------‘)


#输出1-5 95-100
# count=0
# while count<100:
#     count+=1
#     if count>5 and count<95:
#         continue
#     else:
#         print(count)
View Code
#标志位
技术分享图片
#标志位 输出1-100
# flag=True
# count=1
# while flag:
#     print(count)
#     if count==100:
#         flag=False
#     count+=1
View Code
#格式化输出 %s %d %%
技术分享图片
#格式化输出 %s %d
# name=input(‘name:‘)
# age=int(input(‘age:‘))
# hobby=input(‘hobby:‘)
# msg="""
# -----info of %s-----
# name:%s
# age:%d
# hobby:%s
# ---------end----------
# """%(name,name,age,hobby)
# print(msg)

#%%
# print(‘%s的数学成绩占20%%‘%(‘alex‘))
View Code

 







 



python基础

标签:分享图片   世界   code   eof   控制语句   交互   lag   +=   one   

原文地址:https://www.cnblogs.com/liuhongshuai/p/9571225.html

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