
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
12 questions
8th ELA CRM 1.3 RI 2.4
Presentation
•
8th Grade
12 questions
BAB 4 SISTEM KOMPUTER (1)
Presentation
•
8th Grade
9 questions
Quadrant 1 Quiz
Presentation
•
8th Grade
10 questions
QUIZ
Presentation
•
8th Grade
9 questions
9.3 Solving Systems by Elimination
Presentation
•
8th - 9th Grade
12 questions
Linear vs. Nonlinear
Presentation
•
8th Grade
10 questions
Digital Citizenship
Presentation
•
7th - 9th Grade
10 questions
PLAY/GO/DO WITH VERBS
Presentation
•
8th Grade
Popular Resources on Wayground
20 questions
Math Review
Quiz
•
3rd Grade
15 questions
Fast food
Quiz
•
7th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
10 questions
Identify Fractions, Mixed Numbers & Improper Fractions
Quiz
•
3rd - 4th Grade
Discover more resources for Computers
17 questions
guess the logo
Quiz
•
8th Grade
10 questions
Candy
Quiz
•
4th - 8th Grade
10 questions
Fact Check Ice Breaker: Two truths and a lie
Quiz
•
5th - 12th Grade
10 questions
Memorial Day History and Traditions
Interactive video
•
5th - 8th Grade
20 questions
summer trivia
Quiz
•
8th Grade
15 questions
Middle School Fun Trivia Questions
Quiz
•
7th - 8th Grade
7 questions
8th U8 T2 Quiz Review
Quiz
•
8th Grade
10 questions
Video Games
Quiz
•
6th - 12th Grade