N5 Python – Introduction

add2numbersOur 1st Python program makes use of a number of new constructs and variables.

# – Internal Commentary, anything after the # on the same line is ignored by the translator

= (Assignment) – values are assigned to the variables using an equals sign.

input() –  a string is captured from the keyboard using the input() function

int() – this function changes the datatype of the given variable to an integer (Whole number)

Expression – The expression is the right hand side of the =, this is evaluated and any calculations performed, the results are then assigned to the variable on the left hand side of the equals

print() – This function displays a string. The “,” is used to concatenate strings and add a space between them.

 

Mini Projects

If you are looking to give yourself a bit of a challenge then try these mini projects.

There is no set level for these and in fact your solution might change as you learn new constructs and data structures.

AH – Cheat sheets for a range of applications

I found these cheat sheets  on this site and here. A cheat sheet is a condensed (normally 2 A4 sides) set of notes for an aplication or programming language. They are not designed to be notes in themselves, they are more an aide-mémoire to help you recall how to do something.

There are a lot of languages here but I thought it was worth keeping the list intact. There is a lot in here that is in the course so make sure that you read the entire list.

Command Line

Databases

Programming

Unix/Linux

Web Development

Miscellaneous Topics

AH – Objects and Classes

https://www.youtube.com/watch?v=CtzVNCmysFs

Object-oriented programming (OOP) was discussed in Higher but we didn’t spend a lot of time on it. It is the first “difficult” topic to get your head round in AH. The video above gives a quick introduction to OOP in Python. Python is a OOP language, a topic we don’t dwell on before advanced higher but it was one of the reasons we picked Python for use in the school.

The Scholar notes use Standard Reference Language in their examples, it would be very good practice if you were to code them in Python.

OOP

If you are still having problems with Methods, Classes and Objects then you might want a look at the next couple of lessons from Learn Python the Hard Way.

N45 – Scratch

Today we covered

  • Sequence
    • The order that the command are executed in the program
  • Stage
    • The part of scratch where all sprites are displayed (Screen)
  • Sprite
    • This is an object  in scratch which contains instructions (Script)
  • Script
    • An ordered list of command blocks which controls the actions of the sprite.

The class used Scratch to create a program animating a knock knock joke, please look inside the program for further help. The class made use of the Cornell Notes system to record the lesson. For homework the class have to write down the sequence of instructions used (program)