- Hands-On Penetration Testing with Python
- Furqan Khan
- 231字
- 2021-07-02 14:13:47
Numbers
Numbers, as the name suggests, covers all the numeric data types, including both integer and floating data types. Earlier in this chapter, we saw that to use an integer or a float, we can simply declare the variable and assign an integer or a float value. Now, let's write a proper Python script and explore how to use numbers. Name the script numbers.py which is shown as follows:

The preceding screenshot show a simple Python script that adds an integer with a float and then prints the sum. To run the script, we can type the python3 numbers.py command, as follows:

You might have noticed that the command at the beginning of the script says #! /usr/bin/python. What this line does is make your code executable. After the privileges of the script have changed and it has been made executable, the command says that if an attempt is made to execute this script, then we should go ahead and execute it with python3, which is placed in the /usr/bin/python3 path. This can be seen in the following example:

If we observe the print command, we can see that the string formatter is %s. To fill it in with the actual value, the second argument to the print function is passed:

To convert a string into its equivalent integer or float value, we can use the built-in int() and float() functions.
- Puppet 4 Essentials(Second Edition)
- C語言程序設計(第2版)
- Responsive Web Design with HTML5 and CSS3
- 假如C語言是我發(fā)明的:講給孩子聽的大師編程課
- Internet of Things with Intel Galileo
- Visual Basic程序設計實驗指導(第二版)
- Service Mesh實戰(zhàn):基于Linkerd和Kubernetes的微服務實踐
- 交互式程序設計(第2版)
- Learning Python Data Visualization
- Python Programming for Arduino
- Instant Automapper
- Extending Docker
- 編程風格:程序設計與系統(tǒng)構建的藝術(原書第2版)
- Spring MVC Cookbook
- 中小企業(yè)網站建設與管理(靜態(tài)篇)