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. Python socket的客户端

    做一个socket客户端1、声明一个实例2、绑定端口号和地址3、循环发送和接收响应其中要注意粘包的产生,为了防 […]...

  2. Python 读取图像文件的性能对比

    Python 读取图像文件的性能对比 使用 Python 读取一个保存在本地硬盘上的视频文件,视频文件的编码方 […]...

  3. 万恶之源 – Python基础知识补充

    编码转换 编码回顾:   1. ASCII : 最早的编码. ⾥⾯有英⽂⼤写字⺟, ⼩写字⺟, 数字, ⼀些特 […]...

  4. 从零开始学Python 一

    一、安装  1.进入Python官网下载环境:https://www.python.org 2.根据自己的电脑 […]...

  5. Python 开源网上商城项目

    django-oscar  https://github.com/django-oscar/django-os […]...

  6. The given \’driver\’ ] is unknown, Doctrine currently supports only the follo wing drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo

      [Doctrine\DBAL\DBALException]                         […]...

  7. 【线段树】[CodeForces – 717F]Heroes of Making Magic III

    题目大意 一个长度为n的序列,每一个位置都有一些小怪。英雄可以在序列上左右移动,并且可以击杀一个他所到达的位置 […]...

  8. win10下Anaconda 2 和 3 共存安装,并切换jupyter notebook和Pycharm中的对应版本

    win10下Anaconda 2 和 3 共存安装,并切换jupyter notebook和Pycharm中的 […]...

随机推荐

  1. C#拼音帮助类

     如果使用此帮助类需要引用       using Microsoft.International.Conve […]...

  2. 【C#】发票助手二维码生成

    【C#】发票助手二维码生成 2018-01-15 16:25 by JiaJia.Oct, … 阅 […]...

  3. 【Win10】我们无法更新系统保留的分区

      前言 笔者是一个萌新,这个方案也是慢慢摸索出来的,有更好的方案欢迎大家提出 前段时间用公司电脑发现win1 […]...

  4. iOS的非常全的三方库,插件,大牛博客

    转自: http://www.cnblogs.com/zyjzyj/p/6015625.html     gi […]...

  5. USB学习笔记连载(二十):FX2LP如何实现高速和全速切换(转载)

      CYPRESS的USB外设控制器CY7C68013A是一款广泛应用于USB打印机,手机,存储设备,USB测 […]...

  6. 你应该知道的最好Webmail邮件客户端,

    你应该知道的最好Webmail邮件客户端, 2016-03-26 15:46  狼人:-)  阅读(1521) […]...

  7. 撕破脸!360大刀砍向腾讯QQ(zz)

    9月27日上午消息,360安全卫士与腾讯再起争端:今日360安全卫士宣布发布隐私保护器,专门曝光窥私软件,而该 […]...

  8. 产品经理做竞品分析的思路(一) – Ada多一多

    产品经理做竞品分析的思路(一) 本文转自:简书 文/休言万事转头空,觉得分析竞品的思路挺好,所以就转了~ 1. […]...

展开目录

目录导航