
Variables in Python
Presentation
•
Computers
•
8th Grade
•
Practice Problem
•
Hard
Khawla Hijazi
Used 35+ times
FREE Resource
9 Slides • 4 Questions
1
Variables In Python
2
Definition and Usage
The input() function allows user input.
For Example:
If you need to ask the user a question and you expect the user to enter a value.
Like
what is you name?
Or
What is your age?
Or
Enter your birthdate
3
Syntax
Input (prompt)
4
Input(prompt)
Syntax
5
Example
Write a python program to ask the user about their favorite Drink then print the answer “ My favorite drink is …………”
First:
Declare a variable to store the answer inside it
Drink=input(“what is your favorite drink?”)
Write the print command to print the answer
Print(“My favorite drink is “+ Drink)
6
Multiple Choice
Which of the following statements are correct?
Variables varies depending on the circumstances
Variables cannot be changed
Variables can be changed
7
colour=“brown ”
animal=“dog”
print(colour+animal)
Example:
A variable is created the moment you first assign a value to it.
How to declare a variable in Python
8
Single or Double Quotes?
String variables can be declared either by using single or double quotes:
Example:
Student_name="Ahmad"
or
Student_name='Ahmad'
9
Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables:
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive (age, Age and AGE are three different variables)
A variable name cannot be any of the Python keywords.
10
Multiple Select
Choose the correct variable name:
First Student
FirstStudent
1Student
First_Student
11
Multiple Choice
Is variable name CarName is the same as carname?
True
False
12
Fill in the Blanks
13
Use variable practice
Write a pythoin programe using variables to print Welcome yourname :
1. declare the variable
Name="khawla"
2. write the print sentence:
print("welcome " + Name)
The + is used for concatenation ( to combine strings together)
Variables In Python
Show answer
Auto Play
Slide 1 / 13
SLIDE
Similar Resources on Wayground
11 questions
Setting, Conflict, and Irony in "The Lottery"
Presentation
•
8th Grade
13 questions
The Colonization of Africa
Presentation
•
8th Grade
6 questions
Кнопка, напис та їх властивості
Presentation
•
8th Grade
11 questions
Lenguaje Algebraico
Presentation
•
8th Grade
11 questions
CHRISTMAS TRIVIA
Presentation
•
8th Grade
11 questions
Parts of Speech
Presentation
•
8th Grade
12 questions
Solutions
Presentation
•
8th Grade
12 questions
World energy needs
Presentation
•
8th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade