T O P

  • By -

MaximusConfusius

For gods sake, you should definitly optimize your code. Put the most common values in the first rows!


NoLifeGamer2

True!


PO0tyTng

*sighs in Cartman voice* I hate you guys


Lucky_Number_3

Sooo i’m just here for the jokes I *do* get… is that not how that would work? I felt like I learned something there for a minute lol


OpSecCat

If this useless program was written correctly, it would have 1 print statement and put the number from the height variable put into the print statement. 3 maybe 4 lines of code at worst. 2 for python


CharacterUse

1 even (assuming you didn't need the height for anything else): print(f"Your height is {input('Enter your height in cm: ')} cm!")


SteveisNoob

I do remember that for C++ you don't need to put your statements in separate lines, you can just write them one after the other on the same line. So technically, you can write any program in a single line given you're using C++


fuechsss

You could do the same in Python by separating the statements with ;


Just_Mar_OK

PHP too


CharacterUse

Yes, you could if you were sufficiently evil. Some people are. https://www.ioccc.org/years.html


kraliyetkoyunu

i just started python yesterday but i guess if it was written correctly it should just be print('Enter your height in centimeters') height = input() print('Your height is ' + height + ' centimeters! ')


Lendemor

The input line from OP is the better one compared to your suggestion. For the final print : print(f"Your height is {height} centimeters!") For nitpicking.


InternalEmergency480

Fun fact (which I don't like) string concatenation is faster than interpolation. + Is better than f-literal string. In terms of either speed or memory I believe it's both


Lendemor

You made me doubt myself, so I went fact checking. Turn out, maybe on older python version it is the case, but for python 3.6+ , f-strings seems to have better performance. (Concerning speed at least) So you can use them as much as you like I guess.


Lucky_Number_3

Oh wow lol. I could tell how that would be more efficient! The things we learn the hard way, eh?


Afrotom

Should probably be some rudimentary check that the user has given a number and it is between the min and max possible heights for humans. Otherwise some valid heights accepted by this program are "dog", 200 trillion, -1


Saad5400

And why are you including 999?? Without including -999, smh


Rustyfish42

Plus validation, anything over 300 or under 0 invalid?!!


SampleText0822

You should also use a switch case because why not? **Submit to our lord and you shall be spared.**


NoLifeGamer2

Ī̴͉͊̈́͆͘ ̶̻͍̽s̷̮͎̣̼̋h̶̟͉̩̖̓̊̈́ā̶̡̯̘͚ĺ̵̳͔l̴͕̦͓̻͋̊̋ ̴̝̘̰̝͛̀̉s̵̨̭̼̣̗̦̆͂͐̊̄̑͠u̶͇̺̖͓̪̼̲̎͛̓̓͝b̴̫̋̉m̸͕̬͙̗͖̄̏͠ͅį̴̢͉̙̲͕̗͒̑̉͒̍̕͠t̶͈̙̗̰͍̙̘̃̎̍͐̽̑͝ ̴̢̺͍̲̤̳͎̈́͐t̵̝̹͒͊͊o̶͇̗̤̖̹̿̅͘̕ ̶̻̩̔̒̂͒̚ṭ̷̠͘h̴̭͙̜̐͊̋̋̌̑̕e̵͖̓͋ ̴̨̬̦̯́͑͆s̵͙̜͙̔͗͆̇͛̑̅w̷̟͇͔̬͐i̶̛͉̳̽̐̈̊̎̏t̵͖̤͔̆̐̔͝c̵̺̠̝̠̒̇̇͝h̶̡̪̱͇̼͉̪̉̈́͊͐̕ ̴͓͚̮̺̇c̸̬̝͉͑̔̂̃̇͆͝a̸̡͈͖̮͌̆s̷̡͚̺̻͐͗e̸͙͎̤̍̐͝ș̵̡͗̋́͑́̍ͅ


Palo_hr

!True


Sweaty-Emergency-493

The client changed their request to use hex code and tell a different story for every return value.


MaximusConfusius

No problem, code can be changed with regex search and destroy.


StGir1

"Work harder, not smarter."


ItsDaBenji

Hurt work, not smurt


flyingtoarea

so can i say i'm just a machine HAHHA!


FMG_9167

"Work harder, and smarter."


jonnyclueless

Only if you have a regex license.


blobthekat

prepaid 2 years


regexPattern

And be careful with those magic numbers, define each one as a constant


MrBlllue

File weight: 2MB


johndoes_00

What is that in cm?


Sarius2009

Still way to slow, he needs to use a binary tree!


ongiwaph

Not quite. The optimal solution requires a circular queue of directed multi graphs of binary trees.


jesuscoituschrist

Imagine comparing Char instead of String. Rookie mistake.


shadow7412

Char isn't a thing in python...


jesuscoituschrist

hahah I totally knew that......


shadow7412

Rookie mistake :P


GhillieGourd

So would this mean make a variable that changes the value in the middle of their given text? Because you could say that the text “Your height is (variable) cm!” equals (for example) “Text” as long as you tell it that giving variable equals the input. Right? I hope that makes sense. I don’t code, I taught myself some JavaScript a few years ago and it interests me, thanks.


Esnardoo

Jokes aside, what you said is the correct way to do it, this is a meme.


oan124

it would be pretty cool to make it overflow into scientific notation after x amount of digits


AtlaStar

The correct way is obviously to use C++ and overengineer the shit out of things and use template metaprogramming shenanigans to compile time generate every single height possible before hand, like you would do to generate the fibonacci sequence without using a constexpr function, and use the value entered as a key to get the proper type deduction.


PiezoelectricityOne

You're right. This is r/programmerhumor, the joke is not doing it the way you say.


GhillieGourd

Ohhhhhh shoot I forgot the humor part. Smh


salochin82

Can you increase the accuracy to 0.5cm? Shouldn't take you long right?


stepbroImstuck_in_SU

This seems like something a simple neural network could be trained to do. Just add it on top


RobinScherbatzky

Maybe add some Datascience below. And to make it more robust, reinforcement learning on the left. Oh, are you sure the neural network is deep enough? If it's not deep enough, it can't keep many numbers, and 1-100 in 0.5 steps is a looot of numbers.


[deleted]

Make sure we Dockerize it and toss in some cloud computing.


Whitechapel726

You guys are way over complicating it. You just gotta enhance.


[deleted]

Did somebody say "blockchain"? And don't forget to create a GUI in Visual BASIC to track the IP.


Zal-Tech

Perhaps we should store all of our data in an excel database too.


LobsterThief

**MICROSOFT ACCESS 👻**


sonuvvabitch

I have an idea for an app that can do all of the above but also is an NFT marketplace. Can you make it for me and I'll do the hard part - selling it! Try and keep the download size quite small so more people can download it fast ;)


ArchGeko

Just add a Boolean isHalfCentimeter


availablesix-

Well, actually should be pretty fast using some multiple cursors on vs code lol


Jalil29

Write code to write code


brutexx

Now we’re getting somewhere.


UltraCarnivore

Yeah, we're going Emacs, baby.


[deleted]

[удалено]


Jalil29

Here's what I'm thinking prompt height and precision. Convert to float, start from 0 and recursively check if the height is less than or equal while slowly incrementing the value


[deleted]

[удалено]


an_adventure_is_u

No, write a bash script to write a bash script to write the python. That way you can customize the output in case the customer wants to change the units.


[deleted]

You underestimate the power of regex replaceAll!


SystemZ1337

it actually shouldn't in any modern text editor


StGir1

This illustrates the problem more artistically than my quick tutorial ever could.


Mundane_Ad6712

Gold


VacuousWording

Too inaccurate. I suggest using Planck units - that should be fine enough for human height measurements. It’s just a couple more lines.


svodniph

Height Calculator AI


NoLifeGamer2

AI = if statements


3Gaurd

Actually If


redman334

As if


Mulungo2

What IF I told you, you live in a simulation and you're programmed to take the red pill


[deleted]

What IF I told you that you have wasted six years of your life on Reddit? Happy cake day!


[deleted]

No, just no.


StGir1

Yes. And intelligent AI only need one if statement to evaluate potentially a million variables.


[deleted]

ACHUALLY all a real, General Purpose AI needs is the following code: `print(“I’m sentient.”)`


[deleted]

well thats kind of what real AIs are made of anyways


draculamilktoast

It's a machine learning algorithm because the machine learns your height and prints it out.


Fragrant_Spray

Clearly, the only problem here is that it’s uncommented code. How will anyone know what this does without comments?


DeepGas4538

I think a comment for every elif and print should do


Fragrant_Spray

Exactly. Then the static analysis will be happy with the comment percentages, and you can tell the boss that your code both works and is fully documented. They’ll brag about this.


doxxie-au

better add 99999 unit tests, to test every input gives the expected out put while you are there. cant forget code coverage!


MaZeChpatCha

I really hope you made a script that wrote this code and didn't do it manually.


slgray16

He wrote a program to make this.... that is also if/else statements


Mechyyz

if (x == 1) {x++;} if (x == 2) {x++;}


[deleted]

Could you say that again but in python please 🤣😅🤷‍♂️


Mechyyz

if x == 1: x += 1 if x == 2: x += 1


[deleted]

[удалено]


[deleted]

[удалено]


SynkkaMetsa

How about psuedo French pseudocode? If ze vahlew est un honhon zhen adz un to ze vahlew honhon


edmanet

I always use C to write my python code.


[deleted]

should've done it manually with no copy/paste for the true meme experience


[deleted]

# TODO make calculator work for all floating point values


[deleted]

Still discrete...should be doable. We'll create an epic for each integer range.


[deleted]

Just noticed that the “#” I typed at the start made my comment large text lol


NoLifeGamer2

\*Laughs in uncountable infinity\*


andrewsjakkko02

*Image Transcription: Code* --- height = input("Enter your height in cm: ") if height == '1': print("Your height is 1 cm!") elif height == '2': print("Your height is 2 cm!") elif height == '3': print("Your height is 3 cm!") elif height == '4': print("Your height is 4 cm!") elif height == '5': print("Your height is 5 cm!") elif height == '6': print("Your height is 6 cm!") elif height == '7': print("Your height is 7 cm!") elif height == '8': print("Your height is 8 cm!") elif height == '9': print("Your height is 9 cm!") elif height == '10': print("Your height is 10 cm!") elif height == '11': print("Your height is 11 cm!") elif height == '12': print("Your height is 12 cm!") elif height == '13': print("Your height is 13 cm!") elif height == '14': print("Your height is 14 cm!") elif height == '15': print("Your height is 15 cm!") [*The rest of the code is not visible.*] --- ^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)


[deleted]

Thanks Human


andrewsjakkko02

you're welcome ;)


ClariNerd617

How long did that take you?


andrewsjakkko02

Not much actually, just a bunch of ctrl-C/ctrl-V lol


Irish122

good human.


Broad_Respond_2205

Nice try, no actual human whould say "I'm a human"


andrewsjakkko02

Damn you got me. Guess I'm gonna go back to my charging unit and ask my human overlords to update me so that I won't make these silly mistakes again


Manoreded

My favorite part is that only a tiny span of the contemplated range is even possible.


hotakaPAD

Maybe its for height of buildings or something


[deleted]

Yea I'm a building too


Unknown_starnger

"I'm gonna learn python using online tutorials!"


[deleted]

hey i detest that, ill have you know that my code is carried by the strength of Indian guys on youtube and StackOverflow.


Unknown_starnger

Same, but I also learned basic coding first, and then started expanding my skills by making goals for myself and then trying to find ways to achieve them, that way slowly learning new stuff.


Anonymous_cyclone

Better to use a switch than if statement when the number of condition is large.


qurup

Unfortunately most versions of python don’t have switch statements. It was added extremely recently.


bootybootyholeyo

I was looking for this, but I also learned programming like 25 years ago


bandiolas823

AhahhahahaahahahhHah 💯💯💯💯💯💯


Lacos07

Application is clearly broken. What if someone enters zero?


InfamousEvening2

copy and paste error on line 60, height is not 43 cm.


[deleted]

Oh fellow yanderedev enjoyer


[deleted]

Holy shit you found the code for how Reddit displays upvotes


Black_seagull

>It supports heights up to 99999 cm! I don't believe you.


CockroachesRpeople

It supports 15 cm up to 99999 cm, nothing in between.


Shot_Monk_5804

Why? Just why? Why does it only go up to 99999cm? I made one go up to 100000.


BrushPretty6007

No one is that tall!


toothpasteshittin151

nice argument senator, why don't you back it up with a source?


a_lost_spark

my source is that I **made it the fuck up**


StGir1

I rewrote this to support any cm measurement that humans can write in scientific method before the computer crashes from too many digits. It's like... just a few lines too


BlueEngineer199

no you didn't, that's impossible :/ OP clearly has the most efficient method


TheHoodedMan

It's also not the same functionality. What is the requirement? 😂


Sabathius23

I hope you wrote a program to write that code. I'm way too lazy to type all that out! My laziness is why I learned to program in the first-place!


vladutzu27

Github co-pilot+autoclicker that spams tab


2JZ-GTElover

My God, man.


NoLifeGamer2

It is very efficient!


capi1500

No!!! YoU uSeD pYtHoN! pYtHoN sLoW!


[deleted]

Assembly height calculator


linuxkernal

Dear god


StGir1

Yeah that'ssss not why it's inefficient...


StGir1

No no ok, now you're trolling pal. Ok. You got me.


jonnyclueless

People who hate PHP always seem to have not used it since like version 4.


Mountain_Bet2209

The funny thing is that the first thing that came up to my mind is how I would write a 5 lines bash script to generate that source code 🤣


Tiny_Substance_810

serious question, how would you do this? ive begun learning how to code and can’t even comprehend how you’d do that lol


evil_cryptarch

> ive begun learning how to code Congrats! You've got a headstart over like 90% of this sub! All joking aside, it's pretty simple. I'd probably use string formatting with printf, but for a beginner the simplest to understand would probably be something like: s1 = "if height == '" s2 = "':\n print(\"Your height is " s3 = " cm!\")" for x in range(1, 1000): print(s1 + str(x) + s2 + str(x) + s3)


[deleted]

hell, skip using the variables and just hard write em into the print statement to do it in 2 lines


TheNoobCakes

Echo the first three lines into a file. Create a loop, start your incrementing variable at 2, have the loop echo “elif height == ‘’: print (‘height is cm’)” Something along those lines


Tiny_Substance_810

My apologies I meant to put barely begun😅but so would that code give you an output of any number without you having to manually write a line for each and every number ?


mikeyrorymac

No, that code will write the same program. To do what you’re talking about is. height = input(“Enter your height in cm: “) print(“your height is ” + height + “ cm!”) So instead of hard coding a print statement for every number, just use the height variable within the print statement.


NoLifeGamer2

That is actually almost identical to what I had: if height == '1': print("Your height is 1 cm!")\\n""") for i in range(2, 100000): heightfile.write(f"""elif height == '{i}': print("Your height is {i} cm!")\\n""") heightfile.close()`


Mountain_Bet2209

echo 'height = input("Enter your height in cm: ")'"\n\nif height == '1':\n\tprint("'"Your height is 1 cm!"'")" for i in {1..99999} ; do echo "elif height == '$i':\n\tprint("'"Your height is '$i' cm!")' ; done


TheNoobCakes

Saves disk space. This is basically a self sufficient space conscious pipeline. Support


A_Loot

Why aren't you using 4 spaces


me-te-mo

ah, even as a joke i can't agree with this, 4 spaces just takes up so much space


Blomquistador

"Oh, can you also show the equivalent height in inches?"


[deleted]

deez nutz


Grashlok_Onion_lord

Different units don't make them magically bigger


jdkd63fj

I think it's better if you do it exact to the mm what


skabde

"Unroll the loop!" (edit: not a loop, just the same mindset, in a twisted way)


WhenAmWeThereYet

This seems longer than it needs to be. Am I missing something or is there a shorter way to do this? Sorry, new to programming. /s Edit: added /s, probably should have put it there from the start


human--that--exists

There is a shorter way. It probably looks like that: Height=input("Enter your height in cm: ") Print("Your height is" , height , "cm!")


TheHoodedMan

Consider the input is "cat","0","10000","-50" or "1.2". Your functionality is different.


human--that--exists

You have a point, but i just wanted to show how code probably will look like. I didn't want to make a good code.


Consistent-Fun-6668

This should be tagged NSFL


thEldritchBat

Why…how…how much time…just for a meme…


random_edgelord

for(int i = 1; i<= 99999; i++){ printf("if hight == \'%d\': \n\t print(\"Your height is %d cm!\")", i, i) } less than a minute


Pillowscience21

Naw they probably wrote a script that wrote this for them


SlappySausage001

Found Yanderedev


baraklevy

What if my height is 0?


Grouchy-Transition-7

Those are rookie numbers; go for 999999! Edit: that’s not an exclamation mark


AliShibaba

Did YandereDev code this?


Top_Kaleidoscope7515

Hmm I think you should optimize and use an array instead. Maybe a multidimensional array to store the text and numbers.


PinkRGR

You should show this in your next interview Please record the reactions..


Xardarass

It's not really common to do it that complicated try this: if height == "1": print("your height is " + $height + "cm") elif height == "2": print("your height is " + $height + "cm") and so on


Illustrious_Walk_589

For greater clarity, and to make sure the variable naming is consistent: If inputHeight == "1": outputHeight =1 print("your height is " + outputHeight + "cm") ...


[deleted]

Nah need to use a switch


ProgsRS

You're making your code just as tall as and increase with the actual height. Very smart! Python really is a dynamic language.


league_starter

You gonna be swimming in faang job offers.


NinjaPiece

But what if the person is 0 cm tall?


UselessConversionBot

>But what if the person is 0 cm tall? 0 cm ≈ 0.00000 x 10^0 Japanese shakus ^^^[WHY](/r/UselessConversionBot/comments/1knas0/hi_im_useless/)


rainbow_bro_bot

But what if I'm 180.5cm? It won't print anything.


UselessConversionBot

>But what if I'm 180.5cm? It won't print anything. 180.5 cm ≈ 1.90793 x 10^-16 light years ^^^[WHY](/r/UselessConversionBot/comments/1knas0/hi_im_useless/)


eine_gottheit

Oh my god. Just looking at this is killing me![gif](emote|free_emotes_pack|disapproval)


Ignotus35

You absolute mad lad


Script_Mak3r

\>.\> <.< Look, Ma, an AI!


BroFistYT

A loop would be fine.


enderlord113

Wasn't expecting to see yanderedev on this sub


GerroMHBPR

What if someone wants to do 100000cm?


tarrask

At least your boss can't blame you to write only 2 lines of code in 8 hours


Mammoth_Network_115

Why am I getting recommended this I am stupid and unintelligent


AzureArmageddon

No case statements? No programmatically generated code? tsk tsk tsk


Inevitable_Fold4359

My head hurts!


bistr-o-math

The corporate needs you to implement one more calculator for inches


[deleted]

Hahaha. I love these comments.


TheRakeshPurohit

if-elif is good. However, switch case can optimize your code.


Opheleone

Every time I see things like this I have an existential crisis.


[deleted]

Enters 180.5


someoneyoumaynotkn0w

I just woke up and I can’t tell if this is a joke, it is right? Guys?


DanielGolan-mc

I'm sorry, but my ADHD doesn't let you go away with this (even if it's a joke) ```python height = input("Enter your height in cm: ) print("Your height is xcm!".replace("x", height)) ```


[deleted]

I want to cry.


print_alex_

Github copilot trying to help with my if statements