博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python基础学习2
阅读量:7222 次
发布时间:2019-06-29

本文共 862 字,大约阅读时间需要 2 分钟。

一.算数运算符

+加法,-减法,*乘法,/除法,//地板除,%求余,**幂运算。

二.逻辑运算符

非not、且and、或or。优先级依次为not,and,or。

三.print()end结尾

print()#默认为print(end="\n"),想要输出在一行可写为print(end="")

四.while循环

num = 1while num<10:     print(num)      num+=1

  break为终止当前循环体,continue为结束当次循环。

age=30while True:    input_age = int(input("Age is :"))    if input_age == age:        print("It's right.")        break    elif input_age > age:        print("It's bigger.")    else:        print("It's smaller.")       print("End")

五.while和else的配套使用

num = 1while num <= 5:    num += 1       print(num)else:    print("This is else statement")

如果使用break,那么else也不会执行。

六.while的嵌套使用--输出九九乘法表

row = 1while row<=9:    col = 1        while col <= row:        print(  str(col)+"*"+ str(row) +"="+str(col * row), end="\t")        col += 1            print()        row += 1

  

  

 

转载于:https://www.cnblogs.com/sfencs-hcy/p/9505348.html

你可能感兴趣的文章
Spring的起源和背景
查看>>
vue 单页面应用实战
查看>>
MyBatis Generator作为maven插件自动生成增删改查代码及配置文件例子
查看>>
MySql_SQLyog快捷键
查看>>
转】在Ubuntu中安装Cassandra
查看>>
Java多线程系列--“JUC锁”11之 Semaphore信号量的原理和示例
查看>>
RDBMS架构的开源DW/DSS引擎列表
查看>>
【转载】Websocket学习
查看>>
【笔记6】用pandas实现条目数据格式的推荐算法 (基于物品的协同)
查看>>
[LintCode] Best Time to Buy and Sell Stock 买卖股票的最佳时间
查看>>
NPN/PNP和N沟道/P沟道负载的接法
查看>>
我们为什么使用Node
查看>>
怎么取消ie浏览器body与html的间隙
查看>>
java Collections.sort()实现List排序自定义方法
查看>>
如何编辑SDE数据库(转载)
查看>>
JAVA并发-内置锁和ThreadLocal
查看>>
分布式部署引发的问题
查看>>
C# Mongo Client 2.4.2创建索引
查看>>
【nodejs】初识 NodeJS(一)
查看>>
程序编译是出现"field has incomplete type"问题的解决
查看>>