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

the Way of Python Day 2

时间:2018-05-16 19:43:50      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:font   sha   put   enter   exp   eth   was   with   val   

  today,i got lots of knowledge of python ,like how to get the maximum value of three numbers.

  similarly i already was able to write a program of how to get the minium number among many numbers.

  here is the minium value program:

num_one=input("enter number one :")
num_two=input("enter number two :")
num_three =input("enter number three :")

min_num = 1

if num_one>num_two :
min_num= num_one
else :
min_num= num_two
if min_num >num_three:
min_num = num_three
print("the minium number is",min_num)

  here is the maximum value program:

num1=input("enter Num1:")

num2=input("enter Num2:")

num3=input("enter Num3:")

max_num=0

if num1>num2:
max_num=num1
else :
max_num=num2
if max_num < num3:
max_num = num3
print("the max num is ",max_num)

  i would share my experience about these two programs,maybe you could get something from it.

at first , use input to get three numbers.

then ,choose two numbers of them to compare size,and get the larger number.

in the end ,pick the last number to compare with the larger number,so get the maximum number.

the Way of Python Day 2

标签:font   sha   put   enter   exp   eth   was   with   val   

原文地址:https://www.cnblogs.com/margin1314/p/9047518.html

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