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 |
|---|---|---|---|---|---|---|
d2e83bb312aeafc86e82c341963ee93860ecf0f8 | nagapoornima22/flask_chatbot_2_db | /model/create_db.py | 714 | 3.703125 | 4 | import sqlite3
conn = sqlite3.connect('users.db')
conn.execute('''CREATE TABLE userdata
(username TEXT NOT NULL,
password TEXT NOT NULL);''')
print ("Table created successfully")
conn.execute("INSERT INTO userdata (username, password) \
VALUES ('xyz',... |
749541c14533655a6c607e04870a34cb637ac0d7 | madhurirakshith/From_iFrame | /Data_Picker.py | 806 | 3.53125 | 4 | from selenium import webdriver
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome(executable_path="D:\\Browser_drivers\\chromedriver.exe")
#driver = webdriver.Firefox(executable_path="D:\\Browser_drivers\\geckodriver.exe")
driver.get("https://jqueryui.com/datepicker/#dropdown-month-year")
dr... |
b8f857e1b4c58cc2e2cef54ecd6d8aa9575fa9c7 | vrolim/Algoritmos-de-substituicao-de-pagina | /algoritmos substituicao.py | 6,550 | 4.125 | 4 | #############################################
##UNIVERSIDADE FEDERAL RURAL DE PERNAMBUCO ##
##DEPARTAMENTO DE ESTATISTICA E INFORMATICA##
##BACHARELADO EM CIENCIA DA COMPUTACAO ##
##SISTEMAS OPERACIONAIS ##
##AUTOR: VITOR ROLIM ##
##PYTHON VERSION 2.7 #... |
7d23baf9584df37d1bc939e790b8905a05fc6094 | samdrivendevelopment/matching_monkey | /card_matching.py | 2,749 | 3.546875 | 4 |
def should_quit(char):
if char in ('q', 'quit'):
return True
return False
def is_invalid(char, len_board):
if char not in len_board:
return True
return False
def is_overlapping(char_index, board):
if board[char_index] != '_':
return True
return False
def has_matched(s... |
9ff241520b142c7149f1b7900e7ae83dd27715a9 | Shri-85535/SIB_expences | /sib_exp.py | 2,859 | 3.53125 | 4 | from modules import * #Importing classes from modules.py
from flask import Flask, jsonify, request, url_for, abort, g
from flask_httpauth import HTTPBasicAuth #Flask-HTTPAuth is a simple extension that simplifies the use of HTTP authentication with Flask routes.
#This class handles HTTP Basic authentication for Flask... |
703bd7118ff467dc98f9b6a3802ca1b74df9e2a5 | itsmesanju/pythonSkills | /leetCode/7.reverseInteger.py | 912 | 4.15625 | 4 | '''
Given a 32-bit signed integer, reverse digits of an integer.
Note:
Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Example ... |
dea69a7e7f3263cf45e7bd8114da0991b0ca5445 | itsmesanju/pythonSkills | /errorHandling.py | 267 | 3.90625 | 4 | #Error Handling
while True:
try:
age = int(input('whats your age? '))
# print(age)
10/age
except ValueError:
print('Please enter number')
except ZeroDivisionError:
print('no zero please')
else:
print('thanks')
break
|
738ffa1d23118b4d44dea483c24056a020454536 | itsmesanju/pythonSkills | /leetCode/125.valid_Palindrome_two_pointer.py | 1,337 | 3.890625 | 4 | import re
class Solution(object):
def isPalindrome(self, s):
s = re.sub(r'[^a-zA-Z0-9]', '', s).upper()
"""
:type s: str
:rtype: bool
"""
'''
Idea : use to pointer, one from the begning other from the end (while loop)
- check if the letter is v... |
c4fd2362f6e8341e7ad8d832fcdffd050454378b | joao-fontenele/cfc_search_engine_tri | /SearchEngine.py | 14,527 | 3.625 | 4 | #!/usr/bin/env python
#coding: utf-8
from __future__ import division
from Parser import Parser
from collections import Counter
from math import log
from util import Document
from util import Query
import Evaluator
import ast
import heapq
import os
import re
import sys
class SearchEngine(object):
def __init__(self... |
4d8affd34e673df740b476a30877738dda994398 | sirunde/coursera | /week3/Maximum Number of Prizes.py | 519 | 3.65625 | 4 | # Uses python3
import sys
def optimal_summands(n):
summands = []
k = 1
rest = n
while rest != 0:
rest -= k
if rest > k:
summands.append(k)
k += 1
elif rest <= k:
k += rest
summands.append(k)
rest = 0
#write your... |
0e02f81f805542fcc3c4095ea1cdc50c84c08110 | ACNoonan/PythonMasterclass | /CreateDB/test.py | 240 | 3.734375 | 4 | import sqlite3
db = sqlite3.connect("contacts.sqlite")
search_name = input("Who're we 'ookin for then? ")
check_sql = "SELECT * FROM contacts WHERE name = ?"
for row in db.execute(check_sql, (search_name,)):
print(row)
db.close()
|
132c2bba74dfd857faaf3ed42033376e3e9dfb0c | ACNoonan/PythonMasterclass | /ProgramFlow/aachallenge.py | 287 | 4.21875 | 4 | number = 5
multiplier = 8
answer = 0
# iterate = 0
# add your loop after this comment
# My Soultion:
# while iterate < multiplier:
# answer += number
# iterate += 1
# The solution she told you not to worry about
for i in range(multiplier):
answer += number
print(answer)
|
03b78a88aad855b84b82a2fda9673e807012bc5d | ACNoonan/PythonMasterclass | /Sets/sets.py | 2,625 | 4.375 | 4 | # # # 2 Ways to Create Sets:
# #
# # farm_animals = {'sheep', 'cow', 'hen'}
# # print(farm_animals)
# #
# # for animal in farm_animals:
# # print(animal)
# #
# # print('-' * 40)
# #
# # wild_animals = set(['lion', 'tiger', 'panther',
# # 'elephant', 'hare'])
# # print(wild_animals)
# #
# # for a... |
fbd9c13917457895fe4d73e60cfe45975819a51c | ACNoonan/PythonMasterclass | /HelloWorld/idioms.py | 378 | 3.671875 | 4 | # 01234567890123456789012345
letters = "abcdefghijklmnopqrstuvwxyz"
emptyLetters = ""
# 1. Reverse letters
print(letters[::-1])
# 2. Print last 4 letters
print(letters[-4:])
# 3. Print first 4 letters
print(letters[:4])
# 4. Get the first letter, and retrieve nothing if string is empty, since
# print(le... |
e548491168889093d7cfee3532810a4af1a92051 | ACNoonan/PythonMasterclass | /Lists/tuples.py | 1,032 | 4.40625 | 4 | # # Tuples are IMMUTABLE
# # Declaring a tuple w/o parenthesis
# t = "a", "b", "c"
# print(t)
#
#
# print("a", "b", "c")
# # Declaring a tuple w/ parenthesis
# print(("a", "b", "c"))
# Tuples w/o parenthesis w/ multiple data types
welcome = 'Welcome to my Nightmare', 'Alice Cooper', 1975
bad = 'Bad Company', 'Bad Comp... |
915de4df06984d86f0237064bb6d0bf015a1d893 | v2webtest/python | /app.py | 307 | 4.25 | 4 | print("Starting programme..")
enType: int = int(input("\n\nEnter program type.. ").strip())
print(enType)
# Checking of Type and printing message
if enType == 1:
print("-- Type is First.")
elif enType == 2:
print("-- Type is Second.")
else:
print("-- Unknown Type!")
print("End of program.")
|
57464b19f0bd2cbca1d4577804a6a7a873a281bf | MaciejSwierad/sql_try | /sql_employees.py | 282 | 3.65625 | 4 | import sqlite3
import random
with sqlite3.connect("newnum.db") as connection:
c = connection.cursor()
c.execute("CREATE TABLE IF NOT EXISTS nums(number INT)")
for i in range(100):
c.execute("INSERT INTO nums(number) VALUES(?)", (random.randint(0,100),))
|
ea435164660f9651a86189a7ecd56f90e8ee2896 | Oalecia/removing_spaces | /removespaces.py | 80 | 3.65625 | 4 | str=input()
import re
pattern=r" "
newstr=re.sub(pattern, "", str)
print(newstr) |
b9be0492e6edd04f2f5bf78d3ea0ec63915baed4 | Ayon134/code_for_Kids | /tkinter--source/evet.py | 649 | 4.3125 | 4 | #handling button click
#when you press button what will happen
import tkinter
#create a window
window = tkinter.Tk()
window.title("Welcome to Tkinter World :-)")
window.geometry('500x500')
label = tkinter.Label(window, text = "Hello Word!", font=("Arial Bold", 50))
label.grid(column=0, row=0)
def clicked():
... |
be83b51a625271190032fbfabb39bd5666a6ce86 | Ayon134/code_for_Kids | /27FridayClass.py | 152 | 3.65625 | 4 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
sum=a+b+c+d
if(sum % 1==0 and sum % sum==0):
print("prime")
else:
print("Not prime") |
39721449e5e0b44751b8b89e4555259efee23c09 | rushabhjhaveri/Rutgers-CS314 | /Projects/project3/pages.py | 4,568 | 3.546875 | 4 | '''
Author: Rushabh Jhaveri
NetID : rrj28
Principles of Programming Languages, Spring 2018.
Professor Louis Steinberg
'''
import sys
import subprocess
import re
# Calls the R system specifying that commands come from file commands.R
# The commands.R provided with this assignment will read the file named
# ... |
4d9ba6fce3e837aced0294b7c8492ac112b379fc | isolde18/Class | /returnvalues3.py | 196 | 3.84375 | 4 |
def number():
num1=int(input("Please enter number "))
num2=int(input("Please enter number2 "))
return num1,num2
number1 , number2=number()
print(number1)
print(number2)
|
8ad20442eca23b0efecddc3ac0d3797475eda547 | GuangYao-Dou/C | /studytest/test22.py | 1,462 | 3.71875 | 4 | import sys
# num=float(input(''))
# if num%2:
# print(num,"是奇数")
# else:
# print(num,"是偶数")
# number = int(input(''))
# print('{}是{}'.format(number,'奇数'if number%2 else "偶数"))
# score=int(input("请输入得分:"))
# if score>=90:
# print(score,"A")
# elif 90>score>=80:
# print(score,"B")
# elif 80>score>=70:
#... |
387203d2ee472f4db9c047368591db1d074cf00d | whtjdejr0824/macbook | /ex01.py | 82 | 3.78125 | 4 | print("hello world")
print(2 ** 3.0)
print(int("3")+ float("5"))
print(str(4.0)*2) |
dfa7603a582e6018dfc3dc29aeac6ba2922b8113 | ChristopherMichaelOwens/WarAndPeace | /Napoleon.py | 1,778 | 3.71875 | 4 | import re
import numpy as np
import matplotlib.pyplot as plt
#Identifies the number of times Napoleon is mentioned on a per book basis
def napoleon_freq(words):
# opens text file
file = open(words, 'r', encoding="utf8")
# creates a list of words for each line in the text
txt_split = [line.rstrip('\n') for line in ... |
b32454e05f3e5bdc0ad7684f84eb61c27bfb7797 | JoshuaW1990/leetcode-session1 | /leetcode56.py | 703 | 3.703125 | 4 | # Definition for an interval.
# class Interval(object):
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
if intervals == []:
... |
611b4f0db463b4c25e63e1f625ed0c4142038905 | JoshuaW1990/leetcode-session1 | /leetcode224.py | 2,524 | 3.5625 | 4 | """
https://discuss.leetcode.com/topic/15806/easy-18-lines-c-16-lines-python
"""
class Solution(object):
def calculate(self, s):
"""
:type s: str
:rtype: int
"""
result = 0
i, sign = 0, [1, 1]
while i < len(s):
c = s[i]
if c.isdigit():
... |
d29a734448609b9fecf9c8700464bc51e277dbfb | JoshuaW1990/leetcode-session1 | /leetcode300.py | 1,882 | 3.765625 | 4 | """
1. sort the list
2. run LCS
"""
class Solution(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
sort_nums = list(set(nums))
sort_nums.sort()
return self.lengthOfLCS(nums, sort_nums)
def lengthOfLCS(self, nums1, nu... |
c7590f04039378adab64faeeb65939b34150a709 | JoshuaW1990/leetcode-session1 | /leetcode599.py | 836 | 3.53125 | 4 | class Solution(object):
def findRestaurant(self, list1, list2):
"""
:type list1: List[str]
:type list2: List[str]
:rtype: List[str]
"""
dict1, dict2 = dict(), dict()
for i, name in enumerate(list1):
dict1[name] = i
set1 = set(dict1.keys())
... |
a6883f15a069c8a94488a5fee4532fd7c6add27a | JoshuaW1990/leetcode-session1 | /leetcode25.py | 982 | 3.8125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseList(self, head):
if not head:
return None
tail, current, prev = head, head, None
while current.next:
... |
127e19e5ef50eed18c3aa24e4be3e8daa95e0681 | JoshuaW1990/leetcode-session1 | /leetcode563.py | 838 | 3.890625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
self.result = 0
def findSum(self, current_root):
"""
Calculate the sum of the tree whose root is cur... |
4c2b6dfbd0adaec4f7210257470f4eb7377f9e7a | JoshuaW1990/leetcode-session1 | /leetcode383.py | 609 | 3.5 | 4 | """
Use hash map
"""
class Solution(object):
def canConstruct(self, ransomNote, magazine):
"""
:type ransomNote: str
:type magazine: str
:rtype: bool
"""
ch_dict = {}
for ch in ransomNote:
if ch not in ch_dict:
ch_dict[ch] = 1
... |
a7473f5b07d9a489651faf83ade6562d695316cf | JoshuaW1990/leetcode-session1 | /leetcode57.py | 2,032 | 3.828125 | 4 | """
First session
"""
# Definition for an interval.
# class Interval(object):
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution(object):
def insert(self, intervals, newInterval):
"""
:type intervals: List[Interval]
:type newInterval: Interva... |
fe79dc19ad4c96d7948af8f0bcf30d2f92856dae | JoshuaW1990/leetcode-session1 | /leetcode414.py | 679 | 3.84375 | 4 | class Solution(object):
def thirdMax(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
maxList = []
for num in nums:
if num in maxList:
continue
if len(maxList) == 0 or num > maxList[0]:
maxList.insert(0, nu... |
cb4b1efe0243337ad2b7b0404df343fa4c6b0321 | JoshuaW1990/leetcode-session1 | /leetcode322.py | 1,056 | 3.5 | 4 | """
my code: DP
"""
import sys
class Solution(object):
def coinChange(self, coins, amount):
"""
:type coins: List[int]
:type amount: int
:rtype: int
"""
DP = [amount + 1 for i in xrange(amount + 1)]
DP[0] = 0
for num in xrange(1, amount + 1):
... |
ce269d6af986b6b9a2d68c816c830197977e2cd3 | JoshuaW1990/leetcode-session1 | /leetcode543.py | 729 | 3.9375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def helper(self, node):
if node is None:
return 0, 0
leftDepth, leftDiameter = self.helper(no... |
3bddfb7407086a434ce073143197d8d0a9e21f26 | JoshuaW1990/leetcode-session1 | /leetcode2.py | 1,173 | 3.765625 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
ptr1 ... |
81397e526bb846c5734c3354095d4733c7c3d7b3 | tiagoleonmelo/ia | /redes_conhecimento/semantic_network.py | 8,195 | 4.0625 | 4 | from collections import Counter
# Guiao de representacao do conhecimento
# -- Redes semanticas
#
# Inteligencia Artificial & Introducao a Inteligencia Artificial
# DETI / UA
#
# (c) Luis Seabra Lopes, 2012-2020
# v1.9 - 2019/10/20
#
# Classe Relation, com as seguintes classes derivadas:
# - Association - uma as... |
b851d018f28a6d428ddbeab28273dc10a19e00ef | yc65/algorithm | /course1_wk4/wk4_kargerMincut.py | 4,652 | 3.53125 | 4 | # -*- coding: utf-8 -*-
import codecs
import random
def get_data(infile):
all_data = []
with codecs.open(infile) as fi:
data = fi.readlines()
fi.close()
for line in data:
all_data.append(line.strip().split(' '))
return all_data
class AdjNode(object):
"""docstring for AdjNode"""
def __ini... |
9088fe73dc65b4874dc55c40df0b5bd66fb6eddd | yc65/algorithm | /course1_wk3/wk3_exercise.py | 2,510 | 3.78125 | 4 | # -*- coding: utf-8 -*-
import codecs
def read_data(infile):
data_int = []
with codecs.open(infile) as fi:
data = fi.readlines()
for line in data:
data_int.append(int(line.strip()))
return data_int
class QuickSort(object):
"""docstring for QuickSort"""
def __init__(self, arr):
self.arr = arr
self.co... |
a8294e0b0fcdffdb6308476af89ca5fbfc9f0e91 | kushalkarki1/pythondjangoclass | /forloop.py | 1,125 | 3.90625 | 4 | # loop
# [2, 4, 6, 8, 10]
# for i in <iterable_object>:
# block of code
# block of code
# alist = ["python", "PHP", "JS", "Java"]
# print(alist[0])
# print(alist[1])
# print(alist[2])
# print(alist[3])
# for i in alist:
# print(i)
# a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# for i in a:
# print(i)
# ... |
9df7f613f1f637be2df86dd57d4b255abd91b932 | infantcyril/Python_Practise | /Prime_Count_Backwards.py | 2,061 | 4.1875 | 4 | check_a = 0
a = 0
def prim(check,a):
check_a = 0
while (check_a == 0):
try:
check_a = 1
a = int(input("Enter the Number from where you want to start searching: "))
if (a <= 2):
check_a = 0
print("Please enter a value greater t... |
137820c8f3df39e0456ad149c8003925985bd0fb | infantcyril/Python_Practise | /Prime_Number.py | 1,151 | 4.15625 | 4 | check_a = 0
a = 0
def prime(check,a):
check_a = 0
while (check_a == 0):
try:
check_a = 1
a = int(input("Enter the Number from where you want to start searching: "))
if (a <= 1):
check_a = 0
print("Please enter a value greater ... |
2f2d95d2dade981e3e4f3cc50949fa66116c73cb | manmohitgrewal1/Python-Code-Silo | /Data Structure Implementation/1-generalTree.py | 1,679 | 3.859375 | 4 | class TreeNode:
def __init__(self, data):
self.data= data
self.children=[]
self.parent=None
def addchild(self, child):
child.parent= self
self.children.append(child)
def showTree(self):
prefix= " " * self.get_level() *3 + "|--"
print(pre... |
722d462d7142bc66c5abcbcf23867507d5f116cb | r4isstatic/python-learn | /if.py | 417 | 4.4375 | 4 | #!/usr/bin/env python
#This takes the user's input, stores it in 'name', then runs some tests - if the length is shorter than 5, if it's equal to, and if it equals 'Jesse'.
name = raw_input('Please type in your name: ')
if len(name) < 5:
print "Your name is too short!"
elif len(name) == 5:
print "Your name is the ... |
7ac2654a0a4424bb69b7c83218a5c02fb19a2ee5 | gm0907/Social-Networks-Structure | /graph.py | 2,760 | 3.53125 | 4 | import random
import itertools
# ASSIGNMENT
# fare proc per indice di clustering
# 50 run
# - medie e grafico con indice di clustering
# - n = 100, p = [0.1, .., 1] +0.15
class Graph:
nodes = []
def add_edge(self, i, j):
self.nodes[i].add_neighb(self.nodes[j])
self.nodes[j].add_neighb(self.nodes[i])
def ra... |
1c9ec18cd80266e53d4e2f01d73dc0c9fb0099f0 | npradaschnor/algorithms_module | /caesar_cipher.py | 960 | 4.34375 | 4 | # Based on Caesar's Cipher
#Substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number (offset) of positions down the alphabet.
#In this case is upper in the alphabet
def encrypt(plain_text, offset):
cipher_text = ""
for i in plain_text: #for every char in text inputted
... |
3bbce6604801ae9019975edc3ce0e07ea347b90c | npradaschnor/algorithms_module | /odd_position_elements_array.py | 1,141 | 4.15625 | 4 | #Write an algorithm that returns the elements on odd positions in an array.
#Option 1 using 2 functions
def range_list(array):
array = range(0,len(array))
i = []
for e in array:
i.append(e)
return i
def odd_index(array):
oddl = []
a = range_list(array)
for n in a:
if n%2 != 0: #... |
ea07e7f7353344e90bbc9e4b0ccdff5ebc22a87f | npradaschnor/algorithms_module | /merge.py | 561 | 4.1875 | 4 | #recursive function that returns a merged list (1 element of str1 + 1 element of str2...and so on)
def merge(str1,str2):
if len(str1) == 0: #if the number of element in the str1 is zero, return str2
return str2
elif len(str2) == 0: # if the number of element in the str2 is zero, return str1
return str1
... |
f688f488eb0231ca39b3dea0bf2e863281793294 | npradaschnor/algorithms_module | /sum.py | 236 | 3.703125 | 4 | #sum the elements of an array
def sumArray(array):
e = len(array)
if e == 1:
return array[0]
else:
return array[0]+ sumArray(array[1:])
a = range(10)
print(sumArray(a))
#testing with a builtin function
print(sum(a)) |
dd219e9fd40d4a851ede1848adbc5fcde6efebb7 | michaelknopf/WackyPong | /WackyPong.py | 10,657 | 3.890625 | 4 | import pygame, sys, random
from pygame.locals import *
GAMESPEED = 60
WINDOWWIDTH = 700
WINDOWHEIGHT = 700
LINETHICKNESS = 10
BALLRADIUS = 7
BALLSPEED = 4
PADDLEHEIGHT = 10
PADDLEWIDTH = 80
PADDLESPEED = 5
WINDOWMARGIN = 5
BLACK = (0,0,0)
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
WHITE = (255,255,255)
""... |
a03a368c780b1b1ee57664cf997e80f6936b7c45 | jeremykid/FunAlgorithm | /python_practice/nn_main.py | 746 | 3.515625 | 4 | # Data
Xtr, Ytr, Xte, Yte = load_CIFAR10('data/cifar10/') # a magic function we provide
# flatten out all images to be one-dimensional
Xtr_rows = Xtr.reshape(Xtr.shape[0], 32 * 32 * 3) # Xtr_rows becomes 50000 x 3072
Xte_rows = Xte.reshape(Xte.shape[0], 32 * 32 * 3) # Xte_rows becomes 10000 x 3072
# Create nn model tr... |
59e2c22bf1d86e300f9f766ce4c3bfbc21501a29 | jeremykid/FunAlgorithm | /RedPack/ReaPack.py | 341 | 3.75 | 4 |
def main():
inputArray = raw_input("").split(" ")
inputArray = [int(i) for i in inputArray]
for i in range(len(inputArray)):
inputArray[i] = inputArray[i] + 0.5*inputArray[(i+1)%3] + 0.5*inputArray[(i+2)%3]#0 1 2
inputArray[(i+1)%3] = 0.5*inputArray[(i+1)%3]
inputArray[(i+2)%3] = 0.5*inputArray[(i+2)%3]
pr... |
09d048926d54f27b7ff437bb52cfcfc75c204a02 | jeremykid/FunAlgorithm | /python_practice/leetCode/leetcode-102.py | 819 | 3.75 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
result = []
if root == None:
return result
p... |
75cc5d3d94946b67bba2455aa3bdda9c447f4a9b | jeremykid/FunAlgorithm | /python_practice/leetCode/leetcode-7.py | 403 | 3.578125 | 4 | class Solution:
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
INTEGERMAX = 2**31 - 1
INTEGERMIN = - 2**31
res = 0
postive = 1
if (x < 0):
postive = -1
x = abs(x)
res = int(str(x)[::-1])*postive
i... |
3c48d4eec374ef2d44239dd960d01a13e87d8c93 | jeremykid/FunAlgorithm | /python_practice/data_structure/queue/queue_linked_listTest.py | 364 | 3.6875 | 4 | from queue_link_list import queue_linked_list
def test1():
QLL = queue_linked_list()
QLL.enqueue('A')
QLL.enqueue('B')
QLL.enqueue('C')
print "1. QLL = ",QLL
QLL.enqueue('D')
print "2. After QLL.enqueue('D') QLL = ",QLL
print "3. After QLL.empty() = ",QLL.empty()
QLL.dequeue()
print "4. After QLL.dequeue()... |
2e63e5bb0dc013d6ec0171b5da6b4566aaedb8ec | jeremykid/FunAlgorithm | /python_practice/graph/binary_search_tree/binary_search_tree.py | 2,675 | 3.90625 | 4 |
class binary_search_tree(object):
def __init__(self, value):
self.value = value
self.right_node = None
self.left_node = None
def __str__(self):
print self.left_node
print self.value
print self.right_node
def insert_node(self, insert_value):
if insert_value == self.value:
retur... |
59bbfea4987ad635ea94aebd76c9f10b550c6c15 | themohitpapneja/Hacktoberfest-Beginner-level | /Python/merge_sort.py | 609 | 3.8125 | 4 | #coding: utf-8
def merge_sort(array):
if len(array) < 2:
return;
mid = len(array) / 2;
left = array[:mid];
right = array[mid:];
leftI = 0;
rightI = 0;
arrayI = 0;
while leftI < len(left) and rightI < len(right):
if left[leftI] < right[rightI]:
array[arrayI] = left[leftI];
... |
cef11b0b75eec9334c300e27dee423be29ac1ebd | MalSemik/nauka-5.0 | /przelicznik_walut.py | 2,490 | 3.609375 | 4 | # słownik kursów
kursy = {"EUR": 4.2999, "GPD": 5.0272, "USD": 3.8232, "AUD": 2.6994}
def moje_przeliczWaluty(kurs):
# Pobranie informacji co użytkownik chce przeliczyć i w jakiej ilości
podajWalute = input("Podaj walutę do przeliczenia:\n")
while podajWalute.upper() not in kursy:
podajWalute = in... |
e445249a12d9e8719205f6d673efe6422c6498f6 | MalSemik/nauka-5.0 | /dane_osobowe.py | 1,010 | 3.859375 | 4 | while True:
print("""
MENU
1. Dodaj osobę
2. Odcztaj dane osoby
3. Wyjdź """)
choice = input("Wybierz pozycję z menu: ")
if choice == "1":
with open("dane_osobowe.txt", "a") as dane_osobowe:
name = input("Podaj imię: ")
surname = input("Podaj nazwisko: ")
... |
4bd7264e450c8525dd75ff886d301f30c7c0bcb5 | MalSemik/nauka-5.0 | /Spoj/calculator.py | 460 | 3.703125 | 4 | import sys
for line in sys.stdin:
inserted_line = line.split()
sign = inserted_line[0]
a = int(inserted_line[1])
b = int(inserted_line[2])
if sign == "+":
print(a + b)
elif sign == "-":
print(a - b)
elif sign == "*":
print(a * b)
elif sign == "/":
print(a... |
ffa5699cf13e521990c3b482923b5af5e35a48fa | MalSemik/nauka-5.0 | /my_tictactoe.py | 4,178 | 3.859375 | 4 | import random
size = 3
def create_board(size):
board = [[" " for i in range(size)] for j in range(size)]
return board
def print_board(board):
for k in range(len(board)):
print(board[k])
def numarate_cells(): # tu powinien przyjmować tablicę i sam se ją tak numerować, ale nie mogę wymyślic ja... |
86f908c910f7b79750bbd88c0ee17e6eb02d70ef | Diglet7781/technicalInterviewProblems | /ArraysAndStrings/permutationOfEachOther.py | 719 | 4.0625 | 4 | word1 = "test"
word2 ="tSet"
def permutationOfEachOther(word1, word2):
for i in range(len(word1)):
if word1[i] not in word2:
return False
return True
print(permutationOfEachOther(word1, word2))
#Method 2
#sort the two words
#compare each element/character if does not match return False
d... |
eff6bd96ff0bd1155c4629f444675d9c75f7b0b2 | piercepurselley/Python_Web_Dev_Practice | /Python Web Dev Practice/stars.py | 555 | 3.609375 | 4 | Part I
arr = [4,6,1,3,5,7,25]
def draw_stars(arr):
for x in range(0,len(arr)):
print arr[x]*"*"
#as many times as at the index(x)
draw_stars(arr)
Part II
arr = [4,"Tom",1,"Michael",5,7,"Jimmy Smith"]
result = 0
def draw_stars(arr):
for x in range(0,len(arr)):
if isinstance(arr[x],i... |
0fd389ff8fdaa89d7f4d5263c8ba70df7b1546c7 | piercepurselley/Python_Web_Dev_Practice | /Python Web Dev Practice/compare_list.py | 177 | 3.78125 | 4 |
list_one = ['celery','carrots','bread','milk']
list_two = ['celery','carrots','bread','milk']
if list_one == list_two:
print "THAR BE THA SAME"
else:
print "ARRRR no." |
8c8a718561a42913c53ca46d705c7a5658afe835 | coderLong/leetcode | /leetcod/str_algorithm.py | 1,940 | 3.59375 | 4 | #-*-coding:utf-8-*-
# @Author: MaLong
# three sum 三个数相加
def three_sum(nums):
res = []
# 建立字典, value 是下标
hash_sum = {}
for i in range(len(nums)):
key = 0 - nums[i]
if key not in hash_sum:
hash_sum[key] = [i]
else:
tmp = hash_sum[key]
tmp.appen... |
b5b1bb0fbd223a3a5b8d7a9d14955f4f56a860f7 | antunjm/aulas-udacity | /curso-revisao-algebra-linear/vector/main.py | 2,281 | 3.59375 | 4 | #!/usr/bin/python3.5
# -*- coding: utf-8 -*-
"""
Udacity - aulas
"""
from vector import Vector
if __name__ == '__main__':
FOOTER_DIV = '-' * 80
# Quiz 1
print('Quiz 1:')
v1 = Vector([8.218, -9.341])
v2 = Vector([-1.129, 2.111])
print('{} + {} = {}'.format(v1, v2, v1 + v2))
v1 = Vec... |
672f9e38fd6e0b5e1643f19170460f2fe740e2b0 | krajcovic/python-tests | /markpilgrim/tut_2/tut_2_3_5.py | 271 | 4.09375 | 4 | #!/usr/bin/env python3
import fractions
def is_it_true(anything):
if anything:
print(anything, "\t\t= yes, it's true")
else:
print(anything, "\t\t= no, it's false")
is_it_true(1)
is_it_true(-1)
is_it_true(0)
is_it_true(fractions.Fraction(1, 2)) |
c8a46cb568c5eabb5e8914264a02440ded9ddddf | ritzgeorge/Essentials | /class.py | 986 | 3.6875 | 4 | class vehicle:
def __init__(self,make,model,year,weight):
self.make=make
self.model=model
self.year=year
self.weight=weight
self.tripssincemaintainance=0
self.needsmaintance=False
def needsmaintance(self):
self.needsmaintance=False
self.tripssincemaintainance=0
def repair(self):
self.needsmaintance... |
4657fb179ddf454b1e09b4e501028a70fdcc3062 | rnem777/python-project | /class_try.py | 743 | 4.25 | 4 | #it is to modify between the subject and the behaviour
# the name has always to stat with cabital litter
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def walk(self):#self here will give us access to name
print(self.name + ' is a student at sunderla... |
d0693300171bfc11fec4c8b4c51c9023fc56e653 | ethanshealey/Intro-Information-Security | /fileValidator/validator.py | 655 | 3.671875 | 4 | import hashlib
import os
if not os.path.exists('integrity'):
print('File \'integrity\' not found, creating new integrity file')
with open('integrity', 'w+') as file:
with open('target.txt', 'r') as target_file:
target = hashlib.sha256(target_file.read().encode()).hexdigest()
file.wr... |
82593cb7ca8b771914633113f37187cce39b9b36 | TonyPythoneer/codility | /tests/M_DeepestPit.py | 630 | 3.515625 | 4 | def strictly_increasing(L):
return all(x<y for x, y in zip(L, L[1:]))
def strictly_decreasing(L):
return all(x>y for x, y in zip(L, L[1:]))
def solution(A):
# write your code in Python 2.7
n = len(A)
max_ = -1
for i in range(n-2):
for j in range(i+1,n-1):
for k in range(j+1... |
ff9b9d75bfe8cf77665d502ea0c3cd82329994fa | ankitrana1256/LeetcodeSolutions | /Valid Number[ 82.42% ].py | 1,225 | 3.5625 | 4 | # VALIDATE NUMBERS
#s = "0e1"
#s = "0"
#s = "2"
#s = "0089"
#s = "-0.1"
#s = "+3.14"
#s = "4."
#s = "-.9"
#s ="-90E3"
#s = "3e+7"
#s = "+6e-1"
#s = "53.5e93"
#s = "-123.456e789"
# NON VALIDATE NUMBERS
#s = "abc"
#s = "1a"
#s = "1e"
#s = "e3"
#s = "99e2.5"
#s = "--6"
#s = "-+3"
#s = "95a54e53"
... |
2905a37931e56500161e06a2fcb6cd0324781de5 | ankitrana1256/LeetcodeSolutions | /Palindrome Number [ 80.82 ].py | 297 | 3.578125 | 4 | # LEETCODE
class Solution:
def isPalindrome(x: int) -> bool:
y = str(x)
new_list = list(y)
no = new_list[::-1]
new_no = "".join(no)
if y == new_no:
return True
else:
return False
a = Solution.isPalindrome(121)
print(a) |
1b1c90db1bc1dcb482d3222b6a45a4235784f6e3 | ankitrana1256/LeetcodeSolutions | /Valid Palindrome[84.89%].py | 406 | 3.578125 | 4 | class Solution:
def isPalindrome(s):
s = list(s)
res = []
for i in s:
if i.isalnum():
res.append(i)
given = "".join(res).lower()
res = res[::-1]
output = "".join(res).lower()
if given == output:
return True
else:... |
360bb0aae3cf4d6aa936a500cdb2e0c716dbbaac | Morgan1you1da1best/unit2 | /unitConverter.py | 439 | 4.21875 | 4 | #Morgan Baughman
#9/15/17
#unitConverter.py - COnverting Units of stuff
a = ('1) Kilotmeters to Miles')
b = ('2) Kilograms to Pounds')
c = ('3) Liters to Gallons.')
d = ('4) Celsius to Fahrenheit')
print('choose a convertion.')
print('a) Kilotmeters to Miles')
print('b) Kilograms to Pounds')
print('c) Liters to Gallo... |
9a892afe4a0528cbd26ebba1d5861b54e358cecd | Morgan1you1da1best/unit2 | /warmUp3.py | 336 | 4.34375 | 4 | #Morgan Baughman
#9/15/17
#warmUp3.py - practicing if statements
num = int(input('Enter a number: '))
if num% 2 == 0 and num% 3 == 0:
print(num, 'is divisible by both 2 and 3')
elif num% 2 == 0:
print(num, 'is divisible by 2')
elif num% 3 == 0:
print(num, 'is divisible by 3')
else:
print(num , 'is divi... |
55517870a0aa0209f38670fbbba017923ba1f018 | DanielAvdar/Data-Structures-and-Algorithms-Specialization | /evacuation.py | 5,154 | 3.734375 | 4 | # python3
##############################
#
# @author Daniel Avdar
#
# @description:In this problem, you will apply an algorithm for finding
# maximum flow in a network to determine how fast people can
# be evacuated from the given city.
#
# @input: a flow network
#
# @output:Output a single in... |
17b6089b6431db527dd09107ccfc040270dfbbe8 | Dstar4/Computer-Architecture | /ls8/cpu.py | 5,152 | 3.609375 | 4 | """CPU functionality."""
import sys
class CPU:
"""Main CPU class."""
def __init__(self):
"""Construct a new CPU."""
self.pc = 0
self.ram = [0] * 256
self.reg = [0] * 8
self.reg[7] = 0xf4
self.FL = 0b00000000 # Flags
@property
def sp(self):
ret... |
92f1008f1ecdea4024fe8aa7a9cef7ce7391334a | Cyndi-Tokyotech/Utils | /solved_error.py | 421 | 3.703125 | 4 |
# ============
# Error 1
# ============
'''
# Raised Error
TypeError: sequence item 0: expected str instance, int found
# Situation
[文章, 文章, 文章, ・・・] を "".join([list]) でひとつの文章列に結合しようとした。
# Solution
int が混じっていると error になるので, string 化する map 関数を適用
'''
# Example
a = [1,2,3,4]
print("".join(map(str, a)))
# => 1234
... |
30279ec91923a12d9969b22073059a1d69682879 | lee-saint/BucketTerminator | /bucketterminator.py | 1,203 | 3.609375 | 4 | import boto3
if __name__ == '__main__':
client = boto3.client('s3')
s3 = boto3.resource('s3')
# 지우고 싶은 버킷에 들어 있는 문자열을 입력받는다
bucket_name_substring = input('Bucket name you want to find: ')
buckets = client.list_buckets()['Buckets']
bucket_names_to_delete = [bks['Name'] for bks in buckets if bu... |
1721c8bf76ee2545edfd15fae9bc9aac6c55f94d | Necron9x11/udemy_pythonWorkbook100Exercises | /ex-03/ex-03.py | 485 | 3.828125 | 4 | #
#
# Question: Executing the code will throw an error. Can you explain why?
a = 1
b = 2
print(a == b)
print(b == c)
#
# In the 4th line, variable c is undefined so the code will throw a NameError.
#
# Ran it in the interpreter on the CLI so I could add the output that proves my answer.
#
# @>>> a = 1
# @>>> b = 2
# ... |
7ca02e4f2af417d3a67f16cd90e3f87c722515c2 | Necron9x11/udemy_pythonWorkbook100Exercises | /ex-20/ex-20.py | 1,065 | 4.15625 | 4 | #!/usr/bin/env python3
#
# Python Workbook - 100 Exercises
# Exercise # NN
#
# Points Value: NN
#
# Author: Daniel Raphael
#
# ---------------------------------------------------------------------------------------------------------------------
#
# Question: Calculate the sum of all dictionary values.
#
# d = {"a"... |
7425d885a409b50a7a0c59b6959b251b2169a059 | galaxyGGG/trials | /algorithm/search.py | 375 | 3.9375 | 4 | def binary_search(li,val):
left = 0
right = len(li) - 1
while left <= right:
mid = (left + right) // 2
val_mid = li[mid]
if val_mid > val:
right = mid - 1
elif val_mid < val:
left = mid + 1
else:
return mid
else:
return ... |
7db32d46a6e1435dd916719ac8093b32206e4688 | hfu3/text-mining | /Session12/anagrams.py | 945 | 4.375 | 4 | """
1. read the file, save the words into a list
2. (option 1) count letters for each word
'rumeer' -> 6
'reemur' - 6
'kenzi' -> 5
(option2) sort the word
'rumeer' -> 'eemrru' sig
'reemur' - 'eemrru' sig
'kenzi' -> 'ekinz' sig
create empty list for each signature
expected:
['rumeer', 'reemur']
['kenzi']
4. creat... |
e60edd11770dbe28d0778ddbfcf4591ca4d1dcfa | hfu3/text-mining | /Session10/Ex.py | 206 | 3.59375 | 4 | t = ['a', 'b', 'c']
t.append('d')
print(t)
t.extend('d')
print(t)
# t.append('a', 'a', 'a')
# t.extend('a', 'a', 'a')
print(t)
d = ['a', 'a', 'a']
t.append(d)
print(t)
t.extend(d)
print(t)
# t.sort(False)
|
b38051ff2e5f0a6b2565082fbf08ee5c029cb07a | hfu3/text-mining | /Session5/flower.py | 1,266 | 3.609375 | 4 | import turtle
tina = turtle.Turtle()
tina.speed(10)
tina.hideturtle()
background = turtle.Screen()
# tina_background = raw_input("What color should the background be?")
# tina_color = raw_input("What color should Tina use to draw?")
# background.bgcolor(tina_background)
# tina.color(tina_color)
tina.circle(40)
tina... |
63a865803977e2a3bfd843a21291252e410d904d | MubasharAHMED/Projets | /Projet_Terminale/crypter_decrypter_texte.py | 3,512 | 3.890625 | 4 | print("Bonjour, ce programme permet de coder/décoder un texte")
Partie="oui"
while Partie=="oui":
question=input('Voulez vous crypter un texte ou le decrypter?')
M=["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"]
L=["a","b","c","d","e","f","g","h","i... |
e3b2ecd4b3218cfd13e70764f681dfcce7d6f275 | clincl/AoC | /day1/day1.py | 780 | 3.96875 | 4 | '''
Input:
https://adventofcode.com/2018/day/1/input
'''
'''
Part 1
Sum Input File
'''
def frequencies(input = 'input.txt'):
changes = [int(line) for line in open(input)]
return changes
#print(sum(frequencies()))
'''
Part 2
Find the first frequency to appear twice.
'''
from itertools import accumulate
def calib... |
f0bba5c2b8e23dfaf7378b44167bbde0eabd700d | present1001/COVID-20 | /BotMaster/Zombie.py | 689 | 3.515625 | 4 | class Zombie:
def __init__(self, adr):
self.adr = adr # (str_ip, n_port)
self.branches = [] # other zombies
self.hosts = {} # ip : mac
def equals(self, zombie):
if self.adr == zombie.adr:
return True
return False
def add_zombie(self, zombie):
... |
63696e728c640dd9995d7395c8afde8809e36ef1 | riley-csp-2019-20/1-1-5-buggy-code-Jacob78499 | /115Jacobjaniak.py | 915 | 3.75 | 4 | # a115_buggy_image.py
import turtle as trtl
num_turtle = trtl.Turtle()
num_turtle.speed(20)
num_turtle.pensize(40)
num_turtle.circle(20)
num_leg = 8
leg_length = 90
leg_placement = 10000 / num_leg
num_turtle.pensize(5)
leg_count = 0
while (leg_count < num_leg):
print("leg_placement*leg_count=", leg_pl... |
27e8787d1d72a31e466bbeee58dfba269cbc4f49 | gr8h/Udacity_ML_Nanodegree | /technical_interview_practice/Question4/solution.py | 3,362 | 4.03125 | 4 | def get_left_child(T, node):
n = len(T)
row = T[node]
for i in range(n):
if row[i] == 1 and i < node:
return i
return None
def get_right_child(T, node):
n = len(T)
row = T[node]
for i in range(n):
if row[i] == 1 and i > node:
return i
return None... |
54861c9c20c34fb60f1507432dec0e7db836758a | kalebinn/python-bootcamp | /Week-1/Day 3/linear_search.py | 1,164 | 4.25 | 4 | # TODO: Write a function that takes a integer and a list as the input.
# the function should return the index of where the integer was found
# on the list
def search(x, list):
"""
this function returns the index of where the element x was found
on the list.
\tparam : x - the element you're searching fo... |
b8faeae804105f5aee0e21edaf46f51c3264d44b | kalebinn/python-bootcamp | /Week-1/Day 3/review-1.py | 421 | 3.875 | 4 | # TODO: Make a function that takes in 2 inputs: An lower limit and
# an upper limit. The function should return a list of all multiples of 5
# between lower and upper limit (inclusive)
def find_mults(lower, upper):
mults = []
for nums in range(lower, upper+1):
if nums % 5 == 0:
mults.appe... |
c9f4678ea364b027e5577856fe95ac2fd07c23e0 | kalebinn/python-bootcamp | /Week-1/Day 1/4-loops.py | 265 | 4.1875 | 4 | counter = 0
while counter <= 0:
print(counter)
counter += 1
# range(start, stop, increment)
print("using three inputs to range()")
for number in range(0,5,1):
print(number)
print("using one input to range()")
for number in range(5):
print(number) |
fe46d362442e66a048d1b2b5b8b45bc5dc3ccb0e | kalebinn/python-bootcamp | /Week-1/Day 2/random_num_game.py | 491 | 3.921875 | 4 | # import the random module
import random
winning_number = random.randint(0,10)
print(winning_number)
num_guesses = 5
user_won = False
while num_guesses != 0 and user_won == False:
user_guess = int(input("Enter your guess: "))
if user_guess == winning_number:
print("Hey, you won!")
user_won =... |
5fc3fc40bfae5393b974079152123260a1ee9074 | mhee4321/python_algorithm | /thisIsCodingTest/Greedy/2.multiplyOrPlus.py | 741 | 3.59375 | 4 | # data = input()
#
# # 첫 번째 문자를 숫자로 변경하여 대입
# result = int(data[0])
#
# for i in range(1, len(data)):
# # 두 수 중에서 하나라도 '0' 혹은 '1'인 경우, 곱하기보다는 더하기 수행
# num = int(data[i])
# if num <= 1 or result <= 1:
# result += num
# else:
# result *= num
# print(result)
# data = list(input())
# answer... |
790969223825811321bdb59926d5a3344222714e | mhee4321/python_algorithm | /programmers/Level1/poketmon.py | 284 | 3.6875 | 4 | def solution(nums):
result = set()
for i in nums:
result.add(i)
if len(result)> len(nums)/2:
return len(nums)//2
else:
return len(result)
def solution2(nums):
return min(len(set(nums)), len(nums)//2)
nums = [3,1,2,3]
print(solution(nums)) |
e768a85cc2fbeb4df352dd7df4b6c7b4b46764f1 | mhee4321/python_algorithm | /programmers/Level1/processionAdd.py | 529 | 3.78125 | 4 | def solution(arr1, arr2):
for i in range(len(arr1)):
for j in range(len(arr1[0])):
arr1[i][j] += arr2[i][j]
return arr1
import numpy as np
def sumMatrix(A,B):
A=np.array(A)
B=np.array(B)
answer=A+B
return answer.tolist()
def sumMatrix(A,B):
answer = []
for i, j in ... |
02e4d4c614513386defae8ff21ed8df15b067e4e | mhee4321/python_algorithm | /programmers/StackQueue/printer.py | 719 | 3.53125 | 4 | def solution(priorities, location):
count = 0
while(len(priorities)!=0):
if location==0: #출력 여부를 확인하는 맨 앞순서로 왔을 경우
if priorities[0]<max(priorities): #뒤에 중요도가 더 큰 문서가 있으면
priorities.append(priorities.pop(0))
location=len(priorities)-1
else:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.