Respuesta :
Answer:
Following are the method to this question:
def solution(s):#defining a method solution
x=0#defining variable x that assign value 0
for i in s:#defining for loop to count string value in number
if(i.islower()):#defining if block that check input character is in lowercase
x=x+1#increment the value of x by 1
return x#return x
s=input("Enter string:")#defining s variable that input string value
print(solution(s))#defining print method to solution method
Output:
Enter string:Database is the colloection
22
Explanation:
In the given question some data is missing, that's why we define the answer as follows:
- In the above code, a solution method is defined, which takes "s" variable as the parameter, and inside the method, an integer variable "x" is defined, that holds a value that is "0".
- In the next line, for loop is declared, that counts string value without space and inside the loop, if block is defined, that checks only the lowercase character and adds the value in x variable, and returns its value.
- Outside the method s variable is defined, that inputs the string value from the user end, and use the print method to call it and print its calculated value.
The function returns a string of lowercase alphabets of length n, which is prescribed in the function. The function written in python 3 goes thus ;
import string, random
#import the string and random modules
l_case = [x for x in string.ascii_letters if x.islower()]
#use list comprehension to take a list of lower case alphabets
def n_letters(n):
#initialize a function which takes a single parameter, number of letters
lett = random.sample(l_case, n)
#take a random sample of n letters
return "".join(lett)
#use the join function to concatenate the string
print(n_letters(6))
# A sample run of the program is attached.
Learn more :https://brainly.com/question/15086326
