Assignment, Variables, Constants & Sequences
Inputs, Outputs & Type Conversion
IF Statements & Boolean Operators
Nested Selection and Iteration
WHILE, REPEAT-UNTIL Loops
Validation and verification
Validation and authentication routines
High-level & Low-level languages
Assemblers, Compilers & Interpreters
In python we use built in functions to help us with our input and output. The function we use to output to the screen is print() and the function we use to get input from the keyboard is input().
Let us look at the the output method print() first.
...In order to display text output in python you need to surround your message in quotation marks. The print function also needs your output to be surrounded with brackets.
...Any line of code that starts with a # is a comment: it doesn’t affect how the program runs, it’s just there to help explain what the code does.
Your code won’t run at all until you’ve fixed all of the errors: You need to fix all the lines of code even before the first line will run.
Python is case sensitive: be careful with CAPITAL LETTERS and lowercase letters
Click on the Lesson Resources activity for some ASCII art examples
In python if you want the user to input data into the program, you can use the input()function, this is another built in functions to help us put data into our program.
Let us now look at the the input method input().
...In order to get user input in python you need to use the input() function. This puts a prompt onto the screen to allow the user to enter data. If you want to use the data in your program you have to store it in a variable . The print function can then use the variable to output our user input to the screen .
...If we want to use numbers in our code we have to change the user input to the data type of the number we want to use.
For example if the type of number we want to use is a whole number then we convert the input using the int() function.
However if the type of number we want to use was a decimal number then we convert the input using the float() function.