python3cami.docx

Python tom 3

A chess board uses letters and numbers to identify each space. Like this:

We want to create a text-only chess board using nested loops. When you are finished with your first attempt, your output should look something like this:

a8 b8 c8 d8 e8 f8 g8 h8

a7 b7 c7 d7 e7 f7 g7 h7

a6 b6 c6 d6 e6 f6 g6 h6

a5 b5 c5 d5 e5 f5 g5 h5

a4 b4 c4 d4 e4 f4 g4 h4

a3 b3 c3 d3 e3 f3 g3 h3

a2 b2 c2 d2 e2 f2 g2 h2

a1 b1 c1 d1 e1 f1 g1 h1

 

Once you have the above grid completed, copy your script and edit it to obtain the below output:

——————————————

| a8 | b8 | c8 | d8 | e8 | f8 | g8 | h8 |

——————————————

| a7 | b7 | c7 | d7 | e7 | f7 | g7 | h7 |

——————————————

| a6 | b6 | c6 | d6 | e6 | f6 | g6 | h6 |

——————————————

| a5 | b5 | c5 | d5 | e5 | f5 | g5 | h5 |

——————————————

| a4 | b4 | c4 | d4 | e4 | f4 | g4 | h4 |

——————————————

| a3 | b3 | c3 | d3 | e3 | f3 | g3 | h3 |

——————————————

| a2 | b2 | c2 | d2 | e2 | f2 | g2 | h2 |

——————————————

| a1 | b1 | c1 | d1 | e1 | f1 | g1 | h1 |

——————————————

You are to:

1. Work through this Lab  on your own (no peer help on this one!)

2. Submit your own completed Lab file(s) here (click the link above)

3. Leverage all tools covered within your reading up to this lesson.

This activity is worth 10 total points

This lesson's Group Activities are (do both):

1. Brutus the labrador retriever loves to chase tennis balls all day long. You can calculate how far he has run using this formula:

distance = speed * time

As an example, Brutus ran for two hours and ran 15 kilometers per hour. So, (15 kph) * (2 hours) = 30 kilometers.

Write a program that Brutus's owner can use to track his distance. It should:

Allow Brutus's owner to input the speed of his dog

Allow Brutus's owner to input the hours Brutus was playing fetch

Loop to display the distance Brutus ran for each hour like this:

How long did Brutus play fetch? 3How fast did Brutus run? 12==========================================Hour Brutus's Distance==========================================1 12 km2 24 km3 36 km

Helpful Hint:  you've already ready about escape sequences in Lesson 1, but it is useful to really see them in practice. You can make your outputs prettier and more precise by using tabs to seperate your text. To add a tab to a string in Python, you use what's called an   to represent the tab:  t. An escape sequence tells the program not to literally print t but to treat it as a tab. To create the the output header for Brutus, you would type something like this:

print('HourtBrutus's Distance')

2. Write a program that uses nested loops to draw this pattern:

#### ##  ##   ##    ##   ##  ## ####

You are to:

1. Post your code for each exercise in the Lesson 3 Group Activities discussion board

2. Respond to your classmates, providing assistance or commentary as needed

3. Follow the guidelines for Group Activities which are found under  Course Information

LAST PART: challenge

this is a challenge. the goal is to complete each code of column 1 to get the result of column 2

your additions must have a different color so that I can tell the difference.

Complete the code

Desired Output

# Set the control

again = "y"

# Create an iteration value

iteration = 1

# The while clause:

while again == "y":

# display our greeting with iteration number

print("Hi", iteration)

# increase the iteration

iteration += 1

# prompt user to change the /again/ variable

again = input("Do it again? y/n")

Hi 1
Hi 2
Hi 3

# Set out count variable

count = 10

# Write the /while/ clause to match Desired Ouput

# WARNING! Don't create an infinite loop or

# your browser will crash

print("Countdown",count)

count -= 1

Countdown 10
Countdown 9
Countdown 8
Countdown 7
Countdown 6
Countdown 5
Countdown 4
Countdown 3
Countdown 2
Countdown 1
Countdown 0

# Set out count variable

count = 5

# Rewrite the /while/ clause to prevent

# an infinite loop and match the Desired Ouput

# WARNING! Don't create an infinite loop or

# your browser will crash

while count != 0:

print("Countdown",count)

count += 1

Countdown 5
Countdown 4
Countdown 3
Countdown 2
Countdown 1
                    

# Set out count variable

count = 1

# The while statement

while count < 3:

print(count, "fish")

count += 1

# Re-write this statement as an /else/

# clause in the /while/ statement

print("Red fishnBlue fish")

1 fish
2 fish
Red fish
Blue fish

# Create a list of numbers:

fibonacci = [1, 1, 2, 3, 5, 8, 13, 21]

# Introduce the list:

print("The first 8 digits in the Fibonacci sequence are:")

# Create the for loop

# End the Program

print("Neat, huh?")

The first 8 digits in the Fibonacci sequence are:
1
1
2
3
5
8
13
21
Neat, huh?

# Introduce the list:

print("A list of my favorite foods")

# Create the for loop

A list of my favorite foods
ice cream
chocolate
guacamole

# Create a list of numbers:

fibonacci = [1, 1, 2, 3, 5, 8, 13, 21]

# Introduce the list:

print("The first 8 digits in the Fibonacci sequence are:")

# Create the for loop

for number in fibonacci:

print(fibonacci)

# End the Program

print("Neat, huh?")

The first 8 digits in the Fibonacci sequence are:
1
1
2
3
5
8
13
21
Neat, huh?

# Create a list of numbers:

fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

# Introduce the list:

print("Here is part of the Fibonacci sequence:")

# Create counting variable

# Create the for loop

# Print conclusion

Here is part of the Fibonacci sequence:
1
1
2
3
5
8
13
21
34
55
We just displayed 10 numbers

# Create a list of numbers:

fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

# Introduce the list:

print("Here is part of the Fibonacci sequence:")

# Create summing variable

# Create the for loop

# Print conclusion

Here is part of the Fibonacci sequence:
1
1
2
3
5
8
13
21
34
55
They add up to 143

# Create the list of numbers

numbers = [60, 91, 64, 70, 51, 7, 49, 65, 96, 39, 13, 61, 78, 76, 66, 16, 17, 73, 34, 89]

# Create the maximum variable

# Create for statement

# Display results

print("The largest number is")

The largest number is 96

# Create the list of numbers

numbers = [60, 91, 64, 70, 51, 7, 49, 65, 96, 39, 13, 61, 78, 76, 66, 16, 17, 73, 34, 89]

# Create the minimum variable

# Create for statement

# Display results

print("The smallest number is")

The smallest number is 7

# Collect input and assign to /jelly_beans/

jelly_beans = int(input("How many jelly beans do you want? "))

# Write input validation loop

# /jelly_beans/ must be greater than 0

# and less than 100

# Display final result

print("You want", jelly_beans, "jelly beans")# Collect input and assign to /jelly_beans/

jelly_beans = int(input("How many jelly beans do you want? "))

# Write input validation loop

# /jelly_beans/ must be greater than 0

# and less than 100

# Display final result

print("You want", jelly_beans, "jelly beans")

How many jelly beans do you want? -5
Please enter a number between 0 and 100
How many jelly beans do you want? 200
Please enter a number between 0 and 100
How many jelly beans do you want? 75
You want 75 jelly beans

Hi
Hi
Hi
Hi
Hi

# Create a for loop which counts down from 10

for i in range():

# display output

print("Blast off!!")

10
9
8
7
6
5
4
3
2
1
Blast off!!