blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
2d0187fa36da96f8db03db56e6ba363563a4b2d6 | zhenzey/machine_learning_project | /Housing_price/feature_engineering.py | 6,842 | 3.546875 | 4 | #! /bin/env/python3
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import scipy
from scipy import stats
from scipy.stats import norm, skew
from scipy.special import boxcox1p
import sklearn
from sklearn import preprocessing
class Feature:
def __init__(self, df):
... |
b8e831219b276d62e3f1d46bc82edfacc536b352 | PrashantThakurNitP/python-december-code | /com line arg sum.py | 262 | 3.625 | 4 | from sys import argv
print("Inside com line arg sum.py program")
count=0
y=0
for x in argv:
if x=='com line arg sum.py':
continue
y=y+int(x)
count+=1
print("Total no of argument is {} and the sum of argument is {}".format(count,y))
|
350e9388ab21ee5c0ad8d09c811bade6f5bfcf16 | ANUGEETHA03/Network_Automation | /Registration_login.py | 1,985 | 3.734375 | 4 | from flask import Flask, render_template, redirect, url_for, request
data = {}
app=Flask(__name__,template_folder="templates")
@app.route('/')
#Function for displaying the Initial Webpage
def intro():
return render_template('intro.html')
@app.route('/register.html')
#Function for displaying the Register page after ... |
20bb2786fcfa8e46ad2eb5af1b5ae6459a392483 | sclie001/shellhacks2020 | /icebreaker.py | 38,463 | 3.609375 | 4 | from random import randrange
def choose_icebreaker():
icebreakers = ['What was your first job?',
'Have you ever met anyone famous?',
'What are you reading right now?',
'If you could pick up a new skill in an instant what would it be?',
'Who’s someone you really admire?',
'Seen any good m... |
35f1a4243a2a56315eee8070401ee4f8dc38bf9c | JordanJLopez/cs373-tkinter | /hello_world_bigger.py | 888 | 4.3125 | 4 | #!/usr/bin/python3
from tkinter import *
# Create the main tkinter window
window = Tk()
### NEW ###
# Set window size with X px by Y px
window.geometry("500x500")
### NEW ###
# Create a var that will contain the display text
text = StringVar()
# Create a Message object within our Window
window_me... |
d0ad9ee4882356daa2c6a413dc6b827cd7671a6a | Ricky-001/encryptor_decryptor | /algos/affine.py | 15,763 | 3.703125 | 4 | #!/usr/bin/python3
import argparse
from utilities.tools import clear
from utilities.colors import color
keys = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]
def encrypt(plain,key,step):
if key not in keys:
raise ValueError()
plainASCII = [ord(char) for char in plain]
cipherASCII = []
for i in... |
4df8eadf0fe84ff3b194ac562f24a94b778a2588 | Zioq/Algorithms-and-Data-Structures-With-Python | /7.Classes and objects/lecture_3.py | 2,395 | 4.46875 | 4 | # Special methods and what they are
# Diffrence between __str__ & __repr__
""" str() is used for creating output for end user while repr() is mainly used for debugging and development. repr’s goal is to be unambiguous and str’s is to be readable.
if __repr__ is defined, and __str__ is not, the object will behave as... |
835fff2341216766489b87ac7682ef49a47fb713 | Zioq/Algorithms-and-Data-Structures-With-Python | /1.Strings,variables/lecture_2.py | 702 | 4.125 | 4 | # concatenation, indexing, slicing, python console
# concatenation: Add strings each other
message = "The price of the stock is:"
price = "$1110"
print(id(message))
#print(message + " " +price)
message = message + " " +price
print(id(message))
# Indexing
name = "interstella"
print(name[0]) #print i
# Slicing
# [0:... |
f975fe681f3a7bb265f6cf378571cd833cbc49b6 | Zioq/Algorithms-and-Data-Structures-With-Python | /7.Classes and objects/lecture_1.py | 768 | 3.96875 | 4 | # Build Student class
# Make a first word of class name as capitalize letter
class Student:
# `self` means a instance of class itself
# To allow the no course case and fix the error, assign `None` to a relevent parameter
def __init__(self, first, last, courses=None ):
self.first_name = first
... |
9123640f03d71649f31c4a6740ba9d1d3eca5caf | Zioq/Algorithms-and-Data-Structures-With-Python | /17.Hashmap/Mini Project/project_script_generator.py | 1,946 | 4.3125 | 4 | # Application usage
'''
- In application you will have to load data from persistent memory to working memory as objects.
- Once loaded, you can work with data in these objects and perform operations as necessary
Exmaple)
1. In Database or other data source
2. Load data
3. Save it in data structure like `Dictionary`
4... |
be2ba4efc175bc81f37fb99d56383ad9a69604e2 | Zioq/Algorithms-and-Data-Structures-With-Python | /1.Strings,variables/lecture_1.py | 529 | 3.890625 | 4 | # Strings
print('Hello World using single quotes')
print("Hello World using double quotes")
''' print("""Hello world using
triple quotes, also known as
multi-line strings""") '''
print("Hello world I'm using single quotes")
print('Hello world "using quotes here" double quotes')
print('Hello World I\'m using single q... |
517611d9663ae87acdf5fed32099ec8dcf26ee76 | Zioq/Algorithms-and-Data-Structures-With-Python | /20.Stacks and Queues/stack.py | 2,544 | 4.25 | 4 | import time
class Node:
def __init__(self, data = None):
''' Initialize node with data and next pointer '''
self.data = data
self.next = None
class Stack:
def __init__(self):
''' Initialize stack with stack pointer '''
print("Stack created")
# Only add st... |
6aff153c967e821b61c8e5a29facee8663794522 | Zioq/Algorithms-and-Data-Structures-With-Python | /15.Binary Search/binarySearch_recursive.py | 715 | 3.828125 | 4 | # Bisection search - recursive implementation
def bisection_recur(n, arr, start, stop):
# Set the base case first
if start > stop:
return (f"{n} not found in list")
else:
mid = (start + stop) // 2
if n == arr[mid]:
return (f"{n} found at index: {mid}")
elif n > a... |
0be4e99dbd9d44d1e06064a98e038fae55dec91f | oilbeater/projecteuler | /Multiples_of_3_and_5.py | 1,058 | 4.125 | 4 | '''
Created on 2013-10-24
@author: oilbeater
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
import timeit
def sol1():
return sum((i for i in range(1... |
8460e81be8576efe5f66b4953cc4efd243dac762 | jakeseaton/romance_slavic_diachronic_change | /Conjugation Project--Jake/italian/verble_vocab.py | 1,941 | 4.03125 | 4 |
import vocab
import random
"""from threading import Timer
import time
import timer"""
# Verbal?
print "Welcome to Verble!"
# Mode
ask_for = "Italian"
# fill a dictionary with the words to be practiced
words = {}
for x in vocab.all_vocab:
words.update(x)
# account for English mode
if (ask_for == "English"):
print ... |
5bf9aaf7ee509a9d986888c8498627a6c66e7309 | jakeseaton/romance_slavic_diachronic_change | /Conjugation Project--Jake/italian/iverbs.py | 3,471 | 3.53125 | 4 | # write a function that takes the third form and makes it the third, fourth, and fifth.
pronouns = ["io", "tu", "lei", "lui", "Lei", "noi", "voi", "loro"]
imperfect_endings = ["vo", "vi","va","vamo","vate","vano"]
essere = {
"indicative":["sono","sai","e","e","e", "siamo", "siete","sono"],
"past participle": ("derp... |
daf2b57affee09d5157670e35a5a267d5f2c3cac | jemoore/tabula-recta | /tabula.py | 457 | 3.609375 | 4 | #!/usr/bin/env python
from random import randint
from random import seed
from string import ascii_uppercase
seed(73)
for r in range(27):
if r == 0:
print " ",
for s in ascii_uppercase:
print s,# " ",
print
print '-' * 55
continue
for c in range(27):
... |
0d624fefe156321ad52de0d0c4ae42e9cf04d781 | XZZMemory/xpk | /Question13.py | 1,007 | 4.15625 | 4 | '''输入2个正整数lower和upper(lower≤upper≤100),请输出一张取值范围为[lower,upper]、且每次增加2华氏度的华氏-摄氏温度转换表。
温度转换的计算公式:C=5×(F−32)/9,其中:C表示摄氏温度,F表示华氏温度。
输入格式:
在一行中输入2个整数,分别表示lower和upper的值,中间用空格分开。
输出格式:
第一行输出:"fahr celsius"
接着每行输出一个华氏温度fahr(整型)与一个摄氏温度celsius(占据6个字符宽度,靠右对齐,保留1位小数)。只有摄氏温度输出占据6个字符,
若输入的范围不合法,则输出"Invalid."。
'''
lower, upper = inpu... |
76a3faf2f22c74922f3a9a00b3f2380ad878b633 | XZZMemory/xpk | /Question12.py | 593 | 4.15625 | 4 | '''本题要求将输入的任意3个整数从小到大输出。
输入格式:
输入在一行中给出3个整数,其间以空格分隔。
输出格式:
在一行中将3个整数从小到大输出,其间以“->”相连。'''
a, b, c = input().split()
a, b, c = int(a), int(b), int(c)
# 小的赋值给变量a,大的赋值给变量b
if a > b:
temp = a
a = b
b = temp
if c < a:
print(str(c) + "->" + str(a) + "->" + str(b))
else: # c<a
if c < b:
print(str... |
16155fdabc0d8d70124d4e1b76040b5dd5189de4 | Bahram3110/d16_w4_t1 | /task4.py | 233 | 3.75 | 4 | name = input('Введите имя: ')
name1 = name.lower()
name2 = name[::-1]
name2 = name2.lower()
def cheking_name (name_revers):
if name1 == name2:
print("True")
else:
print('False')
cheking_name(name) |
47f9ed21fa7988e2b6bf1fe96d88d8774e83dcae | PaulSayantan/problem-solving | /HACKERRANK/Problem Solving/Implementation/Viral Advertising/viraladv.py | 143 | 3.734375 | 4 | #!/usr/bin/python3
shares, likes = 5, 2
for _ in range(int(input())-1):
shares = (shares // 2) * 3
likes += shares // 2
print(likes)
|
002c584b14e9af36fe9db5858c64711ec0421533 | PaulSayantan/problem-solving | /CODEWARS/sum_of_digits.py | 889 | 4.25 | 4 | '''
Digital root is the recursive sum of all the digits in a number.
Given n, take the sum of the digits of n.
If that value has more than one digit, continue reducing in this way until a single-digit number is produced.
This is only applicable to the natural numbers.
'''
import unittest
def digitalRoot(n:int):
... |
7be21e3ee7c231c8d112a2d0b6788a1f26a0d15c | PaulSayantan/problem-solving | /LEETCODE/Easy/Merge Two Sorted Lists/mergeTwoLists.py | 839 | 3.875 | 4 | from typing import List
def mergeTwoLists(l1: List[int], l2: List[int]) -> List[int]:
return sorted(l1 + l2)
if __name__ == "__main__":
list1 = [int(x) for x in input().split()]
list2 = [int(x) for x in input().split()]
print(mergeTwoLists(list1, list2))
# class ListNode:
# def __init__(self, val... |
1661fa969a32c86a1b03683c6f841bf63a8d1293 | PaulSayantan/problem-solving | /HACKERRANK/Problem Solving/Algorithms/Implementation/Sherlock and Squares/sherlocksquares.py | 214 | 3.5625 | 4 | from math import ceil, sqrt
for _ in range(int(input())):
a, b = (int(x) for x in input().split())
i = ceil(sqrt(a))
cnt = 0
while i <= sqrt(b):
i += 1
cnt += 1
print(cnt)
|
bec67b41cc9eed65b949b86703c5f169be9e0e46 | PaulSayantan/problem-solving | /HACKEREARTH/Data Structures/Arrays/1-D/microArrayUpdate.py | 355 | 3.5625 | 4 | def arrayUpdate(nums: list, target: int) -> int:
if nums[0] >= target:
return 0
return target - min(nums)
if __name__ == "__main__":
res = list()
array_len, tar = (int(x) for x in input().split())
for _ in range(int(input())):
res.append(arrayUpdate([int(x) for x in input().split()]... |
701089394efdb6d31a2266c1dc2b415b17ae3d84 | PaulSayantan/problem-solving | /LEETCODE/Medium/Longest Substring Without Repeating Characters/longestsubstring.py | 756 | 3.65625 | 4 | def lengthOfLongestSubstring(s: str) -> int:
left = length = 0
visited = dict()
for pos, char in enumerate(s):
if char in visited and visited[char] >= left:
left = visited[char] + 1
else:
length = max(length, pos - left + 1)
visited[char] = pos
retur... |
28dbc9321520a7c8d083a6ce05b655f530fbdf6b | PaulSayantan/problem-solving | /HACKERRANK/Python/Collections/namedtuple.py | 586 | 3.921875 | 4 | from collections import namedtuple
''' Simplified Solution '''
total_students, Student = int(input()), namedtuple('Student', list(str(input()).split('\t')))
print('{:.2f}'.format(sum([int(Student(*input().split()).MARKS) for _ in range(total_students)]) / total_students))
''' Descriptive Solution '''
# total_studen... |
0050ecdb924f57520cbcb2d0507e4fe18f370dc5 | PaulSayantan/problem-solving | /CODEWARS/is_divide_by.py | 1,028 | 3.78125 | 4 | import unittest
def is_divide_by(number, a, b):
return (number % a) == 0 and (number % b) == 0
class is_divide_by_Test(unittest.TestCase):
def test_case1(self):
self.assertEqual(is_divide_by(-12, 2, -6), True)
def test_case2(self):
self.assertEqual(is_divide_by(-12, 2, -5), False)
def... |
55951c1717bad99076d718197c1db303a517fce7 | PaulSayantan/problem-solving | /CODEWARS/swapcase_n.py | 1,194 | 3.9375 | 4 | '''
Your job is to change the string s using a non-negative integer n.
Each bit in n will specify whether or not to swap the case for each
alphabetic character in s. When you get to the last bit of n, circle
back to the first bit. If the bit is 1, swap the case. If its 0, don't swap the case.
You should skip the ch... |
85a5e091af32344e43fc344dc4a4bd483dca75a1 | PaulSayantan/problem-solving | /HACKERRANK/Problem Solving/Algorithms/Implementation/Minimum Distances/minDist.py | 867 | 3.75 | 4 | import unittest
from typing import List
from collections import defaultdict
def minimumDistances(arr: List[int], size: int) -> int:
minDist = 10**5
position_map = dict()
position_map = defaultdict(list)
for pos, item in enumerate(arr):
position_map[item].append(pos)
for i in position_map:... |
bf1738dc857220dc5abafc6e02d28be43b938d30 | 2kwattz/Guess-The-Number-Game | /numbergame2.py | 774 | 3.90625 | 4 | import pyfiglet
import random
number = random.randint(0,100)
no_of_guesses = 0
banner = pyfiglet.figlet_format("Guess The Number")
print(banner)
print("Game by 2kwattz \nTries Left:10")
while (no_of_guesses<10):
no_of_guesses = no_of_guesses + 1
guess = int(input("Enter the number\n"))
i... |
cccfb6f481416b650f8bf04d0bfdff9a5e172a54 | yosifbostandzhiev/problem_solving | /loops/prob1.py | 221 | 4.0625 | 4 | # 1. Write a program that inputs a positive integer N and outputs the factorial of 2N
n = int(("Input your positive integer: "))
n = 2 * n
n_fact = 1
for i in range(1, n):
n_fact = n_fact + n_fact*i
print(n_fact) |
704201b4dc10807811036f9d879941ec2e34129f | Kyrixty/lol | /app/utilities.py | 1,116 | 3.734375 | 4 | import hashlib
import random
import string
import os
#test
class Utility:
'''
Provides useful general functions--such as generating a random string--of which
can be useful to multiple programs in the application.
'''
def genRandomString(size=10, chars=string.ascii_letters + string.digits):
... |
6806bab64048c57dde3c6e19b46ac15252453fab | SeesawLiu/py | /radar-ted.py | 1,070 | 3.515625 | 4 | import matplotlib.pyplot as plt
from math import pi
# Abilities data
ted_abilities = {
'COMPUTER': 62,
'ENGLISH': 55,
'LONGBOARD': 40,
'UKULELE': 35,
'DRIVING': 50,
}
# number of variable
# categories=list(df)[1:]
categories = ted_abilities.keys()
N = len(categories)
# But we need to repeat the f... |
96487cf3863ed2216c6ad83109b16e98c8955b3c | SeesawLiu/py | /abc/func/first_class_functions.py | 2,150 | 4.34375 | 4 | # Functions Are Objects
# =====================
def yell(text):
return text.upper() + '!'
print(yell('hello'))
bark = yell
print(bark('woof'))
# >>> del yell
# >>> yell('hello?')
# NameError: name 'yell' is not defined
# >>> bark('hey')
# HEY
print(bark.__name__)
# Functions Can Be Stored In Data Structures
#... |
24d2adffcd84acfb126a3d618de6a9a4822876d2 | KrishnaGupta72/Pandas | /3_different_ways_of_creating_dataframe/pandas_different_ways_of_creating_dataframe.py | 1,109 | 3.765625 | 4 | import pandas as pd
#Read from a CSV file
df = pd.read_csv("weather_data_1.csv")
print(df)
#Read from an Excel file
df=pd.read_excel("weather_data_1.xlsx","Sheet1")
print(df)
#Creating a dataframe in JSON format
weather_data = {
'day': ['1/1/2017','1/2/2017','1/3/2017'],
'temperature': [32,35,28],... |
f99bcedd6bed96991fb8fdf06eba27708ef867b1 | dks1018/CoffeeShopCoding | /2021/Code/Python/DataStructures/dictionary_practice1.py | 1,148 | 4.25 | 4 | myList = ["a", "b", "c", "d"]
letters = "abcdefghijklmnopqrstuvwxyz"
numbers = "123456789"
newString = " Mississippi ".join(numbers)
print(newString)
fruit = {
"Orange":"Orange juicy citrus fruit",
"Apple":"Red juicy friend",
"Lemon":"Sour citrus fruit",
"Lime":"Green sour fruit"
}
veggies =... |
1c4e7bf09af67655c22846ecfc1312db04c3bfe1 | dks1018/CoffeeShopCoding | /2021/Code/Python/Tutoring/Challenge/main.py | 967 | 4.125 | 4 | import time
# You can edit this code and run it right here in the browser!
# First we'll import some turtles and shapes:
from turtle import *
from shapes import *
# Create a turtle named Tommy:
tommy = Turtle()
tommy.shape("turtle")
tommy.speed(10)
# Draw three circles:
draw_circle(tommy, "green", 50, 0, 100)
draw... |
45a6d829ada04a90c64a5bdd99822a5a7d8981c6 | dks1018/CoffeeShopCoding | /2021/Code/Python/etc/test.py | 1,335 | 3.96875 | 4 | # Administrator accounts list
def getCreds():
# Prompt the user for their username and store it in a variable called username
username = input("What's your username? ")
# Prompt the user for their password and store it in a variable called password
password = input("what's your password?")
... |
894d15b0dc03ad3f22b07860143ab48363b71997 | dks1018/CoffeeShopCoding | /2021/Code/Python/Tutoring/chrisName.py | 114 | 4.09375 | 4 | name = str(input("Please enter your name: "))
age = input("How old are you {0} ".format(name))
print(age)
print() |
760537b38c1899088736d0f4a3ba3d27fe3a29c5 | dks1018/CoffeeShopCoding | /2021/Code/Python/Searches/BinarySearch/BinarySearch.py | 1,779 | 4.15625 | 4 |
low = 1
high = 1000
print("Please think of a number between {} and {}".format(low, high))
input("Press ENTER to start")
guesses = 1
while low != high:
print("\tGuessing in the range of {} and {}".format(low, high))
# Calculate midpoint between low adn high values
guess = low + (high - low) // 2
high_... |
7cc8eac1063d0b9c60f6e4ddfd1c504ed1b0fd83 | dks1018/CoffeeShopCoding | /2021/Code/Python/PiProjects/CardGame/players.py | 529 | 3.71875 | 4 | class Gamers:
def __init__(self, players, playerCount):
self._players = players
self._playerCount = playerCount
def __playerInfo__(self):
return "There are " + self.playerCount + " players, they are:\n" + self.players
def __players__(self, count):
self._playerCount = (i... |
a5b5097cfd81bf9b82e4ffd6b2e58001e71a8037 | dks1018/CoffeeShopCoding | /2021/Code/Python/PythonCrypto/Module_3/openImage.py | 534 | 3.5625 | 4 | # Imports PIL module
from PIL import Image
def open_image():
# open method used to open different extension image file
im = Image.open(r"C:\Users\dks10\OneDrive\Desktop\Projects\Code\Python\PythonCrypto\Module_3\eye.png")
file = open('C:\\Users\\dks10\\OneDrive\\Desktop\\Projects\\Code\\Python\\Python... |
960cf574b67f07b2b108e3ae01f2146ea6481777 | dks1018/CoffeeShopCoding | /2021/Code/Python/DataStructures/class_practice1.py | 363 | 3.96875 | 4 | class Person():
def __init__(self,name,DOB,height,weight):
self.name = name
self.DOB = DOB
self.height = height
self.weight = weight
Darius = Person("Darius", "10/18/1995","6 foot", 185)
print(Darius.name)
print(Darius.DOB)
print(Darius.weight)
print(Darius.height)
... |
6ebdc47b984d3f9b7b65663b2ba01f9b54fc7edf | dks1018/CoffeeShopCoding | /2021/Code/Python/Exercises/Calculator2.py | 1,480 | 4.1875 | 4 | # Variable statements
Number1 = input("Enter your first number: ")
Number2 = input("Enter your second number: ")
NumberAsk = input("Would you like to add a third number? Y or N: ")
if NumberAsk == str("Y"):
Number3 = input("Please enter your third number: ")
Operation = input("What operation would you like to perfo... |
8295142ec306661b5435ca646424501b72209109 | nikashamova/nsuPython | /part3/B/taskB.py | 944 | 3.828125 | 4 | import csv
def is_anagram(str1, str2):
return sorted(list(str1)) == sorted(list(str2))
file = open("input.txt", "r", encoding="utf-8")
count = int(file.readline())
prepared_words = (([w.lower().strip() for w in file.readlines()]))
total = []
added = []
for i in range((len(prepared_words) - 1)):
if i in adde... |
b926d7089ecc5e06fa191e30be164c4e10e2586e | nikashamova/nsuPython | /part3/A/task1.py | 396 | 3.59375 | 4 | import re
file = open("input.txt", "r", encoding="utf-8")
output = open("output.txt", "w", encoding="utf-8")
count = int(file.readline())
regex = re.compile('[^а-я]')
for i in range(count):
s = file.readline()
s = s.lower()
s = s.replace('ё', 'е')
s = regex.sub('', s)
#print(s)
if s == s[::-1]:... |
b0bf2e4453a661cf855f33341dee690cb2478e0c | naivenlp/naivenlp-legacy | /naivenlp/structures/trie_test.py | 1,677 | 3.65625 | 4 | import unittest
from .trie import Trie
class TrieTest(unittest.TestCase):
def testTrie(self):
t = Trie()
t.put("上海市 浦东新区".split())
t.put("上海市浦东新区")
print()
t.show()
self.assertEqual('市', t.get('上海市').val)
self.assertEqual('浦东新区', t.get('上海市 浦东新区'.split())... |
dd6608fa6ec0b67c2bb03cb72a1c8e6286930a0f | MarceloMoraesTech/Calculadora | /calculadora.py | 2,504 | 3.953125 | 4 |
menu='''
MENU
====
1- Somar.
2- Subtrair.
3- Multiplicar.
4- Dividir.
Escolha:
'''
def leiaInt(msg):
ok = False
valor = 0
while True:
soma_x = 0
soma_y = 0
subtrair_x = 0
subtrair_y = 0
multiplicar_x = 0
multiplicar_y = 0
... |
9820a6e2fd5ffe8e532618197922cfa761367568 | ajanzadeh/python_interview | /json/footbal_chalange.py | 1,873 | 3.796875 | 4 | # We want to be able to see how many goals a specific football team in the Premier League scored in total during the 2014/2015 season. All the information you need is contained in this JSON file https://raw.githubusercontent.com/openfootball/football.json/master/2014-15/en.1.json
#
# INPUT string teamKey ^^ the footbal... |
7b98a668260b8d5c0b729c6687e6c0a878574c9d | ajanzadeh/python_interview | /games/towers_of_hanoi.py | 1,100 | 4.15625 | 4 | # Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:
# 1) Only one disk can be moved at a time.
# 2) Each move consists of taking the upper disk from one of the stacks and placing it on... |
9d2e20a001b959ae8ec1e3d497245abc28b1eeec | ajanzadeh/python_interview | /algorithms/repated_word_in_a_file.py | 619 | 3.921875 | 4 | # how many times each word in a file has been repated
from collections import defaultdict
def repeate(path):
dic = {}
sort_dic = {}
with open(path,"r") as f:
lines = f.read().splitlines()
for lin in range(0,len(lines)):
words = lines[lin].split()
for word in range(0,len(words)... |
ad5ffac1ad276520d141b2c270ebc461b06d3770 | EddieGarciaDevOps/Dojo | /Python/fundamentals/ComparingLists/ComparingLists.py | 971 | 3.890625 | 4 | def compareLists(list_one, list_two):
if len(list_one) == len(list_two):
for i in range (0,len(list_one)):
if type(list_one[i] == type(list_two[i])):
if list_one[i] == list_two[i]:
pass
else:
print "The lists are not the sam... |
14e2bc48c90948afbe1ed92b65d95ceabc56de1f | EddieGarciaDevOps/Dojo | /Python/fundamentals/FindingCharacters/FindingCharacters.py | 256 | 4.03125 | 4 | word_list = ['hello','world','my','name','is','Anna']
char = 'o'
def findWords(letter, wordList):
newList = []
for word in wordList:
if letter in word:
newList.append(word)
return newList
print findWords(char, word_list)
|
a1b6118e177e6ac1451863e5ae7943fe8fcfc126 | mark-jay/machine-learning | /supervised/tree.py | 10,418 | 3.65625 | 4 | '''
decision tree
'''
from math import log
import operator, sys
#entropy is about the information of target value.
def calEntropy(dataSet):
numEntries = len(dataSet)
labelCount = {}
for featVec in dataSet:
#get the target value
curLabel = featVec[-1]
if curLabel not in labelCount.k... |
e4d99bb5a2f1a22c90c89aae263a6e4222ca54db | mas-kon/Python_Learn | /find_mutiples.py | 959 | 4.03125 | 4 | def find_multipex(x, y):
z = 0
lst = []
# if not isinstance(x, int):
# print("Число должно быть INT!")
# return 0
# elif not isinstance(y, int):
# print("Лимит должен быть INT!")
# return 0
if y < x:
# print("Лимит должен быть больше числа!")
print(lst)
... |
ca091bae52a3e79cece2324fe946bc6a52ca6c2f | mrmuli/.bin | /scripts/python_datastructures.py | 2,019 | 4.15625 | 4 |
# I have decided to version these are functions and operations I have used in various places from mentorship sessions
# articles and random examples, makes it easier for me to track on GitHub.
# Feel free to use what you want, I'll try to document as much as I can :)
def sample():
"""
Loop through number ran... |
356122c10a2bb46ca7078e78e991a08781c46254 | KingHammer883/21.Testing-for-a-Substring-with-the-in-operator.py | /21.Testing-for-Substring-With-the-in-operator.py | 752 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 18, 2019
File: Testing for a Substring with the in operator
@author: Byen23
Another problem involves picking out strings that contains known substrings. FOr example you might wnat to pick out filenames with a .txt extension. A slice would work for this but using Pyt... |
aafdb81d8579da905c67eab9210eaf86eab191cc | ChuckyNTG/PythonProgramming | /main_game.py | 3,785 | 3.9375 | 4 | import random as rand
########
# Command Line Game designed by my 7 year-old sister. Programming done by ChuckyNTG.
#
#
#######
#Add points for correctanswers, powerups for hard questions if you have enough points
#Dress up person with hats
incomplete_sentences = ['The dog ___ outside','I swam ___ dad','My dad ___ lea... |
ce8efceb3e7f107d5f62dd29ad37966b711de7d2 | ChuckyNTG/PythonProgramming | /AlgoDataStruc/Sort/MergeSort.py | 869 | 3.921875 | 4 |
def start(array):
sort(array, 0, len(array))
def sort(array, lo, hi):
#Keep splitting array in half until it is at its base
if lo>=hi:
return
mid = (lo+hi)/2
sort(array,lo, mid)
sort(array,mid+1, hi)
merge(array,lo,hi)
print array
def merge(array, lo, high):
#array to take ... |
69e8422f3960744a76812f8981e9a9aaf8b5e41a | ChuckyNTG/PythonProgramming | /Problems/Kattis/Line_Them_Up.py | 428 | 3.625 | 4 | from itertools import izip, tee
team = []
for _ in range(0,int(raw_input())):
team.append(raw_input())
t = iter(team)
prev, cur = tee(t, 2)
cur.next()
paired = list(izip(prev,cur))
state = 0
for pair in paired:
if pair[0] > pair[1]:
state += -1
else:
state += 1
if state == len(team)-1:
... |
d0a8d768edb0e216948c41c53592d2fadb2241db | Jalbanese1441/Waterloo-CS-Circles-Solutions | /7B Geometric Mean.py | 83 | 3.53125 | 4 | a = float(input())
b = float(input())
import math
test = a*b
print(math.sqrt(test)) |
5826f0021893bd43bd0bb7ef913184f78dad2942 | Jalbanese1441/Waterloo-CS-Circles-Solutions | /15A Smart Simulation.py | 483 | 3.53125 | 4 | def findLine(prog, target):
for i in range(len(prog)):
splited=prog[i].split()
if splited[0]==str(target):
return i
def execute(prog):
location = 0
i=10
visited=[False]*len(prog)
for i in range(len(prog)):
if location==len(prog)-1: return "success"
temp=(prog[location].split())... |
5e5806c33987009c9f599df3eb73b04d2cd84a67 | Jalbanese1441/Waterloo-CS-Circles-Solutions | /11A Lower-case Characters.py | 152 | 3.765625 | 4 | def lowerChar(char):
if ord(char) >= ord('A') and ord(char) <= ord('Z'):
char = chr(ord(char)+32)
return char
else:
return char
|
775ae5471b1d90a1dd88ac4ffb9cad75ac315934 | antdke/Basketball-Simulator-in-Python | /Basketball3.py | 5,422 | 3.9375 | 4 | ## Anthony Dike started: 3/8/18
##
## This is VERSION 3 of a program that
## will simulate basketball games like NBA 2k.
##
## In this version I will add
## 1) More Overtime and Sportcasting (announcers and stuff)
## 2) Notifier that says when team is blown out or a close game
## 3) Win Counter
##
## abbreviations:
## ... |
d73a4b41708799494b39b64071ca0a48ba8c5a74 | swaroski/AIDeepDive | /deepdiveday1.py | 645 | 4.09375 | 4 | #1) function that converts the argument into a string
def convert_to_string(string):
return str(string)
#2) function that takes two lists as arguments,
# checks whether the two lists have overlapping elements
# and either returns the duplicated elements or provides a nice message
a = []
b = []
... |
9c0a683edece6cbd45bc96e33340374ec2962674 | jlgm/vd-scraping | /src/elem_handler.py | 1,350 | 3.65625 | 4 | """this module will deal with the parts of github urls"""
class Elem(object):
"""Class that provides utility for github urls"""
def __init__(self, url):
self.url = url
def is_blob(self):
"""returns true if this elem is a file and false if it is a folder"""
parts = self.url.split('... |
0606ac38799bfe01af2feda28a40d7b863867569 | PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch | /12. Downloading data from input/downloading-data.py | 260 | 4.15625 | 4 | print("Program that adds two numbers to each other")
a = int(input("First number: "))
b = int(input("Second number: ")) #CASTING allows you to change ONE type of variable to another type of variable
print("Sum of a =", a, "+", "b =", b, "is equal to", a + b)
|
1d863dd58506bb382ce3850784b38e60813fa385 | PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch | /24. List 'in', 'not in'/listain.py | 305 | 4.03125 | 4 | # in
# not in
# operations on list
names = ["Arkadiusz", "Claire", "Peter", "Jacob"]
numbers = [3, 12, 24, 7, -8]
if ("John" not in names):
print("Hello John, welcome!")
if (4 in numbers):
print("Number 4 is inside the list called numbers")
else:
print("Number 4 is not inside the list")
|
7702aca0ec88345ab7697aa1f98a136dea291bf0 | PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch | /66. reading content from file/openingfiles.py | 803 | 3.796875 | 4 | """
FILE - name of location that stores pernamently data
RAM - temporary data storage
Operations you can do on a file:
1) opening
2) writing/reading
3) closing
basic modes(ways) of opening files:
r - R ead - default
w - W rite - if the file existed (will be removed), if not will be created
a - A ppend (adding new ... |
ec03b7eaf28bf5ce9f37534754278e630471f494 | PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch | /45. Measuring performance of code/arithmeticsequence.py | 924 | 3.875 | 4 | """
Measuring the performance of code
"""
import time
def sum_up_to(end):
sum = 0
for number in range(1, end+1):
sum = sum + number
return sum
def sum_up_to2(end):
return sum([number for number in range(1, end+1)])
def sum_up_to3(end):
return sum({number for number in range(1, end+1)})... |
cafe85ae01b5271bd86dd82c797fdbcfddb06be5 | rosnikv/OpenCV2-Python | /Official_Tutorial_Python_Codes/2_core/fiter2d.py | 867 | 3.59375 | 4 | ''' file name : filter2d.py
Description : This sample shows how to filter/convolve an image with a kernel
This is Python version of this tutorial : http://opencv.itseez.com/doc/tutorials/core/mat-mask-operations/mat-mask-operations.html#the-filter2d-function
Level : Beginner
Benefits : Learn to convolve with cv2.fi... |
ba212ce447ccd81cede48f43906bd3590a6381cd | rosnikv/OpenCV2-Python | /Official_Tutorial_Python_Codes/3_imgproc/remap.py | 1,821 | 3.9375 | 4 | ''' file name : remap.py
Description : This sample shows how to remap images
This is Python version of this tutorial : http://opencv.itseez.com/doc/tutorials/imgproc/imgtrans/remap/remap.html#remap
Level : Beginner
Benefits : Learn to use remap function
Usage : python remap.py
Written by : Abid K. (abidrahman2@g... |
6ea202990b68777ed61d70b06f5eb9ee7f0acf2a | Anteru/luna | /luna/geo.py | 4,096 | 3.53125 | 4 | from numbers import Number
import copy
class Vector2:
def __init__ (self, *args):
if len (args) == 1:
assert (hasattr (args [0], '__len__') and len (args[0]) == 2)
self.x = args [0][0]
self.y = args [0][1]
else:
assert (len (args) == 2)
as... |
14f05e95c5c6e04b2f0b9c7c2c8f71041c168a6a | Salvatore83/txt_to_py | /classes/prog.py | 4,027 | 3.640625 | 4 | import os
class Programme():
def __init__(self):
try:
self.fichier_python = open("fichiers/fichier_python.py", "w")
except:
quit()
self.content = ""
self.avant = "\t"
self.ligne = ""
self.fin_ligne = ""
self.nombre_indentation = [1]
... |
9dbcec24d2b156aa7f69a8bf1e65ade631e0eea3 | sdelpercio/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 2,202 | 4.1875 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
elements = len(arrA) + len(arrB)
merged_arr = [None] * elements
# Your code here
while None in merged_arr:
if not arrA:
popped = arrB.pop(0)
first_instance = merged_arr.index(None... |
77d79a10d558f871153a02d7386db26c5a37da9d | patelp456/Project-Euler | /lattice_points.py | 571 | 3.84375 | 4 | #!/usr/bin/env python
# ========= Import required modules =====================
# question is not clear
# for using system commands
import sys
# for using os commands like list directeries etc
import os
# for mathematical functions specially matriices
import numpy as np
# for general maths
from math import *
m,n... |
1bbfdce49e5fd9502618f6261b9ff40b0c91ecdc | patelp456/Project-Euler | /even_fiboncacci.py | 484 | 3.546875 | 4 | #!/usr/bin/env python
# ========= Import required modules =====================
# for using system commands
import sys
# for using os commands like list directeries etc
import os
# for mathematical functions specially matriices
import numpy as np
# for general maths
from math import *
limit = int(sys.argv[1])
a =... |
d63827477f880920dbbd73a19befdd5ffb118b02 | ITA-ftuyama/GerenciadorCache | /ProjetoCacheL3.py | 9,587 | 3.75 | 4 | # !/usr/bin/env python
# -*- coding: utf-8 -*-
u"""Simulador de Sistema de Memória."""
# Professor: Paulo André (PA)
# Disciplina: CES-25
# Autor: Felipe Tuyama
class Cache (object):
u"""Classe Cache."""
def __init__(self, size, block_size, associativity):
u"""Inicialização da Cache."""
self.... |
52cf0e8469ba0dbaecfd617bdbcbf00947addb24 | Techsrijan/diplomaiieit | /vendingmachine.py | 272 | 3.953125 | 4 | num=int(input("how many toffe u want"))
av=10
i=1
while i<=num:
if i<=av:
print("Plese collect toffee=",i)
else:
print("out of stock")
break
i=i+1
else: # this else will run when loop properly runs
print("Thanks Please Visit again") |
dfdce15d468daed6d81882ff74db866803720d4f | harshit-dot/python-programs | /array1.py | 125 | 3.578125 | 4 | string=input()
substring=input()
s=string.strip()
sb=substring.strip()
b=s.find(sb)
print(b)
c=s[b:3]
k=s.remove(c)
print(k)
|
2c9093f3321d2ab4226bc1bd44ffe47046261f10 | harshit-dot/python-programs | /happy.py | 448 | 3.984375 | 4 | class rectangle:
def __init__(self,l,b,r):
self.length=l
self.bredth=b
self.radius=r
def area_rectangle(self):
a=self.length*self.bredth
print(a)
def area_circle(self):
p=self.radius*3.14
print(p)
a=int(input('enter the value of length'))
b=int(input('... |
efb0bd28717c73a45d63a9de5646f1832f0579b7 | JuneTse/MyCoding | /2/数组中重复的数字.py | 1,031 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
数组中重复的数字
1. 题目
在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。
也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是第一个重复的数字2。
2. 思路
(1) 使用辅助数组存放每个数字的次数: C[i]存放数组i的次数
"""
class Solution:
# 这里要特别注意~找到任意重复的一个值并赋值到duplication[0]
# 函数返回True/False
... |
94139a93fc64d104d325b54be4b881bc045fc49c | JuneTse/MyCoding | /1.排序/计数排序.py | 868 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
计数排序
1. 前提条件: 假设数组A中的元素都是0到k之间的数,k=O(n)
2. 思想:
* 统计数组A中小于元素A[i]的个数,这样就可以得到A[i]排序后的位置
3. 过程
* 统计元素A[i]出现的个数C[A[i]]
* 累加得到小于等于A[i]的元素个数:C[A[i]]=C[A[i]]+C[A[i]-1]
"""
def count_sort(A,k):
l=len(A)
B=[-1]*l
C=[0 for i in range(k)]
# 1. 统计A[i]的元素出现的次数
... |
d4d05a4ef6d267e776e1fa169b49c79830ab9772 | JuneTse/MyCoding | /2/字符串排序.py | 980 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
字符串排序
1. 题目
输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。
2. 思路
(1)递归: 分解成子问题求解
* 如果len(s)==1:
输出
* 否则,分解为s[i], s[0:i]+s[i+1:n]
"""
class Solution:
def Permutation(self, ss):
if ss is None:
retu... |
b204be17032ba6122a4d3fecdab5be80a5528a50 | Sonnaly/Exercicio-Revis-o- | /questão 8.py | 1,183 | 3.9375 | 4 | notas = 0
lista = []
lista_reversa = []
while True:
notaX= int(input("Digite uma nota: "))
if notaX == -1:
break
notas += 1
lista.append(notaX)
lista_reversa = lista[::-1]
print("")
print(" A quantidade valores lidos foi: %d\n"%(notas))
print(" Os valores na ordem que foram informado... |
eb4b625458c39c548b8ff405192a9fc952f5b0f3 | cspoon/DataStructures-in-Python | /Sort/MergeSort.py | 2,177 | 3.75 | 4 | import DoublyLinkedList
import Vector
class MergeSort(object):
def listMergeSort(self, list, p, n):
"sort n elements at the beginning of node p"
if n < 2:
return p
mid = n / 2
q = list.getNodeAfterNIndex(p, mid)
p = self.listMergeSort(list, p, mid... |
3469a2c651f84505c0af4cf3734eec0e77f308ff | cspoon/DataStructures-in-Python | /Tree/BinTreeTest.py | 1,402 | 3.8125 | 4 | import BinTree
import Utils
def randomBinTree(bt, x, h):
if h <= 0:
return
if Utils.randomRange(h):
randomBinTree(bt, bt.insertAsRC(x, Utils.randomRange(100)), h - 1)
if Utils.randomRange(h):
randomBinTree(bt, bt.insertAsLC(x, Utils.randomRange(100)), h - 1)
def randomBi... |
bb0b64472fbe2b97b79b007368eeec751f87b7d3 | bmart7/School-Projects | /CSE 331/Project2/Recursion.py | 5,133 | 4.15625 | 4 | """
PROJECT 2 - Recursion
Name: Brian Martin
PID: A56350183
"""
from Project2.LinkedNode import LinkedNode
def insert(value, node=None):
"""
Adds a node with value 'value' in ascending order to a list with head 'node' or creates a new list of length 1
:param value: value to add to list
:param node: h... |
605071feb62fca3eda314d4fa1b145999a40ffe9 | softwarelikeyou/CS313E | /Assignment 4 - htmlChecker/htmlCheckerCourtney.py | 2,701 | 3.75 | 4 | import sys
class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items)-1]
... |
04b704d9811a7d1c9db91db0cbff7d11adfa8f13 | zbck/Titanic | /Feature_selection.py | 2,950 | 3.84375 | 4 | import csv
import numpy as np
from pathlib import Path
class Feature_selection:
'''This class is used to select only some features
of the samples written in a csv file.
'''
EXTENTION = '.csv'
TITANIC_FEATURES = ['id', 'pclass', 'survived',
'name', 'sex', 'age', 'sibsp',
'parch', 'ticket', 'fare',
'... |
0684f210b036b64b9821110bdb976908deeca8ca | Guilherme758/Python | /Estrutura Básica/Exercício i.py | 374 | 4.375 | 4 | # Faça um Programa que peça a temperatura em graus Fahrenheit, transforme e mostre a temperatura em graus Celsius.
# C = 5 * ((F-32) / 9).
fahrenheit = float(input("Informe a temperatura em graus fahrenheit: "))
celsius = 5 * (fahrenheit-32)/9
if celsius.is_integer() == True:
celsius = int(celsius)
prin... |
d4393db248c28cafa20467c616da8428496550fb | Guilherme758/Python | /Estrutura Básica/Exercício j.py | 332 | 4.25 | 4 | # Faça um Programa que peça a temperatura em graus Celsius, transforme e mostre em graus Fahrenheit.
celsius = float(input('Passe a temperatura em celsius: '))
fahrenheit = 9*(celsius/5)+32
if fahrenheit.is_integer() == True:
fahrenheit = int(fahrenheit)
print("A temperatura em fahrenheit é:", f'{fahrenh... |
2c3d68c6da066692baa0ed2843ae62abf1492f54 | harmsm/linux-utilities | /split_dir.py | 1,412 | 3.65625 | 4 | #!/usr/bin/env python
"""
split_dir.py
Takes a directory and splits it into some number of smaller directories.
"""
__usage__ = "split_dir.py dir_to_split num_to_split_into"
__author__ = "Michael J. Harms"
__date__ = "070622"
import sys, os, shutil
def splitDir(dir,split):
"""
Split "dir" into "split" new d... |
e0f808f1c93b832eeb29f9133a86ce99dbbe678d | NuradinI/simpleCalculator | /calculator.py | 2,097 | 4.40625 | 4 | #since the code is being read from top to bottom you must import at the top
import addition
import subtraction
import multiplication
import division
# i print these so that the user can see what math operation they will go with
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("... |
b2377860b50e58e29c4dabde578ba8981e993c04 | MandySuperTT/Algorithm-Practice-Python | /二分法.py | 10,525 | 4.15625 | 4 | ‘’‘
Last Position of Target
Find the last position of a target number in a sorted array. Return -1 if target does not exist.
‘’‘
class Solution:
"""
@param nums: An integer array sorted in ascending order
@param target: An integer
@return: An integer
"""
'''
def lastPosition(self, nums, targ... |
1944db6e10434cac6bea84dbb6a93c1031f4d43f | zhoujunjun-apple/Dynamic-Programming-for-Coding-Interviews | /chapter-01/Q-1.1/py3/main.py | 126 | 3.5625 | 4 | def factorialFunc(n: int)->int:
if n<=0:
return 0
if n==1:
return 1
return n * factorialFunc(n-1)
|
50fb9cc69f8dacdb53071aac402fc0e806843bfe | coder-zhanglei/zhanglei.github.io | /python/test/love.py | 2,131 | 3.625 | 4 | from tkinter import *
from tkinter import messagebox
def closeWindow():
messagebox.showinfo(title="警告",message = "不许关闭,好好回答")
# messagebox.showerror(title="警告",message = "")
return
def closeAllWindow():
window.destroy()
def Love():
love = Toplevel(window)
love.geometry("300x100+610+260")... |
b675a618e289c5d995e0368985788b6b2e636ff8 | Raul-Guerra/Proyecto-Final | /Proyecto Final.py | 3,877 | 3.90625 | 4 | #Esta biblioteca sirve para que no se despliegue todo de golpe
import time #Para que no se despliegue todo de golpe
def nombrecliente(nombre):
print("¡Hola"+" "+"%s!"%nombre)
#Time es para que haya un tiempo de despliegue cuando se ejecuta el programa
time.sleep(2)
print("Este es un programa te ayudará a ... |
bae8df0874fd25083af53ea8d5c0bcdd0fca53c8 | DeepakSunwal/Daily-Interview-Pro | /solutions/find_index_at_element.py | 423 | 3.78125 | 4 | def find_index(numbers, low, high):
if low >= high:
return None
mid = (low + high) // 2
if numbers[mid] == mid:
return mid
if numbers[mid] < mid:
return find_index(numbers, mid + 1, high)
return find_index(numbers, low, mid)
def main():
assert find_index([-5, 1, 3, 4, 5... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.