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
# 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 |
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
# 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 |
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
// Given an array of numbers, check if sum of two equals to target or not | |
// Example [4, 7, 8, 9], target = 11 | |
// True | |
// Array of sequence number n | |
let array = [4, 7, 8, 9]; | |
// Constant Target to find | |
const target = 11; |
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
# Question? | |
# What we need to build? | |
# 2 tokens -> Play game 2x | |
# 5 tokens -> Play game 5x | |
# 6 tokens -> PLay game 6x | |
# 10 tokens -> Play game 10x | |
# This token we will be provided by user | |
token = eval(input("Enter Your Token Please: ")) # Evaluating the incoming value to its respective Data type |
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
i = 0 # for Parent While Loop | |
j = 0 # for Child Loop | |
counter = 10 # DON'T TOUCH IT (constant) | |
# What's the Output? | |
# Hello Cat! | |
# Hello Cat! | |
# Hello Cat! | |
# Hello Cat! |
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
# MY JOB | |
# is basically to print all contacts of phonebook on screen | |
# Its list of contacts // phonebook | |
phonebook = [] | |
i = 0 # We are initialization a counter | |
while i == len(phonebook): | |
print(f"Contact no. {i + 1}:\t\t {phonebook[i]}") | |
i = i + 1 # STEPS to increase |
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
i = 0 | |
# DO NOT TOUCH HERE # | |
# DO NOT TOUCH HERE # | |
phonebook_names = ["emma", "aly", "jackson"] | |
phonebook_numbers = ["455-111-222", "455-666-888", "455-333-555", "455-333-871"] | |
# DO NOT TOUCH ABOVE THIS LINE # | |
# DO NOT TOUCH ABOVE THIS LINE # | |
# We are actually printing names with their numbers |
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
# Goal: We want to build a phonebook application | |
# Features: 1. Creating a Contact 2. Viewing all the Contacts | |
phonebook = [] # Empty list of Phonebook | |
saved = int(input("How many contacts you want to store? ")) | |
print() # New-line | |
# I am storing 3 contacts inside my Phonebook | |
for i in range(saved): |
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
# I want to build a program that will forever ask me to enter number | |
while True: | |
# DO WHATEVER | |
name = input("Enter something: ") | |
# Exit the program when user enters shehroz | |
if name == "abc": | |
break | |
print(name) |
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
# 1st Project | |
# Phonebook that can: | |
# 1. Read all contacts | |
# 2. Create contacts | |
# Welcome to Phonebook App | |
# 1. Create new contact | |
# 2. Read contacts | |
# Type option: 1 |