0/5
## Python Shell / Console We can try out code in Python using the Python shell or console. To do this, we type: ```bash python3.11 ``` This will open the Python shell. The shell allows us to write any code we want and have it executed immediately. For example, to print the string "hi", we would type: ```python print("hi") ``` The shell will immediately respond: ``` hi ``` We can also assign values to variables. For example, to assign the value 7 to the variable my_var, we would type: ```python my_var = 7 ``` The shell will not respond to this, since we have only assigned the value. We can then print the variable value by typing: ```python print(my_var) ``` The shell will respond with the value: ``` 7 ``` If we type quit and hit enter, we will exit the shell and return to the terminal. To reenter the Python shell, we would have to type: ```bash python3.11 ``` again. If we try to print the variable my_var without assigning it a value, we will get an error: ```python print(my_var) ``` The shell will respond with: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'my_var' is not defined ``` This error occurs because variables assigned in the shell are not saved when we exit the shell.
A quick guide to entering and exiting the Python shell. The lesson covers how to enter the Python shell, define a variable, and exit the shell. It also emphasizes the importance of understanding the ephemeral nature of the Python shell and that it does not save the user's input upon exiting.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on January 14, 2025
Duration: 2h 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on January 14, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar