Coding Practice¶
The
E01PrintEvenprogram should generate a random number and print if it is evenly divisible by 2. However, the code has an error and always prints “Your number is even”, even if the random number is odd. Fix the code so that it only prints the message when the number is even.The
E02CheckGuessprogram should check your guess against the answer and print that it is too low, correct, or too high. However, the code has errors. Fix the code so that it compiles and runs correctly.The
E03Choresprogram should print “You can go out” if you have done your homework and cleaned your room. However, the code has errors. Fix the code so that it compiles and runs correctly.The
E04TestRangeprogram should print if x is in the range of 0 to 10 (including 0 and 10). However, the code has errors. Fix the errors so that the code runs as intended.The
E05PositiveNegativeZeroprogram should print if x is less than 0, equal to 0, or greater than 0. Finish it to work correctly.Finish the
E06Feverprogram so that it printsYou have a feverif your temperature is above 100 and otherwise printsYou don't have a fever.Finish the
E07Temperatureprogram to printIt is freezingif the temperature is below 30,It is coldif it is below 50,It is nice outif it is below 90, orIt is hotusing nested if else statements.Rewrite the
E08LoopRewrite1program to use awhileloop instead of aforloop to print out the numbers from 1 to 10 (inclusive).Rewrite the
E09LoopRewrite2program so that it uses aforloop instead of awhileloop to print out all the integers from 5 to 15 (inclusive).Rewrite the
E10LoopRewrite3program to use awhileloop instead of aforloop to print out the numbers from 10 to 100 by 10’s (inclusive).The
E11Errors1program should print the values from 1 to 10 (inclusive) but has errors. Fix the errors so that the code works as intended. If the code is in an infinite loop you can refresh the page in the browser to stop the loop and then click on Load History and move the bar above it to see your last changes.The
E12Errors2program should print the values from 10 to 5, but it has errors. Fix the errors so that the code works as intended.The
E13Errors3program should print the values from 10 to 1, but it has errors. Fix the errors so that the code works as intended.Finish
E14Countdownprogram to print a countdown from 100 to 0 by 10’s using a for or while loop.Finish the
E15EvenOddprogram to print the value ofxand" is even"ifxis even and" is odd"if it is odd for all values from 10 to 1.Finish the
E16Multiplyprogram to print the values for10 * xwherexchanges from 0 to 10 using a loop.Finish the
E17program so that it prints a string message minus the last character each time through the loop until there are no more characters in message. The loop condition should test the length of the message. The loop body should print the message and then use substring to create a new message without the last character.Finish
E18MessageXprogram to loop printing the message each time through the loop and remove anxfrom the message until all thex’s are gone.Write a loop in the
E19CountXprogram to print the number ofx’s in the string message. Use theindexOfandsubstringmethods.Write the
E20Rectangle5x3program to print a rectangle of stars (*) with 5 rows of stars and 3 stars per row. Hint: use nested for loops.Write the
E21Rectangle3x5program to print a rectangle of stars (*) with 3 rows of stars and 5 stars per row.Write the
E22NumberTriangleprogram to print 55555, 4444, 333, 22, 1 with each on a different line.