print(b>a)
Basic Python Notes – Grade 6 o/p:
True
1. DATA TYPES
False
a) int (Integer) – Whole numbers
Example: 2. print() FUNCTION
x = 10 Used to display output on the screen.
print(x)
Syntax:
o/p: 10
print("message")
b) float – Decimal numbers
Example:
Example:
y = 3.5
print("Hello Students")
print(y)
o/p:
o/p: 3.5
c) str (String) – Text or number values (written inside quotes) Hello Students
Example:
name = "Rahul" NOTE:
a=”8” What is a Variable in Python?
print(name)
A variable in Python is a name used to store data (a value) in memory.
print(a) You can think of it like a labeled box where you keep information so you
can use it later in your program.
o/p:
Rahul Example:
8 name = "Alice"
age = 20
price = 99.5
d) bool (Boolean) – True or False values
Example: Here:
a=5
name, age, and price are variables
b=3
print(a>b) "Alice", 20, and 99.5 are the values stored in them
Rules for Creating Variables in Python
1. Variable names must start with a letter or underscore (_)
2. Variable names cannot start with a number
Summary for creating a variable
Start with letter or underscore
Cannot start with number
Use letters, numbers, underscore
No spaces
Not a Python keyword
Case-sensitive
3. input() FUNCTION
Used to take input from the user.
Syntax: o/p:
variable = input("message") HiHiHi
Example:
name = input("Enter your name: ") Example 2:
print("Hello", name) print( “2 " * 3)
o/p: o/p:
Enter your name: sakthi 222
Hello sakthi Note: Both string data types can’t be replicated. It must be always one str data
4. STRING CONCATENATION type with int data type.
Joining two strings using + operator.
print(“hi” * “hi”)
Example 1:
first = "Good" o/p: Error
second = "Morning"
print(first + " " + second) 6. BINARY OPERATORS (Arithmetic Operators)
+ Addition
o/p:
- Subtraction
Good Morning * Multiplication
/ Division
Example 2: % Modulus (Remainder)
first = "1" ** Exponent (Power)
second = "2" // Floor Division
print(first + second)
Example:
o/p: a = 10
b=3
12 print(a + b)
print(a % b)
5. STRING REPLICATION
Repeating a string using * operator. o/p:
Example 1: 13
print("Hi " * 3)
1