Professional Documents
Culture Documents
UNIT - 1.
1. INTODUCTION
It is used for:
Example:
print("Hello, World!").
2
Sometimes a developer might want to take user input at some point in
the program. To do this Python provides an input() function.
Syntax:
input('prompt')
# Output
print(type(name))
Output:
Enter your name: GFG
Hello, GFG
<class 'str'>
How to Display Output in Python:
# print() method
print("GFG")
Output:
GFGG F G
In the above example, we can see that in the case of the 2nd
print statement there is a space between every letter and the
print statement always add a new line character at the end of
the string.
print(EXPRESSION)
4
that we want to display.
Examples:
>>>print (“Welcome to Python”) # It is acceptable in Python
version 3
Variables:
Creating Variables:
Example
x = 5
y = "John"
print(x)
print(y)
COMMENTS:
5
Python Comments:
Comments can be used to explain Python code.
Creating a Comment:
Example:
#This is a comment
print("Hello, World!")
Python Comments
Creating a Comment
Example
#This is a comment
print("Hello, World!").
6
5. READING INPUT FROM THE KEYBORAD:
User Input:
The following example asks for the username, and when you
entered the username, it gets printed on the screen:
Python 3.6
username = input("Enter username:")
print("Username is: " + username).
Example:
username = raw_input("Enter username:")
print("Username is: " + username).