Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Use if __name__ == "__main__": if __name__ == "__main__":

This:

 if a > 0:
 sgn_a = ""
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

can be shortened to

 if a > 0:
 sgn_a = ""
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

There also seems to be an extra indentation (4 spaces) at the start of every line. I'm guessing that it is caused when copy-pasting the code.

Also, it is encouraged to use .format() instead of % it is encouraged to use .format() instead of % for formatting strings.

Use if __name__ == "__main__":

This:

 if a > 0:
 sgn_a = ""
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

can be shortened to

 if a > 0:
 sgn_a = ""
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

There also seems to be an extra indentation (4 spaces) at the start of every line. I'm guessing that it is caused when copy-pasting the code.

Also, it is encouraged to use .format() instead of % for formatting strings.

Use if __name__ == "__main__":

This:

 if a > 0:
 sgn_a = ""
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

can be shortened to

 if a > 0:
 sgn_a = ""
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

There also seems to be an extra indentation (4 spaces) at the start of every line. I'm guessing that it is caused when copy-pasting the code.

Also, it is encouraged to use .format() instead of % for formatting strings.

Source Link
Spikatrix
  • 1k
  • 1
  • 9
  • 21

Use if __name__ == "__main__":

This:

 if a > 0:
 sgn_a = ""
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

can be shortened to

 if a > 0:
 sgn_a = ""
 else:
 sgn_a = "-"
 if b > 0:
 sgn_b = "+"
 else:
 sgn_b = "-"
 if c > 0:
 sgn_c = "+"
 else:
 sgn_c = "-"

There also seems to be an extra indentation (4 spaces) at the start of every line. I'm guessing that it is caused when copy-pasting the code.

Also, it is encouraged to use .format() instead of % for formatting strings.

lang-py

AltStyle によって変換されたページ (->オリジナル) /