SpongeBob Mocking Text Generator - Python Last Updated : 10 Mar, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report SpongeBob mocking text (spongemock) is a style of writing in which the alphabets are randomly written in upper and lower case. It is used in internet communities to mock something. The text originated as a meme from the SpongeBob cartoon series.Examples : Input : The quick brown fox jumps over the lazy dog. Output : tHE QuiCK BrOWN fOX juMps over tHe lAzY dOG. Input : This sentence is to test the function. Output : This seNtENce is TO TeST THE funcTiON. Algorithm : Process the input string by character.Check if the character is an alphabet by using isalpha() method.Use random.random() method to generate a random number between 0 and 1.If the number generated is greater than 0.5 then change the character to upper case using upper() method.If the number generated is less than or equal to 0.5 then change the character to lower case using lower() method. Python3 # import the random library import random # Function to convert into spongemock def spongemock(input_text): # variable declaration for the output text output_text = "" # check the cases for every individual character for char in input_text: # check if the character is an alphabet if char.isalpha(): # convert to upper case if random.random() > 0.5: output_text += char.upper() # convert to lower case else: output_text += char.lower() # if character is not and alphabet # add it as it is else: output_text += char # return the output_text return output_text # Driver code if __name__=="__main__": input_text1 = "The quick brown fox jumps over the lazy dog." input_text2 = "This sentence is to test the function." print(spongemock(input_text1)) print(spongemock(input_text2)) Output : tHe qUICk BrOWn fox jUMPs oVEr thE lAZy dOG. THIS seNTEncE IS tO TesT tHe FuNcTIOn. The above code generates the text with equal amount if lower and upper case characters. If we want to skew the balance to favour one side we can switch the random.random() method with random.triangular() method. Python3 # import the random library import random def skewupper(): low = 0 high = 100 mode = 80 return random.triangular(low, high, mode) def skewlower(): low = 0 high = 100 mode = 20 return random.triangular(low, high, mode) # Function to convert into spongemock # with more upper case characters def spongemockupper(input_text): output_text = "" for char in input_text: if char.isalpha(): if skewupper() > 50: output_text += char.upper() else: output_text += char.lower() else: output_text += char return output_text # Function to convert into spongemock # with more lower case characters def spongemocklower(input_text): output_text = "" for char in input_text: if char.isalpha(): if skewlower() > 50: output_text += char.upper() else: output_text += char.lower() else: output_text += char return output_text # Driver code if __name__=="__main__": input_text1 = "The quick brown fox jumps over the lazy dog." print("Spongemock text with more upper case characters :\n" + spongemockupper(input_text1)) print("\nSpongemock text with more lower case characters :\n" + spongemocklower(input_text1)) Output : Spongemock text with more upper case characters : ThE qUICK BROwN FOX jUMPs OVeR THE lazy DoG. Spongemock text with more lower case characters : The qUick BrOwn fOX JuMPs oveR the LaZy DOg. Comment More infoAdvertise with us Next Article How to generate a random letter in Python? Y Yash_R Follow Improve Article Tags : Python Python Programs Practice Tags : python Similar Reads Convert Generator Object To String Python Generator objects in Python are powerful tools for lazy evaluation, allowing efficient memory usage. However, there are situations where it becomes necessary to convert a generator object to a string for further processing or display. In this article, we'll explore four different methods to achieve 3 min read How to generate a random letter in Python? In this article, let's discuss how to generate a random letter. Python provides rich module support and some of these modules can help us to generate random numbers and letters. There are multiple ways we can do that using various Python modules. Generate a random letter using a string and a random 1 min read Using Espeak With Os In Python One such tool is eSpeak, a compact open-source TTS synthesizer capable of converting text into spoken words across multiple platforms. When combined with the OS module in Python, eSpeak becomes even more versatile, allowing developers to integrate speech synthesis seamlessly into their applications. 3 min read How to copy a string in Python Creating a copy of a string is useful when we need a duplicate of a string to work with while keeping the original string intact, strings in Python are immutable which means they can't be altered after creation, so creating a copy sometimes becomes a necessity for specific use cases.Using SlicingSli 2 min read Python - Generate Random String of given Length Generating random strings is a common requirement for tasks like creating unique identifiers, random passwords, or testing data. Python provides several efficient ways to generate random strings of a specified length. Below, weâll explore these methods, starting from the most efficient.Using random. 2 min read Python - Generate Random String of given Length Generating random strings is a common requirement for tasks like creating unique identifiers, random passwords, or testing data. Python provides several efficient ways to generate random strings of a specified length. Below, weâll explore these methods, starting from the most efficient.Using random. 2 min read Like