Skip to content

Commit e4c172c

Browse files
authored
Merge pull request #412 from realpython/ipython-console
Ipython console materials
2 parents 9b63e6f + e18354d commit e4c172c

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

ipython-console/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code Snippets and IPython Cheat Sheet
2+
3+
This folder contains code resources and an IPython magic command cheat sheet based on the content of the Real Python tutorial [Unlock IPython's Magical Toolbox for Your Coding Journey](https://realpython.com/ipython-interactive-python-shell/).

ipython-console/employee.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
first_name = "Han"
2+
last_name = "Solo"
3+
department = "Accounts"
4+
salary = 1000
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import IPython
2+
3+
first_name = "Han"
4+
last_name = "Solo"
5+
department = "Accounts"
6+
print(f"{first_name} {last_name}")
7+
8+
IPython.embed()
9+
10+
salary = 1000

ipython-console/increment.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def salary_increment(salary):
2+
"""Calculate the new salary after applying an increment.
3+
4+
Args:
5+
salary (int): The current salary.
6+
7+
Returns:
8+
str: A string indicating the new salary after increment.
9+
"""
10+
increment = salary / 10
11+
new_salary = increment + salary
12+
return f"Your New Salary is: {new_salary}"
136 KB
Binary file not shown.

0 commit comments

Comments
 (0)