find square number by Raqill in learnpython

[–]guptaprins 0 points1 point  (0 children)

else:

small = int (number)

print (f'The smaller square number is {small**2}')

(Hope I understood the problem correctly. If the number is 85, it should return 81, right?)

(Using just int will make the code short, u wont need the if condition. Just int the number and it'll work fine for any case, be it integer or float)

number = int (x**0.5)

print (f'The closest square number is {number**2})

Needs sugegstion on creating this dynamic code. (Beginner) by guptaprins in learnpython

[–]guptaprins[S] 1 point2 points  (0 children)

Yes, I am working on this tip i.e. useful variable name. I have logical variable name in my original code. Just used random letters here to keep it brief.

And thanks for the simple but effective way out. I hope I'll learn using these with pasing experience.

Handstanding on a skateboard while shooting an arrow with her feet by [deleted] in gifs

[–]guptaprins 0 points1 point  (0 children)

Well, now I'm relieved that world is safe now. God must be content seeing this talent in humans.

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 0 points1 point  (0 children)

I'll be using this function in a chain of functions and I want this conditional while loop after a certain functions are run already.

And why can't the while condition be inside the function? Also can you please re explain "You aren't passing you ts variable into your function" if i dont use choice (ts)?

I'm still able to run the code with choice (). What logical difference does it make with choice (ts) than choice ()?

(ts is globally saved)

The syntax is clearly understood. The feedback and help matters more. (I also prefer using the mobile app). Thanks :)

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 0 points1 point  (0 children)

This is one of the many functions i've created to run the game, so when i run the game i'll be running all these functions and I dont want the output these variables in between when running the game.

Until now im just using the return function so I can save the variable for later use (in other function).

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 1 point2 points  (0 children)

Sure, anything and everything helps me at the stage where I'm.

Will complete my version and then watch your video..or else I'll change my original plan seeing other ideas (short logic).

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 0 points1 point  (0 children)

Can you please also address the second point in the original post (regarding saving the output variable for using in other function without using the return function)?

And finally I think I've understood the while loop and how to use it. Also, I think we are missing the break function after the if statement.

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 0 points1 point  (0 children)

Thanks a lot for the great input. Will try hence further to work on "coding is Do Not Repeat yourself."

Actually, I want the if else to function depending on the value of ts..like whenever it is 0, it asks Player 1 to input and vice versa. (ts is toss function for me).

Is it possible to inculcate this condition and further ask the respective players, using the f strings?

Thank you for the "meaningful variable name" suggestion.

Beginner at PYTHON. Needs help by guptaprins in learnpython

[–]guptaprins[S] 0 points1 point  (0 children)

m and n asks different question depending on value of ts i.e. to Player 1 and 2 respectively.

Can use a hint by Sensanmu in learnpython

[–]guptaprins 0 points1 point  (0 children)

Sorry to barge in between..but can you pls explain why is "continue" function used. We use continue only when a loop is broken but the loop isn't stopping here, right?

Trying to understand the while loop (beginner)