- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 224字
- 2021-07-02 14:00:18
Writing scripts with the Python interactive console
The Python interactive console starts from >>> prefix. This console will accept the Python commands, which you'll write after >>> prefix. Refer to the following screenshot:

Now, we will see how to assign values to the variable, as in the following example:
>>> name = John
Here, we've assigned a character value of John to the name variable. We pressed Enter and received a new line with >>> prefix:
>>> name = John
Now, we will see an example of assigning values to variables and then we will perform a math operation to get the values:
>>> num1 = 5000
>>> num2 = 3500
>>> num3 = num1 + num2
>>> print (num3)
8500
>>> num4 = num3 - 2575
>>> print (num4)
5925
>>>
Here, we assigned values to variables, added two variables, stored the result in a third variable, and printed the result on to the Terminal. Next, we subtracted one variable from the result variable, and the output will get stored in the fourth variable. Then, we printed the result on to the Terminal. So this tells us that we can also use the Python interpreter as a calculator:
>>> 509 / 22
23.136363636363637
>>>
Here, we performed a division operation. We divided 509 by 22 and the result we got is 23.136363636363637.
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- Mastering Entity Framework Core 2.0
- OpenDaylight Cookbook
- 從零開始:數字圖像處理的編程基礎與應用
- 控糖控脂健康餐
- JavaScript Unlocked
- 編寫高質量代碼:改善Python程序的91個建議
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- Java 11 Cookbook
- Linux命令行與shell腳本編程大全(第4版)
- Linux操作系統基礎案例教程
- Java EE 7 Performance Tuning and Optimization
- 執劍而舞:用代碼創作藝術
- Python+Tableau數據可視化之美
- Learning Android Application Testing