Technology Software

How to Use the Numeric Variable in Python Script

    • 1). Open the IDLE text editor in "Program Files" (or "Applications" for Macintosh), in the Python directory. A blank source code file opens.

    • 2). Declare a variable named x and assign it the value 1. Because the value 1 has no decimal part, it becomes an integer data type. The code looks like this:

      x = 1

    • 3). Declare a variable named y and assign it the value 1.00. This value has a decimal component, and therefore it will be assigned the floating point data type. The code looks like this:

      x = 1.00

    • 4). Declare a variable named z and assign it the value 1 + 0j. Because this number has an imaginary component, the variable z is automatically created using a complex numeric type. The code looks like this:

      z = 1 + 0j

    • 5). Print out the types of variables x, y and z by writing the following three lines of code:

      print(type(x))

      print(type(y))

      print(type(z))

    • 6). Execute the script by pressing "F5." The program output looks like this:

      <class 'int'>

      <class 'float'>

      <class 'complex'>

SHARE
RELATED POSTS on "Technology"
How Do I Print Business Cards With Microsoft Publisher?
How Do I Print Business Cards With Microsoft Publisher?
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
Features and Benefits of Project Portfolio Management
Features and Benefits of Project Portfolio Management
Fix Registry - Fix Registry Errors Easily
Fix Registry - Fix Registry Errors Easily
Business Intelligence Solutions and Services
Business Intelligence Solutions and Services
AutoCAD Architecture
AutoCAD Architecture
Best Social Networking Apps
Best Social Networking Apps
IKE
IKE
Help Desk Software by help-desk-software
Help Desk Software by help-desk-software
What's Better - Building a BPM Solution Or Buying One?
What's Better - Building a BPM Solution Or Buying One?
How to Make Music Fade out in Moviemaker
How to Make Music Fade out in Moviemaker
How to Shrink a DVD With Nero Instructions
How to Shrink a DVD With Nero Instructions
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
How to Stop Rootkits
How to Stop Rootkits
3 First-Rate Foundations for Making Movies
3 First-Rate Foundations for Making Movies
How to Build Game Downloads
How to Build Game Downloads
The Linux Modem How-To
The Linux Modem How-To
Text-Terminals on Linux - 11.6 Terminal Server Connection
Text-Terminals on Linux - 11.6 Terminal Server Connection
The Linux Loadable Kernel Module How-To
The Linux Loadable Kernel Module How-To
How to Create Photo Albums With CSS
How to Create Photo Albums With CSS

Leave Your Reply

*