Advertisement
Python253

to_uppercase

May 23rd, 2024
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.81 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Filename: to_uppercase.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. Description:
  9.    This script converts input text to Uppercase format, where all letters are in uppercase.
  10.    The converted text is then saved to a file named "converted_uppercase.txt" in UTF-8 encoding.
  11.  
  12. Requirements:
  13.    - Python 3.x
  14.  
  15. Functions:
  16.    - to_uppercase(text): Converts input text to Uppercase format.
  17.        Parameters:
  18.            text (str): The input text to be converted.
  19.        Returns:
  20.            str: The text converted to Uppercase format.
  21.  
  22. Usage:
  23.    Run the script and provide the text you want to convert when prompted.
  24.    The converted text will be saved to "converted_uppercase.txt" in the same directory as the script.
  25.  
  26. Example Output:
  27.    Input Text: "This is a Test of Case Converting"
  28.    
  29.    Converted Text Has Been Saved To: 'converted_uppercase.txt'.
  30.    
  31.    Converted Text:
  32.            THIS IS A TEST OF CASE CONVERTING
  33. """
  34.  
  35. def to_uppercase(text):
  36.     """
  37.    Convert a given string to Uppercase format.
  38.    
  39.    Parameters:
  40.        text (str): The input string.
  41.        
  42.    Returns:
  43.        str: The Uppercase converted string.
  44.    """
  45.     return text.upper()
  46.  
  47. def main():
  48.     """
  49.    Main function to prompt user input and convert the text to Uppercase.
  50.    The converted text is saved to a file.
  51.    """
  52.     input_text = input("Enter the text you want to convert to Uppercase: ")
  53.     uppercase_text = to_uppercase(input_text)
  54.    
  55.     with open("converted_uppercase.txt", "w", encoding="utf-8") as file:
  56.         file.write(uppercase_text)
  57.    
  58.     print("\nConverted Text Has Been Saved To: 'converted_uppercase.txt'.\n")
  59.     print("Converted Text:\n")
  60.     print(f"\t\t{uppercase_text}")
  61.  
  62. if __name__ == "__main__":
  63.     main()
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement