Python (Primary Commands)

Python (Primary Commands)

ยท

1 min read

Is python hard ? No, not at all. You just need to know where to ask print("Help"). Today, we are going to learn some basic python commands which are going to help you start your Python ๐Ÿ journey

Print()

The print command is used to output text to the user.

print("Text to display")

Input()

This command is used to take input from the user.

input("Input message")

int() and float()

The int() command changes the data type from default string to integer while float() changes it to a floating value (decimal)

a = "1"
b = float(a)
print(b)

The above code should give a output of 1.0

if(): ... elif(): ... else:

The above commands are part of the conditional structure of python. If is the command that is first ran then elif and then else at last.

Note: elif can be used multiple times

if(condition 1):
  # Code to run if the condition is true
elif(condition 2):
  # This code will run when the condition 1 is false and condition 2 is true
else:
  # This code will run when all the other conditions are false

This is it for today's blog. If you liked it tell me in the comments and see you soon :)

ย