blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
1b6bc1d29ff40669e1d3f47d92f5675934c4c8c8 | joeybtfsplk/projecteuler | /10.py | 1,353 | 4.125 | 4 | #!/usr/bin/env python
"""
file: 10.py
date: Thu Jul 31 09:25:11 EDT 2014
from: Project Euler: http://projecteuler.net
auth: tls
purp: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of
all the primes below two million.
Ans: 142913828922 on Fri Aug 1 22:34:07 EDT 2014
"""
def prime_list(... |
27b59e7370b7fba3ee4b4e64551168370b4c9d42 | AgustinBorda/TPInteligenciaArtificial | /Borda_Guevara_Tissera/resolutions/ejercicio1.py | 684 | 3.921875 | 4 | from search import Node
# Implements depth first search algorithm with cycle detection.
# Ejercicio 1
def depth_first_tree_search_cycle_detection(problem):
frontier = [Node(problem.initial)] # Stack, with the initial state of the problem.
while frontier:
node = frontier.pop()
if problem.goal_... |
c3bc5fad6a216aa7a6bb3437744c21e4f2fbfb8a | snlab-freedom/sdntest | /sdntest/examples/customtopo/triangle.py | 1,669 | 3.8125 | 4 | """Custom topology example
s1---s2
| /
| /
| /
s3
Consist of three fixed core switches, and each core switches will connect to m hosts through n switches.
"""
from mininet.topo import Topo
CORE_NUMBER = 3
class TriangleStarTopo( Topo ):
"Simple topology example."
def build( self, m=1, n=1 ):
""... |
d705f631b3b366c1e4679bab9854d471ac16c5f5 | priscilledhuicque/PFE-CryptoStability | /financeAgent.py | 3,914 | 3.953125 | 4 | """
Define the main class from which all agents will inherit
Each possible agent will come from this one
We assume only banks can give loans
"""
from mesa import Agent, Model
import random
class FinanceAgent(Agent):
def __init__(self, unique_id, model):
"""Basic definition of the init function
This function l... |
b9461eb3eac7531e5ad15cf892bc24b5c63cb5f3 | msds-thakur/Practical-Machine-Learning-in-Python | /Thakur_Assignment3.py | 11,061 | 3.9375 | 4 |
# coding: utf-8
# In[1]:
#Prabhat Thakur Date 10/21/2018
#MSDS422 - Assignment3
# In[2]:
# Boston Housing Study (Python)
# using data from the Boston Housing Study case
# as described in "Marketing Data Science: Modeling Techniques
# for Predictive Analytics with R and Python" (Miller 2015)
# Here we use data... |
0cd3f80f80bed75176e9ca50eb0f928d73df4cc6 | zw-999/learngit | /study_script/find_the_largest.py | 481 | 4.21875 | 4 | #!/usr/bin/env python
# coding=utf-8
import sys
def find_largest(file):
fi = open(file,"r")
for line in fi:
line = line.split()
print line
#fi.close()
#line = fi.readline()
largest = -1
for value in line.split():
v = int(value[:-1])
if v > largest:
... |
826e98e201e171c7a33e66b68aba1ed9d4f58ebd | zw-999/learngit | /beautifulsoup/beautiful_test3.py | 2,792 | 3.984375 | 4 | #!/usr/bin/env python
# coding=utf-8
html_doc = """
<html><head><title>The Dormouse's story</title></head>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>,
<a... |
8cade2cfaed9422daeb5ab07aef35ebab54d9d5b | zw-999/learngit | /study_script/line_long.py | 414 | 3.625 | 4 | #!/usr/bin/env python
# coding=utf-8
#查找文件中最长的一行
f = open('/home/ellen/111.txt','r')
longest = 0
alllines = [x.strip() for x in f.readlines()]
f.close()
for line in alllines:
linelen = len(line)
if linelen > longest:
longest = linelen
print longest
#使用max函数
f = open('/home/ellen/111.txt','r')
al... |
8ed0e5c58da6d4368f6217a7a02e9b91e1f4e37f | zw-999/learngit | /cookbook/yj-3_15.py | 246 | 3.71875 | 4 | #!/usr/bin/python3.4
# coding=utf-8
#程序 接受字符串输入,计算两日期的间隔
from datetime import datetime
text = '2016-09-12'
y = datetime.strptime(text,'%Y-%m-%d')
print(y)
z = datetime.now()
print(z)
diff = y-z
print(diff)
|
25c163039a3438ffd215d9b09035cedd7ee6ccad | zw-999/learngit | /study_script/xml_test.py | 4,057 | 3.734375 | 4 | #!/usr/bin/env python
# coding=utf-8
import xml.etree.ElementTree as ET
tree = ET.parse('/home/ellen/ellen.xml')
root = tree.getroot()
tag = root.tag #获取跟节点
print tag
#获取跟节点的属性
attrib = root.attrib
#获取全部的子节点与属性
for child in root:
print (child.tag, child.attrib)
#获取属性对应的值
for goods in root.findall('goods'):
no... |
0c4de54dc4e029397848c1fdd1851037035d3eb9 | zw-999/learngit | /study_script/list_get_somevalue.py | 308 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
若列表中某元素存在时则返回,否则返回默认值,类似于字黄中的get方法L.get(i, v)
'''
def list_get(L,i, v = None):
if -len(L) <= i < len(L):
return L[i]
else:
return v
Li = [1,2,3,4,5,6]
print list_get(Li, 2)
|
0d212995a9bfba362e661723a239d0caf68d9685 | zw-999/learngit | /python_标准库/time-example-1.py | 484 | 3.78125 | 4 | #!/usr/bin/env python
# coding=utf-8
import time
now = time.localtime(time.time())
print now
#now :truct_time(tm_year=2016, tm_mon=6, tm_mday=7, tm_hour=10, tm_min=45, tm_sec=36, tm_wday=1, tm_yday=159, tm_isdst=0)
year, month, day, hour, minute, second, weekday, yearday, daylight = now
#格式化当前时间
print time.strft... |
d10904039a0d75a499c8a798dc986313102f2ebf | zw-999/learngit | /study_script/lei.py | 923 | 4.0625 | 4 | #!/usr/bin/env python
# coding=utf-8
''''
class MyClass(object):
myVersion ='1.1'
def showMyVerson(self):
print MyClass.myVersion
'''
class A(object):
def __init__(self,name):
self.name=name
def getName(self):
return "A" + self.name
class B(A):
def getName(self):
retu... |
9191f98bf69bb7ace8ba4139b1b1d3e3a4ead74a | zw-999/learngit | /study_script/hasattr_getattr_setattr.py | 486 | 3.625 | 4 | #!/usr/bin/env python
# coding=utf-8
class Cat(object):
def __init__(self,name='ketty'):
self.name=name
def sayHi(self):
print self.name + 'say hi~'
cat = Cat('ketty')
if hasattr(cat,'name'):
setattr(cat,'name','tiger') #cat.name='tiger'
print getattr(cat,'name') #print cat.name
getat... |
c37162118de7ebf4a1906b7a44adc9928b2076ae | zw-999/learngit | /study_script/counter.py | 1,074 | 3.828125 | 4 | #!/usr/bin/env python
# coding=utf-8
#使用dict排序
some_data = ['a','2',2,4,5,'2','b',4,7,'a',5,'d','a','z']
count_frq = dict()
for item in some_data:
if item in count_frq:
count_frq[item] += 1
else:
count_frq[item] = 1
print count_frq
#使用defaultdict
from collections import defaultdict
count_... |
e9c0dc29bc5b87aeec17b239c1b6323133413c77 | zw-999/learngit | /study_script/delete_samestring.py | 598 | 3.546875 | 4 | #!/usr/bin/env python
# coding=utf-8
import os
base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
print base_dir
aaaa = os.path.join(base_dir,'tmp')
print aaaa
print 'test:', os.path.dirname(os.path.abspath(__file__))
list = ['a','d','f','b','d','d','e']
print "the list is: ", list
if list:
list.s... |
e5bb5f4405f8f2df8374fc4b4ca8a7e77455951f | zw-999/learngit | /myscript/port.py | 890 | 3.53125 | 4 | #!/usr/bin/env python
# coding=utf-8
import os
#path = '/usr/local'
#查找以conf结尾的文件
def find_conf():
filename = []
path = '/usr/local/'
for root,dirs,files in os.walk(path):
# print "files",files
for name in files:
if name.endswith(".conf"):
file = os.path.join(root,name)
... |
1a2f875189437c1c09d34ece099de1858cdaa880 | Kavitajagtap/Python3 | /Day14.py | 1,792 | 4.375 | 4 | """
1.Write a program to sort a list alphabetically in a dictionary
Enter dictionary = {1: ['B', 'C', 'A'], 2: ['D', 'B', 'A'], 3: ['V', 'A', 'K']}
Sorted list of dictionary = {1: ['A', 'B', 'C'], 2: ['A', 'B', 'D'], 3: ['A', 'K', 'V']}
"""
dict = {}
n = int(input("Enter elements: "))
for i in range(n):
k = int(i... |
87424e37b3e029ddd8fcc1ccd752b23fc5864b33 | Kavitajagtap/Python3 | /Day8.py | 1,852 | 4.59375 | 5 |
# 1.Write a program to create dictionary and access all elements with keys and values
dict = eval(input("Enter dictionary = "))
print("Accessing Elements from dictionary -->")
for key in dict:
print(key,dict[key])
'''
Output :
Enter dictionary = {'Apple':2017,'Microsoft':1985,'Facebook':2012,'Amazon':1997}
Acces... |
71432b142344cfa33686bf7bdcaeafb4f2d4b372 | Kavitajagtap/Python3 | /Day16.py | 1,528 | 4.3125 | 4 |
"""
1. Write program to sort Counter by value.
Sample data : {'Math':81, 'Physics':83, 'Chemistry':87}
Expected data: [('Chemistry', 87), ('Physics', 83), ('Math', 81)]
"""
dict = {}
n = int(input("Enter elements: "))
for i in range(n):
k = (input("key: "))
v = int(input("value: "))
dict[k] = v
print("di... |
b369a56787f0a1d15519d7e228ac7ef2ef6b849a | VolodymyrMeda/Twittmap | /json_navigator.py | 1,646 | 4.1875 | 4 | import json
def reading_json(file):
'''
str -> dict
Function reads json file
and returns dictionary
'''
with open(file, mode='r', encoding='utf-8') as rd:
json_read = json.load(rd)
return json_read
def json_navigation(json_read):
'''
Function navigates user in
json d... |
1cb326e3435b9ff4a02cdd19f24a42429f65e809 | hdmf-dev/hdmf-docutils | /hdmf_docutils/doctools/output.py | 3,543 | 3.578125 | 4 | """
Module with helper classes for printing and other input/output related tasks
"""
import os
import subprocess
class PrintHelper:
"""
Helper functions used for printing color-coded progress and status messages.
"""
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[32m'
WARNING = '... |
f53ac115857e375fcfb39031757fee35c63872cc | m3ller/mnist_cnn | /digit_classifier.py | 5,681 | 3.8125 | 4 | """
A simple convolutional neural network to classify MNIST digits.
"""
import argparse
import numpy as np
import os
from PIL import Image
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
W, H = 28, 28
WH = W*H
N_LABELS = 10
N_HIDDEN = 32
TRAIN_BATCH_SIZE = 16
TEST_BATCH_SIZE = 16
d... |
0faa5425703da2e9df8953f4285e09bc40408ed9 | anthonypt87/coding_katas | /tree_depth.py | 1,326 | 4.03125 | 4 | """Get tree depth from tree"""
import unittest
class Tree(object):
def __init__(self, value, children):
self.value = value
self.children = children
def recursive_max_length(tree):
if not tree.children:
return 1
else:
return 1 + max(
max_length(child) for child... |
7a80e456cd1eb9517125d96f344d1441ea844ad7 | alvarooo98/progAvanzada | /ejercicio11.py | 814 | 3.671875 | 4 | # Ejercicio 11: Eficiencia de combustible
# En los Estados Unidos, la eficiencia del combustible para vehículos se expresa normalmente en millas por galón (MPG).
# En México, la eficiencia del combustible normalmente se expresa en litros por cien kilómetros (L / 100 km).
# Usa tus habilidades de investigación para... |
a92d631d9223c98e4d2d6dd80a63cd4a733017b4 | GabrielJHR/estructura-de-datos-gabriel | /colas_dinamicas.py | 1,421 | 3.90625 | 4 | class Nodo(object):
def __init__(self, dato):
self.dato = dato
self.siguiente = None
def __str__(self):
return str(self.dato)
class Cola(object):
def __init__(self):
self.primero = None
self.tamanio = 0
self.items = self.lista()
def vacia(self):
if(self.tamanio == 0):
return True
else:
ret... |
a1c04c2fe11f06f91f3ce9a8df24697aaff893a7 | GabrielJHR/estructura-de-datos-gabriel | /tp01.py | 4,784 | 3.8125 | 4 | #Ejercicio 1
def Fibonacci(pos):
#Caso Base
if (pos <= 0):
return 0
if (pos == 1):
return 1
#Recursividad
if (pos > 1):
return Fibonacci(pos-1)+Fibonacci(pos-2)
#Ejercicio 2
def SumatoriaEnteros(num):
if(num <= 0):
return 0
else:
return num + SumatoriaEnteros(num-1)
#Ejercicio 3
def Producto(fac... |
c750fc963e025a2eca76ce2c8c44c57754aa0bbe | ambreen2006/random_problems | /dynamic programming/edit distance/edit_distance.py | 1,111 | 3.796875 | 4 | import numpy as np
def edit_distance(T: str, P: str) -> int:
"""Compute edit distance between the two strings using dynamic programming
Arguments:
T - text to convert
P - pattern to convert to
>>> edit_distance("POLYNOMIAL", "EXPONENTIAL")
6
>>> edit_distance("YOU SHOULD", "THOU SHALT")
... |
a75fa80c8412141fd7e8b28978b5a7f92643fbed | annmag/Student-manager | /generator_function.py | 985 | 4.21875 | 4 | # Generator function - a way of crating iterators (objects which you can iterate over)
# Creating generator - defining function with at least one yield statement (or more) instead of return statement
# Difference: return terminates a function entirely
# yield pauses the function saving all it's states and continues ... |
b410e056b58ccb80f09c1f1f0b4534028ca95b66 | ShreyasNaik1/SortingAlgorithmsPython | /Main.py | 8,706 | 4.40625 | 4 | import time
from matplotlib import pyplot as plt
import matplotlib.animation as animate
from SortingAlgorithms import *
import sys
# import music
# main function
if __name__ == "__main__":
# Users get the option of choosing how many elements should be in the list,
N = int(input("Enter the size of the list: ... |
61fac800de225aaf8f9c50d3f5f57185814f74ee | krosinski/akai_python_workshop_2 | /calc/calc/calc.py | 2,340 | 3.546875 | 4 | import sys
import random
import logging
import re
logging.getLogger().setLevel(logging.DEBUG)
def add(x, y):
return x + y
def sub(x, y):
return x - y
def mul(x, y):
return x * y
def div(x, y):
return x // y
#TODO: 2. adding mul and div operators
#TODO: 3. add power function, handle operator priori... |
5849b3f86bbd3bc7c5a0d6325d4b1f9b318deb21 | ShiekhRazia29/JSON | /Q5.py | 465 | 3.53125 | 4 | #to check unique numbers in the given script
import json
dict={
"first":1,
"second":2,
"third":1,
"fourth":5,
"five":5,"six":9,
"seven":7
}
#print("original dictionary will be as ",dict)
list1 =[] # create empty list
for val in dict.values():
if val in list1:
continue
e... |
62b812615feb06386c0bca1fa1977c27fba42f48 | Sarthak99/MachineLearning | /Pandas/IndexingAndFiltering.py | 3,244 | 3.515625 | 4 | import pandas as pd
import numpy as np
df = pd.read_pickle("C:\\Users\\sarth\\Documents\\Pandas\\Dataset\\collection-master\\data_frame1.pickle")
artists = df['artist']
pd.unique(artists)
print(len(pd.unique(artists)))
#Find the no.of times the artist exists in the DataFrame
s = df['artist'] == "Bacon, Francis"
print(... |
0bd27accb7021db31fbfd540a9318d768adb366c | gokullogu/pylearn | /tutorial/list/add.py | 550 | 4.25 | 4 | #to add the the value to end of list use append
cars=["audi","bens","rolls royce"]
cars.append("bmw")
print(cars)
#['audi', 'bens', 'rolls royce', 'bmw']
#to append the list to the list use extend
fruit=["apple","mango","banana"]
veg=["carrot","beetroot","brinjal"]
fruit.extend(veg)
print(fruit)
#['apple', 'mango', 'b... |
28080c6a55b1fc92494501d470c314beb176f11e | gokullogu/pylearn | /tutorial/tuple/access.py | 1,044 | 4.4375 | 4 |
cars=("bmw","rolls royce","MG hector","tata tigor","audi","creta")
print(cars)
#('bmw', 'rolls royce', 'MG hector', 'tata tigor', 'audi', 'creta')
#second item
print(cars[1])
#rolls royce
#last item index -1
print(cars[-1])
#creta
print(cars[2:4])
#('MG hector', 'tata tigor')
print(cars[-5:-1])
#('rolls royce', 'M... |
dc2cbd2c57958e736d570835d204bd0bc8a81b4f | gokullogu/pylearn | /pandass/py_pandas/intro.py | 667 | 3.609375 | 4 | import pandas as pd
#to know the version
print(pd.__version__,"\n")
#1.2.3
#dict
mydataset={
'cars':["bmw","volvo","ford"],
'passings':[3,7,2]
}
pdvar=pd.DataFrame(mydataset)
print(pdvar,"\n")
#simple pandas series
print(" ","pandas series")
a=[3,4,2,6]
pdser=pd.Series(a)
print(pdser,"\n")
#simple pandas s... |
39f45bae07f632c715928a8237750ac70edafdef | gokullogu/pylearn | /tutorial/functions.py | 1,287 | 4.21875 | 4 | #creating functions
def my_fun():
print("hello world")
my_fun()
#hello world
#function with argument
def namefun(fname,lname):
print(fname+" "+lname)
namefun("gokul","L")
#gokul L
#namefun("gokul") will cause to error
#using argument tuple to get values
def namefun(*name):
print(name[2])
namefun("emil",... |
50e3a4dbe8af7537d416e830a6882fcacf7fce1e | gokullogu/pylearn | /tutorial/list/remove.py | 778 | 4.28125 | 4 | #remove() removes item sepecified
fruit=["mango","orange","papaya"]
fruit.remove("mango")
print(fruit)
#['orange', 'papaya']
#pop() removes the list item at specified index
this_list=["john","19","poland"]
this_list.pop(1)
print(this_list)
#['john', 'poland']
#pop() removes the last item if unspecified
this_list1 =... |
8320b816e71e23166bd8ba1be453dbfa1d0be69f | gokullogu/pylearn | /tutorial/sets/remove.py | 440 | 3.796875 | 4 | delset={"items","in","set","are","unordered"}
delset.remove("in") #removes the in from delset
print(delset)
#{'are', 'items', 'set', 'unordered'}
#use discard() if no error should be thrown if item not present
delset.discard("program") #will not get error
print(delset)
#{'unordered', 'items', 'are', 'set'}
#use clear... |
15979d36f288d1712f0e0c6099573e090c7e7f90 | gokullogu/pylearn | /tutorial/string/stringmethods.py | 2,269 | 4.0625 | 4 | #capitalize()
# first letter of every obj
print("hello google".capitalize())
# Hello google
#if number is first results the same number
#casefold()
# is same as lower() but efficient
print("Welcome To Python".casefold())
#welcome to python
#center()
#prints str after 20 characters
print("banana".center(20))
# ... |
33de33e1b694522a1ce35baf5777cab2ba132560 | gokullogu/pylearn | /tutorial/tuple/loop.py | 531 | 4.375 | 4 | #loop through the tuple using for
fruit=("apple","banana","carrot","beetroot")
for x in fruit:
print(x)
#apple
#banana
#carrot
#beetroot
#loop through tuple using index numbers
print("for loop by index number:")
for i in range(len(fruit)):
print(i,"",fruit[i])
#for loop by index number:
#0 apple
#1 banana
#... |
87697dc81a1f2a3e24da87724b92f6bde0da5d25 | gokullogu/pylearn | /self ex/table.py | 154 | 3.765625 | 4 | for x in range(1, 11):
print("table ", x)
for y in range(1, 11):
print(x, " * ", y, " = ", x*y)
print("\n")
#prints table from 1 to 10 |
665a9c4281b0938ce38fb965c5f052b92617080a | sailajamuppalla/Turtle-Graphics | /Turtle_RandomWalk.py | 468 | 3.71875 | 4 | from turtle import Turtle, Screen
import random
tim = Turtle()
tim.shape("turtle")
tim.color("red")
tim.pensize(10)
tim.speed("normal")
colors = ["medium blue", "dark magenta", "dark red", "Dark green", "green yellow"]
angle = [0, 90, 180, 270]
#distance = ["5", "10", "15", "20", "25"]
for _ in range(... |
c036f0909d03d6c0b929248c6bbde38b9e140216 | nathanlad830/Python-vs-Javascript | /PythonName.py | 166 | 4.1875 | 4 | name = "Nathan"
if len(name) >= 3:
print("Cool name!")
print("In case you forgot your name is, "
print(name)
else:
print("That's a cool short name")
print(name)
|
2b38e27717a52b18501d9977d1db9861f0e608fa | jurijw/Maze-Generator-Solver | /visualization.py | 9,390 | 3.84375 | 4 | import os
import sys
import pygame
import numpy as np
# DEBUG - uncomment for consistent results
# np.random.seed(0)
from maze_generation import init_grid, generate_maze_recursive
# Consider decreasing the maze size if memory may be an
# issue rather than increasing the recursion limit.
sys.setrecursionlimit(5000)
#... |
bff509e7057885d4a0c7e480c09a4605db36bcb8 | ChadevPython/WeeklyChallenge | /2017/02-06-2017/EthanWalker/main.py | 240 | 4.3125 | 4 | #!/usr/bin/env python3
from reverse_str import reverse_line
import sys
#open file and get lines
with open(sys.argv[1], 'r') as in_file:
file = in_file.readlines()
# print reversed lines
for line in file:
print(reverse_line(line)) |
09ee095269fd4d85e2845e319064a09c835d1f4e | Arunken/PythonScripts | /2_Python Advanced/7_Gui/GeometryManagement/2_grid.py | 299 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 25 10:01:25 2018
@author: SilverDoe
"""
from tkinter import *
root = Tk( )
b = 0
for r in range(6):
for c in range(6):
b = b + 1
Button(root, text = str(b),
borderwidth = 1 ).grid(row = r,column = c)
root.mainloop() |
b176be28c880dac7278e0637870f5d7bacb5ed74 | Arunken/PythonScripts | /2_Python Advanced/8_Pandas/2_DataFrames.py | 3,985 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 09:34:37 2018
@author: SilverDoe
"""
'''
========================== DataFrame ==========================================
pandas.DataFrame( data, index, columns, dtype, copy)
Parameters :
============
1. data : data takes various forms like ndarray, series, map, lis... |
619568175c4c2a09b5307439ffbde052066faeb9 | Arunken/PythonScripts | /1_Basics/Today2/GUI.py | 435 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 25 14:33:59 2018
@author: Ourabora
"""
from tkinter import *
root = Tk()
root.mainloop()
l1 = Label(root,text='Pavan')
l2 = Label(root,text='is')
l2 = Label(root,text='teaching')
l2 = Label(root,text='python')
l2 = Label(root,text='online')
l1.grid(row = 100,column = ... |
6dddbf78d4f5bee539b7e0720fa1db7e0a1bcc11 | Arunken/PythonScripts | /2_Python Advanced/10_SciPy/13_odr.py | 3,385 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 3 22:26:41 2018
@author: SilverDoe
"""
'''
Regression analysis is a technique used to analyze data consisting of a dependent variable (or response
variable) and one or more independent variables (or explanatory variables). The dependent variable is
modeled as a function... |
2cbb5f40c24d450911f3bd11829c0d21fc012fc6 | Arunken/PythonScripts | /1_Basics/4_String.py | 396 | 3.625 | 4 |
a = 'Arun'
b = 'Kengayil'
# Concatenation
x = a+b
print(x)
# Repetition
print(a*3)
# Indexing
c = x[0] # A
d = x[3] # n
# Negative indexing :
e = x[-1]
f = x[-3]
g = x[-5]
# Slices :
h = x[2:4]
i = x[2:9:2] # take the character sequence from 2 to 9 and then return the characters with that are separated by... |
b67ff5eb44e67e6eb4c67c323a78e51f4f4127f0 | Arunken/PythonScripts | /2_Python Advanced/7_Gui/GeometryManagement/3_place.py | 541 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 25 09:57:56 2018
@author: SilverDoe
"""
from tkinter import *
top = Tk()
L1 = Label(top, text = "Physics")
L1.place(x = 10,y = 10)
E1 = Entry(top, bd = 5)
E1.place(x = 60,y = 10)
L2 = Label(top,text = "Maths")
L2.place(x = 10,y = 50)
E2 = Entry(top,bd = 5)
E2.place(x ... |
9a63728319bc7a007e3edcc2acf916c0e32b988a | Arunken/PythonScripts | /2_Python Advanced/8_Pandas/10_Sorting.py | 1,643 | 4.46875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 21 14:30:07 2018
@author: SilverDoe
"""
'''
There are two kinds of sorting available in Pandas :
1. By Label
2. By Actual Value
'''
'''================== Sorting By Label ========================================'''
import pandas as pd
import numpy as n... |
9fa35473a45aa296a6a47003c6ec74db9a9bd301 | Arunken/PythonScripts | /1_Basics/DataAnalytics/3_CharacteristicsOfDataAnalytics.py | 2,102 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 18 17:10:40 2018
@author: SilverDoe
"""
'''
=============== Characteristics of Big Data Analysis ==========================
1. Programmatic :
==============
There might be need to write program for data analysis by using code to manipulate
it or do any kind... |
afd0ef16bcb75985cad4601132e30d44f2870cda | Arunken/PythonScripts | /1_Basics/Today/20_JsonDump.py | 857 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 12:25:56 2018
@author: Ourabora
"""
import json
# Dictionary
d = {'101':'Arun','102':'Deepak','104':'Anuradha'} # dictionary data
jsonStr = json.dumps(d) # Dumps the dictionary into a json string
print(jsonStr)
nd = json.loads(jsonStr) # loads the data from the j... |
29d8ca3649608305cdfa8ae59bf2a20938537bd7 | ejones/mythril | /mythril/css.py | 13,121 | 3.75 | 4 | """
Python values representing CSS rules, allowing you to create (nestable)
CSS rules in Python. Here is an example::
from mythril.css import css
css( MyClass, border='1px solid #CCC', padding=5, size=( 200, 50 ) )[
css( ('some-class', SomeUtility), pos=( 1, 0, 'relative' ) ) ]
Corresponds to somethi... |
1925ddd9c07e15ce3f04a3d43f7016c4e7ac493f | andredoumad/foobarWithGoogle | /20_08_01.py | 42,818 | 4.09375 | 4 | # Andre Doumad
'''
Please Pass the Coded Messages
==============================
You need to pass a message to the bunny prisoners,
but to avoid detection, the code you agreed to use is... obscure, to say the least.
The bunnies are given food on standard-issue prison plates that are stamped with the numbers 0-9 for... |
511f4e9235677a7c36b8e0d9914fe90351f5b9d2 | fangyihao/Collaborate-use-Python | /turtle/test.py | 214 | 3.734375 | 4 | import turtle
my_turtle = turtle.Turtle()
def drawGraph(len, line):
for i in range(line):
my_turtle.forward(len)
my_turtle.left(360 / line)
#my_turtle.forward(len)
drawGraph(100, 5)
turtle.exitonclick() |
2d849b76af3325432c8cc935496d752415e78aef | mitchwalker1979/crossword | /crossword/puzzle.py | 6,110 | 3.640625 | 4 | #!/usr/bin/python3
import re
from . import utils
from .constants import *
class Space(object):
letter = None
blocked = None
coordinates = None
def __init__(self, coordinates, letter, blocked):
self.coordinates = coordinates
self.letter = letter
self.blocked = blocked
def __... |
8171380df998ce98d12bc37c7e57d7cce1ef4a9d | zwenderk/Python3_NES_Emulator | /memory_owner.py | 839 | 3.90625 | 4 | from abc import abstractmethod, ABC, abstractproperty
from typing import List
class MemoryOwnerMixin(ABC):
# TODO check we have correct amount of memory
@abstractproperty
def memory_start_location(self) -> int:
'''
inclusivo
'''
pass
@abstractproperty
def memory_en... |
0c299a0d7bd74dac485a50c7862e6bfade673ca9 | Lukas-Henze/AdventofCode2020 | /advent-of-code-2020/simplepuzzles/day_1.py | 1,653 | 4.03125 | 4 | import os
from ..loadingdata import loading_text_files
def part_1():
""" Find in a range of numbers two numbers which if added result in 2020.
Then the result of multipling the two will be printed to the command line.
"""
print("Solving day 1 part 1")
# Call the function
input = loading_text_f... |
6380727379fce451388db06dbe6e0b8ac5c7c70f | dante-signal31/cifra | /cifra/attack/transposition.py | 3,757 | 3.5625 | 4 | """Module to attack Transposition cipher texts.
This module uses a brute force method to guess probable key used to cipher
a text using Transposition algorithm.
"""
from typing import Optional
from cifra.attack.dictionaries import IdentifiedLanguage
from cifra.attack.simple_attacks import _assess_key, _integer_key_ge... |
30e18e62bdadd7a573fba51428abbeb0ad0277f7 | dante-signal31/cifra | /cifra/cipher/affine.py | 6,212 | 3.546875 | 4 | """
Library to cipher and decipher texts using Affine method.
"""
import random
# import sys
from enum import Enum, auto
from cifra.cipher.common import DEFAULT_CHARSET, Ciphers, _offset_text
from cifra.cipher.cryptomath import gcd
class WrongAffineKeyCauses(Enum):
multiplying_key_below_zero = auto()
multiply... |
cff935d7f138493f114d62d93a10da4d67e9c21a | HugoChateauLaurent/sBCBG_Nengo | /capitaselecta_chateaulaurent/nengo_spa/vector_generation.py | 3,949 | 3.65625 | 4 | """Generators to create vectors with specific properties."""
import numpy as np
def AxisAlignedVectors(d):
"""Generator for axis aligned vectors.
Can yield at most *d* vectors.
Note that while axis-aligned vectors can be useful for debugging,
they will not work well with most binding methods for Se... |
9dd756e5b7fe604dd95d108d2c9b4a34713c2366 | gdg17/First_Game | /GameTry1.py | 4,124 | 4.0625 | 4 | command = "> "
sad = True
play_game = True
while command.lower() != "quit":
print("Hello... I can't understand much... but want to learn...")
name = input("What's your name?")
command = input(f"Hi {name}, are you doing alright? > ").lower()
if command == "y":
sad = False
if not sad:
... |
7ab829a2cd306232781875e9950482b5928cb70c | nileLivingston/finalProject | /GameBoard.py | 10,802 | 3.8125 | 4 | import util
import random
# Represents a configuration of the cards on the table and in players' hands.
class GameBoard:
# Initializes and shuffles the deck, deals cards to
# players. Sets up all of the appropriate data
# structures.
def __init__(self, players):
self.pile = util.Stack()
self.deck = util.Stac... |
175ec99ed584643619376c0af8841c8d1dbeb16b | Sam-analytic/infa_2020_Sam | /Python week 4/Task1.py | 852 | 3.5 | 4 | import pygame
from pygame.draw import *
pygame.init()
screen = pygame.display.set_mode((600,600))
background_colour=(255,255,255)
screen.fill(background_colour)
#code for figure is here
circle(screen,(255,255,0),(300,300), 230, 0)
circle(screen,(0,0,0),(300,300), 230, 1)
circle (screen,(255,0,0), (180,200), 40, 0)
ci... |
991d140f7e4100ae35f740c3b97f1ed62de4e7f9 | Krishnaarunangsu/LoggingDemonstration | /python_slice_1.py | 1,427 | 4.5 | 4 | # The slice() constructor creates a slice object representing the set of indices specified by range(start, stop, step).
# The slice object is used to slice a given sequence (string, bytes, tuple, list or range) or any object which supports sequence protocol (implements __getitem__() and __len__() method).
# Slice obj... |
610f784daa64df4119e5f37f2e77228d84fbb793 | hakimencem01/DFP40203-STUDY | /textrpggame.py | 2,320 | 3.875 | 4 | from random import randint;
import os;
"""
value = randint(1,10);
print("one day...");
role = input("what type of role are your character?");
bornAge = input("what year are you born ? ");
print(value/10);
"""
textlogo = """
_____________________________________________________
| ... |
1d24c11e60ec6b4925ed41bdaae57516bc132e9f | raviolliii/NeuralNetwork | /NeuralNet.py | 6,398 | 4.28125 | 4 | # ===========================================================
# NeuralNet.py
#
# Full code for a general NeuralNet that uses the
# sigmoid activation function, and backpropagation as
# a learning algorithm.
# ===========================================================
# built in dependencies
import math
import numpy... |
076a093627202f13109ace0c57b7e53879cd8cb9 | DixonCh/Python-Basics-Reference-w3schools | /09 strings.py | 9,084 | 4.5 | 4 | ''''Python Strings:
String Literals:
String literals in python are surrounded by either single quotation marks, or double quotation marks.
'hello' is the same as "hello".
You can display a string literal with the print() function:
'''
#Example:
print("Hello")
print('Hello')
#Assign String to a ... |
dad4d50fb6999cbe3f177289ebea275ee0ce3919 | mathi1811/snakegame | /snake2.py | 770 | 3.578125 | 4 | from turtle import*
from random import randrange
from freegames import square,vector
food=vector(0,0)
snake=[vector(10,0)]
aim=vector(0,-10)
def change(x,y):
aim.x=x
aim.y=y
def inside(head):
return -200<head.x<190 and -200<head.y<190
def move():
head=snake[-1].copy()
head.move(aim)
if not ... |
92fcb82ffdcd43241e2d84afeb5ca1dcb6d65d23 | wangluobing/wa101 | /day02/linklist.py | 2,690 | 4.15625 | 4 | """
linklist.py
功能: 实现单链表的构建和功能操作
重点代码
"""
# 创建节点类
class Node:
"""
思路: 将自定义的类视为节点的生成类,实例对象中
包含数据部分和指向下一个节点的next
"""
def __init__(self, val, next=None):
self.val = val # 有用数据
self.next = next # 循环下一个节点关系
# 做链表操作
class LinkList:
"""
思路: 单链表类,生成对象可以进行增删改查操作
具... |
d634f9dd1f72baad63edef9e5d9ae4dee6e5bd84 | sheridanb2008/CSUMB_Northwest_Tech | /CST 205 Multimedia Design and Programming/Lab 10_version1/Lab_10.py | 3,616 | 3.921875 | 4 | # Brian Sheridan And Samuel Pearce
# CST 205
# Lab 10
# WARM UP
def repeat():
name = requestString("What is your name?")
print "Your name is %s" %name
# WORKING WITH WHILE LOOP
def parrot():
text = ""
while (text != 'stop'):
text = requestString("Enter a word. Type stop to quit")
print "You typed: %... |
7d1e159d41175889ae7de55f8b80ac301ea31bfa | niteshsachdev/hackerrank | /Grading_Students.py | 962 | 3.828125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'gradingStudents' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY grades as parameter.
#
def round_grade(marks):
if marks < 38:
return marks
elif (5*r... |
f718803b224aff52828ca1c194f63fdb8706e64f | yashshah4/python-2 | /ex6.py | 725 | 4.375 | 4 | #creating a string x with formatting method %d
x = "There are %d types of people." % 10
#creating further strings
binary = "binary"
do_not = "don't"
#creating a second string with string formatting method
y = "Those who know %s and those who %s" %(binary, do_not)
#printing the first two strings
print x
print ... |
00d38aa39556de9d7db075af78533305e7007dba | ImtiazMalek/PythonCodesForURIProblems | /uri1018.py | 961 | 3.578125 | 4 | N = int(input())
print(N)
if 0 < N < 1000000:
note1=0
note2=0
note5=0
note10=0
note20=0
note50=0
note100=0
while N >= 1:
if N < 2:
note1 = N//1
N = N % 1
elif N < 5:
note2 = N//2
N = N % 2
elif N < 1... |
ecd6080a2a12318965e7c684741c069bd62d90ff | fly2rain/try_git_pycharm | /unittest/unittest/4_calc_divide.py | 1,034 | 3.625 | 4 | import unittest2
def cacl(a, b):
return a / b
class MyTest(unittest2.TestCase): # 类名需要以大写字母开头
def setUp(self):
print("每个用例执行之前都会执行")
def tearDown(self):
print("每个用例执行之后都会执行")
@classmethod
def setUpClass(cls):
print("所有用例执行之前运行")
@classmethod # 类方法
def tearDow... |
529b1a8ab1516224b6b53ccf6da0733172c88749 | brgermano/estudo_python | /loop/loop_while2.py | 99 | 4.03125 | 4 | numero = 1
while numero%2==1:
numero = int(input("Digite um numero par: "))
print("Done!!!!") |
8f3477536c169937d8052f3d97e730546aa33420 | brgermano/estudo_python | /listas/dicionario3.py | 975 | 4.25 | 4 | #criando um dicionario com dados
dicionario = {"Yoda":"Mestre Jedi", "Mace Windu": "Mestre Jedi", "Anakin Skywalker":"Cavaleiro Jedi", "R2-D2":"Dróide", "Dex":"Balconista"}
#exibindo o dicionário completo
for chave, valor in dicionario.items():
print("O personagem {} é da categoria {}".format(chave, valor))
#remove... |
5aee5b562d0d7168e15fb58f0a96e3d720bc5a6d | brgermano/estudo_python | /variaveis/programa_teste.py | 154 | 3.75 | 4 | valor1 = input("Digite o primeiro valor: ")
valor2 = input("Digite o segundo valor: ")
soma = int(valor1) + int(valor2)
print("A soma é {}".format(soma)) |
566e03d3a6aafdc31f2427f1d04633cdeca96682 | brgermano/estudo_python | /listas/tupla.py | 363 | 4.1875 | 4 | categorias = ("youngling", "padawan", "knight", "master")
print(categorias)
print(categorias[0]) # youngling
print(categorias[1]) # padawan
#usando um indice negativo para exibir o ultimo item da tupla
print(categorias[-1]) # master
# Exibindo cada item da tupla usando um loop
print("======= LOOP ========")
for ca... |
36c92644544f0363e44d4d44e0b793f35586331c | Roberto-Montanez/Pr-cticaListas | /assignments/01YoEstudio/src/exercise.py | 255 | 3.609375 | 4 | def main():
#escribe tu código abajo de esta línea
lista = ['Matemáticas','Física','Química','Historia','Lengua']
i = 0
n = 5
while i<n :
print('Yo estudio '+ lista[i])
i = i+1
if __name__=='__main__':
main()
|
f0e233675d75ce07402c3a23d44d5b533625830b | AliceVandenberghe/Informatica5 | /07a-Iteraties-For-lus/Rij van Fibonacci.py | 295 | 3.90625 | 4 | # invoer
getal = int(input('Getal uit de rij van Fibonacci: '))
getal_1, getal_2, = 1, 1
if getal > 2:
for i in range(3, getal + 1):
getal_3 = getal_1 + getal_2
getal_1 = getal_2
getal_2 = getal_3
print(getal_3)
elif getal == 1 or getal == 2:
print('1')
|
5bd41b3ae6e9fbfd30bd83f9aad3317ac3f85316 | Jadefjg/yuanmahui | /python/ch19-pypy/t2.py | 186 | 3.5625 | 4 | import time
start = time.time()
number = 0
i = 0
while 1:
number += i
i += 1
if i >= 100000000:
break
print(number)
print(f"Elapsed time: {time.time() - start} s")
|
07cf522b16d5d13d48a8a8422ea10b84a60c81b4 | Gladarfin/Practice-Python | /turtle-tasks-master/turtle_11.py | 319 | 4.1875 | 4 | import turtle
turtle.shape('turtle')
turtle.speed(100)
def draw_circle(direction, step):
angle=2*direction
for i in range(180):
turtle.forward(step)
turtle.left(angle)
step=2.0
turtle.left(90)
for i in range(0, 10, 1):
draw_circle(1, step)
draw_circle(-1, step)
step+=0.3
|
6372bab070410f10858d501bf4717d629a143b1e | Gladarfin/Practice-Python | /turtle-tasks-master/turtle_07.py | 183 | 3.90625 | 4 | import turtle
from math import pi, cos, sin
turtle.shape('turtle')
i = 10
while True:
turtle.forward(i)
turtle.left(90)
turtle.forward(i)
turtle.left(90)
i += 5
|
332775837e580c88f2ebbb4a48c3f60d293d132b | mahsa19941994/tamrinat-jalase-2 | /tamrin4.py | 2,396 | 3.734375 | 4 | def print_matrix(mat: dict):
result = []
for r in mat.keys():
c = mat[r]
for c in mat[r].keys():
t = mat[r][c]
print("(", r, ", ", c, ", ", t, ")")
result.append((r, c, t))
return result
def input_matrix(n, m):
vector = dict()
for ... |
47a6aeb5f686281f8df3fdac94908e832c7d7322 | JWilson45/cmpt120Wilson | /madlib.py | 304 | 3.75 | 4 | #madlib.py
def main():
print("Lets make a madlib!")
noun = input("Enter a noun: ")
verb = input("Enter a verb: ")
adj = input("Enter a adjective: ")
place = input("Enter a place: ")
print("Take your", adj, noun, "and", verb, "it at the",place,"!")
print("")
main()
main()
|
b6e57f89bf3fda5a6d8252c204c3072298a37bb7 | aditikhandare4/NBApredict | /NBApredict/models/four_factor_regression.py | 13,429 | 3.71875 | 4 | """
Author: Spencer Weston
Purpose: Four Factor Regression performs a regression on the Margin of Victory (mov) between NBA teams with each teams
four factors(offensive and defensive) as predictors. The regression object is returned from the module.
Args (default):
year (2019): The year of the season desired
... |
409f3f219c0223e04f8d636eb9eb01e00e366291 | alxfed/merge-join | /pivot_table.py | 373 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""...
"""
import pandas as pd
def main():
data2 = pd.DataFrame(
{'a': [1, 2, 3],
'b': [4, 5, 6],
'c': [7, 8, 9]}
)
data_stacked = data2.stack()
data_concat = pd.concat([data2['a'], data2['b']])
data_plus = data2.pivot_table()
print('ok')
if _... |
62fe5a7f5c57dfb95a4d862f8d3be31af26981d7 | alxfed/merge-join | /where_mask.py | 654 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""examples of .where and .mask
"""
import pandas as pd
def condition(frame):
a = frame # Yes, this is the whole frame here.
return frame
def oth(frame):
b = frame
return frame
def main():
data = pd.DataFrame(
[[1, 2, 3],
[4, 5, 3],
[7, 8, 3]]... |
3e428cc2bafef4f11b1062a5b0d630cf696aa362 | alxfed/merge-join | /apply_with_multicolumn_result.py | 900 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""...
"""
import pandas as pd
from datetime import datetime
from numpy.random import randn
def multicolumn(row):
month = row['index'].month
day = row['index'].day
hour = row['index'].hour
# https://docs.python.org/3/tutorial/inputoutput.html?highlight=numbers%20output%20format... |
e0b4849d6bea59c51b50017d00ba93b5defb7963 | johnmarkdaniels/python_practice | /odd_even.py | 272 | 4.125 | 4 | num = int(input('Please input a number: '))
if num % 2 == 0:
print(f'Your number ({str(num)}) is an even number.')
if num % 4 == 0:
print('Incidentally, your number is evenly divisible by 4.')
else:
print(f'Your number ({str(num)}) is an odd number.')
|
eae7b51b1ec2fecb8e44652044513238a3240d40 | zeel1234/mypython | /ma007/Python/Practical2/que3.py | 359 | 3.703125 | 4 | import time;
import sys;
args = sys.argv;
start = time.time();
num = int(args[1]);
number = num;
r=0;
for i in range(num):
d=num%10;
r=(r*10)+d;
num=num//10;
if r==number:
print("is prime");
else:
print("is not prime");
end = time.time();
elapsed = start - end;
time.strftime... |
7bb68d107340fb02b57b4c496601a5ada51f733b | zeel1234/mypython | /ma007/Python/Practical2/que6.py | 224 | 3.796875 | 4 | import sys;
length=(len(sys.argv))-1;
avg=0;
args = sys.argv;
count=0;
i=1;
sum=0;
while(i<=count):
sum=int(args[i])+sum;
'''
for num in range(length):
avg=(avg+num)/length;
print(avg);
'''
|
5dfdf44d7c7c749c5efc12ba9dc8807e3cec8398 | zeel1234/mypython | /ma007/Python/Practical2/que1.py | 207 | 3.90625 | 4 | num1=int(input("enter number1: "));
num2=int(input("enter number2: "));
if num1>num2:
for n in range(num2-1,num1,1):
if n % 2!=0:
print(n);
|
4c306fc9eacf0ba9f7ddfe59162cd0fbd7c3a28b | AriqRashid/password-generator | /main.py | 1,726 | 3.65625 | 4 | import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4'... |
e89510372c3e95dcd8b63854dc093deeeb23d1ee | pollytam/python-challenge | /PyPoll/main.py | 1,350 | 3.71875 | 4 |
import csv
total_votes=0
candidate_list = {}
dataList = []
with open('election_data.csv',"r") as csvFile:
csvReader = csv.reader(csvFile, delimiter=",")
for row in csvReader:
dataList.append(row)
for i in range(1, len(dataList)):
# total number of votes
total_votes = total_votes + 1... |
6d320d8db29665b32b60a26e682459a627f09fb9 | cleltonjm/exercicios_python | /desafio10.py | 138 | 3.75 | 4 | n1 = float(input('Quantos dinheiro você tem na carteira? R$'))
print('Com R${:.2f} você pode comprar US${:.2f} '.format(n1, n1/3.27))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.