0% found this document useful (0 votes)
125 views

Python Programming Examples

The document is about Python scripts for a calculator and other programming lessons. It describes scripts that allow a user to input numbers and have arithmetic performed, check if a user's input is above a certain threshold, and define and call functions to print out values. The scripts demonstrate Python programming concepts like taking user input, performing conditional checks and calculations, and defining reusable functions.

Uploaded by

Henri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Python Programming Examples

The document is about Python scripts for a calculator and other programming lessons. It describes scripts that allow a user to input numbers and have arithmetic performed, check if a user's input is above a certain threshold, and define and call functions to print out values. The scripts demonstrate Python programming concepts like taking user input, performing conditional checks and calculations, and defining reusable functions.

Uploaded by

Henri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Page 1 of 4

Henris Python Programming


Calculator script - 15.12.14

Informs the user of what each


option does by printing out
what it does on each line on
the Python Shell. (e.g. Option
3 is multiply)

Integers are used because the options are whole


numbers and text/decimals cannot be inputted.

Asks the user to input a option

Float is used to ensure no


text is being inserted.

Asks the user to input the


numbers of their problem for
the calculator to calculate

The value which the user gave


for both of the numbers are
now multiplied and displayed

If a option other than the one


listed is selected (e.g. text)
then the program is stopped.

Page 2 of 4

Calculator script - shell

121+10=131

121 x 2 = 242

Page 3 of 4

If statements - lesson 12.12.14


Asks the user to input a whole
number of how much hours
he/she plays computer games

If it isnt 2 or below
then it prints a
different message
The script then checks
if the answer was 2 or
below, then prints a
message

Page 4 of 4

Functions - Lesson 5.12.14


Weve defined a function printinfo,
with name, age and hobby

Once its called, it will print out the


following.

Here we call the function with some


values
It then follows the script by
printing the values to the shell

You might also like