Python Fundamentals · Getting started
20 cards
What Is Python?
-
Quick check
A team must rename and rearrange thousands of photo files by a complicated rule, and wants to repeat the work next month. Which description fits the job Python is meant for?
AA graphics toolkit that edits each image by hand
Editing each image by hand is exactly the manual work the example replaces.
BAutomating a repeated file task in a programming language
Right. Renaming and rearranging many photo files in a complicated way is one of the documented tasks Python takes on.
CA compile-and-link build step that runs before any file is touched
Interpreted execution means no separate compilation and linking stage stands between writing the rule and running it.
3 / 20
-
Quick check
A short shell script has grown into a program with several parts that other people now edit. What does moving it to Python offer?
AMore structure and support for large programs
Right. Python is a real programming language and offers far more structure and support for large programs than shell scripts or batch files.
BFewer built-in data types, so the program must stay small
Python adds high-level built-in types such as flexible arrays and dictionaries rather than removing them.
CA guarantee that the program only moves files and changes text
Moving files and changing text is where shell scripts are strongest; Python covers a much wider problem domain.
6 / 20
-
Quick check
A developer wants to test single functions as they are written, without waiting for a build after each edit. Which capability answers both needs?
ACompile and link before each test
Python needs no separate compilation and linking step, so this is the cycle being avoided rather than the answer.
BWait until the whole application is finished
Interactive use exists precisely so features and functions can be tried before a full program exists.
CUse the interpreter interactively during development
Right. The interpreter can be used interactively to experiment with language features, write throw-away programs, and test functions during development.
9 / 20
-
Keep your progress in the app
That’s 3 of 7 quick checks. In the app they stay answered, and every lesson remembers where you left off.
-
Quick check
Why is a Python program typically shorter than the equivalent C or Java program?
AEvery variable and argument carries an explicit declaration
No variable or argument declarations are necessary, which is one of the reasons Python programs are shorter.
BHigh-level data types express complex operations in a single statement
Right. High-level built-in types let one statement carry work that would take several elsewhere.
CStatements are grouped with beginning and ending brackets
Python groups statements by indentation rather than by beginning and ending brackets.
11 / 20
-
Quick check
A small tool must run on a colleague's Windows laptop, your macOS machine and a Linux server. What does Python's availability mean for that plan?
AThe tool must be rewritten as a shell script for each of the three systems
Rewriting per platform is what a platform-specific shell script would force; Python does not.
BOnly the Unix machines can run it, so the laptop needs a different tool
Python is available on Windows and macOS as well as Unix systems.
CThe same language covers all three families
Right. Python is available on Windows, macOS and Unix operating systems, so one language serves the whole set.
14 / 20
-
Quick check
A C application needs a programmable command language, and one speed-critical operation should stay in C. Which design matches Python's extensibility?
AEmbed the interpreter and add the C operation as a new built-in module
Right. The interpreter can be linked into a C application as an extension or command language, and a new built-in function or module can carry the critical operation.
BReplace the C operation with a batch file and drop the programmable interface
A batch file provides neither the embedded programmable interface nor a home for the C operation.
CRewrite the host application in a shell language
Shell scripts are best at moving files and changing text; rewriting the host in one abandons both requirements.
17 / 20
-
Quick check
A team needs a portable first draft of a small graphical application, and more program structure than a batch file can give. Which summary of Python fits both constraints?
AA platform-specific command language for moving files
That describes a shell script's strength, and it fails both the graphical draft and the structure the team asked for.
BA full high-level language, available on the major desktop systems
Right. Python is a real programming language with far more structure than a batch file, and it is available on Windows, macOS and Unix.
CA build tool that produces a compiled application for one operating system
Python runs through its interpreter with no separate compile-and-link step, and it is not tied to a single operating system.
20 / 20
-
7 quick checks · then the test
In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.
The whole course, on your phone
Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.