Function 2: In this function assume that the first parameter is a string that contains characters in A-Z and a-z only. The only functions you are allowed to use are range(), len(), chr(), ord().
YOU CAN NOT USE .upper or .lower, can only use the functions
said above.
• Examples:
◦ func2("GeorgeMason") → "GeorgeMason"
◦ func2("GeorgeMason", "upper", 2, 3) → "GeORgeMason"
◦ func2("GeorgeMason", "upper", 5) → "GeorgEMASON"
◦ func2("GeorgeMason", "lower") → "georgemason"
◦ func2("GeorgeMason", s=8, c="upper") → "GeorgeMaSON"
◦ func2("GeorgeMason", "lower", e=0) → "georgeMason"
def func2(str1):
print('func2("GeorgeMason") →',str1)
str2=""
for i in range(0,len(str1)):
if(i==2):
p=ord(str1[i])
str2=str2+chr(p-32)
elif(i==3):
p=ord(str1[i])
str2=str2+chr(p-32)
else:
str2= str2+str1[i]
print('func2("GeorgeMason", "upper", 2, 3) →',str2)
str2=""
for i in range(0,len(str1)):
if(i==5 or i>5):
p=ord(str1[i])
if(chr(p-32)>='A' and chr(p-32)<='Z'):
str2=str2+chr(p-32)
else:
str2=str2+str1[i]
else:
str2= str2+str1[i]
print( 'func2("GeorgeMason", "upper", 5) → ',str2)
str2=""
for i in range(0,len(str1)):
p=ord(str1[i])
if(p>=97 and p<=122):
str2=str2+str1[i]
else:
p=ord(str1[i])
str2=str2+chr(p+32)
print('func2("GeorgeMason", "lower") →',str2)
str2=""
for i in range(0,len(str1)):
if(i==8 or i>8):
p=ord(str1[i])
if(chr(p-32)>='A' and chr(p-32)<='Z'):
str2=str2+chr(p-32)
else:
str2=str2+str1[i]
else:
str2= str2+str1[i]
print('func2("GeorgeMason", s=8, c="upper") →',str2)
str2=""
for i in range(0,len(str1)):
p=ord(str1[i])
if(p==71):
str2=str2+chr(p+32)
else:
str2=str2+str1[i]
print('func2("GeorgeMason", "lower", e=0) →',str2)
str1="GeorgeMason"
list1=['A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v',
'w','x''y','z']
count=0
for i in str1:
if i in list1:
#print('hi')
count=count+1
if(count==len(str1)):
func2(str1)

func2 ("GeorgeMason")- GeorgeMason func2 ("GeorgeMason", "upper", 2, 3) - GeORgeMason func2 ("GeorgeMason", "upper", 5)GeorgEMASON func2 ("GeorgeMason", "lower") - georgemason func2 ("GeorgeMa son", s-8, c-"upper")-GeorgeMaSON func2( "GeorgeMason", "lower", e#0)-georgeMason
Function 2: In this function assume that the first parameter is a string that contains characters...
Define a function ValidRoom() that passes in a string parameter and returns true if the string parameter obeys all rules for a building's room address, else returns false. The rules are: (1) Must be two or three characters long. (2) First two characters must be digits, (3) If third character exists, must be a letter (upper or lowercase). Examples of strings yielding true: "65", "00", "21L". Examples of strings yielding false: "356", "7", "A23", " 65", "45AB". Recall some available...
python
Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are both type string. This function checks for the name string in the contacts string and returns that person's contact information. If the person is not found, the function returns, "name not in contact". Assume input is always valid. Assume the same name is not repeated in contacts. [You may use split(), range(), len() ONLY and no other built-in function or method] Examples: contacts =...
project-8a Write a function named count_letters that takes as a parameter a string and returns a dictionary that tabulates how many of each letter is in that string. The string can contain characters other than letters, but only the letters should be counted. The string could even be the empty string. Lower-case and upper-case versions of a letter should be part of the same count. The keys of the dictionary should be the upper-case letters. If a letter does not...
c++ Write a function Count_m_z that takes a string as an input parameter argument and counts the number of m, n, o, ... z characters in it. The function returns an integer value for the number of times those 14 lowercase letters appear in the input string. Your function should be named Count_m_z Your function should take one string parameter Your function should return the number of m, n, o, ... z characters as an integer Your function should not...
10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string object arguments. Let's call them string1, string2, and string3. It should search string for all occurrences of string2. When it finds an occurrence of Programming Challenges string2, it should replace it with string. For example, suppose the three arguments have the following values: stringt: "the dog jumped over the fence" string 2 "the" string3: "that" With these three arguments, the function would return a...
python function will Return True if string x contains 3 vowels in a row, in consecutive locations, false otherwise. assuming that 'vowels' refer to the following lowercase lttrs: a,e,i,o,u programs fails partially, only allowed to use float, str, int, appen, split, strip, len, range def vowels_three(x): for i in range (o, len(x), 2): if x[i] not in ('a,e,i,o,u'): return False return True
2) Hashing functions can be applied to string of characters. For example "amigo" and "annex" can be assigned hashing value 0, "bike" and "bureaucrat" can be assigned 1, "zebra" can be assigned value 25. So in order to find the hashing value of a word, we find the hashing value of the first letter (ht(a)=0, ht(b)=1, ht(c)=2,….,ht(z)=25). So in this case it is necessary 26 buckets. a) Give an example of another hashing function on string of characters, and determine...
Requriements:
Submit only the files requested
Print all floats to 2 decimal points unless stated
otherwise
Descripition :
For this problem you will be implementing a Caesarin Cipher. A
Caesarin Cipher takes a string and a shift amount and shift the
characters in the string by the shift amount.
Specifications:
Only characters should be ciphered
If a character is shifted beyond the end of the aphabet it
should wrap back around
For example if the letter 'y' is shifted 3...
Write a recursive function called abb pattern with a single parameter astr, which is a string. The function returns True if astr is a string of the form a nb 2n (n a-s followed by 2n b-s, where n is a positive integer) and False otherwise. For example, abb pattern("abb"), abb pattern("aabbbb"), and abb pattern("aaaabbbbbbbb") all return True, but abb pattern("") (parameter is an empty string), abb pattern("abbabb"), and abb pattern("aaabbbbb") all return False. you may not use any built-in...
Python please Write a function print_back_upper() that accepts a string my_str as an argument and displays the string backwards and in uppercase, all in one line (Note: Create any necessary variables) For example: if my_str = "Python" then, your output should display as follows: NOHTYP (Hint: You can use for loop navigating up to range of len of string-1, -1, -1 and use reverse() and upper() functions to create and display the string backwards in uppercase)