Nauč se Python > Kurzy > Beginners course PyLadies > Installation > Homework - lesson 1

Homework

Try out these exercises at home. These are just examples. Try to find some more examples in the internet or just play around!

  • Try to start up python and see if this still works:
    >>> 1+1
    2
    
  • How about other operations? Do you remember what * and / are doing? What about % and **? If you don't remember try figuring it out from the Python console. Try, e.g. 1%4, 2%4, 3%4, 4%4, 5%4... or 2**1, 2**2, 2**3, 2**4, 2**5... Can you explain the patterns?

  • In Python you can add also strings of characters. E.g. 'A' + 'B' would produce 'AB'. What's wrong with the result of the following?

    >>> 'Hello' + 'World!'
    
  • Try adding a number to a string. What happens? What is Python trying to tell you? What if you try to add a string to a number?

  • How about multiplying a string by a number? Can this work? 'Ha' * 10


Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.