clubwebsite

Python Workshop

Step 1: Sign in on repl.it

1. Creat a new repl
2. select Python for the language and name the repl Python workshop

Step 2: Create a file called helloWorld.py

1. To start our workshop we will simply print the phrase “hello world”
2. To do this you must type “print()”, and put hello world, in quatations, in the parenthesis
3. After doing this just press run and see if it worked

variables

Creating String Variables

Step 1: create a name for your variable
Step 2: assign the variable a string value, in this case we will assign it the value of “hello world”(Example: variable = “hello world”)
Step 3: To use this variable simply just type print(variable), press run, and it should show hello world

Creating Number Variables

Step 1: Just like for string variables you must come up with a variable name, the only difference is that you have to assign the variable a numerical value
Example: number = 5
Step 2: To check to see if this works type print(number) and see if it prints 5

Basic Operations

Python allows the use of all basic operations, such as addition, subtraction, division and multiplication

Step 1: Try typing in any calculation and then pressing run
You will see that it prints the correct value

Using mathematical operations with variables

Python also allows you to use numerical variables to perform basic mathematical operations

Step 1: create two variables and assign them a numerical value
Step 2: Then try to perform a operation with these variables
Example:

num1 = 7 num2 = 6 print(num1*num2)

This should print 42

User Input with string values

User input allows you to assign variables with values that the user selects

To use user input with string values you must type:

variable = input(“whats your name? “)

This will put a message on the screen that says “Whats your name?” and then allows the user to type their name. It then then assigns the name to the variable.

To print the name just type print(variable)

User input with integer values

Using user input with integer values will be very helpful when trying to make calculators

To do this you just have to type num = int(input(“enter a number: “)) and then print(num)

This will ask the user to “enter a number” then will print that number

If statements

if statements allow the computer to carry out certain commands if certain conditional statements are true

For example:

variable = int(input(“enter a number: “))

if variable < 7:

print(variable)

This would print the value of variable if it is less than 7

Now try to create anything you want using python

I reccomend starting with something like a calculator