Nested loops to generate a triangle

Assignment Help Python Programming
Reference no: EM131268732

Plan each program by writing pseudocode.

Write all lines of your pseudocode as comments immediately.

Add more comments in each program to explain what your code is doing.

Choose descriptive variable names in all programs.

1. Write a program called program41.py that uses a for loop and the range functionto output the numbers from 5 up to 100 by fives exactly as shown (all numbers all on the same line, separated by a single space). Output "That's that!" (note apostrophe) on a new line to end the program as shown below.

SAMPLE RUN
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100

2. Write another program called program42.py that generates exactly the same output as the program above, but by using a while loop.

3. Write a program named program43.py that uses nested loops to generate a triangle as shown in the sample run. The program should begin by prompting the user to enter the number of lines in the triangle.

4. Write a program named program44.py that can be used to determine the average of some integers. The number of integers can vary, and this should not be initially set by user input (see sample output). Instead, use a while loop and a sentinel value of zero to cease integer input. Display the average accurate to two decimal places.
SAMPLE RUN
Enter integer 12
Enter integer 9
Enter integer 8
Enter integer 14
Enter integer 0
The average is 10.75

Reference no: EM131268732

Questions Cloud

How fast is the top of the ladder rising : If the foot of the ladder is pushed toward the wall at 0.5 foot per second, how fast is the top of the ladder rising when the foot is 8 feet from the wall?
What a sustainable system means : Describe in your own words how the interaction of these three themes would result in a sustainable system, as well as what a sustainable system means.
What effects has oprah''s charisma had on her followers : What effects has Oprah's charisma had on her followers?
Write a single statement that assigns the values : Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the "lotterynumbers" array.
Nested loops to generate a triangle : Write a program called program41.py that uses a for loop and the range functionto output the numbers from 5 up to 100 - Write another program called program42.py that generates exactly the same output
Method that returns the number of consonants : Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the ..
Input two arrays of information : Write a program that will input two arrays of information. Each array will contain exactly 4floating point values. Your program will enter these values from standard input.
Malloc up space for a one-dimensional array of n integers : Write a program that will first read in a positive integer number, say n, from standard input. Then you need to create enough space in the heap via a call to malloc to hold an array of n integers.You then need to use array index operators to fill ..
How fast is its daily cost for hamburgers increasing : If the restaurant s daily sales are increasing at the rate of 30 hamburgers per day, how fast is its daily cost for hamburgers increasing?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a modularized body mass index program

Write a modularized Body Mass Index (BMI) Program which will calculate the BMI of a team player. The formula to calculate the BMI is as follows: BMI = Weight *703 / Height^2.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  The managing director of aussie best car abc has invited

the managing director of aussie best car abc has invited you to build a new computer system for them in python. the abc

  Develop and test a python program

Develop and test a Python program that displays the day of the week that the following holidays fall on for a year entered by the user New Year's Eve

  Website to inform about aspect of the local environment

ICT112 Assignment - write a Python program that generates a small web site to inform Sunshine Coast people about some aspect of the local environment or a local sustainability issue.

  What prompted the authors to try and address

What is the question that this study is trying to answer and what prompted the authors to try and address this question?

  Implement the sieve of eratosthenes

Implement the Sieve of Eratosthenes and use it to find all prime numbers less than or equal to one million. Use the result to prove Goldbach's Conjecture for all even integers between four and one million, inclusive.

  Construction of the data dictionary

A first systematic step to a data science process, as we have learned from the lectures and practical sessions, is to construct a data dictionary for the dataset.

  Displays the charges for a patients hospital stay

Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask patient name and if the patient was admitted as an in-patient or an out-patient.

  Design a prgram using python

Design a prgram USING PYTHON that students can use to calculate what score they need on final exam to get a certan final grade for a course.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Write a non-fruitful function drawequitriangle

Write a non-fruitful function drawEquitriangle(someturtle, somesize) which calls drawPoly from the previous question to have its turtle draw a equilateral triangle

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd