Can you explain to me this code !

Started by
15 comments, last by _the_phantom_ 9 years, 7 months ago

Lysy i read the code!!
ok i need answer for this question to be sure !
Try to type 100 you will get You greedy bastard! Good job!that's mean else:dead("You greedy bastard!")& i should get that if "0" in choice or "1" in choice:how_much = int(choice)

Sorry for hard understanding
Thanks

I'm sorry but I have no idea what you're trying to say. What exactly is the problem now? Try to explain as specific as you can.
Advertisement

Lysy i read the code!!

ok i need answer for this question to be sure !

Try to type 100 you will get
You greedy bastard! Good job!
that's mean
else:
dead("You greedy bastard!")
& i should get that
if "0" in choice or "1" in choice:
how_much = int(choice)

Sorry for hard understanding

Thanks

Yes, this is correct, why you need to ask such a trivial question, when you can just run the code to be sure. It seems futile trying to help you out.

To other people:
Since he is an ESL (incase if you don't know, English as Second Language) (so do I), I think we should explain to him in a simpler English or even chat to him in his native language.

To OP:
What language do you talk to your family?

(I know this is off-topic, just remind you guys about this)

EDITEED TO ADD TL;DR: KEEP IN MIND THAT THE OP IS AN ESL, EXPLAIN TO HIM WITH SIMPLER VOCALS.A
A C++ programming beginner from Malaysia.

please no down votes and understand me :)

when you type 100

it will check if the number has 1 or 0

so the condition is true

so how_much = int(choice)

so i shouldn't get "You greedy bastard!"

Thanks :)

when you type 100

it will check if the number has 1 or 0

1. The script works fine, deal with it.

2. Try using 'print' on every variable that you're not sure on what value it is.

3. Your posts will keep getting downvoted as long as they doesn't contain any useful information/doesn't improve the discussion, etc. In simple words: you're spamming.

I'm done. good luck with your learning.

If you enter 100, you will get to how_much = int(choice).

That means how_much is equal to 100.

In the next if statement, we check if how_much is less than 50. 100 is NOT less than 50, so we do not enter the if part of the if statment.

Instead, we enter the else part of the if statement.

Inside the "else" part the dead("You greedy bastard!") code run.

The dead code will print the text you see.

---

Edit:

Like I've done before, I would suggest you slow down. You seem to be going too fast. You might be going through the exercises quickly, but if you don't understand them, you won't learn much.

The questions you're asking indicate you're missing some fundamental knowledge. I would urge you to back to earlier lessons, and not progress until you feel you understand basically every line in the lessons you're working on. If parts are unclear, I'm sure people will help you. That said, I would recommend you ask more specific questions.

Instead of "help what does this do" and post all the code for a lesson.

Hello to all my stalkers.

Yes, you should because that second check is not dependant on the first.

If you type 100 then first of all it checks to see if it contains '0' or '1', if it does then it stores the number.
THEN it goes on to check if that number is less than 50, which it isn't, thus the 'greedy' message.

In your second post you say you input '55', which does not contain '0' or '1' thus you go down the 'learn to type' path, which appends 'good job' in the function it calls before quitting.

This topic is closed to new replies.

Advertisement