Lesson 2 - Data Types- Variables- and InputOutput

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/40

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:33 AM on 8/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

41 Terms

1
New cards
Data Type
A label that tells Python what kind of value is stored in memory.
2
New cards
Integer (int)
Whole numbers.
3
New cards
Integer Example
age = 25
4
New cards
Float (float)
Decimal numbers.
5
New cards
Float Example
price = 99.99
6
New cards
String (str)
Text inside quotes.
7
New cards
String Example
name = "Alice"
8
New cards
Boolean (bool)
True or False values.
9
New cards
Boolean Example
is_student = True
10
New cards
List (list)
A collection of items that is ordered and changeable.
11
New cards
List Example
numbers = [1, 2, 3, 4]
12
New cards
Tuple (tuple)
Like a list, but it cannot be changed.
13
New cards
Tuple Example
coordinates = (10, 20)
14
New cards
Dictionary (dict)
Stores data in key-value pairs.
15
New cards
Dictionary Example
student = {"name": "Alice", "age": 20}
16
New cards
type()
A Python function used to check the data type of a value or variable.
17
New cards
Variable
A named storage location used to store data.
18
New cards
Creating a Variable
A variable is created by assigning a value to a name, such as x = 10.
19
New cards
Variable Assignment
The process of storing a value inside a variable using the = symbol.
20
New cards
Can Variables Change Value?
Yes. A variable can be assigned a new value after it has already been created.
21
New cards
Variable Value Change Example
x = 10 followed by x = 20 changes the value of x to 20.
22
New cards
Do Python Variables Need Their Type Declared?
No. Python automatically determines the data type of a variable.
23
New cards
Automatic Type Detection
Python figures out the data type automatically based on the assigned value.
24
New cards
Automatic Float Detection Example
value = 3.14 is automatically recognized by Python as a float.
25
New cards
Output in Python
Output is used to show information on the screen.
26
New cards
print()
A Python function used to display information on the screen.
27
New cards
print() Example
print("Hello, world!")
28
New cards
Printing a Variable Example
name = "Alice" followed by print("My name is", name)
29
New cards
Input in Python
Input is used to take data from the user.
30
New cards
input()
A Python function used to receive data entered by the user.
31
New cards
input() Example
user_name = input("Enter your name: ")
32
New cards
What Data Type Does input() Return?
input() always gives a string.
33
New cards
Converting User Input to an Integer
Use int() around input(), such as int(input("Enter your age: ")).
34
New cards
int()
A function used to convert a value into an integer.
35
New cards
Numeric Input Example
age = int(input("Enter your age: "))
36
New cards
Using Numeric Input
After converting input to an integer, it can be used in calculations such as age + 1.
37
New cards
Quick Input/Output Example
Ask the user for their name and age, then display the entered information.
38
New cards
Ask for Name Example
name = input("Enter your name: ")
39
New cards
Ask for Age Example
age = int(input("Enter your age: "))
40
New cards
Display Name Example
print("Hello", name)
41
New cards
Display Age Example
print("You are", age, "years old.")