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.git
2cd funstrings
3pip install -e .

Basic Usage

Here's a simple example of how to use FunStrings:

python
1import funstrings
2
3# Reverse a string
4text = "Hello, World!"
5reversed_text = funstrings.reverse_string(text)
6print(reversed_text) # Output: "!dlroW ,olleH"
7
8# Count vowels and consonants
9vowels = funstrings.count_vowels(text)
10consonants = funstrings.count_consonants(text)
11print(f"Vowels: {vowels}, Consonants: {consonants}") # Output: "Vowels: 3, Consonants: 7"
12
13# Check if a string is a palindrome
14is_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 string
  • count_vowels(s): Counts vowels in a string
  • count_consonants(s): Counts consonants in a string
  • is_palindrome(s): Checks if a string is a palindrome
  • to_upper(s): Converts a string to uppercase
  • to_lower(s): Converts a string to lowercase
  • word_count(s): Counts words in a string
  • sort_characters(s, reverse=False): Sorts characters in a string
  • remove_whitespace(s): Removes whitespace from a string

Text Analysis Functions

  • get_word_frequencies(s): Return frequency count of each word
  • longest_word(s): Find the longest word in the text
  • shortest_word(s): Find the shortest word in the text
  • average_word_length(s): Calculate average word length
  • is_pangram(s): Check if text contains all alphabet letters
  • unique_words(s): Return list of unique words
  • most_common_word(s): Return most frequent word
  • sentence_count(s): Number of sentences in text
  • average_sentence_length(s): Average words per sentence
  • character_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:

  1. Start with simple examples: Try each function with simple inputs first
  2. Experiment: Change the examples and see what happens
  3. Read the code: Look at the implementation to understand how it works
  4. 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.