You are on page 1of 3

Python Programming:

Newer language and efficient programming language. Helps you to write “clean code”. Easy to read,
develop and debug.

Purposes:

- Game Development
- Building Web applications.
- Solving problems.
- Research purpose (Heavily used).

A large group of community for diverse support.

Interpreter:

- Directly executes the instructions.


- Generates intermediate machine representation and evaluates it immediately.

Python comes with an interpreter.

Version: Python 3.8.3

Extension (.py ): filename.py

Single line of codes can be executed directly using python shell (Example: Python 3.8.3) which was
called as IDLE.

For writing more than one line of code, it is required to write the program in a new file. New file can
be opened from Python shell.

Variables:

 Container for storing data.


 No need to declare datatype for variable initialization.
 Direct assignment of values. (a=5, b=”string”…)

Rules for naming a variable:


 Variable can contain only letters, numbers and underscores.
 Variable should not start with number.
 Spaces should not be used between variables.
 No predefined python keyword should be used.

Example:
a=10
print(a)
Output:
10
Example:
a="Welcome"
print(a)
Output:
Welcome

Strings:

- Sequence of characters.
- Strings can be given inside single / double quotes.

String Methods:

Title Format:
- Title format uses title() method that displays each first letter of the word in uppercase format.

Example:
a="learning python"
print(a.title())
Output:
Learning Python

UpperCase Method:

- Converts each letter into uppercase format.

Example:
a="learning python"
print(a.upper())
Output:
LEARNING PYTHON

Lowercase Method:

- Converts uppercase format into lowercase format.

Example:
a="LEARNING PYTHON"
print(a.lower())
Output:
learning python
String Concatenation:

- String concatenation involves combining multiple strings into a single string.


- ‘+’ operator is used to concatenate strings.
- Adding new text with existing string variable requires text to be included within double quotes
(“text”).

Example:
a="Welcome"
b="Python Programming"
print(a + " to " + b)
Output:
Welcome to Python Programming

Whitespace Characters:
S.No. Character Description
1. \t Adding space, similar to pressing tab key during
typing.
2. \n Newline character.

Stripping Whitespaces:

- Additional spaces may be disrupting always. Python provides a method for eliminating such kind
of spaces using two mwthods.
- lstrip()
- rstrip()
- strip()

Example:
>>> str=" welcome "
>>> str
' welcome '
>>> str.lstrip()
'welcome '
>>> str.rstrip()
' welcome'

You might also like