0% found this document useful (0 votes)
10 views12 pages

Python

The document provides an overview of Python programming, covering functional, structured, and object-oriented programming methods. It includes examples of basic syntax, variable types, string manipulation, user input, conditional statements, and loops. Key concepts such as comments, sequence types, and string concatenation are also illustrated with code snippets.

Uploaded by

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

Python

The document provides an overview of Python programming, covering functional, structured, and object-oriented programming methods. It includes examples of basic syntax, variable types, string manipulation, user input, conditional statements, and loops. Key concepts such as comments, sequence types, and string concatenation are also illustrated with code snippets.

Uploaded by

Shrey Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Pytho

n
• functional and structured programming methods as well
as OOP
Hello World
# Python code to print "Hello, World!"
print("Hello, World!")

# \n Not required for new line


print("Hello", end=" ")
print("World")
Comment
• #This is single line comment.

• '''
This is
Multi line comment.
'''
Variables
• a = str(123)
• b = int(123)
• c = float(123)
• name, age, city = "Kelly Hu", 27, "Brentwood"
String
• test = "Hello, World!“
print(test[2:5])
print(test[0:])
print(test[:-1])
print(test[:5])
print(test[:])

• name = "Kelly Hu“


age = 27
person = f"My name is {name}, I am {age} years old"
String Concatenation

a = "My Name"
print(a + "is Shrey")
Sequence Types
• List
a = [1, 2, 3, 4, 5]

• Tuple
a = (1, 2, 3, 4, 5)

• Dictionary
a = {"Name" : "John", "Age" : 32}
User Input
• name = input("Enter your name: ")
print("Hello", name)
Condition
a = 10
b = 20
if a > b:
print("a is greater than b")
elif b > a:
print("b is greater than a")
else:
print("a is greater than b")
Loops
students = ["Kelly Hu", "Akanksha", "Peter"]
for s in students:
print(s)

i = 1
while i <= 10:
print(i) i += 1

You might also like