Question

Study guide Intro to PYTHON questions:

25) Write the code that will generate this output using only while loops and if statements (no string multiplication). ###AAA26) Write code that asks the user for a size and prints a triangle of stars of that size that increases by two at each level.22) Write a function total_volume that takes in a users input of width, length, height, and the units that will output the u

0 0
Add a comment Improve this question Transcribed image text
Answer #1

25)Code:

a=1
while(a<3): #two times loop for first 3 lines and second 3 lines
    b=1
    while(b<4): #loop for each line means A,B,C
        c=1
        if(b==1):
            s='A'
        elif(b==2):
            s='B'
        else:
            s='C'
        while(c<15): #loop for print 3#'s and 8 Characters(A or B or C) and 3 #'s
            if(c<=3):
                print("#",end="")
            elif(c>3 and c<12):
                print(s,end="")
            else:
                print("#",end="")
            c=c+1
        print("")
        b=b+1
    a=a+1


Code snippet 25:

a=] while (a<3): #two times loop for first 3 lines and second 3 lines b=1 while (b<4): #loop for each line means A,B,C c=1 if

Output 25:

###AAAAAAAA### ###BBBBBBBB### ###CCCCCCCC### ###AAAAAAAA### ###BBBBBBBB### ## #CCCCCCCC# ##

26) Code:

n=int(input("Size?")) #asking input size
i=1;
j=1;
while(i<=n):
    j=1;
    while(j<=i):
        print("*",end="");
        j=j+1;
    print()
    print()
    i=i+1


Code snippet 26)

naint (input (Size?)) #asking input size i-l; j=1; while(ic=n): j=1; while (j<=i): print(*, end=); j=j+1; print() print

Output 26:

Size25

23)Code:

def study_calculator():
    a=int(input("How many weeks do you want to calculate? "))
    i=1
    c=0;
    while(i<=a):
       b=int(input("How many hours did you spend for this week? "))
       c=c+b;
       i=i+1;
    print("Total amount of hours spent on study for",a,"weeks are",c)
study_calculator()
  


Code snippet 23:

def study_calculator(): a=int(input (How many weeks do you want to calculate? )) i=1 c=0; while (i<=a): b=int (input (How

Output 23:

How many weeks do you want to calculate? 3 How many hours did you spend for this week? 20 How many hours did you spend for th

22)Code:

def total_volume():
    width=int(input("please input a width:"))
    while(1):
        if(width<=0):
            print("Width must be positive")
            width=int(input("please input a width:"))
        if(width>0):
            break
    length=int(input("please input a length:"))
    while(1):
        if(length<=0):
            print("length must be positive")
            length=int(input("please input a length:"))
        if(length>0):
            break
    height=int(input("please input a height:"))
    while(1):
        if(height<=0):
            print("height must be positive")
            height=int(input("please input a height:"))
        if(height>0):
            break
    units=(input("please input a units:"))
    vol=width*length*height
    print("The volume of the object is",vol,end=" ");
    print(units,"^3");
total_volume()


Code snippet 22:

def total_volume(): width=int (input (please input a width:)) while(1) : if(width<=0): print (Width must be positive) wid

Output 22:

please input a width:3 please input a length:3 please input a height:3 please input a units:in The volume of the object is 27

Add a comment
Know the answer?
Add Answer to:
Study guide Intro to PYTHON questions: 25) Write the code that will generate this output using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the code in Python. The output should be exact the same as the given.

    Write the code in Python. The output should be exact the same as the given. Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50...

  • Write a program which will Ask the user a series of questions using the Scanner object Based on t...

    Write a program which will Ask the user a series of questions using the Scanner object Based on the input, draw a grid of star figures on the DrawingPanel You program should ask your user: . What R, G & B values to create a color to draw the figure? How many stars across should the fgure be? How many stars tall should the figure be? Note that your program does not need to error check the users responses Your...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • Only use the code in Objectives and write the code in Python

    Only use the code in Objectives and write the code in Python Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50 $60 $75 Are...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • PYTHON PLEASE Write a function to censor words from a sentence code: def censor_words(sentence, list_of_words): """...

    PYTHON PLEASE Write a function to censor words from a sentence code: def censor_words(sentence, list_of_words): """ The function takes a sentence and a list of words as input. The output is the sentence after censoring all the matching words in the sentence. Censoring is done by replacing each character in the censored word with a * sign. For example, the sentence "hello yes no", if we censor the word yes, will become "hello *** no" Note: do not censor the...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • #PYTHON# In this exercise you will write code which loads a collection of images (which are...

    #PYTHON# In this exercise you will write code which loads a collection of images (which are all the same size), computes a pixelwise average of the images, and displays the resulting average. The images below give some examples that were generated by averaging "100 unique commemorative photographs culled from the internet" by Jason Salavon. Your program will do something similar. Write a function in the cell below that loads in one of the sets of images and computes their average....

  • Use Python and only while loops For this part of the homework you will write code...

    Use Python and only while loops For this part of the homework you will write code to draw an isosceles right triangle. (A right triangle in which the height and base are the same size.) Your program should prompt the user for these inputs, in exactly this order: 1. The height of their triangle 2. The symbol the triangle will be outlined in 3. The symbol the triangle will be filled with For these inputs, you can assume the following:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT