Skip to content

Instantly share code, notes, and snippets.

View Nehadsys's full-sized avatar
🎧
Locked in

Nehad Shakoor Nehadsys

🎧
Locked in
View GitHub Profile
@Nehadsys
Nehadsys / arcadegame.py
Created May 9, 2022 18:41
Arcade Game with token machine.
#The token is provided by the player as an input
token = eval(input("Enter Your Token Please: ")) # Evaluating the incoming value to its respective Data type
print(f"Tokens: {token}\n")
trackToken = token #assigning the tracking variable of token
counter = 0 #starting value --> 0
#using whileloop
while counter < token:
trackToken = trackToken - 1 #subtracting the Token by 1 figure
print(f"| Playing, Chances Left: {trackToken} |")
@Nehadsys
Nehadsys / greedyalgo.py
Created October 26, 2022 12:00
Greedy Algorithm Python
amountRequired = 150 # <---can be changed to desired user input.
amountReturned = 0
counter_25 = 0
counter_10 = 0
counter_5 = 0
counter_1 = 0
while amountRequired >= 25:
amountRequired -= 25
counter_25 += 1
@Nehadsys
Nehadsys / gist:bc412d5428a4943cb95aa94ae26eb7e8
Created May 28, 2024 16:16
Python simple socket get content requests for webservers
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ## Initializes a request
mysock.connect(('data.pr4e.org',80)) # connects to the request
cmd = 'GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n'.encode() # Gets the metadata from the HTTP host and encodes it too.
mysock.send(cmd) # Finally sends it
while True:
data = mysock.recv(512) # recives 512 characters only