the Way of Python Day 2

本文分享了如何使用Python编程语言来确定一组数字中的最大值和最小值的方法。作者介绍了两个实用的程序,分别用于寻找三个输入数字中的最大值及多个数字中的最小值。通过逐步解释代码逻辑,帮助读者理解比较操作的基本原理。

  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.

转载于:https://www.cnblogs.com/margin1314/p/9047518.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值