Python basic syntax

Source: Internet
Author: User

#-*-Coding:utf8-*-Print "Hello python"ifTrue:Print "True"Else:    Print"False"x="a"y="b"#line break Output#Chinese comment error, need to add #-*-Coding:utf8-*-PrintxPrinty#no newline output outputPrintx,PrintY,counter= 100#Assignment Shaping VariablesMiles = 100.0#floating Point TypeName ="John"  #Character TypePrintcounterPrintmilesPrintNamea= b = c = 1PrintA, B, CPrintaPrintbPrintCA, B, c= 1, 2,"John"PrintA, B, cvar1= 1var2= 10Print"the value of the var1 is", Var1delvar1Print "the value of var1 after processing is empty"Str='Hello world!'PrintStr#Output Full StringPrintSTR[0]#the first character in the output stringPrintStr[2:5]#A string between the third and fifth in the output stringPrintStr[2:]#outputs a string starting from the third characterPrintSTR * 2#output String two timesPrintSTR +"TEST"  #string for output connectionPrint "================="List= ['Runoob', 786, 2.23,'John', 70.2]tinylist= [123,'John']PrintList#Output Complete listPrintLIST[0]#the first element of the output listPrintList[1:3]#outputs the second to third elementPrintList[2:]#outputs all elements from the third start to the end of the listPrintTinylist * 2#output List two timesPrintList + tinylist#print a list of combinationsPrint "======================="tuple= ('Runoob', 786, 2.23,'John', 70.2) Tinytuple= (123,'John')PrintTuple#Output Full tuplePrintTUPLE[0]#the first element of an output tuplePrintTuple[1:3]#outputs the second to third elementPrintTuple[2:]#outputs all elements from the third start to the end of the listPrintTinytuple * 2#output tuple two timesPrintTuple + tinytuple#Print a group of tuplestuple= ('Runoob', 786, 2.23,'John', 70.2) List= ['Runoob', 786, 2.23,'John', 70.2 ]#tuple[2] = illegal application in 1000 tuplesLIST[2] = 1000#is a legitimate application in the listPrintList[2]Print "======================"Dict={}dict[' One'] =" This is one"dict[2] =" This is the"tinydict= {'name':'John','Code': 6734,'Dept':'Sales'}Printdict[' One']#the value of the output key is ' one 'PrintDICT[2]#the value of the output key is 2PrintTinydict#output a complete dictionaryPrintTinydict.keys ()#Output All keysPrintTinydict.values ()#Output All Values

Python basic syntax

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.