This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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("----------------") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer