0% found this document useful (0 votes)
6 views2 pages

Python

The document contains Python code snippets demonstrating various programming concepts such as printing output, handling input, using comments, and performing arithmetic operations. It also includes examples of syntax errors and conditional statements. Overall, it serves as a basic tutorial for beginners learning Python programming.

Uploaded by

imranashahjad00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Python

The document contains Python code snippets demonstrating various programming concepts such as printing output, handling input, using comments, and performing arithmetic operations. It also includes examples of syntax errors and conditional statements. Overall, it serves as a basic tutorial for beginners learning Python programming.

Uploaded by

imranashahjad00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

print("Hello, world!

")
Hello, world!

print("She said, "Hello!"")


Error

print(‘She said,”Hello!” ’)
She said,”Hello!”

# For single line comment

""" triple code


Is used for
Multiple lines comment
“””

x="Shahrukh"
y=58
print(x,y)
Shahrukh 58

print(x y)
SyntaxError

name = input("Enter your name: ")


Enter your name: Azaz

print("Hello, " + name)


Hello, Azaz

#Script mode
name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello, " + name + " age")
Enter your name: Rishra
Enter your age: 40
Hello, Rishra 40

# Input of an integer
num1=int(input("Enter the value of num1: "))
Enter the value of num1: 12
num2=int(input("Enter the value of num2: "))
Enter the value of num2: 8
num3=num1+num2
print(num3)
20
print(num1, " + ", num2," = ",num3)
12 + 8 = 20

# if statement
age=int(input("Enter the age: "))
Enter the age: 20
if age >= 18: ( : represents start of bracket)
print("You are an adult.") space in beginning of line represents contents are within bracket
else:
print("You are a minor.")
You are an adult.

# % operator and ** operator


x=30
y=8
z=2
p=x/y
q=x%y
r=y**z
print(p, q, r)
3.75 6 64

You might also like