Docsity

Intro To Programming With Python Questions and Complete Solutions Graded A+, Exams of Computer Science

Toggle sidebar
bg1
Intro To Programming With Python
Questions and Complete Solutions
Graded A+
What do we mean by "programmers are inventors"? - Answer: Programmers create programs that solve
problems, sometimes from scratch, sometimes from existing code. Their creations help power every
industry in the world.
What do we mean by "programmers are fluent"? - Answer: There are thousands of programming
languages, each with a different set of rules and meant for a different purpose. A programmer may
specialize in one language, but it's likely that he or she is fluent in a few.
What do we mean by "programmers are visionaries"? - Answer: They just don't write one program and
move on. A programmer's vision for a program includes bringing it to life and finding ways to expand
and evolve it to new, better programs.
What do we mean by "programmers are gatekeepers"? - Answer: Writing and owning a program
involves testing, debugging, and resolving any issues to make sure the program is working for the user.
What do we mean by "programmers are researchers"? - Answer: Code libraries, programming threads,
and collections of best practices are resources that programmers constantly seek out to improve their
skills and share ideas.
Computer programmers write code that translates commands to.... - Answer: binary code so computers
can understand them.
What is the connection between programming and healthcare? - Answer: Patient portals, robotic
surgery, even 3-D printed prosthetics would not have been possible without programmers.
What is the connection between programming and education? - Answer: The education industry
depends on software to help students stay at the front of today's technology.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Intro To Programming With Python Questions and Complete Solutions Graded A+ and more Exams Computer Science in PDF only on Docsity!

Intro To Programming With Python

Questions and Complete Solutions

Graded A+

What do we mean by "programmers are inventors"? - Answer: Programmers create programs that solve problems, sometimes from scratch, sometimes from existing code. Their creations help power every industry in the world. What do we mean by "programmers are fluent"? - Answer: There are thousands of programming languages, each with a different set of rules and meant for a different purpose. A programmer may specialize in one language, but it's likely that he or she is fluent in a few. What do we mean by "programmers are visionaries"? - Answer: They just don't write one program and move on. A programmer's vision for a program includes bringing it to life and finding ways to expand and evolve it to new, better programs. What do we mean by "programmers are gatekeepers"? - Answer: Writing and owning a program involves testing, debugging, and resolving any issues to make sure the program is working for the user. What do we mean by "programmers are researchers"? - Answer: Code libraries, programming threads, and collections of best practices are resources that programmers constantly seek out to improve their skills and share ideas. Computer programmers write code that translates commands to.... - Answer: binary code so computers can understand them. What is the connection between programming and healthcare? - Answer: Patient portals, robotic surgery, even 3-D printed prosthetics would not have been possible without programmers. What is the connection between programming and education? - Answer: The education industry depends on software to help students stay at the front of today's technology.

What is the connection between programming and military? - Answer: They rely on programmers to develop drones, maintain operational security and develop cutting-edge technology. What is the connection between programming and tech? - Answer: The tech world is made up of programmers who make tomorrow's technology possible! They build social media sites, talking smart cars, etc. What is the connection between programming and entertainment? - Answer: Films, video games, concerts, and more all use programmers to create the effects we enjoy. What is the connection between programming and agriculture? - Answer: Software created by programmers helps us track and plan growth so we can have the healthy food we need. Which statement uses a Boolean condition to test: "If kids are under 10, they eat for free"?

  1. if( kid < 10 ):
  2. if( kid > 10 ):
  3. if( kid == 10 ):
  4. if( kid != 10 ): - Answer: 1) if( kid < 10 ): What is the connection between programming and adaptive tech? - Answer: People with disabilities rely on programmers to create software like screen magnifiers, touch screen displays, and speech recognition software are some examples to help with daily activities. Who is credited to be the first computer programmer? - Answer: Ada Lovelace, dubbed the "Enchantress of Numbers" by Charles Babbage, the inventor of the computer. What does programming look like today? - Answer: Programmers today work in every industry imaginable. There are thousands of different programming languages today, all developed to meet different needs. Mobile devices and constant need to access information, means a higher demand for smarter and more complex programs. What was an important advance in 1981? - Answer: MS-DOS was released, allowing people around the world to use the early operating system for their personal computers.

Con of high-level programming languages? - Answer: When run, programs tend to be slower than ones written with low-level languages. Con of low-level programming languages? - Answer: Written in machine code, which is challenging for humans to understand. Limit of high-level programming language? - Answer: Must be translated into machine code (this is done by interpreting and compiling). Limit of low-level programming language? - Answer: Programs are written for specific computers and will only work on that one type of computer. What can interpreters and compilers both do? - Answer: They can translate a high-level language for a computer to understand. Interpreters and compilers have similar... - Answer: functions but are still a little different. Interpreter - Answer: Translates one line of code and then executes it before moving to the next line. Compiler - Answer: Translates all lines of code together and then executes them at once. What is the IDLE? - Answer: An integrated development environment for Python. When was Python created? - Answer: 1991 Which programming language is a popular one to learn first? - Answer: Python. What is a string? - Answer: A sequence of letters, numbers, spaces, and symbols or alphanumeric information. It can be a single letter, a word, or even a phrase. It is not meant to perform math operations.

Examples of strings? - Answer: Hello, world!.......800-374-1430.........Please enter your first name:.........Your address How much memory space does a string take up? - Answer: It depends on the length of the string. The longer the string, the more memory it takes up. How much memory space does a floating point take up? - Answer: Because floats have decimals, they're more precise. That means they end up taking up a lot of memory. How much memory space does a integer take up? - Answer: As relatively simple numbers, integers don't take up that much room. What kind of data type is a phone number? - Answer: String because you don't use the value to perform math. Examples of integers? - Answer: Total books in the Harry Potter series......6.......Steps I walked today.......Points our basketball team scored Examples of floating point numbers? - Answer: Result on a stopwatch.....The cost of an ice cream cone......8.342.......Number of liters in a gallon What can you do to fix Python assuming all values you enter using the input() function are strings? - Answer: Use the int() or float() functions in your code to indicate your number type. What does "print" mean in programming? - Answer: To display something on the screen. How do you make Python print your strings exactly as written? - Answer: Put them in quotation marks. What do programmers refer to their errors as and why? - Answer: Bugs because the process of removing the bug is called debugging.

Why should you check spacing if you are stuck in finding errors in your code? - Answer: Python expects blocks of code to be spaced properly. Look out for indentations. What is the PMR(Post Mortem Review)? - Answer: A short, written statement that evaluates how the project went, reflecting on what went well and how the program could be improved. What does the Post Mortem Review allow programmers to do? - Answer: Programmers are able to share lessons learned, reflect, and complete future projects efficiently. Turtle Graphics - Answer: A set of functions in Python that allow the programmer to draw on the screen or create images. What are programmers able to do using built-in functions from modules? - Answer: They are able to import pre-written code and make use of it when writing their own programs. This leads to fast and efficient work. Positive and negative values can be used when commanding the turtle. - Answer: True. What does Python's Turtle Graphics Module give you control of? - Answer: An imaginary "turtle" who will follow your instructions, drawing lines as he moves around the screen. In order to make an object draw a line on the screen, __________ such as forward(), left(), right(), and backward() are used. - Answer: functions What do left and right functions do to the turtle? - Answer: It tells it how many degrees to turn. What do forward and backward functions do to the turtle? - Answer: It tells it how many pixels to move. Software Development Life Cycle - Answer: The fully planned out life of a project, from early ideas and planning, to execution and delivery, through steps.

Planning & Analysis - Answer: This first step is where you define your project goal, create a requirements document, and analyze the scope of work. Design - Answer: Next, design your program by writing pseudocode and mocking up how the software will work, and what it will look like. Coding - Answer: This is where you write the actual code needed. Testing - Answer: This step includes identifying defects and debugging to make sure your software is running in tip top shape. Maintenance - Answer: This primarily involves updating and making improvements based on user feedback, as well as resolving any defects that arise. What are the two of the most common methods software development life cycles use? - Answer: Waterfall and Agile. Programming Task Details WATERFALL - Answer: Project teams work on one step at a time. Teams do not move to the next step until the previous step is completed and approved. Extensive documentation allowing teams to keep control over what version of the project they are working on and what changes are needed. Programming Task Details AGILE - Answer: Project teams do smaller portions of the entire project in small sprints. Teams can interact to handle different steps simultaneously if needed. Documentation is still required allowing teams to keep control over what version of the project they are working on and how the project has changed along the way. Benefits WATERFALL - Answer: The process is clear from beginning to end. Benefits AGILE - Answer: As an approach to rapid development, the focus is on development rather than planning, enabling teams to start work more quickly.

for n in range(9, 20, 3): - Answer: When the loop begins, the counter variable n is assigned the start value of 9. After each iteration of the loop, the value of n increments by 3, which is the change value. The loop repeats if the value of the counting variable n is less than 20, the end value. Therefore in the loop, n will have the values of 9, 12, 15, and 18. BASICALLY, 9 is the number that counting begins on, 20 IS THE NUMBER BEFORE IT STOP SO 19 IS THE LAST NUMBER, 3 IS THE NUMBER IT INCREASES BY. What is a for loop example? - Answer: for x in range(0, 1, 10): What is a while loop example? - Answer: x = 0 while(x < 10): x = x + 1 Attributes of a for loop? - Answer: Repeats for a set range of values and the loop variable is given a start value. Attributes of while loop? - Answer: Repeats while a boolean condition is true and the loop variable is assigned a value before the loop. Attributes of while loops and for loops? - Answer: They both will repeat a block of code and will stop once the condition is false. What is an example in real life that works like a while loop? - Answer: WHILE IT'S RAINING OUTSIDE...you use an umbrella. On the condition that it is raining, you will use an umbrella. Otherwise, you'll stop. What are the two main things a while loop needs to know to do? - Answer: What action to do and the conditions for doing that action. Less than or equal to and Greater than or equal to - Answer: <= and >= Equal to - Answer: ==

Not equal to - Answer: != Less than and Greater than - Answer: < and > What does Python use to determine whether the condition is true or false? - Answer: Boolean logic. When will the loop repeat its action? - Answer: As long as the condition provided is true. What happens when the condition becomes false? - Answer: The loop will end. Relational Operator - Answer: Operators used to compare two values, variables, or expressions. Boolean - Answer: A condition that evaluates whether something is true or false. The code in the body of the loop does not get indented. True or False? - Answer: False. When writing a while loop the statement should begin with the keyword "while". True or False? - Answer: True. Where does the test condition go? - Answer: Inside the parentheses. When are while loops best used? - Answer: best used when you don't know the exact number of repetitions needed When are for loops best used? - Answer: When you know the exact number of repetitions needed. Relational operators compare values and determine whether a condition of an if statement is true or false. - Answer: True.

How does memory play a role with int and float? - Answer: You may be working with a program that tends to take up a lot of storage space on your computer. Floating point numbers take more space than integers. Example: If you can use 1 instead of 1.0, you can save yourself some memory. How does precision play a role with int and float? - Answer: You may need to have a specific number that requires decimals. Floating point numbers allow for more precision than integers. How does arithmetic play a role with int and float? - Answer: You may need to have the correct math. The results of integer math and floating point math aren't always the same. Example: 11/5=? Python will tell you the answer to this question is 2. If you change the numbers to decimals, you'll get a different answer: 11.0/5.0 = 2.2. We have to tell Python whether the values we assign to variables are numeric or alphanumeric. - Answer: False, Python can tell on its own. The equal sign in Python is for assigning a value to a variable, not for math. - Answer: True. Python doesn't follow order of operations. - Answer: False. Arithmetic performed with floating point numbers will have a result with at least one decimal place, even if it's just .0. - Answer: True. When you mix integer and float values in your arithmetic, what will the result be? - Answer: It will be a floating point number for a precise answer. What can parentheses do for your code? - Answer: They help you control the order for the final computation. Python won't let you concatenate string literals and numeric variables. - Answer: True. How can we concatenate a string literal and a numeric value? - Answer: Using the str() function.

Why would a programmer use the logical operator "and" in an if statement?

  1. When an action is to be taken that requires both conditions to be false
  2. When an action is to be taken that requires both conditions to be true
  3. When an action is to be taken that requires the first condition to be false
  4. When an action is to be taken that requires the second condition to be true - Answer: 2) When an action is to be taken that requires both conditions to be true. Scout sold fewer than 20 boxes of cookies. Scout missed more than one meeting. Which of the following statements tests if one of the conditions has been met?
  5. if(boxes < 20 and meetingsMissed > 1):
  6. if(boxes < 20 and meetingsMissed >= 1):
  7. if(boxes < 20 or meetingsMissed >= 1):
  8. if(boxes < 20 or meetingsMissed > 1): - Answer: 4) if(boxes < 20 or meetingsMissed > 1): The binary number system uses two digits. - Answer: True. What is the connection between programming and construction? - Answer: Programmers write code to mock up buildings, map out land, and more. Which of the following is an example of a binary number?
  9. 15
  10. 01111
  11. F
  12. Fifteen - Answer: 2) 01111 In Python, what is the purpose of using bin() and hex() functions? - Answer: To convert decimal numbers to other number systems.

How do procedural and object-oriented programming approaches differ? - Answer: Procedural programming breaks down the functions needed for a program step-by-step, while object-oriented programming creates classes with attributes and features. What is one benefit of using object-oriented programming? - Answer: Reusable code. Decimal numbers are based on 10 digits from __________. - Answer: 0- In Python, output starting with 0x indicates a hexadecimal number. - Answer: True. Which of the following represents the numeric value nine as a decimal number?

  1. 9
  2. 01001
  3. N
  4. Nine - Answer: 1) 9 Which of the following is considered information?
  5. A single keystroke
  6. All the characters on a keyboard
  7. An individual test score
  8. Average of a series of test scores - Answer: 4) Average of a series of test scores Each character on the keyboard corresponds to a specific ASCII value. - Answer: True. Unicode has over one million characters and more are being added. - Answer: True. What is one reason a programmer may choose procedural programming over object-oriented programming? - Answer: top-down design Object-oriented programming uses objects to carry out different __________.
  1. actions
  2. attributes
  3. classes
  4. systems - Answer: 1) actions Jamal currently has a class named ReactionButton. In his program, he created two instances named smile and frown. He wants to add one more instance named surprise to the program. Which statement should he use?
  5. class Surprise: ReactionButton
  6. def init(Surprise = ReactionButton)
  7. self.surprise = "ReactionButton"
  8. surprise = ReactionButton() - Answer: 4) surprise = ReactionButton() In programming, it is best practice to use a pronoun for class names. - Answer: False. In Python, the first step of creating a class is to define and name it. - Answer: True. Kim needs to initialize a new object with the attributes player and score. Which of the following correctly sets the initial values?
  9. def init(self; player = ""; score = 0):
  10. def init(self + player = "" + score = 0):
  11. def init(self, player = "", score = 0):
  12. def init(self = player = "" + score = 0): - Answer: 3) def init(self, player = "", score = 0): Geneva has defined her class (class PackingList:). She wants to initialize the attributes clothes and shoes. Which of the following properly initializes the shoes attribute?
  13. self.shoes = ""
  14. self = shoes ""
  15. self + shoes = ""
  16. selfShoes = "" - Answer: 1) self.shoes = ""
  1. Lightning
  2. Mirror backup
  3. Terrorist - Answer: 4) Terrorist What is a way to protect against a security threat to a computer system?
  4. Avoid external links with inconsistent URLs
  5. Create a disaster recovery plan
  6. Open online pop-up notifications
  7. Post personal information online - Answer: 1) Avoid external links with inconsistent URLs In order to avoid phishing scams, delete suspicious ______.
  8. contacts
  9. emails
  10. program codes
  11. text messages - Answer: 2) emails A disaster recovery plan outlines the procedures to recover and protect an organization's data in the event of a catastrophe. - Answer: True. Which backup type should be used to back up all data since the last full backup?
  12. Differential
  13. Full
  14. Incremental
  15. Mirror - Answer: 1) Differential How many characters does ASCII have? - Answer: 256. What is a collection of quantities or characters computers use to perform operations? - Answer: Data.

Once programmers write a useful class for one programming project, they can often reuse that class in another program instead of starting from scratch. How would you classify the characteristic?

  1. An aspect of procedural programming
  2. A benefit of object-oriented programming
  3. A disadvantage of object-oriented programming
  4. A goal of procedural programming - Answer: 2) A benefit of object-oriented programming The programmer starts with a high-level description of what the program will do, and then breaks it down into the functions needed to complete the actions. How would you classify it?
  5. An aspect of procedural programming
  6. A disadvantage of object-oriented programming
  7. An outcome of object-oriented programming
  8. A result of procedural programming - Answer: 1) An aspect of procedural programming What are objects defined by? - Answer: Their attributes and behaviors. Tanya is writing a program to design t-shirts. Which of the following properly defines the t-shirt class?
  9. classTShirt
  10. class + TShirt
  11. class = (TShirt):
  12. class TShirt: - Answer: 4) class TShirt: Corrine is writing a program to design t-shirts. Which of the following correctly sets an attribute for fabric?
  13. self+fabric = fabric
  14. self(fabric):
  15. self = fabric()
  16. self.fabric = fabric - Answer: 4) self.fabric = fabric