PLTW Comp Sci P: Unit 1 Chapter 1.1-1-4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Conditional Expression

A comparison, usually in a while or if statement, that evaluates to a Boolean value of True or False

Zero-iteration Condition (1.1.4)

A loop that never begins because the condition evaluates to true initially

Arthimetic operators

Mathematical processes that are part of most programming languages. They include addition, subtraction, multiplication, division, and modulus operators.

Which of the following will assign the variable x a string data type? (Select all that apply)

x = "1000" x = input("What is your name?) x = input("What is your lucky number?")

Which of the following will assign the variable x an integer data type? (Select all that apply)

x = 50 x = int("100")

Explain the syntax a while loop code: while (condition): *indent*body of while loop

"while" - The while keyword "(condition)" - An expression that evaluates to true or false ":" - While loop headers end with a colon "while (condition)" - Header of the loop "*indent*" - Note the white space "body of while loop" - This is the code, possibly multiple lines, that will repeat

You should have a better understanding of objects like your turtle object. Select all of the statements that are TRUE.

-A class design is like a blueprint or a recipe. -A class design is used to create an instance of a class, called an object. -In the my_turtle.circle(5) statement, my_turtle is an object. -In the my_turtle.circle(5) statement, circle is a method.

Try to recall what you learned about object-oriented programming using a language like Python. Select all of the statements that are TRUE.

-Object-oriented programming focuses on the data represented in the problem. -Properties are the characteristics of your objects. -Methods are the actions that your objects can take. -Object-oriented programs remove details from many programs, making code rewrite less frequent.

The circle method draws a circle with a radius of r. What are the three parameters that are used in the circle method?

-The first parameter, r, specifies the radius of the circle and is required. -The second parameter, e, specifies the extent or angle of the arc to be drawn on the screen. For example, an extent of 180 draws a semicircle. If not specified, the entire circle is drawn. -The third parameter, s, specifies the number of segments or steps in which to draw the circle or arc. Steps can make the circle look like a polygon—for example, five segments or steps would draw a pentagon.

Explain the parameters of each shape:

1) Hexagon is formed from "t.circle(100, 360, 6)" 2) 3/4 of a circle is formed from "t.circle(100, 270)" 3) A right angle is formed from "t.circle(100, 180, 2)" 4) An obtuse angle is formed from "t.circle(100, 90, 2)"

Distinguish the equality to each operator: 1. == 2. != 3. > 4. < 5. >= 6. <=

1. Equal to 2. Not equal to 3. Greater than 4. Less than 5. Greater than or equal to 6. Less than or equal to

Decidable Problem

A decision problem for which an algorithm can be written to produce correct output for all inputs (e.g., "Is the number even?").

Undecidable Problem

A decision problem for which no algorithm can be constructed that is always capable of providing a correct yes-or-no answer.

Algorithm

A finite set of instructions that accomplish a specific task. An algorithm can be expressed in many kinds of notation, such as natural language, pseudocode, and flowcharts. Algorithms are essential to the way computers process data because they contain the specific instructions for what a computer or program does.

Infinite Loop (1.1.4)

A loop that never ends because the ending condition will never evaluate to true

Code statement

A part of a program code that expresses an action to be carried out.

Iteration

A repeating portion of an algorithm. Iteration repeats a specified number of times or until a given condition is met. Also used to refer to a single execution of that repetitive procedure.

Boolean Expression

An expression that evaluates to either true or false; used in the conditional of an if structure.

Output

Data or actions produced by an algorithm. Including any data sent from a program to a device. Program output can come in a variety of forms, such as tactile, audio, visual, or text.

Program Input

Data sent to a computer for processing by a program. Input can come in a variety of forms, such as tactile, audio, visual, or text.

Input

Data that is given to an algorithm during the execution of a program and can affect the results of the algorithm.

What is the output resulting from this code? x = "My favorite color is" y = "blue" print(x, y)

My favorite color is blue

Nested loops take the form: Outer loop Inner Loop

Pseudocode of a nested loop (example): while j < some number: increment j while i < some number: increment i do something

Runtime

The duration of time a program is executing, from start to finish.

Natural Language

The first method is natural language, which is an ordered list of steps expressed in natural language, such as English, Spanish, Portuguese, Mandarin, or any other spoken language.

Programming Language

The fourth method is a programming language such as Python, Java, C++, JavaScript, etc. A programming language is a structured set of instructions with special keywords and formatting, that can be interpreted and executed by a computer or digital device. In this course, you will primarily learn to program using the Python programming language. Clarity and readability are important considerations when expressing an algorithm in a programming language.

Modulo Operator (%)

The modulo operator evaluates to the remainder of the division of two integer operands. Examples: 24 % 10 is 4. Reason: 24 / 10 is 2 with remainder 4. 50 % 50 is 0. Reason: 50 / 50 is 1 with remainder 0. 1 % 2 is 1. Reason: 1 / 2 is 0 with remainder 1.

Algorithmic Thinking

The process of solving problems by identifying the tasks required to solve a problem and using algorithms to clearly describe each task. Algorithmic thinking is an acquired skill that takes practice and repetition and is used in many disciplines.

Flowcharts

The second method is a flowchart, which is a diagram that shows a sequence of steps using standardized shapes such as rectangles to represent actions, rhombuses to represent decisions, and arrows to show the flow of the algorithm.

Pseudocode

The third method is pseudocode, which is a written set of instructions that follow a certain structure. It looks more like code, but cannot be executed by a computer. You will learn more about pseudocode later in this unit.


संबंधित स्टडी सेट्स

Exam #3 (CH 62 - Mgmnt of Pts With Burn Injury)

View Set

Foundations of Nursing (228) Final

View Set

acct exam 2-inventory, tangible assets & depreciation, intangible assets and impairment, investments, debt, deferred taxes, equity&sharebased compensation, EPS

View Set

Chapter 11: Commercial Banks: Industry Overview

View Set

Real Estate National PSI practice exam 2

View Set