Question: 1. Write a program called squares.py that prints a list of the first nine positive integers and their squares. (Make sure to include the colon

1. Write a program called squares.py that prints a list of the first nine positive integers and their squares. (Make sure to include the colon at the end of the while statement, or Python will complain.) Your output should look similar to the following:

Number Square
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81

# copy and paste your code here.

============================

For example, the following loop will display the numbers from 1 to 10.

for counter in range (1, 11):

print(counter)

Rewrite the program (squares.py) by using a for loop.

# copy and paste your code here.

====================================

2. Write a program called happy.py that uses a while-loop to print the output shown below. As you can see, the program should print the numbers 1 through 10, except that between 7 and 8 it should print the word "happy". This can be accomplished by placing an if-statement within the while-loop to do something special for the lineNumber == 7 case.

1
2
3
4
5
6
7
happy
8
9
10

# copy and paste your code here.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!