Expedia Code Academy
Simply put, to get you coding!
It's used by a lot of companies
It has many use cases and it's fun to program in!!
Please check out the guide!
Variables are containers for your data
The name of the variable is chosen by the software developer (that’s you!)
Go to pythontutor.com to test out this code:
my_name = 'Monty'
my_age = 100
We can also change what is inside an existing variable:
my_name = 'Montgomery'
print(my_name)
What do you think will be printed?Will the following lines of code work? Why/why not?
my_Name = 'John Cleese'
my age = 999
Python can do basic maths with pretty big (or small) numbers!
You can do the usual operations on these numbers:
print(calculation) # This will produce an error!
calculation = 55 + 55
print(calculation) # prints 110
calculation = 55 * 55
print(calculation) # prints 3025
Strings are bits of text with apostrophes e.g.
'I am a String, with 34 characters!'
They can include letters, numbers and symbols - all of these are treated as text only, with no special value!
What do you think this line of code will do?
mystery = '1' + '2'
print(mystery)
first = 'Harry'
last = 'Potter'
sentence = 'Welcome to Hogwarts, ' + first + ' ' + last + '!'
print(sentence)
The input function pauses the program until the user types something and presses Enter.
We can then use what the user typed as a variable in the code!
users_name = input('What is your name? ')
print('Hello, ' + users_name + '!')
(⭐⭐️) 1b. Ask the user to enter their first and last names, then welcome them to Hogwarts!
first = 'Harry'
last = 'Potter'
greeting = 'Welcome to Hogwarts,'
print(greeting, first, last)