地 址:上海市青浦66号 电 话:17707521353 网址:hdthjs.com 邮 箱:12434826@qq.com
在Python中,正整(zheng)正整数是正整大于(yu)零的整数,以下是正整一些关于Python正整数的基本操作(zuo)和示(shi)例:(图片来源网络,侵删)
1、正整定义正整数
num = 5print(num)
2、正整正整数的正整加法
num1 = 3num2 = 4sum = num1 + num2print(sum)
3、正整数的正整减法
num1 = 7num2 = 2difference = num1 num2print(difference)
4、正整数的正整乘法
num1 = 3num2 = 4product = num1 * num2print(product)
5、正整数的正整除法
num1 = 8num2 = 2quotient = num1 / num2print(quotient)
6、正整数的正整取余
num1 = 7num2 = 3remainder = num1 % num2print(remainder)
7、正整数的正整幂运算
base = 2exponent = 3power = base ** exponentprint(power)
8、正整(zheng)数的正整比较(jiao)
num1 = 5num2 = 3print(num1 > num2) # Trueprint(num1 < num2) # Falseprint(num1 == num2) # Falseprint(num1 != num2) # Trueprint(num1 >= num2) # Trueprint(num1 <= num2) # False