
![[igCS] Variable and Data types](https://cf.quizizz.com/img/wayground/activity/activity-square.jpg?w=200&h=200)
[igCS] Variable and Data types
Presentation
•
Computers
•
9th Grade
•
Practice Problem
•
Easy
Andy tsui
Used 5+ times
FREE Resource
11 Slides • 12 Questions
1
[igCS] Variable and Data types
by Andy tsui
2
Objectives
Declare and use variables and constants
Understand and use the basic data types
3
Multiple Choice
What will be produced by the following python statement:
print("Hello")
Following output on screen:
"Hello"
Following output on screen:
Hello
Nothing happened
Computer say hello to you
4
Activity
In REPL, create a new PYTHON project, name it variables
# put the following in main.py
name = "your name"
print(name)
5
Variable
Variable is like a container/box which we can put value/data inside
Each variable can store ONE piece of data only at anytime
grade = "F3"
The = sign in the above statement is called "assignment", which means we store a value to a variable
6
Retrieving values
To access the value of variable, simply replace value with the variable name:
# the following will output the value of grade
print(grade)
7
Multiple Choice
What will be the result of following code:
school = "MAC"
print(school)
Outputs:
"school"
Outputs:
School
Outputs:
"MAC"
Outputs:
MAC
8
Variable naming conventions
You can give (almost) any name to a variable, but:
Meaningful and relevant
e.g. class_number, firstname
Keep it explanatory but concise
Variable cannot start with number and not containing symbols (except _) or space
So we use _ to replace space, e.g. average_score
All variables in lowercase letters
although capital letter is acceptable, but this is the conventions used by the Python community
9
Multiple Select
Which of the followings are invalid variable names:
12_floor
twelve_floor
Twelve_floor
twelve floor
10
Multiple Choice
Which of the following is the best variable name, if we want to store someone's home address?
add
Address
home_address
1_address
11
Open Ended
Suggest a good variable name to store class number of a student.
12
Data Types
Each piece of data has it's "data type"
To help the computer to correctly handle and process data
13
String
String means sequence of characters
Python called "str"
To indicate the data is string, we must put string in a pair of " "
# inside print, we are actually giving a string # for print to output:
print("Hello world")
14
Numbers
Two major types of numbers:
Integer - integer is called int in Python
Real - Python called it float
15
Multiple Select
Which of the following is an integer?
1092
-201
221.0
1.5
"100"
16
Character (Char)
Char is one single character
We use 'x' (pair of single quote) to indicate a value is character
There is NO char in python. Python simply use treat character as string
17
Boolean (Logical True/False)
Boolean (bool in Python) consisted of two possible values only
True
False (Note: the first letter is capital in Python)
18
Multiple Choice
Which of the following data types contains two possible values only?
bool
integer
char
string
19
Multiple Choice
What is the data type of the following variable:
p = True
int
float
bool
str
char
20
Multiple Choice
What is the data type of the following variable:
p = (1 > 0)
int
float
bool
str
char
21
Multiple Choice
Which of the following data types is not available in Python
int
float
bool
str
char
22
Multiple Choice
What is the data type of the following variable:
x = 10
int
float
bool
str
char
23
Multiple Choice
What is the data type of the following variable:
y = "10"
int
float
bool
str
char
[igCS] Variable and Data types
by Andy tsui
Show answer
Auto Play
Slide 1 / 23
SLIDE
Similar Resources on Wayground
16 questions
Scatter Plots & Correlation
Presentation
•
9th Grade
15 questions
Microsoft excel
Presentation
•
8th Grade
18 questions
Mengenal Python
Presentation
•
9th Grade
16 questions
MEMAHAMI PSEUDOCODE
Presentation
•
9th Grade
19 questions
[igCS] Authentication
Presentation
•
9th Grade
18 questions
MAINTAIN COMPUTER EQUIPMENT AND SYSTEMS
Presentation
•
9th - 10th Grade
19 questions
[igCS] Analog and digital
Presentation
•
9th Grade
19 questions
6A: Components of DNA and DNA Replication
Presentation
•
9th Grade
Popular Resources on Wayground
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
Discover more resources for Computers
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
10 questions
Fire Prevention
Quiz
•
9th - 12th Grade
24 questions
BIOLOGY STAAR REVIEW
Quiz
•
9th Grade
20 questions
Graphing Inequalities on a Number Line
Quiz
•
6th - 9th Grade
30 questions
English 1 STAAR Review
Quiz
•
9th Grade
46 questions
Linear and Exponential Function Key Features
Quiz
•
9th Grade
20 questions
Grammar
Quiz
•
9th - 12th Grade
30 questions
Biology STAAR Review #3
Quiz
•
9th Grade