0% found this document useful (0 votes)
3 views4 pages

Python Introduction

Python is a high-level, general-purpose programming language created by Guido Van Rossum in 1991, known for its readability and ease of use. The document covers Python comments, variable creation and naming rules, as well as built-in data types, including examples of how to determine the data type using the type() function. It emphasizes that variable names are case-sensitive and outlines the rules for naming variables.
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)
3 views4 pages

Python Introduction

Python is a high-level, general-purpose programming language created by Guido Van Rossum in 1991, known for its readability and ease of use. The document covers Python comments, variable creation and naming rules, as well as built-in data types, including examples of how to determine the data type using the type() function. It emphasizes that variable names are case-sensitive and outlines the rules for naming variables.
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

_Introduction

 Python is a popular programming language. It was created


by Guido Van Rossum, and released in 1991.
 Python is a high-level, general-purpose programming
language known for its readability and ease of use.
 python is also Interpreted and oops language.

Note:

the extension of python is “ . py ”

Python Comments
 Comments can be used to explain Python code.
 Comments can be used to make the code more readable.
 Comments can be used to prevent execution when testing
code.

Creating a Comment
 Single line comments #
 Multi line comments  Starts with ’’’ Ends with ’’’

Variables
 Variables are containers for storing data values.

Creating Variables
 Python has no command for declaring a variable.
 A variable is created the moment you first assign a value to it.

Variable Names
 A variable can have a short name (like x and y) or a more descriptive
name (age, carname, total_volume).

Rules for Python variables:


 A variable name must start with a letter or the underscore character
 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three
different variables)
 A variable name cannot be any of the python keywords

Note:

 Remember that variable names are case-sensitive

Python Data Types


Variables can store data of different types, and different types can do
different things.

 Python has the following data types built-in by default, in these


categories:

Getting the Data Type


 You can get the data type of any object by using the type() function:

Ex:

x=5

print(type(x))

output:

<class 'int'>
Str:
x = "Hello World"

print(x)

print(type(x))

Output:

Hello World
<class 'str'>

Int:
x = 20

print(x)

print(type(x))

Output:

20
<class 'int'>

Float:
x = 20.5

print(x)

print(type(x))

Output:

20.5
<class 'float'>

Complex:
x = 1j

print(x)

print(type(x))

Output:

lj
<class 'complex'>
Bool:
x = True

print(x)

print(type(x))

Output:

True
<class 'bool'>

You might also like