注册 登录
编程论坛 Python论坛

求助,各位英雄豪杰帮小女子一个忙了

catherine716 发布于 2012-06-10 12:06, 1697 次点击
为什么 为什么 十万个问什么它错了呀?
Write a program that reads an integer from input, then outputs one of the capitalized words Positive, Negative, or Zero according to whether the number is positive, negative, or zero


x=int(input())
y=0
if x > y
print("Positive")
if x = = y
print("Zero")
if x < y
print("Negative")


Traceback (most recent call last):
  In line 3 of the code you submitted:
    if x > y
           ^
SyntaxError: invalid syntax
望各路英雄豪杰给解答,小女子这厢无比感谢,撒个花~
4 回复
#2
hziee2012-06-14 11:56
帮你改了!条件语句,函数等,Python都是使用缩进的!

x=int(raw_input())
y=0
if x > y:
    print("Positive")
elif x == y:
    print("Zero")
else:
    print("Negative")
#3
快乐出发02202012-06-15 12:53
if后面是要加“:”的,这个注意点就是了,还有就是python是很注重缩进的。
  代码如下:
x=raw_input()
y=0
if (x > y):
    print("Positive")
elif (x == y):
    print("Zero")
elif (x < y):
    print("Negative")
#4
楼兰后主2012-06-19 13:07
注意if语句格式和缩进
另外我是刚学python,大家有没有好的入门级脚本例子,或者什么适合的资料,给一些,感激不尽。qq:654391777
#5
快乐出发02202012-06-22 13:08
《python》技术详解这本书还不错,我也就是这本书入手的。
1