Skip to content

Instantly share code, notes, and snippets.

View sshehrozali's full-sized avatar
🌍

Shehroz Ali sshehrozali

🌍
View GitHub Profile
@sshehrozali
sshehrozali / exam.py
Created December 30, 2020 08:21
Solution for given Question in paper.
# Dictionary
dic = {"SECP": "Securities and Exchange Commission Pakistan", "SBP": "State Bank of Pakistan", "FBR": "Federal Board of Revenue", "PCB": "Pakistan Cricket Board", "ISPR": "Inter Services Public Relations"}
# Open file in read mode
fp = open("Lab 8/20B - 084 - SE.txt", "r")
# Empty list to store list of lines
lst_lines = []
# Get each line of file
@sshehrozali
sshehrozali / divisible_check.py
Created December 15, 2020 12:41
Python function to print all numbers that are divisible by 2 or 3
# Function to print divisibles of 2 or 3
def even(n):
if n == 2:
print(n)
exit(0)
# Initiliaze counters
prime_counter = 0
check = 0
@sshehrozali
sshehrozali / nested-if-#1.py
Created December 3, 2020 05:46
Representation of Nested IF condition (Python)
# Python Nested IF condition representation (example)
{ # IF condition
if
{ # 1st condition
if
if # 1st condition of above IF
n times if can be used here
@sshehrozali
sshehrozali / ap.py
Last active December 3, 2020 05:41
Python program for arthmetic progression (A.P)
# Ask for First term and Common difference
a = eval(input("\nEnter First Term: "))
d = eval(input("Enter Common difference: "))
# Extend the range to greater upper bound
for i in range(20000000000000000000000):
# Ask for nth term
n = eval(input("\nEnter nth term: "))
@sshehrozali
sshehrozali / matrix_multiply.py
Created November 25, 2020 17:38
Program to multiply 2x2 matrices.
# Program to multiply 2x2 matrices. Developed By Syed Shehroz Ali #
# Welcome Line
print("\n---| Multiplication of 2x2 Matrices | ---\n")
# 2D List for matrices
A = [[], []]
B = [[], []]
# Ask for Matrix A values
@sshehrozali
sshehrozali / result_maker.py
Created November 23, 2020 19:39
Python program to generate result from subjects with student's info and details
# Ask for Student's Name, Father's Name, Batch Year and Roll No.
Student_name = input("Enter Your Name: ")
Father_name = input("Enter Your Father's Name: ")
Batch_No = input("Enter Your Batch Year: ")
Roll_No = input(f"Your Roll No: {Batch_No[-2] + Batch_No[-1]}B - ")
print("_____________________________")
# ENGLISH MARKS #
print("\n\tEnglish")
@sshehrozali
sshehrozali / palindrome_check.py
Created November 23, 2020 19:38
Python program to check whether a text/word is Palindrome or not
# Ask for any word or text from User
text = str(input("Enter any word: "))
# Empty string to store reversed version of original
reversed_text = ""
# Iterate through each char
for i in range(1, len(text) + 1):
# Get char in reversed order (negative indexing)
@sshehrozali
sshehrozali / list_insert.py
Created November 16, 2020 13:33
Python program to demonstrate the use of list.insert()
# Python program to demonstrate the use of list.insert() # Developed By Syed Shehroz Ali
# New List
my_list = ["Hello", "World", "Cat", "Dog"]
# Print List
print("\nList:", my_list)
# Print Total length of list
print("\nTotal Length of list: ", len(my_list), "\n")
@sshehrozali
sshehrozali / lab3.py
Created November 16, 2020 05:49
Student's Exercise (Lab 3)
# Student Exercise (Lab 3) # Performed By Syed Shehroz Ali
# List of months
monthsL = ["Jan", "Feb", "Mar", "May"]
# Tuple of months
monthsT = ("Jan", "Feb", "Mar", "May")
# List exercise #
@sshehrozali
sshehrozali / string_insert.py
Created November 9, 2020 18:54
Python code to insert an alphabet in a string
# Store any word
string = input("Enter any word: ")
# Ask where to insert before
index_Alpha = input("Where do you want to insert?\nEnter Alphabet: ")
# Int to store string index no
index_No = 0
# Iterate until char matches, get index no