Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to Python

Intro to Python

Slides for the Introduction to Python workshop at WTH (2018)

### Tasks

- https://repl.it/@Geekfish/python
- https://repl.it/@Geekfish/RoadTrip
- https://repl.it/@Geekfish/RoadTrip2

### Tutorials/Resources

- [Python 3 Documentation](https://docs.python.org/3/)
- [PEP8 (Python styling guide)](https://www.python.org/dev/peps/pep-0008/)
- [Learn Python the Hard Way](https://learnpythonthehardway.org/python3/)
- [DjangoGirls Django Tutorial](https://tutorial.djangogirls.org/)

### Beginner-friendly conferences

- [PyCon UK](http://2018.pyconuk.org/) (Cardiff, September)
- [EuroPython](https://ep2018.europython.eu/) (Edinburgh, July)
- [DjangoCon Europe](https://2018.djangocon.eu/) (Heidelberg Germany, May)

Eleni Lixourioti

February 23, 2018
Tweet

More Decks by Eleni Lixourioti

Other Decks in Programming

Transcript

  1. Hi

  2. Hi

  3. ▸ Marketing/Advertising ▸ Telecommunications ▸ Commerce ▸ Governance ▸ Graphics

    ▸ CGI ▸ Finance ▸ Medicine ▸ Engineering ▸ Home automation ▸ …
  4. > import this The Zen of Python, by Tim Peters

    Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
  5. ...

  6. a = 10 b = 5 a + b a

    - b a * b a / b
  7. 10 == 5 10 == 10 10 > 5 10

    < 5 10 != 5 10 >= 5
  8. !

  9. !

  10. animal = "cobra" if animal == "python": print("Are you related

    to Python?") else: print("nevermind...")
  11. age = 30 if age < 8: print("Sorry, you are

    not allowed into the Haunted house!") elif age < 12: print("Sorry, you are not allowed to ride the roller coaster") else: print("Being a grown-up is great!")
  12. if sky == "blue": if temperature > 20: print("Let's go

    swimming!") # Same as: if sky == "blue" and temperature > 20: print("Let's go swimming!")
  13. def get_business_card(name, occupation): return f"{name}: professional {occupation}" linda_card = get_business_card("Linda",

    "Python-Whisperer") alice_card = get_business_card("Alice", "Potato Chip Inspector") print(f"Here are my associates: {linda_card} and {alice_card}")
  14. print("giraffe") # giraffe len("giraffe") # 7 min(4, 10, 2, 9)

    # 2 max(4, 10, 2, 9) # 10 int("100") 100 str(100) "100"
  15. import random random.choice(['work', 'study', 'play', 'sleep']) # sleep, hopefully? #

    --- or --- from random import choice choice(['work', 'study', 'play', 'sleep'])
  16. TUTORIALS/RESOURCES ▸ Python 3 Documentation ▸ PEP8 (Python styling guide)

    ▸ Learn Python the Hard Way ▸ DjangoGirls Django Tutorial