ACIS 2504 Python Unit 1 11/3/2020 & 11/12/2020

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

1. width = int(input("Enter with width: ")) 2. height = int(input("Enter with height: ")) 3. area = width * height 4. print("The area is", area, "square units.")

1. In the Code Editor, enter the program from Figure 1-7 that computes the area of a rectangle. 2. Press the Run button and correct any errors that occur. 3. Test the program with different inputs. An example of the program input and output is shown below: Enter the width: 33 Enter the height: 22 The area is 726 square units.

1. base = float(input("Enter the base: ")) 2. height = float(input("Enter the height: ")) 3. area = 0.5 * base * height 4. print("The area is", area, "square units.")

1. Issue the appropriate prompts for the triangle's base and height, and change the name of the width variable to base. 2. Use the formula 0.5 × base × height to compute the area. An example of the program input and output is shown below: Enter the base: 5 Enter the height: 7 The area is 17.5 square units.

1. radius = float(input("Enter the radius: ")) 2. area = 3.14 * radius**2 3. print("The area is", area, "sqaure units.")

1. Request a number representing a radius as input from the user. 2. Use the formula 3.14 × radius to compute the area. 3. Output this result with a suitable label. An example of the program input and output is shown below: Enter the radius: 5 The area is 78.5 square units.

Memory, Central processing unit (C P U) and Set of input/output devices

Basic hardware components of Computer Hardware

float(<a string of digits>)

Converts a string of digits to a floating-point value.

int(<a string of digits>)

Converts a string of digits to an integer value.

input(<a string prompt>)

Displays the string prompt and waits for keyboard input. Returns the string of characters entered by the user.

print(<expression>, ...,<expression>)

Evaluates the expressions and displays them, separated by one space, in the console window.

<string 1> + <string 2>

Glues the two strings together and returns the result.

IDLE

IDE that allows the programmer to save programs in files and load them into a shell for testing

________;__________

Information Prcoessing Starts with _____ Transforms data according to well-defined rules Produces _______

expressions; statements

Inputs are Python ______________ or ______________

input devices

Keyboard and Scanner are two examples of

Hardware; Software

Modern Computer System consists of ______ and _______

output devices

Monitor and Printer are two examples of

results

Outputs are the ________ displayed in the shell

Yes

Programmers inevitably make syntax errors The Python interpreter will usually detect these, halt execution and display an error message. Yes or No?

Behind the Scenes: How Python Works

Python code ==> Syn

scripts

Python program files are also called

.py

Python program files use ____ extension

Python

Resembles English Allow the author to express algorithms in a form that other people can understand high-level programming language used for plain text (no formatting)

Random access memory (R A M)

Short-term memory, also called internal or primary

Integrated Development Environment (IDE)

comprehensive software application that provides tool needed to write and run a program

All of the above

What is IDLE used to do? A. Edit Python programs B. Save Python programs to files C. Run Python programs D. All of the above

Decode and execute instructions

What is the purpose of the CPU? A. Store information B. Receive inputs from the human user C. Decode and execute instructions D. Send output to the human user

the syntax

What is the set of rules for forming sentences in a language called? A. the Semantics B. the Pragmatics C. the Syntax D. the Logic

A recipe, A set of instructions for putting together a utility shed, and The spelling checker of a word processor

Which of the following are examples of algorithms? A. A dictionary B. A recipe C. A set of instructions for putting together a utility shed D. The spelling checker of a word processor

A laptop computer

Which of the following are general-purpose computing devices? A. A cell phone B. A portable music player C. A laptop computer D. A programmable thermostat

Microphone and a mouse

Which of the following are input device(s)? A. Speaker B. Microphone C. Printer D. A mouse

A monitor

Which of the following are output devices? A. A digital camera B. A keyboard C. A flatbed scanner D. A monitor

An audio CD, A book, and A running computer

Which of the following contain information? A. My grandmother's china cabinet B. An audio CD C. A refrigerator D. A book E. A running computer

The print statement

Which of the following outputs data in a Python program? A. The input statement B. The assignment statement C. The print statement D. The main function

An interpreter

Which of the following translates and executes instructions in a programming language? A. A compiler B. A text editor C. A loader D. An interpreter

1. print("Michael Hall") 2. print("Blacksburg") 3. print("757-386-0334")

Write a Python program that prints (displays): Your name Address Telephone number An example of the program output is shown below: Michael Hall Blacksburg 757-386-0334

1. name = (input("Enter your name: ")) 2. age = int(input("Enter your age: ")) 3. print(name, "is", age, "years old.")

Write and test a program that accepts the user's name (as text) and age (as a number) as input. The program should output a sentence containing the user's name and age. An example of the program input and output is shown below: Enter your name: Alex Enter your age: 23 Alex is 23 years old.

Input function

builds a string from the user's keystrokes and returns it to the program

features of an algorithm

consists of a finite number of instructions each individual instruction is well defined describes a process that eventually halts after arriving at a solution to a problem solves a general class of problems

Desktop or laptop

example of computing agent general-purpose problem-solving machines

cell phone

example of computing agent specialized for a small set of tasks

float

for floating-point numbers/decimals

int

for integers

Memory of computer hardware

information stored as patterns of binary digits (1s and 0s)

Loader of computer software

part of operating system and takes a set of machine language instructions and loads them into memory

Hardware

physical devices required to execute algorithms

machine code

program stored in computer memory must be represented in binary digits

CPU (processor)

responsible for processing data

program libraries

save scripts in _______ _______ to reuse or share with others

Algorithms

sequence of steps or set of instructions for doing something

Syntax

set of rules for forming correct expressions and statements in a programming language

Software

set of the algorithms, represented as programs in particular programming languages

Computing Agents

specialized for a small set of tasks or are general-purpose problem-solving machines

Information Processing

transforming data to produce new information

Interpreter

translates a Python program to a lower-level form that can be executed on a real computer

Imagery

visually descriptive or figurative language, especially in a literary work.


Ensembles d'études connexes

General Insurance Quiz questions

View Set

Alabama (Department Of Insurance) Life and Health Insurance

View Set

Voting, Political Parties, and Interest Groups

View Set

Journeys 5th Grade Lesson 3 COMPREHENSION

View Set