#-*-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