Programming Fundamentals/Variables/Python3: Difference between revisions

From Wikiversity
Jump to navigation Jump to search
Content deleted Content added
Creating
(No difference)

Revision as of 19:41, 20 November 2016

variables.py

print("Variables and Data Types")
i = 12345
f = 1.23456789012345
s = "string"

print("int:", i)
print("float:", f)
print("string:", s)
print()

print("Constants")
print("Python doesn't support constants.")
print()

print("Arithmetic Operators")
a = 3
b = 2
print("a =", a)
print("b =", b)
print("a + b =", a + b)
print("a - b =", a - b)
print("a * b =", a * b)
print("a / b =", a / b)
print("a**b =", a**b)
print()

print("Assignment Operators")
a += b
print("a += b is", a)
a -= b
print("a -= b is", a)
a *= b
print("a *= b is", a)
a /= b
print("a /= b is", a)
a **= b
print("a **= b is", a)
print()

print("String Concatenation")
s1 = "Hello"
s2 = "world"
print(s1 + " " + s2 + "!")
print()

print("User Input")
name = input("What is your name? ")
print("Hello " + name + "!")

Try It

Copy and paste the code above into one of the following free online development environments or use your own Python3 compiler / interpreter / IDE.

See Also