0% found this document useful (0 votes)
8 views

Variables in Python

The document outlines the rules for naming variables in Python, emphasizing that variable names must start with a letter or underscore, cannot contain spaces or symbols, and are case sensitive. It also introduces the concept of classes and objects in Python, describing a class as a blueprint for creating objects. An example of a class definition and its usage is provided, demonstrating how to access properties of an object.

Uploaded by

waduire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Variables in Python

The document outlines the rules for naming variables in Python, emphasizing that variable names must start with a letter or underscore, cannot contain spaces or symbols, and are case sensitive. It also introduces the concept of classes and objects in Python, describing a class as a blueprint for creating objects. An example of a class definition and its usage is provided, demonstrating how to access properties of an object.

Uploaded by

waduire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

>>Rules of Variable

1)A variable name must start with letter or the underscore character

2)A variable name cannot start with number

3) A variable name can only contain alpha numeric character and underscores(A-Z,0-9 and_)(No
symbols are allowed as a variable Name

4)Variable names are case sensitive(age,Age and AGE are three different variables)

5)There cant be a space among variable

Example

Legal Variable

myvar=”Himaksh”

my_var==”Himaksh”

_my_var=” Himaksh”

Myvar2=”Himaksh”

Illegal Variables

2myvar=”Himaksh”
My-var==”Himaksh” # In[26]:

Classes and Objects

Python Classes/Objects
Python is an object oriented programming language.

Almost everything in Python is an object, with its properties and methods.

A Class is like an object constructor, or a "blueprint" for creating objects.

Example

class myCar:
carName = "Honda"
carType = "civic"
car1 =myCar()
print(car1.carName)
print(car1.carType)
Output
“Honda”
“Civic”

You might also like