r/badcode • • Aug 27 '21

python Is this code bad or sugoi?

Post image
1.0k Upvotes

154 comments sorted by

View all comments

0

u/[deleted] Aug 27 '21

[deleted] — view deleted comment

0

u/[deleted] Aug 27 '21

[deleted] — view deleted comment

0

u/[deleted] Aug 27 '21

[deleted] — view deleted comment

83

u/dudeitsmason Aug 27 '21

Still, what a legend.

→ More replies (3)

13

u/koni_rs Aug 28 '21

八千以上

173

u/joonatoona Aug 27 '21
name = input("Please enter your name: ")
emoticon = "(°▽°)/ 🙇"
print("Hello {}! {}".format(name,emoticon))
def addNumbers(number1, number2):
    true = True
    if number1 or number2 < 0:
        return not true
    else:
        sum = number 1 + number2
    return sum
        
print("sum =", addNumbers(6, 9))

rain(?) = False
counter = 1
if not not not rain:
    while counter < 11:
        print(str(counter) + ". 😂😂")
        counter = counter + 1

God trying to format that on mobile sucked, and I probably got some of that wrong anyways.

75

u/[deleted] Aug 28 '21

if not not not? WTF is with the triple negative?

40

u/ycohui Aug 28 '21

that was the original code had triple not....

33

u/[deleted] Aug 28 '21

Yes, but why?

47

u/SoulslikePursuer Aug 28 '21

In the case the computer will forget, you always need to remind it a few times...what a stupid questions you ask mate.............

→ More replies (4)

9

u/[deleted] Aug 28 '21

You mean, why not

17

u/BenLeggiero Aug 28 '21

You mean, why not not not

7

u/lkmnoppo Aug 28 '21

You can use double negation to convert from truthy-value to boolean, maybe the programmer wanted to do something like that. But you usually do double negation, not triple. Triple negation should have the same effect as single negation also on truthy values.

16

u/mestrearcano Aug 28 '21

Maybe the phrase not not not rain is a common phrase in japanese or some inside joke for those involved.

27

u/dpk84 Aug 28 '21

I think I’m Japanese but I don’t have any idea about the “not not not 雨”. And besides , 数を計算する is not wrong sentence but 足し算をする is better expression for the function which is just add up. So the code might be written by not a Japanese speaker or I’m ignorance.

45

u/Roflkopt3r Aug 28 '21

I think I’m Japanese

But you aren't certain? :D

→ More replies (3)
→ More replies (2)

9

u/G-Force-499 Aug 27 '21

I really don’t understand the purpose of the last bit of code

→ More replies (1)

4

u/coldnebo Aug 27 '21

not sure about Python, but in Ruby || and “or” have different precedence, so they are not equivalent. work went through a phase a few years ago where everyone thought it was hip to use the words “and” “or” instead of the logical operators not realizing that the words are flow control constructs borrowed from Perl, such as: “file.close or die”. or in Rails: “render and return”

we spend years correcting all the logic errors introduced by those changes.

9

u/TinyBreadBigMouth Aug 28 '21

Python only has or (logical short-circuiting or) and | (binary or). No wonky precedence stuff.

→ More replies (3)
→ More replies (1)

4

u/lumo19 Aug 28 '21

I know a little Japanese and recognized the ame kanji, but didn't want to accept such a non pythonic variable name and assumed I read it wrong.

→ More replies (1)

5

u/GalaxP Aug 28 '21

Good Human

4

u/chunkyasparagus Aug 28 '21

You missed a character in the function name, should be:

数を計算する

Otherwise, awesome work!

→ More replies (1)
→ More replies (2)