0
A
回答
0
你应该回到基本的,因为有两个部分要注意,现在应该是你最基本的。第一个是操作者==
:
>>> a = 1
>>> b = 2
>>> print(a==b)
False
>>> a = 2
>>> print(a==b)
True
的==
操作者对应于布尔值:真或假
第二是%
运算符。 %
运算符将第一个数字除以第二个数字并返回余数。看看下面的,例如:
>>> a = 1
>>> b = 2
>>> print(a%b) # 1/2 = 0 2's + 1 remainder
1
>>> print(b%a) # 2/1 = 2 1's + 0 remainder
0
现在到你的代码:
def modulo(spam):
if spam == 3 % 2: # if spam is one (3/2 = one 2, plus 1 remainder)
print(spam)
else: # I'd add this, so you know the method is being run
print("Spam is not 1.")
0
看来,这样就不会进入print(spam)
条件spam == 3 % 2
是不正确的。尝试调试它。
1
假设python代码正确缩进,没有可能打印,因为3%2
等于1
和spam
不能等于1
。
相关问题
- 1. 为什么下面的JavaScript函数不打印任何东西?
- 2. Python:为什么我的程序不打印任何东西?
- 3. 为什么我的最小功能不打印任何东西?
- 4. 为什么我的dbms_output.put('AAA');不打印任何东西......?
- 5. 这个程序为什么不打印任何东西?
- 6. 为什么这不打印任何东西
- 7. Http POST ..为什么不打印任何东西?
- 8. 为什么不打印任何东西而是空?
- 9. 为什么这个程序不打印出任何东西?
- 10. 这个程序为什么不打印出任何东西?
- 11. 当我编译这个为什么不打印任何东西?
- 12. 我的Javascript不打印任何东西
- 13. System.out.write不打印任何东西?
- 14. 回声“-e”不打印任何东西
- 15. 子进程不打印任何东西
- 16. lyricsForName函数不打印任何东西
- 17. JUnitCore.runClasses不打印任何东西
- 18. ASCII chr()不打印任何东西
- 19. innerHTML不打印任何东西
- 20. PDO查询不打印任何东西
- 21. Mips程序不打印任何东西
- 22. 输出流不打印任何东西
- 23. StringBuffer toString()不打印任何东西
- 24. xll helloworld shellcode不打印任何东西
- 25. Debug.Writeline不打印任何东西
- 26. 这为什么不画任何东西?
- 27. 为什么不删除任何东西?
- 28. 为什么孩子在这里过程不打印任何东西?
- 29. 在Bash中,为什么`x = 100 echo $ x`不打印任何东西?
- 30. Jsoup - 打印element.data()不打印任何东西
什么是你想使用此代码归档? – DZDomi
谁鼓吹这种废话? – Idos
Hallo,我用codecademy学习python,一个问题是我应该编写Python语法 – iratxe