# ╔════════════════════════════════════════════════════════════════════════════════════════════════════════╗ # ║ Name: Variable Demonstration Program ║ # ║ Version: 1.0 ║ # ║ Author: M. T. Smith ║ # ║ Date: 7th July 2015 ║ # ║ ║ # ║ Description: This simple program demonstrates how to create each of the fundamental data-types in ║ # ║ Python and assignment of a value to each of them. ║ # ║ ║ # ║ ║ # ╚════════════════════════════════════════════════════════════════════════════════════════════════════════╝ # The next four lines (15 to 18) are used to create the variables and assign (set) values to each of them Name = "Dusty the Cat" # A string (text) assignment NumberOfLegs = 4 # An integer number assignment Age = 5.5 # A real number assignment Male = True # A Boolean assignment # The next four lines (22-25) are used to display the contents of the variables print("The cat is called: " + Name) # The + joins two strings print("The cat has " + format(NumberOfLegs) + " legs") # The format function converts to a string print("The cat's age is: " + format(Age)) # Using format again print("The cat is Male: " + format(Male)) # Using format again
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question