Question

In: Computer Science

In python idle 3.9.0 write a function that: i) will count all lower case, upper case,...

In python idle 3.9.0 write a function that:

i) will count all lower case, upper case, integers, and special symbols from a given string. The input string is provided by the user.

ii) will check if a sting is a palindrome. User supplies the input string.

Solutions

Expert Solution

OUTPUT:

def function(string):
#initilaize values with 0
lower_case=0
upper_case=0
integers=0
special_chars=0
#special chars list
special_characters ="!@#$%^&*()-+?_=,<>/\""
for ch in string:
#if char is lower
if ch.islower():
lower_case+=1
#if char is upper
if ch.isupper():
upper_case+=1
#if it is a digit
if ch.isdigit():
integers+=1
#if it in special_characters increment special_chars
if ch in special_characters:
special_chars+=1
#print it
print(lower_case,upper_case,integers,special_chars)

s=input('Enter a string:')
function(s)

comment if any doubts


Related Solutions

Write functions in Python IDLE that do the following: i) A function that takes 2 arguments...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both.
Write a function flipSwitches that accepts one argument, a sequence of upper or lower case letters...
Write a function flipSwitches that accepts one argument, a sequence of upper or lower case letters (the sequence can either be a str or a list, if you write your code correctly, it shouldn’t matter). This is a sequence of switches, uppercase means to turn a switch on, and lowercase to turn a switch off.   For example, ‘A’ means to turn the switch ‘A’ on, and ‘a’ means to turn the switch ‘A’ off.   (Turning an on switch on again,...
In a c programming Write a program that converts upper case letters to lower case letters...
In a c programming Write a program that converts upper case letters to lower case letters or vice versa: Enter a sentence: What a GREAT movie is! Converted sentence: wHAT_A_great_MOVIE_IS_ Convert all non-alphabetical letters to ‘_’
Write for Python IDLE 3.8.5 Write functions: i) One that prompts a user for 2 numbers....
Write for Python IDLE 3.8.5 Write functions: i) One that prompts a user for 2 numbers. ii) Adds the two numbers if they are even iii) Multiplies the two numbers if they are odd iv) Displays the appropriate output to the user You are writing 4 functions and calling them to test functionality.
Python 2. Please ensure you run the tests in idle Write a function orderPizza that allows...
Python 2. Please ensure you run the tests in idle Write a function orderPizza that allows the user input to build a pizza. It then prints a thank you message, the cost of the pizza and then returns the Pizza that was built. >>> orderPizza() Welcome to Python Pizza! What size pizza would you like (S,M,L): M Type topping to add (or Enter to quit): mushroom Type topping to add (or Enter to quit): onion Type topping to add (or...
Write a function divisibleBy3 with 2 positive integer inputs, a lower bound and an upper bound....
Write a function divisibleBy3 with 2 positive integer inputs, a lower bound and an upper bound. Generate a list of integers from the lower bound to the upper bound and determine how many numbers in the list have a remainder equal to zero when dividing by 3. Hint: Use a loop and the MATLAB built-in function rem to calculate the remainder after division. The remainder of N divided by P is rem(N,P).
Please use python and run in IDLE Question 1 Write functions that do the following: i)...
Please use python and run in IDLE Question 1 Write functions that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both. Question 2 Write functions: i) One that prompts a user for 2 numbers. ii)...
I am trying to write a python code to create a function that returns all possible...
I am trying to write a python code to create a function that returns all possible dimensions (reshaping) for an input matrix, can someone explains the math and write a python code with explaining all the steps and give me a test cases, and please explain if there is more than one approach. so if we have 1*8 matrix we should return 1*8, 2*4,4*2,8*1 def reshaping(M) should return a n ORDERED list AND the all possible reshaped matrices
Find the upper and lower sums for the region bounded by the graph of the function...
Find the upper and lower sums for the region bounded by the graph of the function and the x-axis on the given interval. Leave your answer in terms of n, the number of subintervals. f(x) = 7x2    [0, 3]
Write a program in JAVA that prompts the user for a lower bound and an upper...
Write a program in JAVA that prompts the user for a lower bound and an upper bound. Use a loop to output all of the even integers within the range inputted by the user on a single line.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT