TASK
Click the image above to access the article from Code Academy "What is computer programming". You need to answer these questions:
Is HTML or CSS a programming language?
What languages should you learn?
Can you say what are front end and back end programming languages?
Why should someone learn computer programming?
What are soft skills?
Click the link below to run coggle. Try setting up this Mind Map. Use it to answer the questions.
Why Learn Python?
Python is a general-purpose, versatile and popular programming language. It’s great as a first language because it is concise and easy to read, and it is also a good language to have in any programmer’s stack as it can be used for everything from web development to software development and data science applications.
TASK
Find out from Techterms what Python is.
Find out how popular Python is as a programming language from this topcomputerlanguages website.
Find out why we are learning Python 3 and not 2 at python3vspython2.
High-level Languages
Compilers and Interpreters
TASK
Complete this worksheet on high level languages and interpreters/compilers.
CODING GROUND
Coding ground is an online IDE (Integrated Development Environment) for all the most popular programming languages.
It includes:
<> Line by line coding
<> The ability to execute (Interpret or compile) programs
<> Saving of files and folders
TASK
Click the image to go to the Coding Ground IDE for Python 3.
Sign up for Coding Ground. You need to sign up to save files.
Read through the Help to give you some idea on how the IDE works.
Repl.it/repls
This is another online coding platform. some lessons that can be done here are not easy in the Coding Ground.
Try: Getting input from the user, building a basic calculator, mad libs game, building a better calculator, and while loops.
Try: Getting input from the user, building a basic calculator, mad libs game, building a better calculator, and while loops.
PYCHARM IDE
The Pycharm Integrated development environment includes a terminal interpreter that allows the programmer to run their code within the application. PyCharm is not difficult to use, here are some images showing it in operation.
You should have a 'Programs' folder in your 'Python3' folder. Select this location to save your next Python file. Click File, New, Python File. Type in the file's name "Working". Click 'OK'. Type in your code (see above).
Click on the Terminal panel as seen here. If it's not visible choose View> Tools Windows> Terminal. This is to view the program in operation.
Click the right-facing arrow to Run the code. The code should operate as shown. You will need to click after the colon ":" and type in your name. Then press enter.
YouTube Tutorial
This tutorial from freeCodeCamp.org is an excellent tutorial for teaching the basics of Python 3 to beginners.
TASK
Click on the image to bring up the tutorial.
Also click on the SHOW MORE button to get the contents (as show below).
We will start at the introduction but skip a few tutorials. But there's lots of fun Pythoning to do ..............
Programming Challenges
Using Coding Ground
Name Challenge
Create a program that has 3 variables for:
Create a program that has 3 variables for:
- Your first name
- Your nick name
- Your last name
Joke Challenge
Create a program that will display a joke.
Don't display the answer until the user presses enter.
EXTENSION
Get the program to tell more than on joke.
Create a program that will display a joke.
Don't display the answer until the user presses enter.
EXTENSION
Get the program to tell more than on joke.
Area of Circle Challenge
Create a program that has 3 variables for:
Create a program that has 3 variables for:
- The value of pi (3.1415)
- The radius of a circle (eg 3)
- The area of the circle (calculated by area = pi * (r * r)
Distance a car travels Challenge
Create a program that will calculate the speed a car travels if the user enters the distance and time.
Speed = Distance/ Time or s=d/t. This formula can be re-arranged so d is on the left-hand side.
In NZ a cars speed is measured in km/hr (km is kilometers and hr is hours) and time in hours (hr).
EXTENSION
Write another program that tells you the speed to travel to go a given distance (kilometres) in a given time (hours).
Create a program that will calculate the speed a car travels if the user enters the distance and time.
Speed = Distance/ Time or s=d/t. This formula can be re-arranged so d is on the left-hand side.
In NZ a cars speed is measured in km/hr (km is kilometers and hr is hours) and time in hours (hr).
EXTENSION
Write another program that tells you the speed to travel to go a given distance (kilometres) in a given time (hours).
List Challenge
Create a program that uses a list to store all your classes today eg. classes_today = ["Advisory", etc.]
Use the a classes_today[0] list index to show what's first using print and also show what you have lesson 1, 2 and 3.
Create a program that uses a list to store all your classes today eg. classes_today = ["Advisory", etc.]
Use the a classes_today[0] list index to show what's first using print and also show what you have lesson 1, 2 and 3.
List Functions Challenge
Lets say you have a test every week in one of your classes. Your test scores can be put into a list. Using the List Functions you can calculate the average of your test scores. The List Function sum() will add all the scores in your list. The List Function len() will tell you how many numbers there are in the list. Once you have these two values it's an easy calculation to get the average. Its the sum of test scores divided by the number of test scores. To get a result with decimal places you will need to use the float() function.
Lets say you have a test every week in one of your classes. Your test scores can be put into a list. Using the List Functions you can calculate the average of your test scores. The List Function sum() will add all the scores in your list. The List Function len() will tell you how many numbers there are in the list. Once you have these two values it's an easy calculation to get the average. Its the sum of test scores divided by the number of test scores. To get a result with decimal places you will need to use the float() function.
IF Statement Challenge 1
The simplest IF Statement is one that has an action only if the statement is true. For example if there is an in_class boolean variable (Boolean can only be True or False). An if statement that prints "I need to pay attention and do my work" if the variable is True otherwise nothing happens. The code should look like this"
in_class = True
if in_class:
print("I need to pay attention and do my work") # Note the print function is indented
The simplest IF Statement is one that has an action only if the statement is true. For example if there is an in_class boolean variable (Boolean can only be True or False). An if statement that prints "I need to pay attention and do my work" if the variable is True otherwise nothing happens. The code should look like this"
in_class = True
if in_class:
print("I need to pay attention and do my work") # Note the print function is indented
IF ELSE Statement Challenge 2
In the IF ELSE Statement there is an alternative if the IF is NOT True. For example have_password is a boolean variable. If it's set to True then a "You can login to the computer network" message is sent. If it's not True but False then "See the teacher to get my password" message is sent. This code looks like this:
have_password = False # try changing the have_password variable to True
if have_password:
print("You can login to the computer network")
else:
print("See the teacher to get my password")
In the IF ELSE Statement there is an alternative if the IF is NOT True. For example have_password is a boolean variable. If it's set to True then a "You can login to the computer network" message is sent. If it's not True but False then "See the teacher to get my password" message is sent. This code looks like this:
have_password = False # try changing the have_password variable to True
if have_password:
print("You can login to the computer network")
else:
print("See the teacher to get my password")
Tax Calculation Program
Personal income tax (PAYE) is calculated by:
$0 - $14,000 10.5%
$14,001 - $48,000 17.5%
$48,001 - $70,000 30%
$70,001 and above 33%
Can you write a program that accepts someone's income and calculates the amount of tax they should pay. You will need to use float() to convert input string to a decimal number and str() to convert a float number to a string.
Reflection "variables"
In a Google Doc named "Reflection Variables" answer these questions:
Techterms Variable
Python For Beginners Variables
In a Google Doc named "Reflection Variables" answer these questions:
- What is a variable?
- How are they used in Python?
- Name the 3 basic variable types?
Techterms Variable
Python For Beginners Variables
Reflection "High-level programming language and interpreters"
In a Google Doc named "Reflection High level programming language and interpreters" answer these questions:
How is Python a high-level programming language?
Why is it easier to use a high level programming language then a low level programming language?
What is an interpreter?
How is the interpreter used in the Codingground application?