Upload
maurice-fields
View
218
Download
1
Tags:
Embed Size (px)
Citation preview
Please log on
The
AN INTRODUCTION TO
‘Python is a high-level, general purpose programming
language’
Python is one of the many programming languages
available to the public and is used daily to create
anything from games to Operating Systems.Coding language is the
foundations of anything you use on the computer – Python is but
one of them.
WHAT IS PYTHON?
• Variables• Strings• Strings and Variables • Combining Numbers
and Strings
WHAT WE’RE LEARNING
Variable
Value
red=15 blue=10 yellow=5
print(red,blue,yellow)
red=15
blue=10
yellow=blueprint(red+blue+yellow)
bool=Truename=‘ ………… ’age=…………
print (name + ‘ is ’ + str(age) + ‘ years old ’)
EXERCISE
StringsA string is just a combination of letters in order, e.g. “The IT Crowd”A String can be declared by either single, double or triple quoting the string – e.g. ‘The IT Crowd’ “The IT Crowd” “““The IT Crowd” ” ”
The you want to incorporate quotation marks into the string itself then you need to put a backslash before them e.g. ‘Nathaniel said \“Hello Everyone\”’
Combining Variables and Strings
We’re going to write a question which the user can respond to
question= “What did you have for lunch?”print(question)
answer= input() put your answer here
print(“You had ” + answer+ “ for lunch?”)
question= “What\’s your name?”print(question)
answer= input()(insert name here)
print=(“ You\’re called ” + answer + “ ?”)
Combining Numbers and Strings
When using Python we have to tell the programme whether the value or word we’ve entered is either a string or an integerTo do this we use the commands str() and int()
We’re going to write a programme which asks the user for a question then adds 10 to that number
print(“Give me a random number”)response=input()number=int(response)plusTen=number+10print(“If we add 10 to your number we get ” + str(plusTen)
I want you to write a programme which asks what you had for lunch, then the
price. The programme should then tell the user how much the meal would be with the
addition of £1.00
Challenge
Recap What does each of these functions do? •print(…..)•input()•len()•str()•int()
THANKS FOR COMING@BittTeam