Python full Stack Road "one" foundation

Source: Internet
Author: User

The first sentence of code

Hello World

Python3

Print ("HelloWorld")

Python2

Print " Hello World "

Linux

# ! /usr/bin/env pythonprint ("HelloWorld")

Variable

Variable refers to a value of a change

Variables can only consist of letters, numbers, underscores, and cannot start with a number

Python keyword cannot be variable

Name ==print(name,age)

Conditional statements

If Else

Name = input ("name:")if name = = Amada    :Print( " Hello Amand " )else:    pass

While loop

Count = 0 while Count <:       print      (count)= Count + 1

Homework

1. Use while loop input 1 2 3 4 5 6 8 9 10

Count = 1 while count < one:   if  count = =7       :pass    else:       Print(count)   = count + 1

2. For all numbers of 1-100

s == 0 while Count <101:    = s + count    = count + 1    Print(count)    print(s)

3. All odd numbers in output 1-100

Count = 1 while count < 101:     = count% 2     if a = = 1         :print  ( count)     = Count +1

4. All even numbers in output 1-100

Count = 1 while count < 101:     = count% 2     if a = = 0         :pri NT  (count)     = Count +1

5, Beg 1-2+3-4+5 ... 99 of all numbers of the and

s == 0 while C <100:    = c% 2    if q = = 0        := S- c
    Else:        = s + c    = c +1print(s)

6. User Login (three chance retry)

Count =0 whileCount < 3: Name= Input ("Account Number:") passwd= Input ("Password:")    ifName = ="Ada"  andpasswd = ="123":         Print("Welcome to login")          Break    Else:         Print("incorrect account or password") Count= Count + 1

Python full Stack Road "one" foundation

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.