0% found this document useful (0 votes)
2 views6 pages

Python Course Learning Code

The document provides an overview of basic programming concepts including variables, arithmetic operators, strings, and lists. It demonstrates variable assignments, arithmetic operations, string manipulations, and list operations with examples. Additionally, it covers the use of placeholders and string formatting.

Uploaded by

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

Python Course Learning Code

The document provides an overview of basic programming concepts including variables, arithmetic operators, strings, and lists. It demonstrates variable assignments, arithmetic operations, string manipulations, and list operations with examples. Additionally, it covers the use of placeholders and string formatting.

Uploaded by

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

# This is a comment 1 (Topic 1)

print("Comment (Topic 1):")

print("Hello World!")

# Variable and Multiple Assiments 2 (Topic 2)

print("Variable and Multiple Assiments(Topic 2):")

print("Variable (a):")

a = 20

print("a:", a)

b = "My name is Aayan"

print("b:", b)

# Respective Variables (a1)

print("Respective Variables:")

Aayan, Sidra, Imran = 12, 35, 41

print("Aayan:", Aayan)

print("Imran:", Imran)

## Another on the respective topic (a2)

print("Respective Variales 2:")

name, age, hobby = Aayan, 20, "Playing"

print("name:", name)

print("age:", age)

print("hobby:", hobby)
# Equaltoo Variables (b)

print("Equaltoo Variables:")

Aayan = Sidra = Imran = 20

print("Aayan:", Aayan)

print("Sidra", Sidra)

# Arthematic Operaters and strings...(Topic 3)

print("Arthematic Operators and strings (Topic3):")

# Arithmetic Operaters (Topic 3a)

print("Arthemtic Operaters:")

print("-,+,*,/,%,**,//")

a=2

b=4

print("Subtraction:", a-b)

print("Addition:", a+b)

print("Mutiplication:", a*b)

print("Division:", a/b)

print("Modulus:", a%b)

print("Square:", a**b)

print("Floor Division:", a//b)

# Strings (Topic 3b)

First_Name = "Aayan"
Last_Name = "Khan"

print(First_Name + " " + Last_Name)

print("Aayan "* 10)

### Addition, Subtraction, and Modulus do not work n Strings...

## Slices

sent = "My Name is Imran"

print(sent[11:17])

# Place holdres in Strings

## The Dayssi Tarrika

print("The Dayssi Tarrika:")

name1 = "Sidra"

name2 = "Fatima"

name3 = "Aayan"

print(name1, " has recieved there Fee Challan")

# Place Holder Exaple 1

print("Place Holder Exaple 1:")

n1 = "Aayan"

n2 = "Sidra"

n3 = "Fatima"

x = "%s has received his fee challlan."

print(x % n1)
print(x % n2)

print(x % n3)

# Place Holder Exaple 2

print("Place Holder Exaple 2:")

sentence = "%s and %s have recieved their Fee Challan."

print(sentence % ("Aayan", "Fatima"))

#### ...Important Notes...

### %s is for SENTENCE (Ali is a boy.)

### %d is for INTEGER (12)

sent = "%s is %d years old"

print(sent % ("Aayan", 12))

# Formating Strings (!)

name = "Husna"

print(f"Hello {name}")

### we can add "," b/w "print(f"Hello""," {name}")"

x = 10

y = 20

print(f"The sum of x and y is {x + y}")

# Introduction to Lists

print("Introduction to Lists:")

list_1 = ["Apples", "Banana", "Mango", "Peach"]

print(list_1)
## When we want the specific Value

print("When we want the specific Value:")

print(list_1[0])

print(list_1[1])

print(list_1[2])

print(list_1[3])

### When we want the specific Value from 0:___

print(list_1[0:2])

# When we want to add a Value to the lists

print("When we want to add a Value to the lists:")

list_1.append("Blueberries")

print(list_1)

# When we want to Update items in our list

print("When we want to Update items in our list:")

list_1[0] = "Cherries"

print(list_1)

# Deleting Value

del list_1[1]
print(list_1)

# print lenth of list

print("print lenth of list:")

print(len(list_1))

list_2 = ["1-Mart", "Metro", "Al-Fateh", "Save Mart"]

# Aplying Arethematic Operations in it

print("Aplying Arethematic Operations:")

print(list_1 + list_2)#Multiply

print((list_1 + list_2)*2)#Divide

# Min & Max

print("Min & Max:")

num_list = [13, 23, 76, 68, 21, 40, 39, 49, 73, 34, 38]

print(max(num_list))

print(min(num_list))

You might also like