Page 136 - CodePilot V5.0 C6
P. 136
Syntax of print() function:
print(<value>)
Here, the value can be an expression, string or variable that you want to display. You can also In Python, keywords and identifiers are two important concepts that define the structure and
print multiple items by separating them with commas. naming conventions of a program.
For example: KEYWORDS
print("Let's code together!") Keywords are reserved words with special
>>> Let's code together! meanings in Python, used for tasks like control Python has 35 reserved keywords that cannot
flow (if, for, while), functions (def) and classes be used as variable names.
Program 1 To use the input( ) and print( ) functions.
(class). They cannot be used as variable
Program1.py names. Here is a list of Python keywords:
File Edit Format Run Options Window Help False None True and as assert
async await break class continue def
name = input("Enter your name: ") del elif else except finally for
print("Your name is", name)
from global if import in is
lambda nonlocal not or pass raise
return try while with yield
Output You cannot use keywords as variable names. For example, you cannot name a variable ‘if’ or ‘for’.
Enter your name: Ankit
IDENTIFIERS
Your name is Ankit
An identifier is a name used to uniquely identify a variable, function, class or object in Python. It
represents the values you store, like numbers or text.
Examples of Identifiers:
RAPID RECALL Tick ( ) if you know this.
Variable identifiers: age, score, temperature
1. The print() function is used to display output on the screen in Python.
Function identifiers: print_message(), calculate_sum()
2. The input() function is used to take input from the user. Class identifiers: Person, Student
VARIABLES IN PYTHON
In Python, variables store values that can be accessed or changed later. Their names are
CHARACTER SET identifiers and you don’t need to specify their type because Python is dynamically typed.
A character set is the collection of characters a programming language recognises. Python
accepts all ASCII and Unicode characters, including: RULES FOR NAMING VARIABLES
When creating variable names, make sure to follow these rules:
Letters of the alphabet: All capital letters (A-Z) and small letters (a-z).
Variable names can contain letters (a-z, A-Z), digits (0-9) and underscores (_).
Digits: All digits from 0 to 9.
Variable names must begin with a letter or an underscore (_), but not a number.
Special symbols: Python supports a wide range of special symbols such as:
Variable names are case-sensitive, so ‘age’ and ‘Age’ are considered two different variables.
" ' ; : ! ` ~ @ # $ % ^ & * ( ) _ + - = { } [ ]
Variable names cannot use Python keywords (such as if, else, for) as variable names.
White spaces: White spaces like tab space, blank space, newline (\n) and carriage return (\r).
Variable names cannot contain spaces.
134
CodePilot (V5.0)-VI
5

