Activity Sheet 1: Programming in Python
Activity Sheet 1: Programming in PythonBefore you start download the starter program for this week from <your shared drive>Start Python by opening Idle – the default Python editorFile – Open - > Find starter_activity_sheet_1.py that you downloaded 76200156019500You have already had a guess at what the program might do. Now try it out!Run the programGo to File – Save and save this program in your own areaGo to Run – Run Module (or press F5) See if it did what you would expect.QuestionsSee if you can answer the following questions about the programHow many variables can you find in this program and what are they being used for?……………………………………………………………………………………………………………………………………………………………………………………………………………………print() is a function that you can use to display to the screen. What other function is in this program and what does it do? …………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………What is the “+”being used for in this program?……………………………………………………………………………………………………………………………………………………………………………………………………………………What happens when you use print() with nothing inside the brackets?……………………………………………………………………………………………………………………………………………………………………………………………………………………Now add comments (beginning with #) to the program to make sure everything you understand is included in your program for future reference. When you think you understand how this program works then go on to the exercises.ExercisesChange the program so that it uses your name instead of Billy. Change the program so that it lets you type in your answer on the same line as the question.Change the program so that it asks the user (the person using your program) what their name is at the beginning of the programSave your file (Save as…) with a new name and write a new program building on the first one. Ask the user three questions, and each time give a suitable response:What their name isWhat they had for breakfastWhat their favourite colour isThen ask another person to test your programExtensionAsk the user how old they are and then tell them how old they will be on their next birthday. HINT: You will need to use int(input(“How old are you?”)) as int() changes the answer from the keyboard into a number, and use str(age) to print out the age next to some text. Key terms from this sheet:TermWhat it meansHow to do it in PythonVariableSomething you can give a value to and then change it at other times in the programInput/OutputGetting input from the keyboard or outputting something to the screen.AssignmentWhere a variable is given a valueKey points to remember in Python The colon : is used to announce that a new block of code is coming and all the lines in the block MUST be indented the same amount of spaces. At the end of the block, you can stop indenting. Anything that happens if a condition is true after an if statement is also a block of code.Python is case sensitive so Name and name will be treated as completely different things. ‘Name error’ is an error you get if the variable name or function name you have used in Python is not recognised. Sometimes it’s caused by a lower case/upper case mis-typing or a spelling error. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- python 101 pennsylvania state university
- an introduction to using python with microsoft azure
- python tutorial netcdf
- basic python programming for loops and reading files
- python files i o tutorialspoint
- working with files in python
- syllabus for python section of course
- student lab 1 input processing and output
- setting up python 3 4 numpy and matplotlib on your own
- python programming project university of south alabama
Related searches
- macro programming in excel
- ied activity 5.1 calculating properties of shapes answer key
- programming in excel
- programming in java pdf
- ied activity 5 1 calculating properties of shapes answer key
- programming in matlab
- object oriented programming in matlab
- programming in basic
- blank number sheet 1 100
- number sheet 1 100 printable
- counting sheet 1 100
- activity sheet for toddlers