Python study notes_006

The sample code in Chapter 4 is as follows.

--Point --The length of the list can be calculated with len () and used as the upper limit of the index in the for loop. --Since there is one space between multiple values separated by commas in print, the way to avoid it is to output as one string by concatenating strings.

sample04.py


scores = [60, 50, 60, 58, 54, 54,
          58, 50, 52, 54, 48, 69,
          34, 55, 51, 52, 44, 51,
          69, 64, 66, 55, 52, 61,
          46, 31, 57, 52, 44, 18,
          41, 53, 55, 61, 51, 44]

length = len(scores)

for i in range(length):
    print("Test proposal#" + str(i),"Score:",scores[i])

high_score = max(scores)
max_list = []
for i in range(length):
    if scores[i] == high_score:
        max_list.append(i)
        
print("Total number of tests:",length)
print("Highest score:",max(scores))
print("Maximum index:",max_list)

--Output result サンプル4の出力結果の一部

Recommended Posts

Python study notes _000
Python study notes_006
Python study notes _005
Python study notes_001
Python study note_002
Python scraping notes
Python learning notes
Jupyter study notes_006
Python beginner notes
Python study note_004
Linux study notes
python C ++ notes
Python study note_003
Python grammar notes
Python Library notes
Jupyter study notes_008
python personal notes
Jupyter study notes_004
Jupyter study notes_001
python pandas notes
python learning notes
Python3.4 installation notes
Python study day 1
missingintegers python personal notes
Python package development notes
python decorator usage notes
Python ipaddress package notes
[Personal notes] Python, Django
Python Pickle format notes
[Python] pytest-mock Usage notes
First Python miscellaneous notes
Matlab => Python migration notes
Notes around Python3 assignments
Notes using Python subprocesses
Python try / except notes
Python framework bottle notes
Python notes using perl-ternary operator
Web scraping notes in python3
Python
Python standard unittest usage notes
Python notes to forget soon
Study Python with Google Colaboratory
Python notes using perl-special variables
Python 處 處 regular expression Notes
Python Tkinter notes (for myself)
Study from Python Hour4: Object-oriented ②
Study from Python Hour3: Functions
[Python] Notes on data analysis
Python data analysis learning notes
Notes on installing Python on Mac
python pandas study recent summary
[WIP] Fluent Python Study Note
Study from Python Hour4: Object-oriented ①
New Linux textbook (study notes)
Get Evernote notes in Python
Notes on installing Python on CentOS
Notes on Python and dictionary types
Minimum grammar notes for writing Python
Notes on using MeCab from Python
selenium case study summary python pyCharm
Study from Python Hour2: Control statements