SDUT-ACM OJ of Shandong University of Technology: Python Code and analysis

Source: Internet
Author: User
Tags for in range

Python basic grammar learning completed, first brush the basic problem 100 to consolidate, with title, Code, Knowledge analysis

Title: http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/1000= input (). Split ( ); Print ((int) (s[0]) + (int) (s[1])) Knowledge Analysis:1, Python input ()   2, Split () is the split string operation 3, Python can use str [0] Take the string subscript 0 character
1000, a+b problem

 

Title: http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/1010. html code:while  True:    s=input (). Split ()    print((int) (s[0]) + (int) (S[1))analysis Knowledge:1 , Python boolean type has true False  remember is uppercase 2, while true: the   following colon must have  parentheses do not necessarily need to have, the specification is not  different from Java
1010, A+b for Input-output Practice (I)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1011= (int) (input ())  for  in range (1,num+1):    = input (). Split ()    print((int) (s[0]) + (int) (s[1 ]) Knowledge Analysis:1, for loop use structure for    in range (1,num+1)     1 to Num  
1011, A+b for Input-output Practice (II)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1012. html code:  while True:     = input (). Split ()    if and (int) (s[1]) = =0        :break     Print((int) (s[0]) + (int) (s[1])) Knowledge Analysis:1, Python and operation is and  or operation is or   
1012, A+b for Input-output Practice (III)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1013. html code:  while True:    s=input (). Split ()    if s==['0']:        break = 0 ;           for  in range (1, Len (s)):        sum=sum+(int) (s[i])    print(sum)
1013, A+b for Input-output Practice (IV)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1014= input ()  for in range (0, int (s)):    s=input (). Split ()    = 0;      for  in range (1, Len (s)):        sum=sum+(int) (s[i])    print(sum)
1014, A+b for Input-output Practice (V)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1015. html code:  while True:    s=input (). Split ()    sum=0     for in range (1, Len (s)):        sum+ =(int) (S[i]    )print(sum) knowledge Analysis: None
1015, A+b for Input-output Practice (VI)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1016. html code:  while True:    s=input (). Split ()    print((int) (s[0]) + (     int) (s[1])  Print()
1016, A+b for Input-output Practice (VII)

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1017. html code: S= input ()  for inch Range (0, (int) (s)):     = input (). Split ()    = 0;      for  in range (1, Len (ss)):        sum+ =(int) (Ss[j]    )print(sum)     Print ()
1017, A+b for input-output practice

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1123. html code: num =(int) (input ())if num==0:    Print(1)else:     = 1;    I=0    for in range (1,num+1):        *= i       Print(sum) knowledge Analysis:1,if  else inside need to have:
1123. Factorial (cyclic structure)

title: http:acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1201. html code: s=input (). Split (" ")#adding three strings to a listList =[]list.append (S[0]) list.append (s[1]) list.append (s[2]) List.sort () forIinchRange (len (list)):Print(list[i],end="')    Print(" ", end="') Knowledge Analysis:1, List add element method append2, List Sort method sort ()3, output does not change line add, end="'
1201. Sorting Strings

title: http:acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1249. html code: whiletrue:s=input ()Print(S.title ()) Knowledge Analysis:1, input () is entered after the string2, S.title () built-in methods to capitalize the first letter of each word to the rest of the lowercase other methods are as follows: Str="www.runoob.com"Print(Str.upper ())#converts lowercase letters in all characters to uppercase lettersPrint(Str.lower ())#converts uppercase letters in all characters to lowercasePrint(Str.capitalize ())#Convert the first letter to uppercase, the remaining lowercasePrint(Str.title ())#Convert the first letter of each word to uppercase, the remaining lowercaseexecute the above code output as: WWW.RUNOOB.COMwww.runoob.comWww.runoob.comWww.Runoob.Com
1249. Capitalize the initial letter

title: http:acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/1442. html code: NUM=(int) (input ()) forIinchRange (0,num): s= input (). Split (" ")    #a space split is a string converted into a list.List =[] list.append ((int) (s[0])) list.append ((int) (s[1])) list.append ((int) (s[2]) Ave= (List[0]+list[1]+list[2])/3#Calculate AverageIsLarge = 0#the number of 3 numbers greater than the average     forJinchlist:ifJ >Ave:islarge+=1ifIslarge>1:        Print("Yes")    Else:        Print("No") Knowledge Analysis:1. Range (0,num) is 0 to num-12, s = input (). Split (" "gets the string that is separated by a space and enters into the list such as input:1 2 3The value of S is: ['1','3','4']
1442. Number of advantages

title: http://acm.sdut.edu.cn/onlinejudge2/index.php/home/index/problemdetail/pid/2247. html code: S= Input (). Split ("")print(S[0].count (s[1)) Knowledge Analysis:1, Str.count (s) Returns the number of occurrences of s in str
2247. Number of statistics

SDUT-ACM OJ of Shandong University of Technology: Python Code and analysis

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.