Embed presentation
Download as PDF, PPTX













![Python Basics Strings – sequence of characters >>> s = “hello world”● Looking inside >>> s[0]● Concatenation >>> s = ”hello ” + “world”● Finding length >>> len(s)● Slicing >>> s = s[0:5]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-14-2048.jpg&f=jpg&w=240)

![Python Basics● Get the second word 'world' by slicing >>> “hello, world”[x:y]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-16-2048.jpg&f=jpg&w=240)
![Python Basics Lists – collection of values● Declaring >>> l = list() >>> l = []● Can hold different types >>> l = [1, 'a', [2, 3], 4] >>> l[2]● Appending >>> l.append('an item') >>>del(l[2])](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-17-2048.jpg&f=jpg&w=240)
![Python Basics Lists – collection of values● Getting length >>> len(l)● Slicing >>> l[1:4]● Converting between strings and lists >>> strlist = “this is a string”.split('s') >>> “z”.join(strlist)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-18-2048.jpg&f=jpg&w=240)
![Python Basics● Append an item to the list within the list >>> l = [1, 'a', [2, 3], 4] >>> l = [1, 'a', [2, 3, 5], 4]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-19-2048.jpg&f=jpg&w=240)
![Python Basics● Handy functions Sum >>> sum([2, 3, 4]) Max >>> max([2, 3, 4]) Min >>> min([2, 3, 4])](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-20-2048.jpg&f=jpg&w=240)
![Python Basics Dictionaries – key, value pairs Associative array, hash table● Declaring >>> d = dict() >>> d = {}● Setting a value >>> d[“event”] = “bootcamp” >>> d = {“event” : “bootcamp” }● Getting a value >>> d[“event”]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-21-2048.jpg&f=jpg&w=240)





![Boolean Values● True >>> 1 < 2● False >>> 1 > 2● Also evaluate to False: “”, [], {}, 0](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-27-2048.jpg&f=jpg&w=240)
![Loops● While loop – while condition is true x=0 while x < 10: print x x=x+1● For loop – loops over items words = ['this' , 'is', 'a', 'list'] for w in words: print w● Loop over strings, dictionaries..● Range() function >>> range(3) >>> range(0, 10, 2)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-28-2048.jpg&f=jpg&w=240)








This document summarizes a Python bootcamp presentation covering the basics of Python including features, common uses in industry, data types, operators, strings, lists, dictionaries, functions, modules, file I/O, and accessing the web. It provides examples of Python code and concludes with next steps and resources for further learning Python.













![Python Basics Strings – sequence of characters >>> s = “hello world”● Looking inside >>> s[0]● Concatenation >>> s = ”hello ” + “world”● Finding length >>> len(s)● Slicing >>> s = s[0:5]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-14-2048.jpg&f=jpg&w=240)

![Python Basics● Get the second word 'world' by slicing >>> “hello, world”[x:y]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-16-2048.jpg&f=jpg&w=240)
![Python Basics Lists – collection of values● Declaring >>> l = list() >>> l = []● Can hold different types >>> l = [1, 'a', [2, 3], 4] >>> l[2]● Appending >>> l.append('an item') >>>del(l[2])](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-17-2048.jpg&f=jpg&w=240)
![Python Basics Lists – collection of values● Getting length >>> len(l)● Slicing >>> l[1:4]● Converting between strings and lists >>> strlist = “this is a string”.split('s') >>> “z”.join(strlist)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-18-2048.jpg&f=jpg&w=240)
![Python Basics● Append an item to the list within the list >>> l = [1, 'a', [2, 3], 4] >>> l = [1, 'a', [2, 3, 5], 4]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-19-2048.jpg&f=jpg&w=240)
![Python Basics● Handy functions Sum >>> sum([2, 3, 4]) Max >>> max([2, 3, 4]) Min >>> min([2, 3, 4])](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-20-2048.jpg&f=jpg&w=240)
![Python Basics Dictionaries – key, value pairs Associative array, hash table● Declaring >>> d = dict() >>> d = {}● Setting a value >>> d[“event”] = “bootcamp” >>> d = {“event” : “bootcamp” }● Getting a value >>> d[“event”]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-21-2048.jpg&f=jpg&w=240)





![Boolean Values● True >>> 1 < 2● False >>> 1 > 2● Also evaluate to False: “”, [], {}, 0](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-27-2048.jpg&f=jpg&w=240)
![Loops● While loop – while condition is true x=0 while x < 10: print x x=x+1● For loop – loops over items words = ['this' , 'is', 'a', 'list'] for w in words: print w● Loop over strings, dictionaries..● Range() function >>> range(3) >>> range(0, 10, 2)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fpython-bootcamp-slides-121124004127-phpapp02%2f75%2fPython-bootcamp-C4Dlab-University-of-Nairobi-28-2048.jpg&f=jpg&w=240)






