Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

Python Basics Part 1

$
0
0

Let’s start with python basics, with the help of program .Theory part in posts is just enough to understand the program.

Python Data Type: Numbers Strings List Tuple Dictionary Numbers : Int 1 ,10,-145, 22 Float 1.1,0.9,-29.9 Complex 1.4j, 4e+6j Strings

Way to remember how slices work in string is to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right edge of the last character of a string of n characters has index n , for example:

“Crazyouters ” represented in indices form

0 1 2 3 4 5 6 7 8 9 10 11 C r a z y r o u t e r s -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 Program Code : Str.py
Python Basics   Part 1
Output
Python Basics   Part 1

There are special operators in strings

Program Code :str1.py
Python Basics   Part 1

Output


Python Basics   Part 1

3. List

The list is a most versatile datatype available in Python which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that items in a list need not be of the same type. Unlike string ,List is mutable type means its content can be changed.

Program Code : list.py
Python Basics   Part 1
output :
Python Basics   Part 1

Viewing all articles
Browse latest Browse all 9596

Trending Articles