Solution Manual for Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud, 1st Edition
Preview Extract
PyCDS_02_IntroToPython.fm Page 1 Tuesday, May 21, 2019 11:16 AM
Introduction to Python
Programming
2
Objectives
In this chapter, youโll:
โ Continue using IPython
interactive mode to enter code
snippets and see their results
immediately.
โ Write simple Python
statements and scripts.
โ Create variables to store data
for later use.
โ Become familiar with built-in
data types.
โ Use arithmetic operators and
comparison operators, and
understand their precedence.
โ Use single-, double- and triplequoted strings.
โ Use built-in function print to
display text.
โ Use built-in function input to
prompt the user to enter data
at the keyboard and get that
data for use in the program.
โ Convert text to integer values
with built-in function int.
โ Use comparison operators and
the if statement to decide
whether to execute a
statement or group of
statements.
โ Learn about objects and
Pythonโs dynamic typing.
โ Use built-in function type to
get an objectโs type.
PyCDS_02_IntroToPython.fm Page 2 Tuesday, May 21, 2019 11:16 AM
2
Introduction to Python Programming
Note: Throughout the Instructor Solutions Manual, solutions are not provided for project,
research and challenge exercisesโmany of which are substantial and appropriate for term
projects, directed-study projects, capstone-course projects and thesis topics. Before assigning a particular exercise for homework, instructors should check the IRC to be sure the
solution is available. These Instructor Solutions Manual PDFs contain only answers to
short-answer exercises and any discussion questions asked in other exercises. Code corresponding to programming exercises can be found in the solutions folderโs chapter-specific subfolderโe.g., ch01 for Chapter1, ch02 for Chapter 2, etc. Code generally is
provided both in Python source-code files (.py) and Jupyter Notebooks (.ipynb).
Exercises
Unless specified otherwise, use IPython sessions for each exercise.
(What does this code do?) Create the variables x = 2 and y = 3, then determine what
each of the following statements displays:
a) print(‘x =’, x)
Answer: x = 2
b) print(‘Value of’, x, ‘+’, x, ‘is’, (x + x))
Answer: Value of 2 + 2 is 4
c) print(‘x =’)
Answer: x =
d) print((x + y), ‘=’, (y + x))
Answer: 5 = 5
2.1
2.2
(Whatโs wrong with this code?) The following code should read an integer into the
variable rating:
rating = input(‘Enter an integer rating between 1 and 10’)
Answer: Function input returns a string, so to get an integer, youโd have to use:
rating = int(input(‘Enter an integer rating between 1 and 10’))
2.3
(Fill in the missing code) Replace *** in the following code with a statement that
will print a message like ‘Congratulations! Your grade of 91 earns you an A in this
course’. Your statement should print the value stored in the variable grade:
if grade >= 90:
***
Answer:
if grade >= 90:
print(‘Congratulations! Your grade of’, grade,
‘earns you an A in this course’)
ยฉ Copyright 2020 by Pearson Education, Inc. All Rights Reserved,
Document Preview (2 of 744 Pages)
User generated content is uploaded by users for the purposes of learning and should be used following SchloarOn's honor code & terms of service.
You are viewing preview pages of the document. Purchase to get full access instantly.
-37%
Solution Manual for Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud, 1st Edition
$18.99 $29.99Save:$11.00(37%)
24/7 Live Chat
Instant Download
100% Confidential
Store
William Taylor
0 (0 Reviews)
Best Selling
The World Of Customer Service, 3rd Edition Test Bank
$18.99 $29.99Save:$11.00(37%)
Chemistry: Principles And Reactions, 7th Edition Test Bank
$18.99 $29.99Save:$11.00(37%)
Test Bank for Hospitality Facilities Management and Design, 4th Edition
$18.99 $29.99Save:$11.00(37%)
Solution Manual for Designing the User Interface: Strategies for Effective Human-Computer Interaction, 6th Edition
$18.99 $29.99Save:$11.00(37%)
Data Structures and Other Objects Using C++ 4th Edition Solution Manual
$18.99 $29.99Save:$11.00(37%)
2023-2024 ATI Pediatrics Proctored Exam with Answers (139 Solved Questions)
$18.99 $29.99Save:$11.00(37%)