Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rearrange _ vowels string to be iterated through (str) string starting with all

ID: 3883353 • Letter: R

Question

Rearrange _ vowels string to be iterated through (str) string starting with all of the vowels of the original string, and ending with all of the consonants of the original string (str) Write a function that takes in a string and separates all of the vowels from the consonants, and creates a new string made from the separated portions The ordering of the vowels and consonants should be the same order that they are present in the string. Capitalization should also be preserved. Any spaces present in the original string should be ignored and not added to the final output. You must use a for loop in the function to receive full credit. > > > rearrange_vowels("hello") rightarrow "eohll" > > > rearrange., vowels ("Oklahoma-) rightarrow "Oaoaklhm" > > > rearrange_vowels ("Computer Science") rightarrow "oueieeCmptrScnc" censor string to censor (str) censored string (str) You are working at a children's television network, and your job is to censor any words that could potentially be inappropriate. In order to do this, you have to replace certain letters with symbols. You must use a for loop in this function to receive full credit. The rules for censorship or as follows: "a" or "A" rightarrow "!" "u" or "U" rightarrow " " "i" or "I" rightarrow " " "e" or "E" rightarrow " " > > > censor("what the heck!") rightarrow "wh!t the h#ck" > > > censor('You smell bad") rightarrow "Yo" small b!d" > > > censor("I love CS!") rightarrow "@ lov# CS!"

Explanation / Answer

//rearrange_vowels

def rearrange_vowels(str):
v=""
vowels='aeiouAEIOU'
cons='qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNM'
c=""
for i in str:
if i in vowels:
v=v+i
elif i in cons:
c=c+i
s = v+c
print (s)
  

//censor

def censor(str):
a1='aA'
a2='uU'
a3='iI'
a4='eE'
st = str
for i in str:
if i in a1:
st = st.replace(i,'!')
elif i in a2:
st = st.replace(i,'*')
elif i in a3:
st = st.replace(i,'@')
elif i in a4:
st = st.replace(i,'#')
print(st)