Python Basics
Python Basics
Python Basics
Here we provided the latest Python 3 version compiler where you can edit
and compile your written code directly with just one click of the RUN
Button. So test yourself with Python’s first exercises.
print("Hello World! Welcome to Python Basics")
Comments in Python
Comments in Python are the lines in the code that are ignored by the
interpreter during the execution of the program. Also, Comments enhance
the readability of the code and help the programmers to understand the
code very carefully.
# USE # for adding comments
# A floating point
salary = 1456.8
# A string
name = "John"
print(age)
print(salary)
print(name)
Output
45
1456.8
John
Example: This code assigns variable ‘x’ different values of various data
types in Python.
x = "Hello World" # string
x = 50 # integer
x = 60.5 # float
x = 3j # complex
x = ["geeks", "for", "geeks"] # list
x = ("geeks", "for", "geeks") # tuple
x = {"name": "Suraj", "age": 24} # dict
x = {"geeks", "for", "geeks"} # set
x = True # bool
x = b"Geeks" # binary
Python Input/Output
This function first takes the input from the user and converts it into a
string. The type of the returned object always will be <class ‘str’>. It does
not evaluate the expression it just returns the complete statement as
String, and will print it.
# Python program show input and Output
val = input("Enter your value: ")
print(val)