INF1339ComputationalThinking-Week3-Slides-Part1

pdf

School

University of Toronto *

*We aren’t endorsed by this school

Course

1339

Subject

Computer Science

Date

Oct 30, 2023

Type

pdf

Pages

86

Report

Uploaded by hsoidsf

INF1339 Introduction to Computational Thinking WEEK 3 SEPTEMBER 25 AND 27, 2023 – PART 1 (LECTURE)
For thousands of years the University of Toronto has been the traditional land of the Huron- Wendat, the Seneca, and the Mississaugas of the Credit. Today, this meeting place is still the home to many Indigenous people from across Turtle Island and we are grateful to have the opportunity to work on this land. For more information, see the Final Report of the Steering Committee for the University of Toronto Response to the Truth and Reconciliation Commission of Canada and the Faculty of Information’s Commitment to the Findings and Call for Action of the Truth and Reconciliation Commission .
Agenda Introduction What people found most important / most challenging General questions Textbook objectives Solving Problems Problem Definition Logical Reasoning Decomposition Abstraction Algorithms Name Binding Selection Repetition Modularization
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Agenda Introduction What people found most important / most challenging General questions Textbook objectives Solving Problems Problem Definition Logical Reasoning Decomposition Abstraction Algorithms Name Binding Selection Repetition Modularization
Important Learning from Week 2
Most Challenging from Week 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Go over Solution for Week 2 Logic Circuit Working in pairs or individually, using https://logic.ly/demo/ or paper / pen, create a logic circuit for the following: Scenario : You've been recruited by an intergalactic alliance to help design a security system for a spaceship. The spaceship has aliens from three different planets: Xanadu, Yarnia, and Zeltron. There are three input sensors for access to the spaceship's control room: A, B, and C. 1. A - detects if the alien is from Xanadu. 2. B - detects if the alien is from Yarnia. 3. C - detects if the alien is wearing a special Alliance Ring. The spaceship's control room should grant access (output 1 or "ON") under any of the following conditions: 1. The alien is from Xanadu (A) and is wearing the Alliance Ring (C). 2. The alien is from Yarnia (B) but doesn't need to wear the Alliance Ring (so, B alone is enough). 3. The alien is from Zeltron but MUST wear the Alliance Ring (C alone). However, access should be denied (output 0 or "OFF") if: 1. The alien is from Xanadu (A) without the Alliance Ring. 2. The alien is from Zeltron without the Alliance Ring (so, no input is detected). 7
Solution 1. For aliens from Xanadu with the Alliance Ring: A AND C 2. For aliens from Yarnia: B 3. For aliens from Zeltron with the Alliance Ring: C AND NOT A AND NOT B (This ensures that neither A nor B are active when C is.) Combining the conditions: (A AND C) OR B OR (C AND NOT A AND NOT B) 8
Any Questions about the Course?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Objectives (from Riley & Hunt Ch 4) To examine problem definition as the beginning of all good problem solving To explore functional requirements as the core of algorithmic problem definitions To examine several ways that logical reasoning is applied to software development, including cause-effect relationships, deductive reasoning, and inductive reasoning To understand that programming is an activity that often relies upon knowledge of patterns and that the five basic patterns of control flow are sequences, selection, repetition, control abstraction, and concurrency To understand the central role algorithms play in computational problem solving and explore many forms of algorithms To examine divide and conquer as a key problem-solving strategy, useful in outlining and top-down design To explore prototyping as a form of decomposition that is well suited to solving many of today’s problems To consider the impact of alternative approaches to data decomposition, such as linear searching as opposed to binary searching To explore many forms of abstraction that are significant to computer science, including control abstraction, class diagrams for data abstraction, and use-case diagrams for definition abstraction
Objectives (from Riley & Hunt Ch 5) To understand the concept of software and program execution To understand that algorithms involve choices and choices take the form of selections involving logical conditions To understand that algorithms often involve the repetition of statements To understand how algorithms are modularized To understand the form and function of flowchart elements for imperative statements including naming, selection, and repetition To understand the concepts of computational state, events, and actions To model sequential algorithms of ten or fewer states
Agenda Introduction What people found most important / most challenging General questions Textbook objectives Solving Problems Problem Definition Logical Reasoning Decomposition Abstraction Algorithms Name Binding Selection Repetition Modularization
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Four Strategies for Solving Problems Computationally 1. Problem definition 2. Logical reasoning 3. Decomposition 4. Abstraction
Four Strategies for Solving Problems Computationally 1. Problem definition 2. Logical reasoning 3. Decomposition 4. Abstraction
1. Problem Definition Successful design and implementation is only possible given adequate analysis Problem definition is when “centre of the table” capabilities are critical because the customer, information systems designer, developer, possibly other stakeholders are involved A properly engineered software problem definition consists primarily of a list of requirements
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Requirements Functional requirements Specify the particular task(s) the software must perform Nonfunctional requirements Define other characteristics and constraints such as reliability, safety, security, performance, delivery, and help facilities Requirements Engineering: “Requirements Engineering (RE) is a set of activities concerned with identifying and communicating the purpose of a software-intensive system, and the contexts in which it will be used. Hence, RE acts as the bridge between the real-world needs of users, customers, and other constituencies affected by a software system, and the capabilities and opportunities afforded by software-intensive technologies.” – Easterbrook, S. https://www.cs.toronto.edu/~sme/papers/2004/FoRE-chapter01-v7.pdf
Requirements Engineering
Requirements Functional requirements are product features that developers must implement to enable the users to achieve their goals. They define the basic system behavior under specific conditions. Functional requirements examples The system must send a confirmation email whenever an order is placed. The system must allow blog visitors to sign up for the newsletter by leaving their email. The system must allow users to verify their accounts using their phone number. Functional requirements describe what the product should do; non-functional requirements place constraints on how the product should do it Functional requirement: "The system must allow the user to submit feedback through a contact form in the app.“ Non-functional requirement: "When the submit button is pressed, the confirmation screen must load within 2 seconds." https://www.nuclino.com/articles/functional-requirements
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Requirements Should be: Clear: Easily understood in the same way by all customers, users, and developers Unambiguous and precise Possibly translatable into logic propositions (mostly for safety-critical applications) Consistent: No contradictions Complete: Every possible scenario considered and explained in one or more requirement All possible combinations of situations considered State-activity tables can help with this: a complete set of functional requirements contains requirements in every cell except those that are impossible
“State-Activity Table”
Example (Functional) Requirements Problem 1: Wordsearch Puzzle Solver Problem 2: Play Battleship Against a Human Problem 3: Maze Solver Algorithm Problem 4: Canadian Postal Code Lookup Problem 5: Word Sorting Challenge
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example (Functional) Requirements Problem 1: Wordsearch Puzzle Solver The solver should accept a grid of letters (2D matrix) as input Problem 2: Play Battleship Against a Human The game board should be represented as a grid, traditionally 10x10 cells Problem 3: Maze Solver Algorithm The algorithm should accept a representation of the maze in the form of a 2D array or matrix, where open paths and walls are distinctly represented using 1s (walls) and 0s (paths) Problem 4: Canadian Postal Code Lookup Enable users to input a valid Canadian postal code of the form "ANA NAN" (where A is a letter and N is a digit) Problem 5: Word Sorting Challenge The algorithm should accept a list of words
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Four Strategies for Solving Problems Computationally 1. Problem definition 2. Logical reasoning 3. Decomposition 4. Abstraction
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
2. Logic Reasoning Part of problem definition Consider cause and effect
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example Cause and Effect Problem 1: Wordsearch Puzzle Solver Problem 2: Play Battleship Against a Human Problem 3: Maze Solver Algorithm Problem 4: Canadian Postal Code Lookup Problem 5: Word Sorting Challenge
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example Cause and Effect Problem 1: Wordsearch Puzzle Solver Still words to be read in read in the next word Word is found in the puzzle store the starting and ending coordinates for the word Problem 2: Play Battleship Against a Human Human puts a bomb on grid point D3 and grid point D3 has a ship indicate “hit” Human puts a bomb on grid point D3 and grid point D3 has no ship indicate “miss” Problem 3: Maze Solver Algorithm Reach the goal print the path taken Move left and hit wall move [down | up | right] Problem 4: Canadian Postal Code Lookup Invalid postal code entered prompt user to enter postal code in correct format Valid postal code entered search for postal code in database Problem 5: Word Sorting Challenge Still words to read read next word List sorted print out the sorted list
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Look for Patterns Examples: Reading in and storing a list of words Prompting the user for input Printing out a list of words Drawing a grid Reading in a grid Traversing a grid Etc.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Four Strategies for Solving Problems Computationally 1. Problem definition 2. Logical reasoning 3. Decomposition 4. Abstraction
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3. Decomposition Divide and Conquer: Separate (divide) a problem into subproblems Solve (conquer) each subproblem individually Often the subproblems can also be considered as individual problems so repeat
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition: Essay Writing
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition: Course Design INF1339 Fall 2023:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 1: Wordsearch Puzzle Solver Problem 2: Play Battleship Against a Human Problem 3: Maze Solver Algorithm Problem 4: Canadian Postal Code Lookup Problem 5: Word Sorting Challenge
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 1: Wordsearch Puzzle Solver Puzzle Initialization Word Selection Word Placement
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 2: Play Battleship Against a Human Game Initialization Board Setup Gameplay Loop
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 3: Maze Solver Algorithm Maze Representation Input and Initialization Pathfinding Algorithm
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 4: Canadian Postal Code Lookup Database Setup Handling Input Query Database
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Decomposition Problem 5: Word Sorting Challenge Read Input Sorting Algorithm Comparison Mechanism
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Four Strategies for Solving Problems Computationally 1. Problem definition 2. Logical reasoning 3. Decomposition 4. Abstraction
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4. Abstraction Recognizing patterns and simplifying complex systems by hiding details Reduces details Factors out specifics Enables designers and developers to focus on a few concepts at a time Real-world objects are too complex to be completely captured / represented
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Abstraction? Where real-world objects cannot be represented or captured completely Patterns are used to simplify the complexities and hide details What are some examples of abstraction?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Abstraction: TTC Subway Map https://www.ttc.ca/routes-and-schedules
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Examples of Abstraction: Conference Proceedings
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example of Abstraction: Conference Proceedings See INF1343
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Abstraction Accomplished Using Models such as UML (Universal Modeling Language) See INF1341
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example: UML Use Case Diagram A use case is a set of events that occurs when an actor uses a system to complete a process. Normally, a use case is a relatively large process, not an individual step or transaction: 1. Define the system boundary : what is considered external or internal to the system. 2. Identify the actors : external entities (people, other systems, organizational role) that interact with the system 3. Identify Use Cases : specific functionalities or processes that the system can perform in response to a request from one of its actors; think about goals each actor wants to achieve with the system (goals use cases) 4. Define associations : between actors and the use cases they interact with (shows which actor can initiate which use case) 5. Add Relationships (if needed): Include : If a use case is a part of another use case, use the "include" relationship. Extend : If under certain conditions, an extension of the use case behavior happens, use the "extend" relationship.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Three-Tiered Architecture Model Consider each problem-solving technique (problem definition – requirements, logical reasoning; decomposition; abstraction) separately within three tiers: 1. Software for communicating with the user 2. Software for calculating results (doing things) based on user input and/or retrieved data 3. Software for retrieving and storing data See INF1342 https://www.ibm.com/blog/four-architecture-choices-for-application-development/
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Three Tier Architecture Layer Organizes applications into three logical and physical computing tiers: 1. presentation tier, or user interface 2. data tier, where the data associated with the application is stored and managed 3. application tier, where data is processed Benefit: Each tier runs on its own infrastructure Each tier can be developed simultaneously by a separate development team Each tier can be updated or scaled as needed without impacting the other tiers A bit dated – was prominent for client-server applications: Replaced by cloud-native technologies such as containers and microservices https://www.ibm.com/topics/three-tier-architecture See INF1342
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Microservice Architecture See INF1342
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Agenda Introduction What people found most important / most challenging General questions Textbook objectives Solving Problems Problem Definition Logical Reasoning Decomposition Abstraction Algorithms Name Binding Selection Repetition Modularization
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Algorithms A sequence of clearly defined steps that describe a process to follow A finite set of unambiguous instructions with clear start and end points A way of specifying a multi-step task Are especially useful when we wish to explain to a third party (be it human or machine) how to carry out steps with extreme precision A correct algorithm is the ultimate basis of any computer-based solution Beecher, K. (2017, August). Computational thinking. BCS.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Algorithms An algorithm is a sequence of discrete actions that when followed, will result in achieving some goal or solving some problem Many of life’s activities involve following a sequence of simple and discrete steps to solve some larger problem: Baking a dozen cookies Tying a knot Developing a business plan Diagnosing an illness Designing a commercial jumbo jet Other examples? Riley and Hunt
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Algorithms A well-defined sequence of actions that takes a set of values as input and produces some set of values as output A sequence of computational actions that transform the input into the desired output Example chocolate chip cookie recipe: The list of ingredients is the input to the recipe The directions constitute the algorithm (an orderly sequence of discrete actions that transform the input into the desired output) The output is the plate of chocolate chip cookies
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Algorithms Algorithms must be meaningful and precise The actions of an algorithm must have only one possible interpretation An action cannot be ambiguous or have conflicting interpretations
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Actions Computational algorithms are expressed as a well-defined sequence of actions that the computer must follow What are some examples of possible actions (“computable functions”)?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Actions Computational algorithms are expressed as a well-defined sequence of actions that the computer must follow Examples from the textbook: Name binding (defining and initializing variables) Selection (one-way, two-way, multiway) Repetition Modularization
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name Binding myDog “Fido” yourDog “Rover” myDog yourDog yourDog myDog A 1 B 10 while A < 5 do if B <= 5 then A A+1 B B-2 else A A+2 endif endwhile
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name Binding: Proper Naming
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name Binding: Proper Naming % is the modulus operator (computes the remainder) // is the “floor division” operator (divides and floors the result) https://www.w3schools.com/python/python_operators.asp
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name Binding: Proper Naming What do these identifiers represent? divideBy2 remstack decNumber rem binString
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Selection Control flow refers to the specific order that actions are executed Normally, in the order that they are written Sometimes, have to execute something different depending on certain inputs (flexibility) Selection is an example of a control flow statement: One-way selection statement: either perform an action or skip the action Two-way selection statement: choose between one of exactly two actions Multiway selection statement: choose one of several alternative actions
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
One-Way Selection Either perform an action or skip the action:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Two-Way Selection Choose between one of exactly two actions
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Multiway Selection Choose one of several alternative actions
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Multiway Selection
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Repetition A loop is a control structure that repeatedly executes a sequence of actions While-do loop: Checks logical condition and repeats sequence of actions as long as that logical condition holds Does not execute sequence of actions even once if the condition does not hold Do-while or repeat-until loop: Executes a sequence of actions at least once, and then repeats the block while a specified condition is true (or until a specified condition becomes true) For loop: Iterates over a list of items and executes a sequence of actions for each item in the list Infinite loop: Executes until end of the program occurs Recursion: Not really a loop but allows a function to call itself
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Modularization Algorithms can be modularized by breaking them into independent subprocesses (consider recipes) Modules (functions, procedures) have the following criteria: 1. Understandability—Every module is self-contained, which implies that it can be fully understood without any knowledge of actions that take place outside of the module itself. 2. Encapsulation—Every module affects only the data that it contains. Any errors that arise from a module are also contained within the module. 3. Composition—Every module can be incorporated into a larger module without special treatment.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Modularization Read in decimal numbers For each decimal number decNumber hexNumber=baseConverter(decNumber, 16) binNumber=baseConverter(decNumber, 2)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State Name bindings change as the program executes while decNumber > 0: rem = decNumber % 2 remstack.push(rem) decNumber = decNumber // 2 remstack 14 decNumber rem
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State Name bindings change as the program executes while decNumber > 0: rem = decNumber % 2 remstack.push(rem) decNumber = decNumber // 2 remstack 14 0 decNumber rem 0 7
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State Name bindings change as the program executes while decNumber > 0: rem = decNumber % 2 remstack.push(rem) decNumber = decNumber // 2 remstack 7 1 decNumber rem 0 1 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State Name bindings change as the program executes while decNumber > 0: rem = decNumber % 2 remstack.push(rem) decNumber = decNumber // 2 remstack 3 1 decNumber rem 0 1 1 1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State Name bindings change as the program executes while decNumber > 0: rem = decNumber % 2 remstack.push(rem) decNumber = decNumber // 2 remstack 1 1 decNumber rem 0 1 1 0 1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State – what values are printed? myDog “Fido” yourDog “Rover” myDog yourDog yourDog myDog print(“myDog is: ”, myDog, “ and yourDog is: ”, yourDog) A 1 B 10 while A < 5 do if B <= 5 then A A+1 B B-2 else A A+2 endif endwhile print (“A is: ”, A, “ and B is: ”, B)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
State – what values are printed? myDog “Fido” yourDog “Rover” myDog yourDog yourDog myDog print(“myDog is: ”, myDog, “ and yourDog is: ”, yourDog) A 1 B 10 while A < 5 do if B <= 5 then A A+1 B B-2 else A A+2 endif endwhile print (“A is: ”, A, “ and B is: ”, B) myDog is: Rover and yourDog is: Rover A is: 5 and B is: 10
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Example: Calculate Average Grade Have a list of grades Read in the grades one by one and add them Calculate the average (need to know how many grades) Print out the average 72 80 65 93 88 74 79 90 8 grades sum is: 641 average is: 641/8 = 80.1 72, 80, 65, 93, 88, 74, 79, 90
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
https://www.zenflowchart.com/guides/pseudocode-flowchart
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
https://www.zenflowchart.com/guides/pseudocode-flowchart
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Read a list of numbers # Get input from the user input_string = input("Enter numbers separated by spaces: ") # Split the input string into a list of strings string_numbers = input_string.split() # Convert the list of strings into a list of floats numbers = [] for num in string_numbers: numbers.append(float(num))
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Read a list of numbers numbers = [float(num) for num in input("Enter numbers separated by spaces: ").split()] # Calculate the count of numbers count_of_numbers = len(numbers) # Calculate the sum of numbers sum_of_numbers = sum(numbers) # Calculate the average if count_of_numbers != 0: average = sum_of_numbers / count_of_numbers else: average = 0 # Print out the average print(f"Average of the entered numbers: {average}")
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Read a list of numbers numbers = [float(num) for num in input("Enter numbers separated by spaces: ").split()] # Calculate the count of numbers count_of_numbers = len(numbers) # Calculate the sum of numbers sum_of_numbers = sum(numbers) # Calculate the average if count_of_numbers != 0: average = sum_of_numbers / count_of_numbers else: average = 0 # Print out the average print(f"Average of the entered numbers: {average}") What is the purpose of this selection?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
FUNCTION doSomething (X, Y) IF (X > Y) THEN T X X Y Y T ENDIF PRINT (X, Y) ENDFUNCTION What does this function do? doSomething(10, 11) doSomething(11, 10) doSomething(100, 200) doSomething(200, 100)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
FUNCTION doSomething (X, Y) IF (X > Y) THEN T X X Y Y T ENDIF PRINT (X, Y) ENDFUNCTION What does this function do? doSomething(10, 11) doSomething(11, 10) doSomething(100, 200) doSomething(200, 100) X Y X>Y? Print 10 11 F 10 11 11 10 T T 11 X 10 Y 11 10 11 100 200 F 100 200 200 100 T T 200 X 100 Y 200 100 200
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
FUNCTION doSomethingFun(n): output 0 FOR i FROM 1 TO n IF i MOD 2 == 0 THEN # i MOD 2 calculates the remainder of dividing i by 2 output output + i END IF END FOR PRINT “Mystery output is: ", output END FUNCTION
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
FUNCTION doSomethingFun(n): output 0 FOR i FROM 1 TO n IF i MOD 2 == 0 THEN output output + i END IF END FOR PRINT “Mystery output is: ", output END FUNCTION doSomethingFun(11) which means n = 11 i i MOD 2 == 0? output 0 1 1 MOD 2 = 1 (F) 0 2 2 MOD 2 = 0 (T) 0+2 = 2 3 3 MOD 2 = 1 (F) 2 4 4 MOD 2 = 0 (T) 2 + 4 = 6 5 5 MOD 2 = 1 (F) 6 6 6 MOD 2 = 0 (T) 6 + 6 = 12 7 8 9 10 11 Mystery output is:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
FUNCTION doSomethingFun(n): output 0 FOR i FROM 1 TO n IF i MOD 2 == 0 THEN output output + i END IF END FOR PRINT “Mystery output is: ", output END FUNCTION doSomethingFun(11) which means n = 11 i i MOD 2 == 0? output 0 1 1 MOD 2 = 1 (F) 0 2 2 MOD 2 = 0 (T) 0+2 = 2 3 3 MOD 2 = 1 (F) 2 4 4 MOD 2 = 0 (T) 2 + 4 = 6 5 5 MOD 2 = 1 (F) 6 6 6 MOD 2 = 0 (T) 6 + 6 = 12 7 7 MOD 2 = 1 (F) 12 8 8 MOD 2 = 0 (T) 12 + 8 = 20 9 9 MOD 2 = 1 (F) 20 10 10 MOD 2 = 0 (T) 20 + 10 = 30 11 11 MOD 2 = 1 (F) 30 Mystery output is: 30
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Move to your Breakout Room Mondays we start at 4:45pm 1. Breakout Room 1: Room 140: Ramsay Wright Laboratories, 25 Harbord Street 2. Breakout Room 2: Room 507: Claude T. Bissell Building, 140 St George St 3. Breakout Room 3: Room 538: Claude T. Bissell Building, 140 St George St Wednesdays we start at 7:45pm 1. Breakout Room 1: Room 126: Woodsworth College, 117/119 St. George Street 2. Breakout Room 2: Room 116: Claude T. Bissell Building, 140 St George St 3. Breakout Room 3: Room 728: Claude T. Bissell Building, 140 St George St
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Find the market equilibrium point for the following demand and supply functions. Demand:     p  =…
Q: 46. Two natural factors that have been proposed to cause climate changes over the past few decades…
Q: a.True or False:               There will be more dispersion in the sampling distribution of the…
Q: Neurotransmitters: a. Often progressive and may be fatal b. N c. D a. Plays a role in mood and sleep…
Q: Car A is traveling on the circular road at the constant speed of VA = 60 km/h. At the instant shown,…
Q: Explain what stem cells are and how they are helpful in an organism
Q: ethanol  CH3CH2OH in it reacts with oxygen gas  O2 from the air to form water  H2O and acetic…
Q: What elements of the Perceptual Process could you identify? What Processes of Perceptual Selectivity…
Q: What are Puritan values?
Q: (d) The first two random numbers for arrivals are 55 and 12. The first two random numbers for…
Q: A client requires an internet presence that is equally good for desktop and mobile users. What…
Q: A triangle has a perimeter of 90 centimeters. a. Write and use a linear system to determine the…
Q: Match the words in the left column to the appropriate blanks in the sentences on the right. Make…
Q: Modify the die-rolling simulation in Section 5.17.2 to omit displaying the frequencies and…
Q: Madison, what was one purpose of the Senate?
Q: Let's consider an isolated system of two oppositely- charged particles. How does the magnitude…
Q: Q7/Chose the correct answer for the output Q of the following circuit (Assume that A=…
Q: A pawn shop in Arlington, Texas, has a drive-through window to better serve customers. The following…
Q: If the demand for a pair of designer high heel shoes is given by 3p+6q = 1125 and the supply for the…
Q: easurement of every angle shown and justify your answer stating which relations 1. m/2 = 57 IUE 1E…
Q: In Country A, the population mean height for 10-year-old girls is 54.9 inches with a standard…
Q: 7. GEOMETRY The formula for the volume of a cylinder with radius r and height h is pi times the…