A test script that is readily written in the Python learning process-test1.py

Source: Internet
Author: User

# # Reference input, and display text when referencing input
Name = input (' What's Your name ')
# # NAME = ' Stan '

Print (' Your name is ', name)

# #/For exact division,//for dividing, leaving only integral parts,% to take remainder
Print (' 10/3 = ', 10/3)
Print (' 10//3 = ', 10//3)
Print (' 10%3 = ', 10%3)

# # Try using Chinese
Print (' Chinese ')

# # defines and references the list array, using []
# # The input negative number in the array is the countdown start count
TSTR = [' T1 ', ' T2 ', ' T3 ']
Print (' Tstr is ', tstr)
Print (' tstr[0] = ', tstr[0], ', tstr[1]= ', tstr[1], ', tstr[2]= ', tstr[2])
Print (' tstr[-3] = ', tstr[-3], ', tstr[-2]= ', tstr[-2], ', tstr[-1]= ', tstr[-1])
# # Insert new data into the array
Tstr.insert (1, ' T_insert ')
Print (' Run Tstr.insert, Tstr is ', tstr)
# # Append Add a number to the last array
Tstr.append (' T_insert2 ')
Print (' Run tstr.append, Tstr is ', tstr)
# # POP () deletes the array data, deletes the last one when no number is lost, deletes the specified position when entering a number
Tstr.pop ()
Print (' Run Tstr.pop (), Tstr is ', tstr)
Tstr.pop (1)
Print (' Run Tstr.pop (1), Tstr is ', tstr)
Tstr.pop (-1)
Print (' Run Tstr.pop ( -1), Tstr is ', tstr)

# # Other data can also be used in arrays
TSTR2 = [' Z1 ', ' Z2 ']
Print (' Tstr2 is ', TSTR2)
Tstr.insert (1,TSTR2)
Print (' Insert tstr2, Tstr is ', tstr)
Tstr2.insert (2, ' Z3 ')
Print (' After TSTR2 changed, Tstr2 is ', TSTR2)
Print (' After TSTR2 changed, Tstr is ', tstr)

# # defines and references a tuple array, uses (), cannot be modified after a tuple definition, 1 elements must be defined with a comma ', ' to disambiguate
# # Although the tuple is immutable, the tuple value also changes when the list,list change can be quoted
STU1 = (1,2,TSTR2)
STU2 = (1,)
Print (' stu1 is ', STU1)
Print (' stu1[0] is ', stu1[0], ' stu1[1 "is ', stu1[1])
Print (' Stu2 is ', STU2)
Print (' stu2[0] is ', stu2[0])

A test script that is readily written in the Python learning process-test1.py

Related Article

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.