Download presentation
Presentation is loading. Please wait.
1
Python Basics with Jupyter Notebook
Workshop 1
2
Download Anaconda Visit anaconda.com/download and download the relevant distribution for your operating system. Download Anaconda with Python 3.7
3
Open Jupyter Notebook
4
Print Statements The print function in Python allows you to output data to the user. You can print items of different datatypes including string, int and lists. Try outputting some text on your notebook.
5
Storing data in variables
You can store data in variables using the ‘=’ operator. Try figuring out how the code below works
6
Taking inputs Use the input function to prompt user to enter some data. Data stored in a given variable.
7
Changing the datatype Sometimes in Python you have to change the datatype of a variable. An example of this is when user input is taken, it is stored as a string. If the input an integer, you must convert the string to an integer if you want to apply any operations to the data. Converts input to an integer
8
If, else and elif statements
In Python you can run code based on decisions using if statements.
9
Lists Lists allow you to store multiple data items under one variable.
10
Accessing list items You can access items in a list by using variableName[index] Python indexes start with 0 so the first item is variableName[0]
11
For Loops For Loops allow you to repeat a portion of the program a number of time. A variable assigned loops through items in a list.
12
Range range(a,b) creates a list of numbers starting with a and ending in b-1. The first parameter is inclusive but not the second parameter.
13
Functions Python lets you create your own functions.
Each function takes parameters as input and ‘returns’ a result.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.