complete the following program
instructions:
1. Complete the function asn4_1(): accept two parameters—a string and an integer. Print the first character from the string; after that, print every nth character. If the string is “abcdefghijklmn” and the integer is 3, asn4_3() should print “adgjm”. Use a loop—do not use string slicing.
2. Complete the function asn4_2(): given a name, return an acronym. For example, if the user enters James Tiberius Kirk, asn4_2() should return JTK. While the expectation is for the user to enter a name, the algorithm should return the first character of each word in the string – you can assume that words are separated by spaces (but the acronym should have no spaces). This function should return the acronym – it should not print it.
3. Complete the function asn4_3(): given a string, return (don’t print) the number of characters in the string that are NOT digits.
4. Complete the function asn4_4(): given a string, extract all the upper-case characters in the string and make a new string from them. Return (don’t print) the new string that has only the upper-case characters.
def asn4_1(s, n):
'''Use a loop to print the first character in string s; after that, print every nth character '''
pass #You can take this out or leave it; either way is ok
asn4_2(s):
''' Return the first character of every word in s (words are separated by spaces) '''
pass
def asn4_3(s):
''' Return the number of characters in s that are NOT digits '''
pass #You can take this out or leave it; either way is ok
def asn4_4(s):
'''Return a string consisting of all the upper case characters from s'''
#Create a new string and set it to empty string
#For each character in s
# If the character is upper case
# Add it to the new string
#Return the new string
pass #You can take this out or leave it; either way is ok
def main():
''' Don't change anything below this point. But you can comment out some of these statements if one of your functions is crashing your program. '''
s = input("Please enter a string for ans4_1: ")
asn4_1(s, 3)
s = input("Please enter a string for asn4_2: ")
print(asn4_2(s))
s = input("Please enter a string for asn4_3: ")
print(asn4_3(s))
s = input("Please enter a string for asn4_4: ")
print(asn4_4(s))
main() #Start execution
Python 3 code
============================================================================================
def asn4_1(s, n):
'''Use a loop to print the first character in string s; after that,
print every nth character '''
print(s[0],end="")
for i in range(n,len(s),n):
print(s[i],end="")
print()
def asn4_2(s):
''' Return the first character of every word in s (words are
separated by spaces) '''
words = s.split()
letters = [word[0] for word in words]
str1="".join(letters)
return str1
def asn4_3(s):
''' Return the number of characters in s that are NOT digits
'''
count=0
for i in range(0,len(s)):
if s[i].isalpha():
count=count+1
return count
def asn4_4(s):
'''Return a string consisting of all the upper case characters from
s'''
#Create a new string and set it to empty string
newstr=""
#For each character in s
for char in s:
if char.isupper():
newstr=newstr+char
return newstr
def main():
''' Don't change anything below this point. But you can comment out
some of these statements if one of your functions is crashing your
program. '''
s = input("Please enter a string for ans4_1: ")
asn4_1(s, 3)
s = input("Please enter a string for asn4_2: ")
print(asn4_2(s))
s = input("Please enter a string for asn4_3: ")
print(asn4_3(s))
s = input("Please enter a string for asn4_4: ")
print(asn4_4(s))
main() #Start execution
============================================================================================
Output

complete the following program instructions: 1. Complete the function asn4_1(): accept two parameters—a string and an...