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.
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 ‘_’
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...
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)...
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.
Write a Python program that calls a function to sum all the numbers in a list...
Write a Python program that calls a function to sum all the numbers in a list and returns the result to the caller. The main program creates a list (with hard-coded or user input) and passes the list as an argument to the function. You may not use the built-in function, sum. The program calls a second function to multiply all the numbers in a list passed to it by main and returns the product back to the caller. List...
code in python I want to make a function that adds all the multipliers together. The...
code in python I want to make a function that adds all the multipliers together. The code is posted below and please look at wanted output section to see what I want the code to output. The last line of the code is the only addition I need. Thanks. Code: initial=int(input("Initial value : "))       #taking inputs multiplier=float(input("Multiplier : ")) compound=int(input("No of compounds : ")) print("Your values are:") mult=initial                         #initalizing to find answer for i in range(0,compound):         #multiplying by multiplier    ...
Python: How would I write a function that takes a directory and a size in bytes,...
Python: How would I write a function that takes a directory and a size in bytes, and returns a list of files in the directory or below that are larger than the size. For example, I can use this function to look for files larger than 1 Meg below my Home directory.
Python: How would I write a function that takes a URL of a webpage and finds...
Python: How would I write a function that takes a URL of a webpage and finds the first link on the page? The hint given is the function should return a tuple holding two strings: the URL and the link text.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT