Class 9: Python Administration Training – Mastering Built-in Functions: input(), eval(), and print()
We explored the powerful built-in functions in Python that are essential for every Python developer.
In Class 9, we explored the powerful built-in functions in Python that are essential for every Python developer. From taking input from users to formatting output, these functions are a must-know to write efficient and interactive Python programs!
📅 Agenda for Today:
1. input() Function 📝
Definition: The
input()function allows you to get input from the user.Syntax:
input(prompt)
Example:
name = input("Enter your name: ")
print("Hello, " + name)
Key Concepts:
Default Data Type: The
input()function returns a string by default.Type Conversion: You can convert the input to other data types like integers or floats.
age = int(input("Enter your age: "))  # Convert input to an integer
Get Multiple Inputs: Use lists or the
split()method to capture multiple values at once.
data = input("Enter numbers separated by space: ").split()
print(data)
2. eval() Function 🔍
Definition: The
eval()function parses the expression passed to it and runs Python expression within it.Example:
result = eval("3 + 4")
print(result)  # Output: 7
3. print() Function 🖨️
Definition: The
print()function is used to display output to the console.Syntax:
print(object, sep=' ', end='\n')
Example:
print("Hello, Python!")
Key Concepts:
Printing Variables: You can print variables directly.
age = 30
print(age)
Using
format()Method: Format strings in Python.
name = "Alice"
print("Hello, {}".format(name))  # Output: Hello, Alice
Concatenation with
+: Concatenate multiple strings.
print("Hello, " + name)  # Output: Hello, Alice
Repetition with
*: Repeat a string.
print("Hi " * 3)  # Output: Hi Hi Hi
Using Separator: Specify a separator between printed items.
print("apple", "banana", "cherry", sep="-")  # Output: apple-banana-cherry
Using Escape Sequences: Format text using special characters.
print("He said, \"Hello!\"")
Using Quotation Marks: You can print text with single or double quotes.
print('She said "Python is awesome!"')
💡 Stay tuned for Class 9 Recording 📹, and enhance your understanding of essential Python built-in functions like input(), eval(), and print()!



