Getting started with Python

Source: Internet
Author: User

Getting started with Python
1. For the scope of a variable, the execution statement exists in the memory, and the variable can be used (I .e., the scope) if 2 = 2 in the following code: name = 'Alex 'print name is the following conclusion correct? The outer variable can use the memory variable by the inner variable and cannot be used by the outer variable to execute the above Code :#! /Usr/bin/env python #-*-coding: utf8-*-if 2 = 2: name = 'Alex 'print nameprint name [root @ Python day001] # python new_test.pyalexalex [root @ Python day001] # conclusion: For Python, as long as the variables are declared in the memory, then you can directly use the binary and ternary operations result = value 1 if condition else value 2 if condition true: result = value 1 if condition false: result = value 2 example ① name = 'Alex 'if 1 = 1: name = 'SB' else: name = '2b 'code rewrite: name = 'SB 'if 1 = 1 else 2b then you can take out the name directly for corresponding processing. 3. binary representation of various hexadecimal methods, 01 octal, 01234567 decimal, 0123456789 hexadecimal, 0123456789 abcde iv. Python basics ① for Python, everything is an object, and objects are created based on classes (or objects are created by classes) ② In Python, any object has its own class, and any object attribute is referenced by its own class method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.