the Way of Python Day 3

margin1314 2018-05-18 原文

the Way of Python Day 3

today,i learned so much knowledge about  the basis of python.

firstly,i studied  methematical operators like ‘+’,’/’ and so on.

  for instance,2*3=5 , 4/2=2.0 and so on.

And, i also knew about comparison operators like ‘>’,'<=’,’==’ and the rest.

  for exmple,2 < 3,2 <=3,3==3 and the rest.

afterwards,i mastered assigning operators like ‘=’,’+=’,’**=’ etc.

in the end of morning,i grasped the usage of logical operator,and、or、not.

secondly,i knew a expression is a statement or code consisting of operands and operators ,like 1 * 3 * 4(1、3、4 stand for operand ,* stand for operator ),expressions can get value ,so put them on the right of “=” to assign value to a veriable.

thirdly,i mastered the usage of while loop ,so i spent the whole afternoon going about doing it.

  the first program i writed(how to get odd number and even number):

num = 1
while num <= 100:
if num%2 == 0 :
print(num)
num += 1

  and 

num = 1

while num <= 100 :
if num%2 != 0 :
print(num)
num += 1

  a program of guessing age:

age = 50

user_input_age = int(input(“age is : “))

while user_input_age != age :

if user_input_age == age :
print(“yes”)
elif user_input_age > age :
print(“bigger”)
else :
print(“smaller”)
user_input_age = int(input(“age is : “))
print(“End”)

   or

age = 51

flag = True

while flag :
users_age = int(input(“Age is “))
if users_age == age:
print(“yes”)
flag = False
elif users_age > age:
print(“bigger”)
else :
print(“smaller”)
print(“End”)

  or(and the usage of ‘break’)

age = 51

while True :
users_age = int(input(“Age is “))
if users_age == age:
print(“yes”)
break
elif users_age > age:
print(“bigger”)
else :
print(“smaller”)
print(“End”)

  and

num = 1
while num<10 :
print(num)
num += 1
if num == 3 :
break

    a program of using # to get a rectangle :

num_height = 1
height = int(input(“Please input the height of the retangle: “))
width = int(input(“Please input the width of the retangle:”))

while num_height <= height :
num_width = 1
while num_width <= width :
print(“#”,end=””)
num_width += 1
num_height += 1
print()

    a way to get the multiplication table:

first = 1

while first <= 9 :
third = first
second = 1
while second <= third :
print(str(second)+”*”+str(third)+”=”+str(second*third),end=”\t”)
second += 1
print()
first += 1

 

发表于 2018-05-18 23:03 margin1314 阅读() 评论() 编辑 收藏

 

版权声明:本文为margin1314原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/margin1314/p/9058374.html

the Way of Python Day 3的更多相关文章

  1. 实现spaCy实体标注模型

    命名实体识别是指对现实世界中某个对象的名称的识别。与词性标注一样,是自然语言处理的技术基础之一。它的作用主要是 […]...

  2. Web of science|SCIE|影响因子|SSCI|高被引论文|领域中热点论文|

    Web of science|SCIE|影响因子|SSCI|高被引论文|领域中热点论文| 信息检索: 数据库 […]...

  3. Python Web实战:Python+Django+MySQL实现基于Web版的增删改查

    前言 本篇使用Python Web框架Django连接和操作MySQL数据库学生信息管理系统(SMS),主要包 […]...

  4. python 爬取糗事百科 gui小程序

      前言:有时候无聊看一些搞笑的段子,糗事百科还是个不错的网站,所以就想用Python来玩一下。也比较简单,就 […]...

  5. python 抓取数据,pandas进行数据分析并可视化展示 – jack_Meng

    python 抓取数据,pandas进行数据分析并可视化展示   感觉要总结总结了,希望这次能写个系列文章分享 […]...

  6. Python 参考手册

    声明:转载自 http://blog.csdn.net/jerry_1126/article/details/ […]...

  7. Python – Python语法

    Python 基础1. 注释1. 单行注释 # 2. 多行注释 2. 单下划线、双下划线、头尾双下划线说明以单下划线开头 _foo 的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用 from xxx impo...

  8. python 正则,常用正则表达式大全

     Nginx访问日志匹配 re.compile #re.compile 规则解释,改规则必须从前面开始匹配一个 […]...

随机推荐

  1. 使用SyncNavigator进行SqlServer或者MYsql数据库的实时、增量同步

    SyncNavigator是一款高效的数据库同步工具,支持sqlserver数据库和mysql数据库,采用增量 […]...

  2. Odoo数据库快速备份与还原

    Odoo数据库快速导入导出方法介绍 数据库GB以下方法(Odoo提供的集合工具) 浏览器进入:domain.c […]...

  3. JAVAEE——BOS物流项目03:学习计划、messager、menubutton、登陆拦截器、信息校验和取派员添加功能

    1 学习计划 1、jQuery easyUI messager使用方式 n alert方法 n confirm […]...

  4. 互动教程,让你5分钟掌握 Flexbox 布局模式

    Flexbox 布局模块目前是 W3C 候选标准,旨在提供一个更有效的方式进行布局,对齐和为容器里的项目分配空 […]...

  5. CAD绘填充命令

    CAD绘填充命令 1.单击菜单栏,“绘图”->“ 填充”。 2.单击绘图工具栏“绘填充命令”按钮。 3. […]...

  6. 码农人生——技术人在互联网如何变现——第003期博文

    如果你对个人如何在互联网变现感兴趣,我推荐你读这篇文章,这是我从各位大佬收费群总结的对我有价值的一些文字,一样 […]...

  7. 详解SVM模型——核函数是怎么回事

    大家好,欢迎大家阅读周二机器学习专题,今天的这篇文章依然会讲SVM模型。 也许大家可能已经看腻了SVM模型了, […]...

  8. python模块的导入详解

    一:一个小问题:什么是模块?   我的理解是:有通用功能的文件的集合。 二:为什么要使用模块?   我们通常为 […]...

展开目录

目录导航