Getting Started with FunStrings
This guide will help you get started with the FunStrings package. It's designed to be beginner-friendly and educational.
Installation
You can install FunStrings using pip:
bash
pip install funstrings
Or install directly from the source code:
bash
1git clone https://github.com/nilkanth02/funstrings.git2cd funstrings3pip install -e .
Basic Usage
Here's a simple example of how to use FunStrings:
python
1import funstrings23# Reverse a string4text = "Hello, World!"5reversed_text = funstrings.reverse_string(text)6print(reversed_text) # Output: "!dlroW ,olleH"78# Count vowels and consonants9vowels = funstrings.count_vowels(text)10consonants = funstrings.count_consonants(text)11print(f"Vowels: {vowels}, Consonants: {consonants}") # Output: "Vowels: 3, Consonants: 7"1213# Check if a string is a palindrome14is_pal = funstrings.is_palindrome("A man, a plan, a canal: Panama")15print(is_pal) # Output: True
Available Functions
FunStrings provides 44 utility functions organized into eight categories:
Basic String Operations
reverse_string(s)
: Reverses a stringcount_vowels(s)
: Counts vowels in a stringcount_consonants(s)
: Counts consonants in a stringis_palindrome(s)
: Checks if a string is a palindrometo_upper(s)
: Converts a string to uppercaseto_lower(s)
: Converts a string to lowercaseword_count(s)
: Counts words in a stringsort_characters(s, reverse=False)
: Sorts characters in a stringremove_whitespace(s)
: Removes whitespace from a string
Text Analysis Functions
get_word_frequencies(s)
: Return frequency count of each wordlongest_word(s)
: Find the longest word in the textshortest_word(s)
: Find the shortest word in the textaverage_word_length(s)
: Calculate average word lengthis_pangram(s)
: Check if text contains all alphabet lettersunique_words(s)
: Return list of unique wordsmost_common_word(s)
: Return most frequent wordsentence_count(s)
: Number of sentences in textaverage_sentence_length(s)
: Average words per sentencecharacter_ratio(s)
: Uppercase/lowercase/number ratio
For a complete list of functions, see the API Reference.
For Students and Beginners
If you're new to Python or programming in general, here are some tips:
- Start with simple examples: Try each function with simple inputs first
- Experiment: Change the examples and see what happens
- Read the code: Look at the implementation to understand how it works
- Build something: Use these functions to build a simple text processing tool
Next Steps
Examples
Check out the examples for practical applications.
API Reference
Read the API documentation for detailed function descriptions.
Playground
Try the playground to test functions interactively.