Python Basics – Variables, Data Types, type(),
input()
Variables
A variable is a name used to store a value.
name = "Vaishnavi"
age = 23
city = "Chennai"
print(name)
print(age)
print(city)
Rules for Naming Variables
- Can contain letters and numbers
- Can use underscore (_)
- Must start with a letter
- No spaces or special characters
name = "Python"
age1 = 25
user_name = "Admin"
Data Types
Integer: Whole numbers
Float: Decimal numbers
String: Text inside quotes
Boolean: True or False
age = 25
price = 99.5
name = "Vaishnavi"
is_active = True
type() Function
Used to check the data type of a variable.
name = "Vaishnavi"
age = 23
price = 99.5
print(type(name))
print(type(age))
print(type(price))
input() Function
Used to get input from the user.
name = input("Enter your name: ")
print(name)
Multiple Inputs
name = input("Enter name: ")
age = input("Enter age: ")
print(name)
print(age)
Summary
Variable – store value
Data types – int, float, string, boolean
type() – check datatype
input() – get user input