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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  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.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  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.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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