top of page

Variables in Python

Updated: Apr 19, 2023

A value to a variable can be assigned using the = operator.



a = 10
print(a)
b = "Wow!"
print(b)
c = str(a)
print(c)
d = int(a)
print(d)
e = float(a)
print(e)

The type of the variable can be obtained using the type() method.


#Printing type
print(type(a))
print(type(b))
print(type(e))

A string can be declared using single quotes or double quotes.



#Double quotes or single quotes
f = 'Hello World'
print(f)
g = "Hello World"
print(g)


The variable names in Python are case sensitive.


#Case sensitive variable names
G = "Cool!"
print(G)

The link to the Github repository is here .

14 views

Related Posts

How to Install and Run Ollama on macOS

Ollama is a powerful tool that allows you to run large language models locally on your Mac. This guide will walk you through the steps to...

bottom of page