chapter 4 Flashcards

(51 cards)

1
Q

how do you access the help mode on IDLE?

A

type help() and hit enter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the purpose of color coding?

A

color coding lets you see commands with greater ease and differentiate commands from other sorts of text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how do you exit out of the help mode?

A

press enter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is one of the many reasons why IDLE is easier to use than the command line

A

because the color coding in IDLE makes things a lot easier to read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what 7 functionalities does IDLE provide you with?

A
  1. write python code
  2. Recognize and highlight keywords and certain types of special text.
  3. perform both simple editing (such as cut copy paste) and code specific editing (such as showing the parentheses that surround an expression).
  4. save and open python files.
  5. browse the python path to make locating files easy.
  6. browse and locate python classes
  7. perform simple debugging tasks (removing errors from the code)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what 3 entries does the help menu give you for obtaining help? give a brief description for each.

A
  1. About IDLE: provide you with the latest information about IDLE.
  2. IDLE help: shows you a text file containing information about working with IDLE IDE. For example , this is where you find a list of the IDLE commands.
  3. Python Docs: Contains information required to work with Python commands and other elements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how can you perform the task of editing text better?

A

by clicking options > Configure IDLE to see the IDLE preferences. this is where you can choose things like what font IDLE uses when displaying text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do you choose the size and style font used in text along with the number of spaces used for indentation?

A

Options > Configure IDLE > Font/Tabs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how do you change color themes for the color coding in Python?

A

click options > configure IDLE > Highlights tab. then click “choose color for” then name your “custom theme name” and then click ok. a custom theme is created that you can tweak to your preference colors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what are the 5 main reasons to change the color theme of your color coding in Python?

A

1️⃣ Reduce Eye Strain / Lighting Conditions

2️⃣ Increase Readability

3️⃣ Spot Errors Quickly

4️⃣ Improve Focus

5️⃣ **Personal Preference /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how do you change the shortcut keys in Python?

A

click options > configure IDLE > click the keys tab > click “save as new custom key set” > then name your new key set > and under key bindings choose a default action key to change into a new key or set of keys by then clicking “get new keys for selection > choose a key or a combination of keys to set for the new action key. but some new keys may not be placed due to it conflicting with other keys that are already in use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

if keys are already in use when mapping out a new action key, what is the best option to avoid this error when mapping out the custom key set?

A

in the “get new keys” dialog box click on advanced key binding entry button > in this new dialog box you can overide and assign any key or set of keys to an action key regardless of it already in use so you would have to map out the entire custom key set and making sure you do not copy any of the new action keys to other action keys similar to mapping buttons on a video game emulator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is a shell window and an edit window good for?

A

shell is for experimentation and the edit window is for creating an application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how does the shell window contrast the edit window?

A

the shell window is interactive, which means that it gives you immediate feedback for any commands you type.
while, the edit window provides a static environment, where you type commands, save them, and then run them after you type enough commands to create an application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how do you open an edit window and how can you tell the difference between a shell window and an edit window?

A

choose file > New file to create a new edit window. the way to tell the difference between a shell window or an edit window is that an edit window contains the word “untitled” in the title bar and the edit window contains the run command. while shell window contains the word “shell” in the title bar and the shell window contains 3 right arrows»> at the starting point of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is the difference when you press enter when writing code in the shell window or edit window?

A

shell immediately executes a command while the edit window moves to the next line rather than execute a command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

in what window do you save the commands you typed and why?

A

only in the edit window can you save work for later use but the shell window is for immediate execution of commands for experimentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does a name.py followed by a path to a directory in the title bar of the edit window signify

A

It means that that current open program is the name of the program and it’s file directly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what does the restart message in python shell mean?

A

it means that everything after that message is the output for running your program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what does it mean in shell when you have two restart messages?

A

it means that you ran code twice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

how does python interpret indentation?

A

python ignores identation

22
Q

what is the purpose for indentation?

A

to provide visual cues about your code. indentation in code shows the relationships between various code elements

23
Q

what is concatenation?

A

adding text from multiple lines together into a single piece of text is called concatenation

24
Q

what happens to the indentation when you extend a line with a plus sign after you hit enter?

A

the edit window automatically indents some type of text to it’s original position

25
how do you make multiple lines of text appear on a single line of output?
Use concatenation
26
what message is displayed in shell everytime you run an application?
the Restart message
27
what is a form of a note used to jog human's memories in source code?
comments
28
what 2 methods of defining text as a comment and not a code to execute?
the first method is the single line comment which uses a # at the start of text
29
when do you typically use a single line comment?
when you need a short descriptive text such as an explanation of a particular bit of code
30
what type of comment is used to create a longer comment ?
a multiline comment which consists of 3 " " " double quotes at the start and ending of a multiple line comment
31
what is the a mutli line comment usually created for?
common use of multiline comments are usually for longer explanations of who created an application, why it was created, and what tasks it performs.
32
what does the IDLE editor use for you to easily identify a single comment or a multiline comment?
the IDLE editor uses coloration as an easy way to spot a single comment or a multiline comment
33
what color is a single line comment in the IDLE editor?
red text
34
what color is a multiline comment in the IDLE editor?
green text
35
what are the 6 common reasons to use comments in your code?
1 reminding yourself about what the code does and why you wrote it 2 telling others how to maintain your code 3 making your code accessible to other developers 4 listing ideas for future updates 5 providing a list of documentation sources you used to write the code 6 maintaining a list of improvemtns you've made
36
when do you need more comments than usual?
whenever the code gets more complex youll need a bigger explanation to explain the code to others so you will need a multiline comment
37
1️⃣ FRONT: What does Python do with any line that starts with #? .
BACK: Ignores it completely. It’s a single-line comment for humans.
38
2️⃣ FRONT: What happens when Python sees a triple-quoted string (""" ... """) that is not assigned to a variable?
BACK: Python creates the string but immediately throws it away; it has no effect.
39
3️⃣ FRONT: Why do programmers use triple-quoted strings even though they’re not real comments?
BACK: To write big explanations or disable blocks of code because Python ignores unassigned strings.
40
4️⃣ FRONT: When does a triple-quoted string actually do something?
BACK: When it is assigned to a variable or used as a docstring inside a module, class, or function.
41
5️⃣ FRONT: In the line print("Hello") # comment, which part executes?
BACK: Only print("Hello") executes. Everything after # is ignored.
42
6️⃣ FRONT: What is the purpose of #!/usr/bin/env python at the top of a file?
BACK: It tells the operating system which Python interpreter to use (ignored by Python itself).
43
7️⃣ FRONT: What is the purpose of the line # coding: utf-8?
BACK: Declares the text encoding for the file; Python treats it as a comment.
44
8️⃣ FRONT: What is the difference between: """ text """ and myString = """ text """?
BACK: Unassigned = ignored; assigned = stored as a real multiline string variable.
45
9️⃣ FRONT: Why does this not run? ''' print("Hello") '''
BACK: It’s just a string literal, not code, and not assigned—Python ignores it.
46
what are two ways to comment out a region of code?
either set the starting and ending point with a set of three double quotes or select the region you want commented out then choose format> comment out region
47
why are two ## used when commenting out a region using the Format> Comment out Region option?
this way will let you know where you commented out a region incase you want to undo the region you commented out
48
how do you undo commenting out a region in your code?
highlight the part that you commented and go to Format> Uncomment out Region
49
how do you open a py file from your drive from the command prompt?
first type "cd" for change directory followed by the directory address to the folder of where the file is second, hit enter then type "python" followed by the name of the py file example step1 cd "D:\MAIN FOLDER\Python projects 8-7-25\bp4d" step2 python BPP4D3E_04_Comments.py
50
what are the two ways to close a phython window?
1 file menu> close 2 file menu> exit
51
what are the differences between file> close and file> exit?
file> close closes the current window your in file> exit closes all windows associated to the current window