The path to learning in Python--09 basic articles

Source: Internet
Author: User

In Python, an array can hold integers and strings at the same time, because there is no strict variable type in Python, you give him what type, what type he is, so this gives us the convenience of dealing with multiple types of variables, Python, like other languages, has a while loop, an effect type, and uses formatting to conform to Python's syntax rules.

Learn Python according to the topic:

Millet is a kindergarten teacher, every semester of clay sculpture class, she will give each student not more than 250 cubic centimeter of the same amount of clay, teach you to do sculpture. In the course of the class, she found that each class happens to have a little friend to rob another kid's clay, so she decided, in the formal beginning to do before the sculpture, let everyone put the hands of the dough into a cube, and measured in the hands of the long, wide and high pinch of dough. So she could know who had been robbed of the dough.

Input format

Xiaomi teachers may take one or more classes in different semesters, so the input data may have one or more groups.

The first behavior of each set of input data is an integerNN, indicating the number of children in this class, and thenNn rows each row consists of three integers separated by spaces and a string that represents the child's name, and the first three integers are the length, width, and height of the dough block in the student's hand. According to kindergarten regulations, each class has a maximum of99 Children, at least 22 Children, each child in the status of the system of the name of not more than 88 characters. When the number of children who appear in a class is -1? 1 o'clock, it means there are no more classes.

Output format

The number of output lines and Xiaomi teacher with the same number of classes, X took clay from Y. in the form of, please refer to sample output.

Sample input
310 2 Jill5 3 Will5 5 Bill42 4 Cam4 3 7 SAM8 1 GRAHAM6 2 7 Pam-1
Sample output
Bill took clay from Will.graham took clay from Cam.
In fact, the integer and string are processed together, so that the Python code is much shorter than the C code, (if C is estimated to use a struct, you can store multiple types of variables in a struct array.) )
#!/usr/bin/ven python3.6#-*--coding:-utf8--*-Clas=[[0 forIinchRangeTen)] forIinchRangeTen)] while(1): x=input () n=int(x)ifn==-1:         Break     forIinchrange (n): Y=input (). Split () clas[i][0]=int(y[0]) clas[i][1]=int(y[1]) clas[i][2]=int(y[2]) clas[i][3]=y[3] clas[i][4]=clas[i][0]*clas[i][1]*clas[i][2] Maxx=-1Minn= -NA1=" is"Na2=" as"     forIinchrange (n):ifclas[i][4]>Maxx:maxx=clas[i][4] Na1=clas[i][3]        ifclas[i][4]<Minn:minn=clas[i][4] Na2=clas[i][3] Print (Na1+'took Clay from'+na2+'.')

The path to learning in Python--09 basic articles

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.