codescracker


python

Python Basic Syntax



« Previous Tutorial Next Tutorial »


Here, you will learn about basic syntax of a python program. Basic syntax of a python program is too simple than other languages. Let's take an example, here the following program prints "Hello Python, I am Python Basic Syntax" as output:

# Python Basic Syntax - Example Program
print("Hello Python, I am Python Basic Syntax");

Here is the sample output of the above Python program:

python basic syntax

As you can see from the above Python program, there is only one statement required to print the string "Hello Python, I am Python Basic Syntax".

Let's take another example demonstrating basic syntax of Python language.

print("This is,\nPython basic syntax\nExample");
print("You will learn all about Python");

If you run the above example, then below is the output, you will see on your output screen.

python basic syntax example

As you can see from the above output, \n is used to break the line.

Read User Input from Keyboard in Python

You can use input() function to read input from the keyboard in python. Here is an example program, demonstrating, how to get and read input from user in python:

# Python Basic Syntax - Example Program

strn = input("Enter your name: ")

print("You name is ", strn);

Here is the sample run of the above python program:

python read user input

More Examples

Here are list of some more examples, you may like:


« Previous Tutorial Next Tutorial »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test