Ask the user to input from the keyboard a positive non-zero

Assignment Help Python Programming
Reference no: EM132356908

Assignment

Purpose:

To allow you to exercise with a logical thinking process to formulate algorithms, and to implement the algorithms using the Python Programming Language. The logic will include simple inputs and outputs, looping, using counters, conditional statements (if and else), and basic functions. This is an individual assignment.

Questions:

Write a separate Python program for each of the following:

a. Ask the user to input from the keyboard a positive non-zero number. You are to validate that the input is indeed as expected. Each time the user inputs an invalid input, you will give them an error message, and ask them to input another value. Impose a limit of three wrong attempts for the inputs, after which you quit the program. Any number starting with the +sign is also accepted. Decimal numbers cannot start with `.1, and cannot end with `.1. If the three wrong attempts have been exhausted, print to the screen a message indicating that, otherwise print correct input.

To validate the input, you must create a function for this problem called isValid(x) that takes a number x, and returns a true or false indicating whether the number x is valid or not.

b. Ask the user to input from the keyboard a string composed of the characters a, b, or c. Your input is case sensitive (a's are different than A's as an example). However, the user may decide to input a string with invalid characters. Your program will output to the screen the number of a's in the string, the number of b's, the number of c's, as well as the number of all other invalid characters (non a, b, or c). This means that you will not prohibit the user from inputting a string composed of other characters also.

c. The objective is for you to print all the numbers divisible by a number n in the range [start, end]. You are to ask the user to input through from the keyboard integer numbers (+ and - signs are accepted before the number):

i. A variable start to indicate the start of the range.

ii. A variable end to indicate the end of the range, and

iii. A variable n to indicate the number to check divisibility for.

For example, if the user inputs 1000 for start, 3500 for end, and 5, your program will print all the numbers divisible by 5 in [1000,3500]. You
must validate that start, end, n are valid integers. If an input is invalid, you need to keep on asking the user for a valid input without any limitation on how many times this can happen.

d. Let the user input ten numbers from the keyboard, and find and print their maximum. (Hint: use a loop, start by assuming maximum to be the first one that is input. Each time you find a number greater than max, make it the max, then at the end, print it out). You cannot use the max function in Python for this exercise. You cannot sort either. Assume that the input is proper (no need for validation).

e. Input five numbers from the keyboard, compute and print their standard deviation. The standard deviation is given as:

σ = √(1/N ΣNi=1(xi-μ)2)

To compute the standard deviation, you are to:

i. Compute the average of the five numbers.

ii. Subtract the average from each number, then square the result, call this quantity the square of the difference.

iii. Sum up all of the square of the differences.

iv. Divide the square of the differences by 5.

v. Compute the square root of the value in (iv).

vi. Print the result.

Make sure each of the above steps is performed properly before you proceed with the next one. Assume that the numbers are all valid (no
need for validation).

Reference no: EM132356908

Questions Cloud

Discuss the impact of each technology on your industry : ITECH3214/6214 - Emerging Technologies In Business Assignment - Report & Presentation, Federation University Australia. Discuss the impact of each technology
Determine what is most important in the essay : Determine what is most important in the essay you selected and summarize the main argument and Convert brainstorming ideas into a workable outline as part
What does holden notice about dick slagle suitcases : ENG 132-Why isn't Holden at the football game with everyone else? What does Holden notice about Dick Slagle's suitcases? Why do you think he points this out?
Identify the process in organization : Identify the process in an organization, discusses current practices used to put people through, assess service member's needs,
Ask the user to input from the keyboard a positive non-zero : ITI1120D-Ask the user to input from the keyboard a positive non-zero number. You are to validate that the input is indeed as expected.
Processes better when it comes to organizing to learn : What can we learn from them and apply to our concern to make the processes better when it comes to Organizing to Learn.
The lens of selected developmental theory : Create a summary of the developmental stage as viewed through the lens of a selected developmental theory.
Context of a business organization : Define what is meant by an "organization" in the context of a business organization and the role of the manager in an organization.
Where might you use modeling in the future : In the last weeks of the class, we are going to write a reflection activity. If you have not watched the introduction video for this week, please make sure.

Reviews

Write a Review

Python Programming Questions & Answers

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Implement a battleship game in python

Assignment Summary: Battleship is a children's game where players guess (x,y) coordinate positions of the opposing player's ship pieces in a 10x10 grid. For the official Hasbro rules and additional game context, read http://www.hasbro.com/common/i..

  How do you make a function that prompt the user to enter

How do you make a function that prompt the user to enter two sentences. Then it will print a combined sentence, consisting of alternating words.

  Write a function that works exactly like pythons random

Write a function random_cho ice that works exactly like Python's random. choice function: it takes a list as an argument and returns one of it's elements.

  Develop an employee class that keeps data attributes

Develop an Employee class that keeps data attributes for the following pieces of information: Employee name and Employee number.

  Convert between temperatures in fahrenheit

Write a Python application that allows the user to convert between temperatures in fahrenheit and temperatures in celsius.

  Write a program that prompt the user to enter five numbers

Write a program that prompt the user to enter five positive numbers and calculate the average. When a negative number is entered, program will be terminated.

  Explain the relationship between objects and references

Explain the relationship between objects, references, and aliasing. Also You need to make 3 examples examples with Python lists.

  Write program that will extract the web addresses

write a program that will take this database file and extract the Web addresses that the user visited, the number of times the page was visited and the last

  Design reusable parameterised functions

create multiple icon styles that can be drawn at different sizes, it would be very repetitive if you tried to code the whole solution using ‘brute force.' Instead you are strongly encouraged to design reusable parameterised functions to draw the i..

  Calculate and print bills for the city power company

Write program that will calculate and print bills for the city power company. The rates vary depending on whether the use is residential, commercial

  Write a python program that prompts the user to enter

Write a Python program that prompts the user to enter an integer and reports whether the input was even or odd.The program must use a while loop.

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