Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 7, Problem 15PE
Program Plan Intro

Draw a line

Program plan:

  • Import the necessary modules.
  • Define the “main()” function,
    • Draw the square window using “GraphWin()” method.
    • Set the coordinates for the window.
    • Get two mouse clicks from the user.
    • Draw the window.
    • Get mouse clicks for two points.
    • Assign coordinates in variables “x1”, “x2”, “y1”, and “y2”.
    • Create a line with midpoint “cyan”.
    • Calculate the length of the line.
    • Check whether the difference between two points is zero,
      • If it is true, assign the text.
      • Otherwise, calculate the slope of the line.
      • Assign the text with slope of the line.
    • Print length and slope of the line.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
Problem Description: In the Whimsical Library, each book is enchanted with a magical code to ensure the protection of knowledge. The validation process for these magical codes involves a combination of mathematical spells. The validation process is described as follows: Take the sum of the digits at odd positions from left to right. Take the sum of the squared digits at even positions from left to right. If the absolute difference between the results from step 1 and step 2 is a prime number, the book code is considered valid; otherwise, it is invalid. Example 1: Consider the magical book code 86420137. Step 1. Take the sum of the digits at odd positions from left to right. 8+4+0+3=15 Step 2. Take the sum of the squared digits at even positions from left to right. 6^2+2^2+1^2+7^2=36+4+1+49 = 90 Step 3. If the absolute difference between the results from step 1 and step 2 is a prime number. 115-901 75 (not a prime number) Book code 86420137 is invalid. Example 2: Now, let's examine the…
Modify the BarChart program from Chapter 6 Exercise 13 to accept the number of points scored by each player in a season. The bar chart displays one asterisk for each 10 points scored by a player. For example, if a player has scored 48 points, then display 4 asterisks. An example of the program is shown below: Enter points earned for the season by Art >> 10 by Bob >> 20 by Cal >> 30 by Dan >> 40 by Eli >> 50 Points for Season (each asterisk represents 10 points) Art * Bob ** Cal *** Dan **** Eli *****   import java.util.Scanner; public class BarChart2 {     public static void main (String[] args) {         Scanner input = new Scanner(System.in);         int artPoints;         int bobPoints;         int calPoints;         int danPoints;         int eliPoints;         final int AMT_EACH_ASTERISK = 10;         System.out.println("Enter points earned for the season");         System.out.print("    by Art >> ");         artPoints = input.nextInt();…
can you make it that it asks if the player wants to make the first selection or if they want to go second after theprogram moves.also once the game is over, the program should ask the user if they want to playagain. If so, clear the board and start the game. Otherwise, the programs exits.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY