Python Fundamentals and String Methods for Data Preparation
Day 1: Python Basics for AI/ML Preparation
Output Statements
print()– Displays output to the console.end=" "– Prevents a new line after the print statement.sep=","– Specifies the character used to separate multiple items in the output.
Input and Type Casting
- The
input()function always returns a string data type. - Adding strings results in *concatenation* (e.g.,
"5" + "10" = "510"). - Use
int()orfloat()for numerical input conversion:Example:
num = int(input("Enter a number: "))
Variables and Data Types
- Common types include
int(integer),float(decimal),str(string), andbool(boolean). - Use
type(variable)to check the data type of any variable.
Formatted Strings (f-Strings)
- Used for easy string formatting and embedding variables:
Example:
print(
with a size of 5.02 KB