Python Road-1:Python History and Introduction

Python History

Python is an interpretedhigh-levelgeneral-purpose programming language. Created by Guido van Rossum and first released in 1991, Python’s design philosophy emphasizes code readability with its notable use of significant whitespace. it is a dynamically typed and garbage-collected language…

Use Python for …

Web Deployment: Django, Pyramid, Bottle, Tornado, Flask, web2py
GUI Deployment: tklnter, PyGObject, PyQt, PySide, Kivy, wxPython
Scientific and Numeric: SciPy, Pandas, IPython
Software Development: Buildbot, Trac, Roundup
System Administration: Ansible, Salt, OpenStack

And a lot of famous technology giants are using Python, such as Youtube, Dropbox, BT, Quor, Google, Yahoo!, Facebook, NASA.


Python Environment

Install Python

Windows:

1. Download Installation package
    https://www.python.org/downloads/
2. Install
    Default install path (but you can install another location) C:\Users\username\AppData\Local\Programs\Python\Python38
3、Setting Environment Variables
    【Computer】-->【Properties】-->【Advanced System Settings】-->【Advanced】-->【Environment Variables】-->【Find Path】 --> 【Append Python install path and end with ;】

Linux & Mac:

Python is built-in Program in Linux and Mac.

Python 101

1. First coding in Python

Open Python IDE and input bellow code
Print("hello world")

2. Variables

#!/usr/bin/env python
# -*- coding: utf-8 -*-
name = "Anson"

it defines a variable, variable name is name, value is Anson.

Tips:

The first character in a variable name cannot be number.

Following keywords cannot be declear as variable name:
[‘and’, ‘as’, ‘assert’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘exec’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘not’, ‘or’, ‘pass’, ‘print’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]

3. Input

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# assign a input value to name
name = raw_input("Please Input name:")
 
# print name
print name

When input the password, Function ‘getpass’ can make the password invisible.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
import getpass
 
# assign a input value to password
password = getpass.getpass("Please input password:")
 
# print password
print(password)

Leave a Reply

Your email address will not be published. Required fields are marked *