Professional Documents
Culture Documents
Python Programming
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).
Interpreter:
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:
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:
Example:
a="learning python"
print(a.upper())
Output:
LEARNING PYTHON
Lowercase Method:
Example:
a="LEARNING PYTHON"
print(a.lower())
Output:
learning python
String Concatenation:
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'