将整数除以整数给我一个浮点数

use*_*300 -1 python python-3.x

其他一切都很好但除了两个

People = input("Number of people: ")
Cookie = input("Numnber of cookies: ")
People = int(People)
Answer = int(Cookie) / int(People)
Remain = int(Cookie) % int(People)
print ("Cookies per person: ", Answer)
print ("Cookies returning to the jar: ", Remain)
Run Code Online (Sandbox Code Playgroud)

使用两个变量4(people)和11(cookies)运行代码会返回:

Number of people: 4
Number of cookies: 11
Cookies per person:  2.75
Cookies returning to the jar:  3
Run Code Online (Sandbox Code Playgroud)

如何将2.75更改为2?

Python 3.3

DSM*_*DSM 7

int在此处恢复Python 2.X的行为,您可以使用//:

>>> 11/4
2.75
>>> 11//4
2
Run Code Online (Sandbox Code Playgroud)

// 就此而言,也适用于Python 2.