Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

1) Make Python program that counts the number of odd numbers, even numbers, squares of an integer and cubes of an integer from 2 to 130 (inclusive)

Computer Science Apr 08, 2022

1) Make Python program that counts the number of odd numbers, even numbers, squares of an integer and cubes of an integer from 2 to 130 (inclusive). For example, 9 is both odd and a square, 8 is even and a cube.

Use constants to set the beginning and ending of the range.

For output, print a title with the total range.

For Odd and Even, print the totals and the range of the numbers in scope.

For Squares and Cubes, print the totals and a list of the numbers that meet the criteria

Nothing printed should be hard coded.

 

Example of Output:

Checking numbers from 2 to 130

Odd (64): 3...129

Even (65): 2...130

Square (10): [4, 9, 16, 25, 36, 49, 64, 81, 100, 121]

Cube (3): [8, 27, 125]

 

2.    Set a constant with an odd length string.

Confirm in code that the string is of an odd length. Otherwise, print a relevant message for the user and end the program.

For a string of odd length, print each of the following in double quotes:

·     Print the entire string and its length.

·     Print the middle character.

·     Print the string up to but not including the middle character.

·     Print the string from immediately following the middle character to the end.

 

Example of Output:

My 27 character string is: "A man a plan a canal Panama"

The middle character is: "a"

The 1st half of string is: "A man a plan "

The 2nd half of string is: " canal Panama"

 

3) Write a program that prompts the user for a sentence and calculates the number of uppercase letters, lowercase letters, digits, and punctuation. Output the results neatly formatted and labeled in columns.

 

Example of Output:

# Upper  # Lower  # Digits # Punct.

-------- -------- -------- --------

  2        36       4        5   

Expert Solution

For detailed step-by-step solution, place custom order now.
Need this Answer?

This solution is not in the archive yet. Hire an expert to solve it for you.

Get a Quote
Secure Payment