Question

1. How many times the loop below will be executed? What is the value of variable...

1. How many times the loop below will be executed? What is the value of variable counter after the loop?

counter = 1

while counter < 7:

counter+=2

print(counter)

2. An integer is stored in a variable MyInt. Write the Python if statement to test if MyInt is even number or odd number, and print a message to show “It is even number.” or “It is an odd number”.

3. Complete the python below that asks user to enter the measurement of three lengths in feet and inches as integer values and compute the total length in feet and inches. For example, the total length of 5 feet 7 inches, 3 feet 8 inches, and 2 feet 10 inches is 12 feet inch; and 5 feet 3 inches, 3 feet 2 inches, and 2 feet 6 inches is 10 feet 11 inches.

feet1 = int(input('Enter feet of length 1: '))

inches1 = int(input('Enter inches of length :'))

feet2 = int(input('Enter feet of length 2: '))

inches2 = int(input('Enter inches of length 2 :'))

feet3 = int(input('Enter feet of length 3: '))

inches3 = int(input('Enter inches of length 3 :'))

Homework Answers

Answer #1
Question 1:
counter = 1
while counter < 7:
    counter+=2
print(counter)
Number of times the loop below will be executed is 3
Value of variable counter after the loop is 7


Question 2:
if MyInt%2==0:
    print("It is an even number")
else:
    print("It is an odd number")


Question 3:
feet1 = int(input('Enter feet of length 1: '))
inches1 = int(input('Enter inches of length :'))
feet2 = int(input('Enter feet of length 2: '))
inches2 = int(input('Enter inches of length 2 :'))
feet3 = int(input('Enter feet of length 3: '))
inches3 = int(input('Enter inches of length 3 :'))
inches = inches1+inches2+inches3
feets = feet1 + feet2 + feet3 + (inches//12)
inches = inches%12
print(feets,"feet and",inches,"inches")
Know the answer?
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
Similar Questions
3.plese to write the correct code: The code below will loop as long as the number...
3.plese to write the correct code: The code below will loop as long as the number that you enter isn’t negative. It will add each non negative number to the current sum. It will print out the sum and average of all of the numbers you have entered. But someone jumbled up the code. Can you reorganize and indent it so it works properly? count = count + 1 message = "Enter an integer or a negative number to stop"...
How many times will the body of the loop be executed? var Total = 1; for...
How many times will the body of the loop be executed? var Total = 1; for (intIndex = 1; intIndex < 7 ; intIndex += 2) { Total += intIndex; }
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking...
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking option entered by the user print("Enter 0 to 5 for following options: ") print("0-> Issue new ticket number.") print("1-> Assign first ticket in queue to counter 1.") print("2-> Assign first ticket in queue to counter 2.") print("3-> Assign first ticket in queue to counter 3.") print("4-> Assign first ticket in queue to counter 4.") print("5-> Quit Program.") tickets = [] #Declaring list to store...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0 if(x<1): print('Error') exit() print('Initial value is: ',x,' ',end='') while(x!=1): if(x%2==0): x=x/2 else: x=3*x+1 count+=1 if(x!=1): rint('Next value is: ',int(x),' ',end='') else: print('Final value ',int(x),', ',end='') print('number of operations performed ',int(count),' ',end='') break
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
Assembler lanaguage program   The program is to prompt the user to enter a number between 2...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2 and 100. Reject any invalid user inputs and terminate the program if invalid inputs are entered. Print each even number from 2 to the user entered number. Sum these even numbers and print the sum. Print each odd number from 1 to the user entered number. Sum these odd numbers and print the sum. Exit the program when the output is complete. The output...
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in...
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in the sequence, the next number in the sequence is determined by two simple rules: If the current number n is odd, the next number in the sequence is equal to 3 * n + 1 If the current number n is even instead, the next number in the sequence is equal to one half of n (i.e., n divided by 2) We repeat this...
For coding below how do i loop every letter of the input of the password. When...
For coding below how do i loop every letter of the input of the password. When my first letter is a number it detects as passowrd with numeric but if i put the number in the end of the word its doesnt detect password with numeric password=input("Enter your Password: ") if (len(password)<6): print("Must be at least 6 characters long") for i in password: if i.isnumeric== True: print("All good characters") else: print("Your password must contain at lease 1 number") break
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT