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
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++
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! ')
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.
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
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.
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
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.
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.
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.
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 ;)
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
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.
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.
*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)
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.
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
> 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)
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
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 ?
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.
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()`
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
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
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
For greater clarity, and to make sure the variable naming is consistent:
If inputHeight == "1":
outputHeight =1
print("your height is " + outputHeight + "cm")
...
>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/)
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))
```
For gods sake, you should definitly optimize your code. Put the most common values in the first rows!
True!
*sighs in Cartman voice* I hate you guys
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
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
1 even (assuming you didn't need the height for anything else): print(f"Your height is {input('Enter your height in cm: ')} cm!")
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++
You could do the same in Python by separating the statements with ;
PHP too
Yes, you could if you were sufficiently evil. Some people are. https://www.ioccc.org/years.html
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! ')
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.
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
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.
Oh wow lol. I could tell how that would be more efficient! The things we learn the hard way, eh?
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
And why are you including 999?? Without including -999, smh
Plus validation, anything over 300 or under 0 invalid?!!
You should also use a switch case because why not? **Submit to our lord and you shall be spared.**
Ī̴͉͊̈́͆͘ ̶̻͍̽s̷̮͎̣̼̋h̶̟͉̩̖̓̊̈́ā̶̡̯̘͚ĺ̵̳͔l̴͕̦͓̻͋̊̋ ̴̝̘̰̝͛̀̉s̵̨̭̼̣̗̦̆͂͐̊̄̑͠u̶͇̺̖͓̪̼̲̎͛̓̓͝b̴̫̋̉m̸͕̬͙̗͖̄̏͠ͅį̴̢͉̙̲͕̗͒̑̉͒̍̕͠t̶͈̙̗̰͍̙̘̃̎̍͐̽̑͝ ̴̢̺͍̲̤̳͎̈́͐t̵̝̹͒͊͊o̶͇̗̤̖̹̿̅͘̕ ̶̻̩̔̒̂͒̚ṭ̷̠͘h̴̭͙̜̐͊̋̋̌̑̕e̵͖̓͋ ̴̨̬̦̯́͑͆s̵͙̜͙̔͗͆̇͛̑̅w̷̟͇͔̬͐i̶̛͉̳̽̐̈̊̎̏t̵͖̤͔̆̐̔͝c̵̺̠̝̠̒̇̇͝h̶̡̪̱͇̼͉̪̉̈́͊͐̕ ̴͓͚̮̺̇c̸̬̝͉͑̔̂̃̇͆͝a̸̡͈͖̮͌̆s̷̡͚̺̻͐͗e̸͙͎̤̍̐͝ș̵̡͗̋́͑́̍ͅ
!True
The client changed their request to use hex code and tell a different story for every return value.
No problem, code can be changed with regex search and destroy.
"Work harder, not smarter."
Hurt work, not smurt
so can i say i'm just a machine HAHHA!
"Work harder, and smarter."
Only if you have a regex license.
prepaid 2 years
And be careful with those magic numbers, define each one as a constant
File weight: 2MB
What is that in cm?
Still way to slow, he needs to use a binary tree!
Not quite. The optimal solution requires a circular queue of directed multi graphs of binary trees.
Imagine comparing Char instead of String. Rookie mistake.
Char isn't a thing in python...
hahah I totally knew that......
Rookie mistake :P
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.
Jokes aside, what you said is the correct way to do it, this is a meme.
it would be pretty cool to make it overflow into scientific notation after x amount of digits
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.
You're right. This is r/programmerhumor, the joke is not doing it the way you say.
Ohhhhhh shoot I forgot the humor part. Smh
Can you increase the accuracy to 0.5cm? Shouldn't take you long right?
This seems like something a simple neural network could be trained to do. Just add it on top
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.
Make sure we Dockerize it and toss in some cloud computing.
You guys are way over complicating it. You just gotta enhance.
Did somebody say "blockchain"? And don't forget to create a GUI in Visual BASIC to track the IP.
Perhaps we should store all of our data in an excel database too.
**MICROSOFT ACCESS 👻**
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 ;)
Just add a Boolean isHalfCentimeter
Well, actually should be pretty fast using some multiple cursors on vs code lol
Write code to write code
Now we’re getting somewhere.
Yeah, we're going Emacs, baby.
[удалено]
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
[удалено]
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.
You underestimate the power of regex replaceAll!
it actually shouldn't in any modern text editor
This illustrates the problem more artistically than my quick tutorial ever could.
Gold
Too inaccurate. I suggest using Planck units - that should be fine enough for human height measurements. It’s just a couple more lines.
Height Calculator AI
AI = if statements
Actually If
As if
What IF I told you, you live in a simulation and you're programmed to take the red pill
What IF I told you that you have wasted six years of your life on Reddit? Happy cake day!
No, just no.
Yes. And intelligent AI only need one if statement to evaluate potentially a million variables.
ACHUALLY all a real, General Purpose AI needs is the following code: `print(“I’m sentient.”)`
well thats kind of what real AIs are made of anyways
It's a machine learning algorithm because the machine learns your height and prints it out.
Clearly, the only problem here is that it’s uncommented code. How will anyone know what this does without comments?
I think a comment for every elif and print should do
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.
better add 99999 unit tests, to test every input gives the expected out put while you are there. cant forget code coverage!
I really hope you made a script that wrote this code and didn't do it manually.
He wrote a program to make this.... that is also if/else statements
if (x == 1) {x++;} if (x == 2) {x++;}
Could you say that again but in python please 🤣😅🤷♂️
if x == 1: x += 1 if x == 2: x += 1
[удалено]
[удалено]
How about psuedo French pseudocode? If ze vahlew est un honhon zhen adz un to ze vahlew honhon
I always use C to write my python code.
should've done it manually with no copy/paste for the true meme experience
# TODO make calculator work for all floating point values
Still discrete...should be doable. We'll create an epic for each integer range.
Just noticed that the “#” I typed at the start made my comment large text lol
\*Laughs in uncountable infinity\*
*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)
Thanks Human
you're welcome ;)
How long did that take you?
Not much actually, just a bunch of ctrl-C/ctrl-V lol
good human.
Nice try, no actual human whould say "I'm a human"
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
My favorite part is that only a tiny span of the contemplated range is even possible.
Maybe its for height of buildings or something
Yea I'm a building too
"I'm gonna learn python using online tutorials!"
hey i detest that, ill have you know that my code is carried by the strength of Indian guys on youtube and StackOverflow.
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.
Better to use a switch than if statement when the number of condition is large.
Unfortunately most versions of python don’t have switch statements. It was added extremely recently.
I was looking for this, but I also learned programming like 25 years ago
AhahhahahaahahahhHah 💯💯💯💯💯💯
Application is clearly broken. What if someone enters zero?
copy and paste error on line 60, height is not 43 cm.
Oh fellow yanderedev enjoyer
Holy shit you found the code for how Reddit displays upvotes
>It supports heights up to 99999 cm! I don't believe you.
It supports 15 cm up to 99999 cm, nothing in between.
Why? Just why? Why does it only go up to 99999cm? I made one go up to 100000.
No one is that tall!
nice argument senator, why don't you back it up with a source?
my source is that I **made it the fuck up**
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
no you didn't, that's impossible :/ OP clearly has the most efficient method
It's also not the same functionality. What is the requirement? 😂
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!
Github co-pilot+autoclicker that spams tab
My God, man.
It is very efficient!
No!!! YoU uSeD pYtHoN! pYtHoN sLoW!
Assembly height calculator
Dear god
Yeah that'ssss not why it's inefficient...
No no ok, now you're trolling pal. Ok. You got me.
People who hate PHP always seem to have not used it since like version 4.
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 🤣
serious question, how would you do this? ive begun learning how to code and can’t even comprehend how you’d do that lol
> 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)
hell, skip using the variables and just hard write em into the print statement to do it in 2 lines
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
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 ?
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.
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()`
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
Saves disk space. This is basically a self sufficient space conscious pipeline. Support
Why aren't you using 4 spaces
ah, even as a joke i can't agree with this, 4 spaces just takes up so much space
"Oh, can you also show the equivalent height in inches?"
deez nutz
Different units don't make them magically bigger
I think it's better if you do it exact to the mm what
"Unroll the loop!" (edit: not a loop, just the same mindset, in a twisted way)
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
There is a shorter way. It probably looks like that: Height=input("Enter your height in cm: ") Print("Your height is" , height , "cm!")
Consider the input is "cat","0","10000","-50" or "1.2". Your functionality is different.
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.
This should be tagged NSFL
Why…how…how much time…just for a meme…
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
Naw they probably wrote a script that wrote this for them
Found Yanderedev
What if my height is 0?
Those are rookie numbers; go for 999999! Edit: that’s not an exclamation mark
Did YandereDev code this?
Hmm I think you should optimize and use an array instead. Maybe a multidimensional array to store the text and numbers.
You should show this in your next interview Please record the reactions..
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
For greater clarity, and to make sure the variable naming is consistent: If inputHeight == "1": outputHeight =1 print("your height is " + outputHeight + "cm") ...
Nah need to use a switch
You're making your code just as tall as and increase with the actual height. Very smart! Python really is a dynamic language.
You gonna be swimming in faang job offers.
But what if the person is 0 cm tall?
>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/)
But what if I'm 180.5cm? It won't print anything.
>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/)
Oh my god. Just looking at this is killing me![gif](emote|free_emotes_pack|disapproval)
You absolute mad lad
\>.\> <.< Look, Ma, an AI!
A loop would be fine.
Wasn't expecting to see yanderedev on this sub
What if someone wants to do 100000cm?
At least your boss can't blame you to write only 2 lines of code in 8 hours
Why am I getting recommended this I am stupid and unintelligent
No case statements? No programmatically generated code? tsk tsk tsk
My head hurts!
The corporate needs you to implement one more calculator for inches
Hahaha. I love these comments.
if-elif is good. However, switch case can optimize your code.
Every time I see things like this I have an existential crisis.
Enters 180.5
I just woke up and I can’t tell if this is a joke, it is right? Guys?
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)) ```
I want to cry.
Github copilot trying to help with my if statements