Please answer each question separately and write a new program for each required question. 1. Write pseudocode for a program that repeatedly prompts the user to enter a number or "x" to end. Upon...

1 answer below »
Please see file


Please answer each question separately and write a new program for each required question. 1. Write pseudocode for a program that repeatedly prompts the user to enter a number or "x" to end.  Upon entering "x", the program displays the sum (total) of the numbers. 2. Write Python code that uses the following variable/data to print the desired output. Your solution should involve looping through the data so that it would display appropriate output regardless of how many items are in the list. For your convenience, the following line contains the data in a form that you can copy and paste: data = [{'name': 'Adam', 'age': 57}, {'name': 'Betty', 'age': 21}, {'name': 'Carlos', 'age': 42}] 3. Write pseudocode (2 marks) and Python code (3 marks) for a function named "random_list". The function should receive 3 parameters: · "length", an integer · "minimum", an integer · "maximum", an integer You may assume that the parameter values are of the expected type – you do not need to check that they are integers or convert them to integers. If "length" is smaller than 1 or if "minimum" is bigger than "maximum", the function should return the boolean value of False.  Otherwise, the function should return a list of "length" random integers between "minimum" and "maximum". Examples: random_list(5, 2, 8) should return a list of 5 random numbers between 2 and 8, such as [4, 8, 4, 5, 2] random_list(2, 1, 5) should return a list of 2 random numbers between 1 and 5, such as [2, 1] random_list(0, 1, 5) should return False, since "length" is less than 1 random_list(2, 5, 1) should return False, since "minimum" is larger than "maximum" 4. Write pseudocode (2 marks) and Python code (5 marks) for a function named "count_chars". The function should receive 1 parameter: · "text", a string You may assume that the parameter value is of the expected type – you do not need to check that it is a string or convert it to a string. The function's purpose is to count occurrences of different types of characters in "text" and return the information as a dictionary.  The function must determine how many of the following types of characters are in "text": · Letters (lowercase and uppercase) · Numbers (i.e. the digits 0-9) · Spaces · Other characters (anything that is not a letter, number or space) The function must return the four totals in a dictionary with keys of "letters", "numbers", "spaces" and "others". Examples: count_chars('Abc123') should return {'letters': 3,  'numbers': 3,  'spaces': 0, 'others': 0} count_chars('Hello, world!') should return {'letters': 10,  'numbers': 0,  'spaces': 1, 'others': 2} count_chars('') should return {'letters': 0,  'numbers': 0,  'spaces': 0, 'others': 0} 5. Write a Python program (8 marks) that implements the following requirements: · Prompt the user to enter their name, age and email address. · Make sure that: · The name is at least one character long. · The age is an integer (use exception handling for this) and at least 18. · The email address contains a "@" character. · If any of the criteria is not met, print “Invalid Data”. · Otherwise, if all of the criteria is met: · Store the three details in a dictionary using keys of "name", "age" and "email". Make sure that the age is stored as an integer. · Write the dictionary to a file named "info.txt" in JSON format. · Print "Data Saved".
Answered Same DayJun 21, 2021

Answer To: Please answer each question separately and write a new program for each required question. 1. Write...

Neha answered on Jun 22 2021
136 Votes
1. Declare a list
Start a while loop
Ask the user to enter the number
Add all the elements in th
e list
Break while loop if user enters x
Print the sum
2. Prompt user to enter length
Prompt user to enter minimum number
Prompt user to enter maximum number
Create a method and pass length minimum and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here