Python Learning DAY2

Source: Internet
Author: User

S3 Date and Time

1. Get the current time DateTime.Now ()

2 extract Year,month, etc. from the information obtained from DateTime.Now

3 introduce the format of the output date into mm//dd//yyyy, we use the + to convert

4 introduce the format of the output date into HH:MM:SS, we use the + to convert

S4 Conditions and Control Flow

1 Python uses 6 ways to compare = =,! =, >, >=, <, <=, the result of comparison is true or false

Practice

1 set the value of Bool1 to < 118%100

2 Set the value of the bool2 to 100 = = 33*3 + 1

3 Set the value of Bool3 to <= 2**4

4 Set the value of the Bool4 to -22 >= -18

5 Set the value of BOOL5 to 99! = 98+1

2 connector and is used only if both sides of and are true then the result can be true

3 The use of the second connector or, as long as there is a true on either side of or, the result can be true

4 third connector not, if not true then result is false,not false result is true

5 because of the many expressions, we often use () to enclose some expressions so that they are more readable.

6 If, Elseif,else format is similar to C + +

def using_control_once ():     if 1 > 0:        return"Success #1"def  Using_ Control_again ():    if 1 > 0:        return"Success #2  print ( using_control_once ())print (Using_control_again ())

Operation Result:

Python Learning DAY2

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.