Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
www.tutorialrank.com
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 1 Python LAB 2.14 Formatted output Hello World!
CYB 130 Week 1 Python LAB 2.15 Formatted output No parking sign
CYB 130 Week 1 Python LAB 2.31 Expression for calories burned
during workout
CYB 130 Week 2 Python LAB 3.11 Input and formatted output Right-
facing arrow
CYB 130 Week 2 Python LAB 3.13 Input and formatted output House
real estate summary
CYB 130 Week 3 Python LAB 4.14 LAB Count input length without
spaces, periods, or commas
CYB 130 Week 3 Python LAB 4.15 Password modifier
CYB 130 Week 3 Python LAB 4.18 Smallest and largest numbers in a
list
CYB 130 Week 3 Python LAB 4.19 Output values in a list below a user
defined amount
CYB 130 Week 5 Python LAB 6.24 Varied amount of input data
CYB 130 Week 5 Python LAB 6.25 Filter and sort a list
CYB 130 Week 5 Python LAB 6.5 Checker for integer string
.....................................................................................................................
.........................................
www.tutorialrank.com
Now that you have spent one week navigating your zyBook, what
observations have you made about its design? Which elements were
most helpful to you? Which features are still troublesome? What
strategies have you applied that could be of use to someone else?
Describe another situation in which zyBooks could help you learn
content.
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 1 Python LAB 2.14 Formatted output Hello World!
Write a program that outputs "Hello World!" For ALL labs, end with
newline (unless otherwise stated).
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 1 Python LAB 2.15 Formatted output No parking sign
Write a program that prints a formatted "No parking" sign as shown
below. Note the first line has two leading spaces. For ALL labs, end
with newline (unless otherwise stated).
NO PARKING
.....................................................................................................................
.........................................
CYB 130 Week 1 Python LAB 2.16 Input Welcome
message
For more course tutorials visit
www.tutorialrank.com
Write a program that takes a first name as the input, and outputs a
welcome message to that name.
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 1 Python LAB 2.29 Divide by x
Ex If the input is
2000
.....................................................................................................................
.........................................
www.tutorialrank.com
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows
Ex If the input is
20.0
3.1599
www.tutorialrank.com
CYB 130 Week 1 Python LAB 2.31 Expression for calories burned
during workout
Write a program using inputs age (years), weight (pounds), heart rate
(beats per minute), and time (minutes), respectively. Output calories
burned for women and men.
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows
Ex If the input is
49
155
148
60
.....................................................................................................................
.........................................
www.tutorialrank.com
Ex If the input is
5.0
1.5
3.2
.....................................................................................................................
.........................................
www.tutorialrank.com
Respond to the following in a minimum of 175 words:
This week you will learn about basic code structure. The term structure,
as it relates to programming, refers to the decisions you make to design
your program to best meet its objective. Python provides features to
create clean, efficient code. How can the basic if/elif/else control
statements help meet structural design objectives in your code? Provide
a code example to support your comments.
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 2 Python LAB 3.11: Input and formatted output: Right-
facing arrow
Given input characters for an arrowhead and arrow body, print a right-
facing arrow.
Ex: If the input is:
******##
******###
******##
.....................................................................................................................
.........................................
www.tutorialrank.com
8005551212
(800) 555-1212
Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2
digits of 572 is gotten by 572 % 100, which is 72.
Hint: Use // to shift right by the desired amount. Ex: Shifting 572 right
by 2 digits is done by 572 // 100, which yields 5. (Recall integer division
discards the fraction).
www.tutorialrank.com
CYB 130 Week 2 Python LAB 3.13: Input and formatted output: House
real estate summary
Sites like Zillow get input about house prices from a database and
provide nice summaries for readers. Write a program with two inputs,
current price and last month's price (both integers). Then, output a
summary listing the price, the change since last month, and the estimated
monthly mortgage computed as (current_price * 0.051) / 12.
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows:
print('{:.2f}'.format(your_value))
Ex: If the input is:
200000
210000
.....................................................................................................................
.........................................
print('{:.0f}'.format(your_value))
Output each floating-point value with three digits after the decimal
point, which can be achieved as follows:
print('{:.3f}'.format(your_value))
Ex: If the input is:
8.3
10.4
5.0
4.8
2072 7
2071.680 7.125
.....................................................................................................................
.........................................
www.tutorialrank.com
Write a program whose inputs are three integers, and whose output is the
smallest of the three values.
Ex: If the input is:
15
.....................................................................................................................
.........................................
www.tutorialrank.com
Write a program that takes a date as input and outputs the date's season.
The input is a string to represent the month and an int to represent the
day.
Ex: If the input is:
April
11
Spring
In addition, check if the string and int are valid (an actual month and
day).
Blue
65
Invalid
The dates for each season are:
.....................................................................................................................
.........................................
www.tutorialrank.com
No change
45
1 Quarter
2 Dimes
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 2 Python LAB 3.28: Leap year
Write a program that takes in a year and determines whether that year is
a leap year.
1712
1913
.....................................................................................................................
.........................................
www.tutorialrank.com
www.tutorialrank.com
CYB 130 Week 3 Python LAB 4.14 LAB: Count input length without
spaces, periods, or commas
21
Note: Account for all characters that aren't spaces, periods, or commas
(Ex: "r", "2", "!").
.....................................................................................................................
.........................................
www.tutorialrank.com
i becomes !
a becomes @
m becomes M
B becomes 8
o becomes .
mypassword
Myp@ssw.rdq*s
www.tutorialrank.com
Write a program that takes in a line of text as input, and outputs that line
of text in reverse. The program repeats, ending when the user enters
"Quit", "quit", or "q" for the line of text.
Hello there
Hey
quit
erehtolleH
yeH
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 3 Python LAB 4.18: Smallest and largest numbers in a
list
Write a program that reads a list of integers into a list as long as the
integers are greater than zero, then outputs the smallest and largest
integers in the list.
10
21
-6
2 21
You can assume that the list of integers will have at least 2 values.
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 3 Python LAB 4.19: Output values in a list below a user
defined amount
Write a program that first gets a list of integers from input. The input
begins with an integer indicating the number of integers that follow.
Then, get the last value from the input, which indicates a threshold.
Output all integers less than or equal to that last threshold value.
Ex: If the input is:
50
60
140
200
75
100
50
60
75
The 5 indicates that there are five integers in the list, namely 50, 60, 140,
200, and 75. The 100 indicates that the program should output all
integers less than or equal to 100, so the program outputs 50, 60, and 75.
Such functionality is common on sites like Amazon, where a user can
filter results.
.....................................................................................................................
.........................................
www.tutorialrank.com
Python lists are commonly used to store data types. Lists are a collection
of information typically called a container. Think of a physical container
that can hold all kinds of objects, not just one object of the same type.
Python includes a built-in list type called a list. They can be managed by
many built-in functions that help fill, iterate over, add to, and delete a
list. Why is it useful to store information with different data types?
When do you choose to use a list over a dictionary? Provide a code
example that supports your comments.
.....................................................................................................................
.........................................
CYB 130 Week 4 Python LAB 5.18 Miles to track laps
For more course tutorials visit
www.tutorialrank.com
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows:
print('{:.2f}'.format(your_value))
6.00
2.2
8.80
def miles_to_laps(user_miles)
.....................................................................................................................
.........................................
www.tutorialrank.com
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows:
print('{:.2f}'.format(your_value))
20.0
3.1599
1.58
7.90
63.20
Your program must define and call the following driving_cost()
function. Given input parameters driven_miles, miles_per_gallon, and
dollars_per_gallon, the function returns the dollar cost to drive those
miles.
50 20.0 3.1599
7.89975
Note: This is a lab from a previous chapter that now requires the use of a
function.
.....................................................................................................................
.........................................
www.tutorialrank.com
Output each floating-point value with two digits after the decimal point,
which can be achieved as follows:
print('{:.2f}'.format(your_value))
Ex: If the input is:
5345
2.67
Your program must define and call the following function. The function
should return the amount of miles walked.
def steps_to_miles(user_steps)
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 4 Python LAB 5.21: Leap year - functions
Write a program that takes in a year and determines whether that year is
a leap year.
1712
1913
Your program must define and call the following function. The function
should return true if the input year is a leap year and false otherwise.
def is_leap_year(user_year)
Note: This is a lab from a previous chapter that now requires the use of a
function.
.....................................................................................................................
.........................................
www.tutorialrank.com
Write a program whose input is two integers and whose output is the two
integers swapped.
83
Your program must define and call the following function.
swap_values() returns the two values in swapped order.
www.tutorialrank.com
no change
Ex: If the input is:
45
1 quarter
2 dimes
Your program must define and call the following function. The function
exact_change() should return num_dollars, num_quarters, num_dimes,
num_nickels, and num_pennies.
def exact_change(user_total)
Note: This is a lab from a previous chapter that now requires the use of a
function.
.....................................................................................................................
.........................................
CYB 130 Week 4 Python LAB 5.24 Even/odd values in a
list
For more course tutorials visit
www.tutorialrank.com
Write a program that reads a list of integers, and outputs whether the list
contains all even numbers, odd numbers, or neither. The input begins
with an integer indicating the number of integers that follow.
10
the output is:
all even
all odd
Your program must define and call the following two functions.
is_list_even() returns true if all integers in the list are even and false
otherwise. is_list_odd() returns true if all integers in the list are odd and
false otherwise.
def is_list_even(my_list)
def is_list_odd(my_list)
.....................................................................................................................
.........................................
www.tutorialrank.com
.....................................................................................................................
.........................................
www.tutorialrank.com
CYB 130 Week 5 Python LAB 6.5: Checker for integer string
Forms often allow a user to enter an integer. Write a program that takes
in a string representing an integer as input, and outputs yes if every
character is a digit 0-9.
Ex: If the input is:
1995
yes
42,000
no
6.5.1: LAB: Checker for integer string