Skip to content

Instantly share code, notes, and snippets.

View sshehrozali's full-sized avatar
🌍

Shehroz Ali sshehrozali

🌍
View GitHub Profile
@sshehrozali
sshehrozali / pyramid.py
Created November 9, 2020 18:47
Python code to print Left & Right aligned Pyramid
# Developed By Syed Shehroz Ali #
# Ask user for height of pyramid
height = input("Enter Height of Pyramid: ")
# -------------------------------------
# Start printing Left-aligned pyramid
print("\n----------------")
print("Left pyramid")
print("----------------")
@sshehrozali
sshehrozali / string_reverse.py
Created November 9, 2020 18:53
Python code to reverse a string
# Prompt user to enter any name
name = input("Please enter any name: ")
# Print name in reverse order
print("Reversed: ", end="")
# Iterate till last char of string, print reversely
for i in range(1, len(name) + 1):
print(name[-i] ,end="")
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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