Programming Essentials Python - Predefined Functions - Overview Of Predefined Functions

Let us get an overview of Pre-defined Functions using Python. We will go through the details related to string manipulation, date manipulation, numeric functions, etc. All programming languages have robust pre-defined functions that are available out of the box, which we can leverage to add key functionalities required for our applications.

When working with applications, we often read data from databases, files, or through requests such as REST APIs. Once the data is retrieved, we typically process it using pre-defined functions to manipulate and analyze it. After processing the data, we may save it back to databases or files, or provide responses to requests like REST APIs.

Although Python offers thousands of pre-defined functions and libraries, let’s explore the most common ones to start with, including Numeric Functions, String Manipulation Functions, and Date Manipulation Functions.

Here are examples of user data that can be read from files:

  • CSV (Text File): ‘1,123 456 789,Scott,Tiger,1989-08-15,+1 415 891 9002,Forrest City,Texas,75063’
  • JSON: {“id”: 1, “uniq_id”: “123 456 789”, “first_name”: “Scott”, “last_name”: “Tiger”, “dob”: “1989-08-15”, “contact_no”: “+1 415 891 9002”, “city”: “Forrest City”, “state”: “Texas”, “zip”: 75063}

We also use JSON data for REST API requests and responses, which we will explore using Python functions.

[Insert the video link here]

Key Concepts Explanation

Numeric Functions

Numeric functions in Python allow us to perform operations on numbers. For example:

# Addition
result = 10 + 20
print(result) # Output: 30

# Subtraction
result = 30 - 15
print(result) # Output: 15

String Manipulation Functions

String manipulation functions help us work with text data. For example:

# Concatenation
full_name = "John" + " Doe"
print(full_name) # Output: John Doe

# String Length
name = "Alice"
length = len(name)
print(length) # Output: 5

Hands-On Tasks

  1. Perform basic arithmetic operations using numeric functions in Python.
  2. Manipulate strings by concatenating them and finding their length.

Conclusion

In this article, we explored the concept of pre-defined functions in Python. We looked at numeric functions for working with numbers and string manipulation functions for text data. By practicing the hands-on tasks, you can enhance your understanding of these functions and their practical applications. Remember to engage with the community and continue learning to expand your Python skills further.

Watch the video tutorial here