This file contains hidden or 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
import urllib.request | |
# get data | |
def get_data(target): | |
listo=[] | |
response=urllib.request.urlopen(target).read().decode('utf-8').split('\n') | |
for line in response: | |
listo.append(line) | |
return listo | |
#find common values | |
def find_intersection(data): |
This file contains hidden or 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
import urllib.request | |
import ssl | |
import statistics | |
def calculate_mean(d): | |
x=statistics.mean(d['Air_temp']) | |
y=statistics.mean(d['Barometric_press']) | |
z=statistics.mean(d['Wind_Speed']) | |
return x,y,z | |
def calculate_median(d): | |
x=statistics.median(d['Air_temp']) |
This file contains hidden or 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
import csv | |
import math | |
def deg_to_rad(deg): | |
return deg*(math.pi/180) | |
def calculate_distance(a,b): | |
#distance calculation according to Haversine formula | |
new_listo=[] | |
new_listo.extend(a) | |
new_listo.extend(b) |
This file contains hidden or 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
import threading | |
import time | |
import queue | |
num_list=[i for i in range(500)] | |
prime_list=[] | |
listo=[] | |
#if you take a look at processing time,you will see that threading takes more time than normal calculation, it is because of time to be needed to | |
#create threads.Threading OS dependent and time taking process and in simple calculations like this one is not a good example to show threading. | |
#so,I have added time sleep to check_prime function to show efficiency of threading.Try it with and without time sleep. | |
def check_prime(num): |
This file contains hidden or 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
class A: | |
def __init__(self,num): | |
self.num=num | |
self.num_list=[1,4,5,9,10,40,50,90,100,400,500,900,1000] | |
self.rom_list=['I','IV','V','IX','X','XL','L','XC','C','CD','D','CM','M'] | |
self.roman_num=" " | |
self.next_val= num | |
def convert(self,num): | |
while self.next_val!=0: | |
if self.next_val<1000: |
This file contains hidden or 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
class A: | |
def convert(self,roman): | |
num_list=[1,4,5,9,10,40,50,90,100,400,500,900,1000] | |
rom_list=['I','IV','V','IX','X','XL','L','XC','C','CD','D','CM','M'] | |
next_val= 0 | |
for i in range(len(roman)): | |
if i!=len(roman)-1: | |
if rom_list.index(roman[i])>=rom_list.index(roman[i+1]): | |
next_val+=num_list[rom_list.index(roman[i])] | |
else: |
This file contains hidden or 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
import ssl | |
import socket | |
import csv | |
import queue,threading | |
def checker(value): | |
try: | |
a=[] | |
target='{}'.format(value) | |
port=443 | |
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
This file contains hidden or 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
import threading | |
import queue | |
import argparse | |
def happy_number_finder(num,re_list): | |
top=0 | |
if len(re_list)==2:del re_list[-1] | |
re_list.append(num) | |
for ch in num: | |
top+=(int(ch))**2 | |
This file contains hidden or 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
import urllib.request | |
# get data | |
def get_data(target): | |
listo=[] | |
response=urllib.request.urlopen(target).read().decode('utf-8').split('\n') | |
for line in response: | |
listo.append(line) | |
return listo | |
#find common values | |
def find_intersection(data): |
This file contains hidden or 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
from tkinter import * | |
from random import randrange | |
def drawshape(): | |
x1,x2,x3=150,400,250 | |
y1,y2,y3=250,150,350 | |
can1.create_line(y2,x3,y3,x3,width=2,fill=coul) | |
can1.create_line(y1,x1,y1,x2,width=2,fill=coul) | |
def change_shape_colour(): | |
global coul | |
pal=['purple','red','blue','orange','yellow'] |
OlderNewer