concept secret in category python

appears as: secret
Get Programming: Learn to code with Python

This is an excerpt from Manning's book Get Programming: Learn to code with Python.

"the secret of life is 42".split("s")

Listing 18.5. Comparing code that does and doesn’t use the continue keyword
### Version 1 of some code ###
x = 0
for x in range(100):
    print("x is", x)
    if x > 5:
        print("x is greater than 5")
        if x%10 != 0:
            print("x is not divisible by 10")
            if x==2 or x==4 or x==16 or x==32 or x==64:
                print("x is a power of 2")
                # perhaps more code

### Version 2 of some code ###
x = 0
for x in range(100):
    print("x is", x)
    if x <= 5:
        continue                                              #1
    print("x is greater than 5")                              #2
    if x%10 == 0:
        continue                                              #1
    print("x is not divisible by 10")                         #3
    if x!=2 and x!=4 and x!=16 and x!=32 and x!=64:
        continue                                              #1
    print("x is a power of 2")                                #4
    # perhaps more code
Hello App Inventor!: Android programming for kids and the rest of us

This is an excerpt from Manning's book Hello App Inventor!: Android programming for kids and the rest of us.

You’re going to do something much simpler, but equally sneaky. You’ll detect whether the user types a space at the beginning of their name (we said it was sneaky). That way, you (and anyone you tell the secret) will get a nice message, and your other friends and family won’t be able to work out the trick. To get started, save a new version of the Personality Judge app with a name like PersonalityJudge2.

  • If you’re struggling to remember which compass direction you need to point the phone, you could lay out the cards in their compass positions. So, place the 2 of clubs in the northeast position on the table, the 3 of clubs southeast, and so on, in a circle with the phone face down in the center—but don’t be surprised if your audience guesses the secret.