2 Your First Python Program.py - C:/Users/AdamR/OneDrive/Documents/Programming/Pytho... File Edit Format Run Options Window Help SUFFIXES 3D (1000: ['КВ', "МB', GB', "TB', "ЕВ', 'ZB', "ҮВ'], 1024: ['Kiв', "MiB', 'тіB', 'PiB', 'EiB', 'ZіB', 'YiB']} def approximate_size(size, a_kilobyte_is_1024_bytes=True): '"Convert a file size to human-readable form. Keyword arguements: size -- file size in bytes a_kilobyte is 1024 bytes -- if True (default), use multiples of 1024 if False, use multiples of 1000 Returns: string P SyntaxError if size < 0: raise ValueError ('number must be non-negative') X invalid syntax multiple = 1024 if a kilobyte is 1024 bytes else 1000 for suffix in SUFFIXES [multiple]: size /= multiple if size < multiple: return '{0:.1f}{1}'.format(size, suffix) OK raise ValueError('number too large') if name == ' main ': print (approximate_size(1000000000000, False)) print (approximate_size (1000000000000))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I'm getting an "invalid syntax" error in this following Python Code. Can someone tell me how to correct it?

Your First Python Program.py - C:/Users/AdamR/OneDrive/Documents/Programming/Pytho...
File Edit Format Run Options Window Help
' ZB'
'EiB',
" GB'
'EB'
'YB']
{1000: ['KB', 'MB',
1024: ['KiB', 'MiB',
SUFFIXES
TB
'TiB',
ΤPIB',
'ZiB', 'YiB']}
def approximate_size (size, a_kilobyte_is_1024_bytes=True):
'''Convert a file size to human-readable form.
Keyword arguements:
size
file size in bytes
- -
if True (default), use multiples of 1024
if False, use multiples of 1000
a_kilobyte_is_1024_bytes
Returns: string
SyntaxError
if size < 0:
X invalid syntax
raise ValueError('number must be non-negative')
1024 if a kilobyte is 1024 bytes else 1000
multiple
for suffix in SUFFIXES[multiple]:
size /= multiple
if size < multiple:
return '{0:.1f}{1}'.format(size, suffix)
OK
raise ValueError('number t0o large')
if name
main ':
print (approximate_size (1000000000000, False))
print (approximate_size (1000000000000))
Transcribed Image Text:Your First Python Program.py - C:/Users/AdamR/OneDrive/Documents/Programming/Pytho... File Edit Format Run Options Window Help ' ZB' 'EiB', " GB' 'EB' 'YB'] {1000: ['KB', 'MB', 1024: ['KiB', 'MiB', SUFFIXES TB 'TiB', ΤPIB', 'ZiB', 'YiB']} def approximate_size (size, a_kilobyte_is_1024_bytes=True): '''Convert a file size to human-readable form. Keyword arguements: size file size in bytes - - if True (default), use multiples of 1024 if False, use multiples of 1000 a_kilobyte_is_1024_bytes Returns: string SyntaxError if size < 0: X invalid syntax raise ValueError('number must be non-negative') 1024 if a kilobyte is 1024 bytes else 1000 multiple for suffix in SUFFIXES[multiple]: size /= multiple if size < multiple: return '{0:.1f}{1}'.format(size, suffix) OK raise ValueError('number t0o large') if name main ': print (approximate_size (1000000000000, False)) print (approximate_size (1000000000000))
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education