
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
Create a variable named carname and assign the value Volvo to it.
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
ALGORITMA & PEMROGRAMAN
Presentation
•
8th Grade
11 questions
Reading News Online
Presentation
•
5th Grade
12 questions
RI 8.5: SE_ANALYZING TEXT STRUCTURES
Presentation
•
8th Grade
12 questions
GREETING CARD
Presentation
•
8th Grade
11 questions
Dialogue
Presentation
•
8th - 9th Grade
10 questions
Solving Equations
Presentation
•
6th Grade
12 questions
Formatting Tags - Font Tag
Presentation
•
7th - 8th Grade
12 questions
9-klass informatika 40-sabaq
Presentation
•
8th Grade
Popular Resources on Wayground
6 questions
PRIDE Always and Everywhere
Presentation
•
12th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
26 questions
KOR Review Kahoot Questions
Quiz
•
8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
12 questions
Unit Zero lesson 2 cafeteria
Presentation
•
9th - 12th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
10 questions
Riddles Riddles fun Riddles
Quiz
•
6th - 12th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade