1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Eddi Din [679]
4 years ago
12

6.12 Nested Increments Write a program for spiritual lumberjacks who want to show their appreciation for each tree they 'kill' b

y celebrating its years of life. Ask the lumberjack how many trees he wants to cut. Verify you got the number correctly by printing it to output. Write a loop that iterates over all the trees the lumberjack wants to cut down. Print the tree number to the screen to make sure your loop is working correctly. Query the lumber jack for how many rings are in this tree and print this number to make sure you got the correct number of rings. Write an inner loop that iterates over the years of the tree. Print each year to make sure you are iterating correctly and hitting each year that it lived. Change the necessary print statements and to match the correct formatting from the output examples.
Computers and Technology
1 answer:
Nina [5.8K]4 years ago
7 0

Answer:

trees_to_cut = int(input("How many trees do you wants to cut? "))

print(str(trees_to_cut) + " tree(s) will be cut.")

for i in range(trees_to_cut):

   print("Tree #" + str(i))

   

   rings = int(input("How many rings in tree " + str(i) + "? "))

   print("There are " + str(rings) + " ring(s) in this tree.")

   for j in range(rings):

       print("Celebrating tree #" + str(i) + "'s " + str(j+1) + ". birthday.")

Explanation:

*The code is in Python.

Ask the user to enter the number of trees to cut

Print this number

Create a for loop that iterates for each tree

Inside the loop:

Print the tree number. Ask the user to enter the number of rings. Print the number of rings. Create another for loop that iterates for each ring. Inside the inner loop, print the celebrating message for each birthday of the tree

You might be interested in
Write a function swap that swaps the first and last elements of a list argument. Sample output with input: 'all,good,things,must
zubka84 [21]

Answer:

li=list(map(str,input().strip().split()))#taking input of the string.

#swapping first and last element.

temp=li[0]

li[0]=li[-1]

li[-1]=temp

print(li)#printing the list.

Explanation:

I have taken the list li for taking the input of strings.Then after that swapping first and last element of the list.Then printing the list.

7 0
3 years ago
Read 2 more answers
An expression that can’t be reduced any further is:
MakcuM [25]

Answer:

i think it’s b by process of elimination.

a value is just the value of number, fundamental isnt a math term, and variables change so

Explanation:

5 0
4 years ago
Read 2 more answers
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This
Shtirlitz [24]

Answer:

def newton(n):

       #Define the variables.

       t = 0.000001

       esti = 1.0

       #Calculate the square root

       #using newton method.

       while True:

               esti = (esti + n / esti) / 2

               dif = abs(n - esti ** 2)

               if dif <= t:

                       break

   

       #Return the result.

       return esti

#Define the main function.

def main():

   

       #Continue until user press enters.

       while True:

               try:

         

                       #Prompt the user for input.

                       n = int(input("Enter a number (Press Enter to stop):"))

                       #display the results.

                       print("newton = %0.15f" % newton(n))

     

               except:

                       return

#Call the main function.

main()

7 0
4 years ago
Create and apply a CSS class named YellowBackground that selects a yellow background. Apply the class to your HTML file’s body t
RSB [31]

<!DOCTYPE html>

<html>

<head>

 <title>Page Title</title>

</head>

<body class="YellowBackground">

 <style>

    .YellowBackground {

        background-color:yellow;

    }

</style>

</body>

</html>


Like this?

7 0
3 years ago
Company Wizzy is having trouble with network security. Issues with authentication, viruses, malware/spyware, and other network i
Darya [45]

Answer:

B) security as a service I'm just doing the work

4 0
3 years ago
Other questions:
  • How does the mantle interact with the tectonic plates at a convergent boundary?
    14·2 answers
  • Which of the following should you NOT do when using CSS3 properties to create text columns for an article element? a. make the c
    12·2 answers
  • To generate a report with exact results based on specific criteria it is best to base the report on a(n) ____________________ cr
    6·1 answer
  • A store trying to analyze the behavior of its customers will often maintaina two-dimensional array A, where the rows correspond
    6·1 answer
  • X = 19 y = 5 print (x % y)
    11·1 answer
  • With ____________________, you can insert and remove a device while the computer is running.
    11·1 answer
  • The _______ of a secondary storage device indicates how much data the storage medium can hold.
    13·1 answer
  • Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the ou
    10·1 answer
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    12·1 answer
  • Write a program that inputs a five-digit integer, spearates the integer into its digits and prints them seperated by three space
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!