Python Study the next day

Source: Internet
Author: User

    • Memory address query for Python variables
# !/usr/bin/env python # -*-coding:utf-8-*- " Zhang "  "Frank"ID (name)
    • Process Control and Indentation
    1. Syntax for Process Control

If condition:

Executes the next statement (content)

Content 2

Else

Content 3

Content 4

Python language indentation must be the same, or with 4 spaces, it is generally strongly recommended to use four spaces instead of Indentation. Because it can be used in different system Environments. There is no problem with program incompatibility due to indentation problems.

The difference between = and = = is an equal value of two equals is a comparison

#!/usr/bin/env python#-*-coding:utf-8-*-#The following procedure is to determinename1 = Raw_input ("Please enter the first user name") name2= Raw_input ("Please enter a second user name")ifName1 = =name2:Print("congratulations on your writing.")        Print("you're not Stupid.--good by")Else:        Print("Please re-enter")

Simple User name Password login program

#!/usr/bin/env python#-*-coding:utf-8-*-#The following procedure is to determineName = Raw_input ("Please enter user name") PWD= Raw_input ("Please enter your password")ifName = ="Zhangkun"  andPWD = ="123": # If name = = "zhangkun" or pwd = = "123":    
Print("Congratulations on your successful login") Print("you're not Stupid.--good by")Else: Print("Logon Failure")

Multiple Judgment syntax

If condition 1:

Elif condition 2:

....

Elif condition 3:

23444444

Else

Ssssss

The conditions are multiple and varied can be false, True, <,>,<>, = =, a==b and b==c, a = B or v = w, a! = b

#!/usr/bin/env python#-*-coding:utf-8-*-Name = Raw_input ("plase input a name:")ifName = ="Zhangk":        Print("Good")elifName = ="Frank":        Print("NO!!!, name is a 中文版 name")elifName = ="Yes":        Print("you input yes isn't OK")elifName = ="No":        Print("input No is not OK too!!!!!!!!!")Else:        Print("you name does konw? is a SB")
    • The While Loop statement uses the

While Condition:

......

The loop body is introduced after the condition is met. If the condition is not satisfied, it is called the cycle of Death.

code block

#!/usr/bin/env python#-*-coding:utf-8-*-A = Raw_input ("plase input a num:") b= 1ifA = ="3":         whileb < 10:                PrintStr"It's Circulating.")+a B= B+1Else:        Print("He's a bloody Dead Man.")

When the loop body executes, How do you let the program execute once in a second? a time module is used here

#!/usr/bin/env python#-*-coding:utf-8-*-Importtime  a= Raw_input ("plase input a num:") b= 1ifA = ="3":         whileb < 10:                PrintStr"It's Circulating.")+a time.sleep ( 1 ) b= B+1Else:        Print("He's MD S.")

Python Study the next day

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.