Question

In: Computer Science

Q. 3 [35 pts] Print out the following output. You must use exactly 2 for statements,...

Q. 3 [35 pts] Print out the following output.

You must use exactly 2 for statements, 2 range statements, and 3 print statements. No modules are to be used for this problem.

Calculating x ** 1
1
3
5
====
Calculating x ** 2
1
9
25
====
Calculating x ** 3
1
27
125
====

Solutions

Expert Solution

Python Code:

for i in range(1,4):            #Loop will run 3 times i=1,2,3
  print("Calculating x **",i)   #one print statement
  for j in range(1,6,2):        #Loop will run 3 times j=1,3,5
    print(j**i)                 #printing square
  print("====")                 #printing required output

Here I am using only 2 for statements, 2 range statements, and 3 print statements. No module is used in above Program

Output Screenshot:

If you have any doubt feel free to ask and if you like the answer please upvote it .

Thanks


Related Solutions

Print out the following output. You must use exactly 2 for statements, 2 range statements, and...
Print out the following output. You must use exactly 2 for statements, 2 range statements, and 3 print statements. (python) Calculating x ** 1 1 3 5 ==== Calculating x ** 2 1 9 25 ==== Calculating x ** 3 1 27 125 ====
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an...
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an indirect proof technique. (a) (10 pts) Prove indirectly that, if a 2 is a multiple of 31, then so is a. Your proof should not consist of 30 cases – this includes absolutely no implied cases using horizontal dots (· · ·) and/or vertical dots (. . .). (b) (15 pts) Using the result of question (a), prove that √ 31 is not a...
You MUST use a while loop to print numbers 1-100. If the number is divisible by 3 print Soda instead of the number.
You MUST use a while loop to print numbers 1-100. If the number is divisible by 3 print Soda instead of the number. If the number is divisible by 5 print Pop instead of the number. If the number is divisible by 3 AND 5 print *SP*.Print 10 numbers/words to a line. Display the numbers/words in right-aligned columns. Use printf statements to do this. For example:System.out.printf( "5d", number );    System.out.printf( "5s", "Soda" );Every time there are ten numbers on a...
Your code must print all the steps in the output as an Eg> When you run...
Your code must print all the steps in the output as an Eg> When you run your Merge sort code the sequence of output should be: 1) Enter input sequence 2) Show n/2 division of the input sequence 3) keep showing n/2 division of your sequence until you get one attribute 4) Sort first two numbers 5) Make a stack of 4 by merging 2 * 2 and sort them 6) keep showing merging and sorting until you show the...
Consider the following annual returns on 2 stocks: (10 pts) Year HCA WLMT 2017 35% 3%...
Consider the following annual returns on 2 stocks: (10 pts) Year HCA WLMT 2017 35% 3% 2016 20% 5% 2015 3% 9% 2014 -12% 15% Calculate the expected return on each stock. (2 pts) Calculate the standard deviation on each stock. (3 pts) Assume you create a portfolio with equal weight in each stock. Calculate the expected return of the portfolio. (2 pts) Calculate the standard deviation of the equally weighted portfolio. (3 pts)
(10 pts) A firm has the following short run total costs, where Q is output and...
(10 pts) A firm has the following short run total costs, where Q is output and TC is total cost: Q TC 0 $ 100 1 110 2 130 3 160 4 200 5 250 6 310 7 380 8 460 9 550 10 650 11 760 What is total fixed cost equal to? $100 What is average total cost at Q = 4? $50 What is average variable cost at Q = 7? $40 What is marginal cost at...
Solve EXACTLY 6 questions out of 10. At least 2 questions MUST be quantitative! "X" =...
Solve EXACTLY 6 questions out of 10. At least 2 questions MUST be quantitative! "X" = 7, "Y" = 4: QUANTITATIVE – You work for Lynn, Inc. Your boss has asked you to complete a forecast for February and March using two forecasting methods and then to evaluate the two methods to identify the “best” method. You decide to try a weighted moving average of the last two months using weights of 60% (previous month) and 40% (2 months prior)....
P q TC MC 1 60 35 2 85 25 3 35 50 4 55 The...
P q TC MC 1 60 35 2 85 25 3 35 50 4 55 The TR for 2 units of output is equal to__________ dollars. The MR for the 3rd unit of output is equal to__________ dollars. The marginal profit of the first unit of output is equal to__________ dollars. The price of the second unit of output is equal to__________ dollars. The TVC for 3 units of output is equal to__________ dollars. The TC of 3 units of...
Q No. 3 Explain Why you agree or disagree with the following statements. The answer should...
Q No. 3 Explain Why you agree or disagree with the following statements. The answer should not be more than 3 sentences. Be specific in your answer and write only the most relevant explanations (Total Marks 7.5, Each 1.5). a. If a bond sells at a discount, yield to call is more likely to occur. b. A firm should select the capital structure that is fully unlevered. c. Leveraged beta represents fundamental operational risk. d. All other things held constant;...
Find the output for the following statements. System.out.println(3%2+1+(3/2)); char ch = 69; System.out.println(ch); int x =...
Find the output for the following statements. System.out.println(3%2+1+(3/2)); char ch = 69; System.out.println(ch); int x = 30; int y = 4; double z = x/y; System.out.println(z);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT