blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
a340c9355b5215fa6aee942e17feac5757602567 | zokaaagajich/max-k-sat | /dummy.py | 4,086 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from random import randint, uniform, random
import os
import math
import argparse
def clauses_from_file(filename):
"""
Functions returns array of clauses [[1,2,3], [-1,2], ... ]
and number of literals(variables)
"""
with open(filename, "r") as fin:
... |
49001b3cf61ca3ce50724600a5cf6f15beb847ba | Rivarrl/leetcode_python | /leetcode/offer/57.py | 676 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# ======================================
# @File : 57.py
# @Time : 2020/3/12 23:58
# @Author : Rivarrl
# ======================================
from algorithm_utils import *
class Solution:
@timeit
def twoSum(self, nums: List[int], target: int) -> List[int]:
n = len(nums)... |
20cdb2e03415d935c9510597d2dbd54f129cf78e | sami10644/Data-structure-and-Algorithm- | /Mergesort.py | 1,531 | 4.09375 | 4 | #helper function to help sami for merging
def merge(customList,left,mid,right):
#number of elements in 1st subarray
n1 = mid-left + 1
n2 = right - mid
# creating subarray
left_subarray = [0] * n1
right_subarray = [0] * n2
#copying values from customList to subarray
for i in range(0,n1):... |
530e83dfe7c53311f44f2887b4690d27b7935cad | lsifang/python | /python变量/py_for.py | 345 | 3.625 | 4 | str='我就,是牛逼'
for a in str:
print(a)
else:
print('已全部打印完毕')
result=''
for a in str:
result=a+result
print(result)
for i in range(1,101):
if i%2==0:
print('%s是偶数'%i)
#九九乘法表
for i in range(1,10):
for j in range(1,i+1):
print('%d*%d=%d'%(j,i,j*i),end='\t')
print(' ') |
8d2cf63071b2d5fa6b03da0e599f960c7953aaa8 | mapkn/Numpy | /numpyarrays2.py | 2,241 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 8 11:05:07 2018
@author: patemi
"""
import numpy as np
#initialise an empty array
aa=np.empty((5,5))
#########################################
## Adding to existing array
# Using append to add / combine
a = np.array([[1,2,3],[2,3,4]])
z = np.zeros... |
17edd11ff21d1429029bd2c7a5750ada3275f3e0 | marco-hrlic/mothmusicplayer | /mothmusicplayer3/timeConverter.py | 1,048 | 3.65625 | 4 | #!/usr/bin/env python2
def convert_time(time=None):
# convert_ns function from:
# http://pygstdocs.berlios.de/pygst-tutorial/seeking.html
# LGPL Version 3 - Copyright: Jens Persson
if time == None:
return None
hours = 0
minutes = 0
seconds = 0
time_string = ""
time = time... |
7f6be5695d43761d25add65c39aabbedac6f27e0 | TSantosFigueira/Data-Structures-Algorithms | /Algorithmic Toolbox/week4_divide_and_conquer/quicksort.py | 1,238 | 4.125 | 4 | # python3
import random
def partition3(A, l, r):
lt = l # We initiate lt to be the part that is less than the pivot
i = l # We scan the array from left to right
gt = r # The part that is greater than the pivot
pivot = A[l] # The pivot, chosen to be the first element of the array, that why we'l... |
a97744bc44223f721dabd9f057a9e4147f056517 | Cordivae/checkio | /party_invitations.py | 1,514 | 4.03125 | 4 | class Friend:
"""A class used to store information about a friend and their invites."""
def __init__(self, name):
self.name = name
self.invite = "No party..."
def show_invite(self):
return self.invite
def get_invite(self, invite):
self.invite = invite
class Party:
... |
c069243d649283c178ce752daca7d7678415d8ea | Aasthaengg/IBMdataset | /Python_codes/p02860/s508140536.py | 70 | 3.59375 | 4 | a = int(input())
s = input()
print("Yes" if s[:a//2]*2 == s else "No") |
07d23687396337bee5ffd3e5b741679e5210ee71 | AnaTimpano777/PythonProjects | /simpleEncryption.py | 2,114 | 4.46875 | 4 | #Programmer: Ana Timpano
#Course Code: ICS4UE
#Date: February 20, 2020
#Decription: Encrypts or Decrypts a message inputed by the user
print("This program will encrypt or decrypt a phrase using the simple encyption method of roatating the letters.")
print(" ")
phrase = str(input("Please enter a phrase(do not ... |
b3779f63da7a260d778c4dfe686ea29300b95075 | chiao3bb33/Python | /start12-import.py | 1,310 | 3.578125 | 4 | # Python 程式設計入門
# 模組的載入與使用
"""
1.載入模組
2.使用模組
3.內建模組
4.自訂模組
"""
""" .................載入模組................ """
# 載入模組
"""
獨立的程式檔案
將程式寫在一個檔案中,此檔案可重複載入使用
載入 > 使用
先載入模組,在使用模組中的函式或變數
"""
# 基本語法
"""
1. import 模組名稱 #檔案名稱不加副檔名
2. import 模組名稱 as 模組別名
"""
""" .................使用模組................ """... |
180d1d96e1169274c1534cc70f80152931773e66 | iistrate/ChutesAndLadders | /PyChutesLadders/Game.py | 2,056 | 3.78125 | 4 | import Spinner
import Player
import Board
class Game(object):
"""Game loop and settings """
def __init__(self):
self._mbrunning = True
def quit(self):
self._mbrunning = False
#game loop
def run(self):
#settings
PLAYER_TYPES = dict(PLAYER1 = 1, ENEMY = 2)
... |
e377992858ca5c886220def4d2617f11e7dcea19 | jpcp13/L2 | /2017/TP4/rsa.py | 948 | 3.75 | 4 | from math import sqrt
from random import randint
def is_prime(n) :
if n==0 or n==1 :
return False
if n == 2:
return True
else :
i = 2
k = 1
while i<= sqrt(n):
if n % i == 0:
k = 0
break
else :
i = i+1
if k == 0 :
return False
else :
return True
def primes(n) :
return [i for... |
e029f33a4b1187da2c5d99d41f76f6a1a5ddd549 | Hrishikesh-3459/coders_club | /Day_1/3.py | 196 | 4.1875 | 4 | # Write a program to add two integer numbers entered by user
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
print(f"The sum of the two numbers is: {a + b}") |
30946bd107067041826e62e6564454ede1ed2a0c | ElizabethZapata/Mision_07 | /Mision07.py | 2,103 | 3.984375 | 4 | #Autor: Elizabeth Citlalli Zapata Cortes
# Mision 7
def dividir(dividendo, divisor):
cociente= 0 #contador número de veces que se pudo restar
numeroInicial= dividendo
while dividendo >= divisor:
dividendo= dividendo - divisor
cociente += 1
return numeroInicial, divis... |
79c8d2bc234d67bad87d5dfcda2efad1dcb9897f | gabriellaec/desoft-analise-exercicios | /backup/user_282/ch25_2020_03_09_19_13_16_986544.py | 370 | 3.859375 | 4 | import math
velocidade = float(input('que velocidade? '))
angulo = float(input('e que angulo? '))
def distancia(velocidade, angulo):
d = ((velocidade**2)*math.sin(math.radians(2*angulo)))/9.8
if d<98:
return('Muito perto')
elif d>102:
return('Muito longe')
else:
return('Acerto... |
013e4c97027639f058ecf50f516e8db75d03939d | LaManchaWLH/CuteGuideDog | /c6_2.py | 509 | 4.09375 | 4 | phonebook = {"James":12345, "Bond":77777}
for i in range(1,100):
print("Here is your options: 1-Add/Edit phonebook 2-Look up phonebook 3-Quit")
option = input("Plz input your option ID: ")
option = int(option)
if option == 1:
name = raw_input("Plz input the user name: ")
num = raw_input("Plz input your phone nu... |
9db4516fb9ad8468292f8d745067b7e2c0499f84 | MrzAtn/Prog_Python | /Apprentissage/casino.py | 3,397 | 3.828125 | 4 | import random
from math import *
def r_roulette(nb_D, nb_F):
result = random.randrange(nb_D, nb_F)
return result
def arrondi(gain):
gain = ceil(gain)
return gain
if __name__ == "__main__":
continuer_Partie = True
mise = 0
nb_D = 0
nb_F = 49
argent = 100... |
e8603a6c0d4d2c348806fa227711b195454a574d | coding-rev/likely_computer_science_questions_solved | /Detecting Even and Odd numbers.py | 449 | 4.25 | 4 | #Program to ask a user a number
# Algorithm
#1. Ask the users number
#2. get all the even numbers
#3. Compare the user number to the even numbers
#4. Print GOOD if the user's number is even
#CODE:
while True:
user_num = int(input("Enter your number: "))
mod = user_num % 2
if mod != 0:
prin... |
931c283cfe56acb0b02c9e26205980a3fda9f4ff | Gwinew/To-Lern-Python-Beginner | /Pluralsight/Intermediate/Unit_Testing_with_Python/1_Unit_Testing_Fundamentals/2_First_Test/test_phonebook.py | 1,405 | 4.1875 | 4 | """Given a list of names and phone numbers.
Make a Phonebook
Determine if it is consistent:
- no number is a prefix of another
- e.g. Bob 91125426, Anna 97625992
- Emergency 911
- Bob and Emergency are inconsistent
"""
import unittest
#class PhoneBook: # Right-cli... |
4c40a6101624caaee1fb5dda02d2bddb563bc6e8 | chaowan2017/sudoku | /soduku.py | 3,627 | 4.09375 | 4 | import random
import itertools
from copy import deepcopy
def make_board(m=3):
numbers = list(range(1, m**2 + 1 ))
board = None
while board is None:
board = attempt_board(m, numbers)
return board
def attempt_board(m,numbers):
n = m**2
board = [[None for _ in range(n)]for _ in range(n)]
for i,j in iterto... |
18d7352467b86f3653ab71922d7c3560b7ab1e43 | fengjisen/python | /20190108/index.py | 6,441 | 3.609375 | 4 | #str
s = 'ABCDEFG'
print(s[-1]) # G
print(s[-2]) # F
print(s[0:-1]) #ABCDEF
print(s[:]) #ABCDEFG
print(s[4:1:-1]) #EDC
print(s[0:4:2]) #AC
print(len(s)) #7
ret9 = 'title,Tilte,atre,'.split('t')
print(ret9) #['', 'i', 'le,Til', 'e,a', 're,']
#list
t = list([1,2,'3'])
print(t) # [1, 2, '3']
print(t.__len__()) # 3
t.appen... |
d5c02e76a13ba5494715ba0f46d0703caaa4e3d3 | DarkBoulder/GPA-calculator | /算gpa (excel ver).py | 3,962 | 3.765625 | 4 | import os
import xlrd
class Course:
def __init__(self, name, type, credit, score):
self.name = name
self.type = type
self.credit = credit
self.score = score
def display(self):
print("{} {} {} {}".format(self.name, self.type, self.credit, self.score))
d... |
81e4a2f2a585d78399cabd2ddd40d96aae15abcc | sumantasunny/TensorFlowB2E | /TFBasics/Named/Palceholder.py | 880 | 3.734375 | 4 | """
Know more, visit my Python tutorial page: https://morvanzhou.github.io/tutorials/
My Youtube Channel: https://www.youtube.com/user/MorvanZhou
"""
import tensorflow as tf
x1 = tf.placeholder(dtype=tf.float32, shape=None)
y1 = tf.placeholder(dtype=tf.float32, shape=None)
z1 = tf.add(x1, y1) #or x1+y1
x3 = t... |
f817dffcdf31df65563339c743a49d5b3974d847 | Sourlun/Python-Demo | /Project-1.py | 195 | 3.78125 | 4 | score = int(input("请输入一个数字:"))
if 100 >= score:
print("A+")
elif 90 <= score < 100:
print("A")
elif 80 <= score < 90:
print("B")
elif score < 80:
print("不合格!") |
9398ff81fb89d098ead5c2280e6d75da72149013 | Jochoniah/The-Complete-Python.PostgreSQL-Course-2.0 | /PYTHON-REFRESHER/Advanced-sets/code.py | 299 | 3.859375 | 4 | local = {"Rolf"}
abroad ={"Bob","Anne"}
# local_friends = friends.difference(abroad)
# friends = local.union(abroad)
art = {"Bob", "Jen", "Rolf", "Charlie"}
science ={"Bob", "Jen", "Adan", "Anne"}
# find out which friends take both art and science
both = art.intersection(science)
print(both)
|
069558918ceba1b8b60fdc6debf130d01a77fd7a | chenjienan/python-leetcode | /Udacity/3.basic-algorithm/problem_5.py | 1,939 | 3.640625 | 4 | ## The Trie itself containing the root node and insert/find functions
class Trie:
def __init__(self):
## Initialize this Trie (add a root node)
self.root = TrieNode()
def insert(self, word):
## Add a word to the Trie
cur_node = self.root
for w in word:
cur_no... |
cd3e5049228d69b6f0ad44105c1eca28bd754ce5 | VarunB7/Machine-Learning-Projects | /Regression_Based_Projects/Decision_Tree_Regression/decision_tree_regression.py | 1,211 | 3.71875 | 4 | # Decision Tree Regression
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv(r'C:\Users\hp\Desktop\MLDL\Machine Learning A-Z (Model Selection)\Regression\Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].valu... |
b8c84b41e51bf0dece4c44c419bfa3d0d97d4cb7 | ARWA-ALraddadi/python-tutorial-for-beginners | /02-Workshop/Workshop-Solutions/homework_questions/crosshairs.py | 2,805 | 4.15625 | 4 | # Crosshairs - Draw a "gunsight" crosshair image
#
# As practice in drawing an image using Turtle graphics, draw the
# familiar image of a gunsight's crosshairs, consisting of a
# cross formed from two lines, plus a circle. To make it interesting,
# we will aim the crosshairs at an evil alien monster intent on
# destr... |
dc2b8887abb2d627896163624cfa6cf45a593ebc | nairachyut/dataquest-projects | /Python Programming - Intermediate/Challenge_ Modules, Classes, Error Handling, and List Comprehensions-186.py | 1,367 | 3.90625 | 4 | ## 2. Introduction to the Data ##
import csv
f = open("nfl_suspensions_data.csv")
nfl_suspensions = list(csv.reader(f))
nfl_suspensions = nfl_suspensions[1:]
years = {}
for suspension in nfl_suspensions:
row_year = suspension[5]
if row_year in years:
years[row_year] = years[row_year] + 1
else:
... |
df475eda571800dfba4e2e9d115f7ab92118b6bb | mike-kane/fb_ml_practice | /bst.py | 3,576 | 3.578125 | 4 | class Node():
def __init__(self, key, val, parent=None, l_child=None, r_child=None):
self.data = data
self.l_child = l_child
self.r_child = r_child
self.parent = parent
def has_r_child(self):
return self.r_child
def has_l_child(self):
return self.l_child
... |
c80850f3e3f03b7981526e3e1d15ae88e36d8e39 | Ahsanhabib1080/CodeForces | /problems/A/SerejaAndDima.py | 1,047 | 3.78125 | 4 | __author__ = 'Devesh Bajpai'
'''
https://codeforces.com/problemset/problem/381/A
Solution: This is very similar to the DP card game problem. Since the numbers are distinct, it avoids
the complex case when both the ends are same and the player would pick the side which exposes the
smaller number for next round. That w... |
b241e2710d2d6b748ee1d8a8558b7bffeed537eb | Opeyemi19/ours_tutos | /Tuto_Python3/17_gestion_temps/main.py | 990 | 3.890625 | 4 | import time
"""
localtime()
(TIMESTAMP) --------------> structure de temps
<---------------
mktime()
%d : jour (01 à 31)
%m : mois (01 à 12)
%Y : année (ex: 2021) - %y (00 à 99)
%H : heures (00 à 23)
%I : minutes (00 à 59)
%S : secondes (00 à 59)
%p : AM/PM
%A ... |
d9e02eab528c12649f0c7a39514163c2f82bc2ad | AmyYang1799/HB-melon-delivery-report | /produce_summary.py | 995 | 4.09375 | 4 | # Create a file object from .txt so we can access its
# contents via Python
day_1_file = open("um-deliveries-20140519.txt")
day_2_file = open("um-deliveries-20140520.txt")
day_3_file = open("um-deliveries-20140521.txt")
def melon_summary(day_file, day_num):
"""Print melon report for last three days"""
print... |
aa22c351533772565b422f03eded6a0666cb0f75 | aniruddhamurali/python-algorithms | /src/math/calculus/Euler's-Method/improved_euler.py | 449 | 3.609375 | 4 | '''Improved Euler's Method'''
def improved_eulers(xn, yn, h, finalx):
approx = yn
steps = int((finalx - xn)/h)
tempx = xn
tempy = yn
for step in range(1, steps+1):
m1 = f(tempx,tempy)
m2 = f(tempx + h, tempy + h*m1)
approx = tempy + h*(m1 + m2)/2
tempx += h
... |
84041ef903204e0a628850b3f303eafaa3f4902c | katerina-ash/Python_tasks | /Цикл while/Числа Фибоначчи.py | 596 | 3.9375 | 4 | #Задача «Числа Фибоначчи»
#Условие
#Последовательность Фибоначчи определяется так:
#φ0 = 0, φ1 = 1, φn = φn−1 + φn−2.
#По данному числу n определите n-е число Фибоначчи φn.
#Эту задачу можно решать и циклом for.
fib1 = 1
fib2 = 1
n = input("Номер элемента ряда Фибоначчи: ")
n = int(n)
i = 0
if n == 0:
print(0)
... |
b3314c608bbd1f9fc7ae9e57bd7ff7947b8cfb34 | Xovesh/Personal-Projects | /sudoku/Game.py | 2,068 | 3.734375 | 4 | from sudoku import Sudoku
class SudokuGame:
def __init__(self, n):
self.table = Sudoku.Sudoku()
self.finish = False
# available position that can be modified
self.gamenumbers = []
self.initialize(n)
def visualize(self):
self.table.visualize()
def initializ... |
51fd89f0b464b1adc16872c136c66884e1affaad | PiyushChaturvedii/My-Leetcode-Solutions-Python- | /Leetcode 4/Average of Levels in Binary Tree.py | 1,320 | 3.71875 | 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 averageOfLevels(self, root):
"""
:type root: TreeNode
:rtype: List[float]
"""
... |
eaaf6aef6e823e8dae0b408426d9d1656e8a3068 | ananthuk7/Luminar-Python | /data collections/set/sets/addinset.py | 112 | 3.6875 | 4 | set1 = set()
n = int(input("enter the limit"))
for i in range(0, n):
set1.add(input("enter"))
print(set1)
|
81738c1e8345d4e6c0118bf164a2eacbf4f763dc | prasanganath/python | /queues/cQueue.py | 1,600 | 4.0625 | 4 | # implementing Class circular Queue
# This is Complete
class cQueue:
# circular queue, create circular queue by passing the maxSize
def __init__(self, maxSize):
self.maxSize = maxSize
self.count = 0
self.front = 0
self.back = maxSize - 1
self.items = [None for _ in rang... |
8c92477fbda0c2af4785227e8ea1d21a1f0eba28 | anjalilajna/Bestenlist | /day7.py | 940 | 3.5 | 4 | #1.
from list import mo
mo[3]=33 # [1, 6, 7, 8, 3, 5]
print(mo) # [1, 6, 7, 33, 3, 5]
#2.
import pandas as pd
series1 = pd.Series([1,2,3,4])
print(series1)
#0 1
#1 2
#2 3
#3 4
... |
be354ef1a357333bf1c582cf7729c976b2ad2d0e | webdeveloperdharma/company | /problem_1_solution_code.py | 1,082 | 4.34375 | 4 | def sum_of_multiples_1():
multiples = [] # An empty list to store all the multiples of 3 or 5
for numb in range(1,1000): # Iterating from 1 to 999
if numb%3 == 0 or numb%5 == 0: # If the remainder is zero after dividing the number w... |
a02206b096c2527ae0f004f97ec6a4b0abfd3613 | RiRam/coursework | /week4/stream_stats.py | 2,480 | 3.65625 | 4 | #!/usr/bin/env python
import sys
import fileinput
if __name__ == '__main__':
d = {}
measures = {}
# Computing the median (like this) has added an additional memory requirement
# of storing a sorted copy and then determine the length of the list and an
# index at which the median is. If there is ... |
f38acc7f85631f87eb8d93b7964dc6f9a10aea35 | sfwarnock/Introduction-to-Algorithms | /MIT 6.00/MIT 6.00 - Lec 3.py | 619 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 4 06:24:01 2019
@author: Scott Warnock
"""
x = 25
ans = 0
if x >= 0:
while ans*ans < x:
ans = ans + 1
#print ('ans = ', ans)
if ans * ans != x:
print('x is not a perfect square')
else:
print(ans)
else: print... |
a2a2d04cc3fd027cc27dac07994b0bf9c2c4f7f5 | Kapil-1729/Codechef | /bballs.py | 434 | 3.6875 | 4 | def balls():
d=int(input())
i=0
while(1):
if (2**i)>d:
i-=1
break
i+=1
temp=0
result=0
j=i
while(j>=0):
if (temp+(2**j))==d:
return result
if (temp+(2**j))>d:
j-=1
else:
t... |
2828098d1bb83f40e0f45c17a2c5c04d4379c124 | norrismei/data-structures-ebook | /stack_parens_checker.py | 751 | 4.1875 | 4 | from data_structures import Stack
def parens_checker(parens_string):
"""Checks if parentheses in given string is balanced"""
open_parens = Stack()
for paren in parens_string:
if paren == "(":
open_parens.push(paren)
else:
if open_parens.is_empty():
... |
d3d511953715a458313d966f725e8f202a216019 | nena-undefined/Python_dev_problem | /solution/janken.py | 831 | 3.921875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import random
import sys
print("0: グー, 1: チョキ, 2:パー")
print("じゃんけん...")
#入力受け取り
a = input()
#入力が0, 1, 2以外の文字の時
if(a != "0" and a != "1" and a != "2"):
print("0, 1, 2のいずれかを入力してください")
sys.exit()
#文字列->整数
a = int(a)
#CPUがどの手を出すかランダムで決める
b = random.randint(0,2)
... |
e23a9383628004728acfc89385198f3cfe5d5f3e | LanLi-PR/Thurs-C-A6 | /graph_final.py | 16,114 | 3.953125 | 4 | import networkx as nx
class Navigation:
def __init__(self):
# Create an instance of networkx DiGraph class as the class Navigation attribute
self.G = nx.DiGraph()
# Create a dictionary to store the building nodes.
self.Building2Node={}
def add_building(self, building, stree... |
7b83fb8b8c214da2235f48a3047de725232c478d | danaher-j/code-wars | /Python/8kyu/Is_n_divisible_by_x_and_y.py | 493 | 4.125 | 4 | # 8 kyu
# Problem: Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits.
# Examples:
# n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3
# n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6
# n = 100, x = 5, y = 3 => false be... |
69a83ea50c24dfdcca1391bd93273f2dc1142f54 | pratik-iiitkalyani/Python | /comprehension/dict_set_comprehension/dict_comprehension_ifElse.py | 150 | 4.0625 | 4 | # dict_comprehension with if else
# dict = {1:'odd', 2:'even'}
even_odd = {i: ( 'even' if i%2 == 0 else 'odd') for i in range(1,11)}
print(even_odd)
|
69e2a2502c7f9bddee1b4df08cc485a40acb489f | khoalu/land-conquer-demo | /gamestate.py | 10,145 | 3.65625 | 4 | class Color:
''' enum color '''
RED = 0
BLUE = 1
NONE = 2
class Action:
''' data class for an action '''
def __init__(self, r, c):
self.r = r
self.c = c
def __repr__(self):
return "Action({}, {})".format(self.r, self.c)
class Zone:
''' data class for a zone... |
d99af8d7a19d0e1545818127008ba451c76e0669 | zainab404/zsfirstrepo | /packing_with_dictionaries.py | 390 | 4.375 | 4 | #packing is when you can pass multiple arguments.
#here, we used **kwargs to signify the use of multiple arguments.
#the for loop will iterate over the arguments given and print each one
def print_student(**kwargs):
for key,value in kwargs.items():
print("{} {}".format(key,value))
print_student(name = "Z... |
e86b04da6740d863c6d84e4cd52f1e211e15a694 | tayloryeow/Codemon2.0 | /Renderer.py | 1,436 | 3.59375 | 4 | '''
Class that renders the board into graphical format.
It is the controller that build the view from the models that is the Board class
Board contains references to that needs to be represented in it, so only board
'''
'''
Class that renders the board into graphical format.
It is the controller that build the view ... |
5531f2ec297c60c2652371fe59ced9e8babeeedc | jjhangu/algopython | /quicksort.py | 1,431 | 4.0625 | 4 | arr = [5, 2, 6, 1, 3, 4]
def swap(arr, i, j):
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
def partition(arr, left, right):
print("")
position = left
compare = 0 # 0 인경우 ascending, 1, descending compare
while True:
print(arr, "l:", left,"r:", right, " : p : ", position)
if... |
c60b3f11b9bde948b705a3fb2f476cd34f509356 | Sanngeeta/List1 | /odd even_list.py | 612 | 3.578125 | 4 |
lst=[9,8,6,5,4,2,7]
i=0
a=[]
y=[]
count=0
count1=0
while i<len(lst):
b=lst[i]
if b%2==0:
a.append(b)
count=count+1
else:
y.append(b)
count1=count1+1
i=i+1
print("Even:",a,"count=",count,"___""Odd",y,"count=",count1)
# pri... |
660a90840460ebf433ac0b909e2132345f96d9e7 | Pradeepsuthar/pythonCode | /PythonProgramsTraining/programsFiles/regex/sub46.py | 350 | 3.625 | 4 | import re
str = "2019 was good but i hope that \
2020 will be better but i need 2020200 Rs in 2020\
i learnt python in 2019 but want to learn ML in 2020\
with Fees of 20200 Rs"
print(str)
str1 = re.sub("\s+2020|2020\s+", '2021 ', str)
print(str1)
str2 = re.sub('\s+20\d{2}|20{2}\s+... |
46e5e95708c2dae3f8f215c1b8ea53d8ecda6831 | TimothyDJones/learn-python | /edx_6.00.1x_python/6.00.1x_loop_2.py | 210 | 3.828125 | 4 | s = 'dboobsiobobbobbbobbobobbobobxaybobboboboboo'
num_bob = 0
for x in range(len(s) - 2):
print(x, s[x:x+3])
if s[x:x+3] == 'bob':
num_bob += 1
print("Number of times bob occurs is:", num_bob)
|
61292aaa72843786f9f6e53576ff967362c27807 | SaloniGandhi/leetcode | /26. Remove Duplicates from Sorted Array.py | 1,057 | 3.578125 | 4 | class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
index=1
#index represents where we would place our next unique element
#index takes value 1 because we would return unique array elements with length atleast 1
for i in range (len(nums)-1):
if nums[i]!=n... |
e1c965769f4ab4aff9661c9a9eacbe45660196fd | vladsavelyev/deeplearning | /karpathy/micrograd.py | 7,478 | 4.3125 | 4 | """
Reproducing https://github.com/karpathy/micrograd
"""
import math
from typing import Union
class Value:
"""
A value can be constructed using a series of operations. Value will memorise
this series, and roll backwards when val._backward() is called
"""
def __init__(
self,
da... |
01453d88fd8f242e445ac6d75077da913a0652a1 | kevinislas2/Iprep | /python/permutations/alternatingParityPermutation.py | 1,274 | 3.59375 | 4 |
class Node(object):
def __init__(self, value, options, used):
self.value = value
self.options = options
self.used = used
self.children = []
def populateNode(node):
for option in node.options:
if(option & 1 != node.value & 1):
otherOptions = []
fo... |
6157e34614e49830e4899261da0db857eac845f2 | ZhaoHuiXin/MachineLearningFolder | /Part 2 - Regression/Section 4 - Simple Linear Regression/simple_linear_regression_practice2.py | 764 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 12 17:29:51 2019
@author: zhx
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
dataset = pd.read_csv('Salary_Data.csv')
X = dataset.iloc[:,0:1].values
y = dataset.iloc[:,1].values
from sklearn.model_selection import trai... |
1c214bf1a99e2ce8f7f0bc98a56252ae4da60bea | wenbinDong/dong | /work/python_pycharm/lesson1/helloworld.py | 221 | 3.8125 | 4 | #学习python第一程序
#实现的功能是:打印helloworld
'''
学习python第一程序
实现的功能是:打印helloworld
'''
print("hello world")
print("hello python")
# print("hello java")
# print("hello c") |
ea9d1d3d4f1fc434c03b46bcf4060e4f22b22074 | pyvista/pyvista | /examples/01-filter/image-fft.py | 3,715 | 3.515625 | 4 | """
.. _image_fft_example:
Fast Fourier Transform
~~~~~~~~~~~~~~~~~~~~~~
This example shows how to apply a Fast Fourier Transform (FFT) to a
:class:`pyvista.ImageData` using :func:`pyvista.ImageDataFilters.fft`
filter.
Here, we demonstrate FFT usage by denoising an image, effectively removing any
"high frequency" co... |
7e0fe9dc98f5f5fbbd4876afb095f81ad7955dac | nazardoom1/py | /02-odd-or-even/main.py | 365 | 3.953125 | 4 | '''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
print ("Hi, give me a number: ")
num = input ()
if int(num) == 4:
print("It`s 4, ez")
elif int(num) % 2 != 0:
pri... |
e1390ca9de32aa44bb755fc08d7c19f690215514 | GitDavids/Minesweeper | /Start Menu.py | 5,704 | 3.78125 | 4 | import turtle, random
SetupFile = open("setup.txt","w")
turtle.getscreen()
turtle.ht()
turtle.colormode(255)
turtle.bgcolor(190,190,190)
screen=turtle.Screen()
screen.setup(width=1.0, height=1.0, startx=None, starty=None)
#I create a new turtle and name it "T"
#Initialy I liked calling turtle Thomass but T is shorter... |
1dcb1ec635ffce0591c498437b15cf7be9903718 | snagesh2/Scraping-Wiki-Graph | /src/Graph/Edges.py | 432 | 3.5 | 4 | import json
import ast
class Edges:
def __init__(self, actor, movie, weight):
self.actor = actor
self.movie = movie
self.weight = weight
def info(self):
"""
Class Edges creates edges for the graph
:return: An edge datatype structure
"""
ret = {'... |
c508cb3eb2e6de622feca349158703bc998e96a8 | jaswanth767/project1 | /task2.py | 106 | 4.15625 | 4 | str = input("enter the file name :")
if str[-2:]== 'py' :
print("The extension of file is :'python'")
|
76aaf70fae276c18b3bdaf4a19e1132546fbc629 | fortune-07/alx-system_engineering-devops | /0x16-api_advanced/100-count.py | 673 | 3.515625 | 4 | #!/usr/bin/python3
""" Recursive function that queries the Reddit API
parses the title of all hot articles, and prints a sorted count"""
import requests
import sys
after = None
count_dic = []
def count_words(subreddit, word_list):
"""parses the title of all hot articles, and prints a sorted count of given
... |
bac4b10910744fe610f35b2293573c8737efd04d | jrahman1988/PythonSandbox | /myDataStruct_List.py | 2,121 | 4.3125 | 4 | '''
List in Python is like an array but only difference is it can contain different types of data in single list
#List is defined by specifying items separated by commas with square brace
#Items can be deleted or added in a list
A list is a data structure that holds an ordered collection of items i.e. you can store a ... |
faee1ea3839d9fe775ca669b9bca176ea2ba7fff | Aasthaengg/IBMdataset | /Python_codes/p03042/s925911912.py | 356 | 3.65625 | 4 | S = input()
former = int(S[:2])
latter = int(S[2:])
if((former >= 13 or former == 0) and 1 <= latter <= 12):
print("YYMM")
if((latter >= 13 or latter == 0) and 1 <= former <= 12):
print("MMYY")
if(1 <= former <= 12 and 1 <= latter <= 12):
print("AMBIGUOUS")
if((former >= 13 or former == 0) and (latter >= ... |
e104704f919afc1a03d29d47b6b4906d3fe516b9 | Dfields174/backend-morsecode-assessment | /morse.py | 4,137 | 3.640625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Morse code decoder
https://www.codewars.com/kata/decode-the-morse-code/python
https://www.codewars.com/kata/decode-the-morse-code-advanced/python
When transmitting the Morse code, the international standard specifies that:
"Dot" – is 1 time unit long.
"Dash" – is 3 ... |
cdb6c33d1e32b2a51ff004c87958694633a8af3b | xiangyang0906/python_lianxi | /lianxi1/jjjj.py | 128 | 3.640625 | 4 | ii = 1
jj = 1
while ii <= 7:
jj = 1
while jj <= ii:
print(f"*", end=" ")
jj += 1
print()
ii += 1 |
cddbea9e081acefe627febab2d7dd2ed9548a328 | madeibao/PythonAlgorithm | /PartA/Py单一数值的二叉树.py | 1,403 | 4.0625 | 4 |
class Solution:
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def isUnivalTree(self, root: TreeNode) -> bool:
self.val = None
def check(root):
if not root: return True
if self.val is None: self.val = root.val
return root.val==s... |
c490417f3cd1aa888ca5d4aff9a509650cb6cc4d | DikranHachikyan/python-PLDA-20191011 | /ex09.py | 289 | 3.546875 | 4 | #!/home/wizard/anaconda3/bin/python
if __name__ == '__main__':
# 2+4+...+98+100 = 2550
i = 1
nSum = 0
while i <= 100:
i += 1
if ( i % 2) != 0: continue
nSum += i
else:
print('--- else ---')
print(f'1+2+3+...+99+100={nSum}') |
5ddacf633e5a0a81f94aff007ac778075e3ccab6 | ShunKaiZhang/LeetCode | /count_of_smaller_numbers_after_self.py | 1,194 | 3.578125 | 4 | # python3
# You are given an integer array nums and you have to return a new counts array.
# The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].
# Example:
# Given nums = [5, 2, 6, 1]
# To the right of 5 there are 2 smaller elements (2 and 1).
# To th... |
018be9f0d164af0be20c89e35e0dd9f26a0088c9 | hhwjj/forgit | /quiz/기본수학1/1193.py | 216 | 3.59375 | 4 | iter=int(input())
n=0
Sn=0
while Sn<iter :
n+=1
Sn=n*(n+1)/2
#짝수일때
k=int(Sn)-iter
r1=""
if n%2==0 :
r1="{}/{}".format((n-k),(k+1))
#홀수일때
else :
r1="{}/{}".format((k+1),(n-k))
print(r1) |
e1efb91cd57ac2ae0d1c205db80d1ddf6ce0eb5b | a1864754/python | /大二一些代码/实验6/平均分.py | 643 | 3.5625 | 4 | """(二)用户输入若干个分数,求所有分数的平均分。每输入一个分数后询问是否继续输
入下一个分数,回答“yes”就继续输入下一个分数,回答“no”就停止输入分数。请使用异
常处理机制来编写程序。"""
from numpy import *
listone = []
boolone = "yes"
while boolone == "yes":
try:
num = float(input("请输入一个数:"))
listone.append(num)
boolone = input("是否继续输入,继续请输入yes,结束输入no:")
except(ValueE... |
6294c8dd265f0db10a6620f057e39db2af6b923f | alexanu/algo | /src/log.py | 1,361 | 4.09375 | 4 | """
File: log.py
Python version: 3.4
Description: Class for writing to a log file.
How to use:
Import the class from the module and call `write()`.
The location of the log file is specified in a config file.
Initialization is automatic, but the log file must be closed manually
b... |
6ec489a649412662d43e0c1a97319104ec960ca5 | Harmon758/Harmonbot | /tests/test_calculation.py | 6,159 | 3.546875 | 4 |
import unittest
import math
from hypothesis import assume, given
from hypothesis.strategies import characters, integers, lists, text
import pyparsing
from units.calculation import calculate
class TestCalculate(unittest.TestCase):
@given(integers(min_value = 0))
def test_identity(self, number):
self.assertEq... |
b0521984f8a8f488faa886c4364e6a28cdc0343e | toriz7/solveAlogorithmProblem | /5_11650.py | 434 | 3.734375 | 4 | #5
N=int(input())
arr=[]
for i in range(N):
temp=input().split()
arr.append( (int(temp[0]) , int(temp[1]) ))
arr.sort()
# 기본 정렬 라이브러리 sort() 의 특징. 여기서는 둘다 증가하는순서대로 한다 : 사실 sort 함수의 특징이며, 아래처럼 key 값 지정 필요가 없는것
#arr.sort(key=lambda x:(x[0], x[1]), )
#arr=sorted(arr,key=lambda x:(x[0],x[1]))
for i in arr:
pr... |
bb54bdb8e33aef1dd99ab531833d66d29d6912ab | ccyyoyo/MyLearningNote | /Other/heap.py | 2,501 | 3.65625 | 4 | # # root = i
# # left = root*2
# # right = root*2+1
# -----------------------------------------------
# def MaxHeapify(A):
# for i in range(len(A)):
# root = i
# left = i*2+1
# right = i*2+2
# if (left < len(A)-1) and (A[left] > A[root]):
# MaxIndex = left
# else:... |
9f98225c0e726d3801636dc60592177ac9f4cdcd | zingpython/greatKaas | /day_six/mergesort.py | 776 | 4.09375 | 4 |
def mergeSort(unsorted):
sorted_list = []
for item in unsorted:
sorted_list.append( [item] )
while len(sorted_list) > 1:
iter_list = []
for index in range(0, len(sorted_list), 2):
left = sorted_list[index]
if index == len(sorted_list)-1:
right = []
else:
right = sorted_list[index+1]
... |
070d7330482f3ed8207fbf71e82c6e766118dab6 | jguardado39/A-Kata-A-Day | /Python/slove.py | 644 | 4.03125 | 4 | def solve(arr):
"""
In this Kata, you will remove the left-most duplicates from
a list of integers and return the result.
# Remove the 3's at indices 0 and 3
# followed by removing a 4 at index 1
solve([3, 4, 4, 3, 6, 3]) # => [4, 6, 3]
More examples can be found in the test cases.
Good luck!
"""
unique_a... |
5a403252d9e319c7e43bd719b8ea8ffd5e68ebbd | Manish25-3/Python-Zero-to-hero | /ASSIGNMENT 1/Q1-Ass1.py | 125 | 3.953125 | 4 | a = int(input("Enter the 1st number : "))
b = int(input("Enter the 2nd number : "))
sum = a+b
print(a,' + ',b,' = ',sum)
|
8574c212b65b32a5c6a3c6e9897b86b0c746ee72 | kpranshu/python-demos | /08-Inheritance/inherit-1.py | 627 | 3.953125 | 4 | #Inheritance
#declaration
#class childclass(baseclass):
#types of inheritance (single, multilevel)
#Parent/Super/Base
#Child/Sub/Derive
class Parent:
id=0
name=''
def __init__(self,id,name):
self.id=id
self.name=name
def Get(self):
print("Id : " + str(self.id))
print("... |
9735579e60215bae0eb1e32c86d65214bfe78de0 | joseruben123/EjerciciosVideosClases | /cargo.py | 411 | 3.59375 | 4 | class Cargo:
secuencia=0
def __int__(self,des):
Cargo.secuencia=Cargo.secuencia+1
self.codigo=Cargo.secuencia
self.descripcion=des
cargo1=Cargo()
print("cargo 1",cargo1.codigo,cargo1.descripcion)
cargo2=Cargo("Docente")
print("cargo 2",cargo2.codigo,cargo2.descripcion)... |
5400634fc278625f36b88420e3919eea775f7aaf | rrwt/daily-coding-challenge | /daily_problems/problem_101_to_200/problem_144.py | 1,064 | 4.25 | 4 | """
Given an array of numbers and an index i, return the index of the nearest larger number
of the number at index i, where distance is measured in array indices.
For example, given [4, 1, 3, 5, 6] and index 0, you should return 3.
If two distances to larger numbers are the equal, then return any one of them.
If the a... |
e658bdd1c6921872b0fa1743cf8f27efeefdfcfb | fzingithub/SwordRefers2Offer | /4_LEETCODE/1_DataStructure/3_Stack/单调栈/矩阵中的最大矩形.py | 959 | 3.578125 | 4 | class Solution:
def largestRectangleArea(self, heights):
if not heights:
return 0
length = len(heights)
minL = [-1] * length
minR = [-1] * length
Stack = [] # 单调递减栈
for i in range(length):
while Stack and heights[i] <= heights[Stack[-1]]:
... |
d894857c9d0e6d217782a7cfda00e31123cc0b30 | kevinelong/AM_2015_04_06 | /Week1/pocket_change_answer.py | 530 | 3.5625 | 4 | pocket_change = {
"pennies": 13,
"nickels": 3,
"dimes": 2,
"quarters": 4
}
change_values = {
"pennies": 1,
"nickels": 5,
"dimes": 10,
"quarters": 25
}
def add_up(pocket_change):
totals = {}
grand = 0
# ... DO YOUR WORK HERE
for k in pocket_change.keys():
subtot... |
3f0bfab374affe6df9264875e7b8f538a5eab01c | lorenzo-sall/DSA-review | /sorting_searching/sorting.py | 6,978 | 4.15625 | 4 | # implementing different sorting algorithms
# bubble sort
# adjacent items are compared and if [i]>[i+1] they are swapped
# best case performance: O(n)
# worst case performance: O(n^2)
def bubble_sort(l):
for pass_n in range(len(l)-1, 0, -1):
for i in range(pass_n):
if l[i] > l[i + 1]:
... |
a43f9316b6cc1c5c13c4ef8c426a6470cdd8e6e7 | coolrajesh7/python | /Health Management.py | 4,141 | 4.03125 | 4 | # coding = utf-8
'''
create a program which will take inputs from the user to log or retrieve exercise or food intake by the client
have to use specified functions
'''
# print("Welcome to Health Management System \n")
# client_name = input("Enter the first name of your client \n")
# client_name = client_name... |
23c55395feda535c0dd09154078c5aa293132fb9 | huynmela/CS261 | /dynArrayAddAt/dynArrayAddAt/dynArrayAddAt.py | 1,599 | 3.796875 | 4 |
class DynamicArrayException(Exception):
"""
Custom exception class to be used by Dynamic Array
DO NOT CHANGE THIS CLASS IN ANY WAY
"""
pass
class DynamicArray:
def __init__(self, start_array=None):
"""
Initialize new dynamic array
DO NOT CHANGE THIS METHOD IN ANY WAY... |
225ad39afaeb5c541fc433060577c04a3fc01bf3 | dolthub/menus | /validation/validate_pks.py | 1,584 | 3.96875 | 4 | from utils.strings import *
from static import *
def validateName(name):
if len(name) < 3:
msg = f"\nmenu_items.name {name!r} has less than 3 characters. Is that correct?"
print(msg)
def validateRestaurantName(restaurant_name):
if len(restaurant_name) < 3:
print(f'menu_items.restaurant_name {restaura... |
fea80caff63e9a3e44dd06b38f3f5e2d781e0482 | dimyalt/python_learning | /magic_ball/magic_ball.py | 1,785 | 3.796875 | 4 | # -*- coding: utf-8 -*-
from random import *
x = randrange(1, 21)
question = input('Задай свой вопрос: ')
while True:
if x == 1:
print('Бесспорно')
break
elif x == 2:
print('Предрешено')
break
elif x == 3:
print('Никаких сомнений')
break
elif x == 4:
... |
8efe94d9f5fb1b8bb571026fe6da7b48a895404d | DanielBacci/algorithms | /staks/stack.py | 1,426 | 3.921875 | 4 | class Node:
def __init__(self, value, node_next):
self.value = value
self.node_next = node_next
class Stack:
def __init__(self):
self.top = None
self.bottom = None
self.lenght = 0
def pop(self):
node = self.top
if not node:
return None... |
c3a85c815b653867582662551325a3c56ea6c91b | yamn15/U_Python3 | /4-16_list.py | 2,148 | 3.8125 | 4 | print('******************************************************************')
#リスト化
l = [1, 20, 4, 50, 2, 1, 2]
print(l)
##リストにもインデックスがある。インデックス指定でリストの中身を表示できる。
##[0, 1, 2, 3, 4, 5, 6]←インデックスの番号
print(l[0])
print(l[1])
print(l[6])
print('******************************************************************')
##「-」を使えば、イ... |
6575a800fa6e2375a659e4cbc5dac509bc86a746 | kruzda/project_euler_solutions | /euler004.py | 580 | 3.5 | 4 | #!/usr/bin/python
def ispal(n):
return int(str(n)[::-1])==n
results=[]
"""
for i in range(100,999):
for j in range(100,999):
if ispal(i*j):
results.append(i*j)
results.sort()
print(results[-1])
"""
"""
palindrome algebra:
abccba
100000a + 10000b + 1000c + 100c + 10b + a
100001a + 10010b + 1100c
11(9091a + 9... |
80b63f2bf9b804b9d66cd36aef2d85874e434dda | simrit1/QuickPotato | /examples/non_intrusive_example_code.py | 2,317 | 3.765625 | 4 | import time
import math
def slow_method():
num = 6 ** 6 ** 6
return len(str(num))
def fast_method():
num = 6 ** 6 ** 6
return int(math.log10(num))
class FancyCode:
"""
A totally random piece of code used to examples quick profiling.
"""
# @performance_breakpoint <-- (Uncomment thi... |
f2643287a33f9c3211c08f40bfa48a974598d45b | Amitesh-2001/Scripting-Language-Lab | /tuple.py | 230 | 4.25 | 4 | tuple1=(10,20,30,40,50)
tuple2=("a","b","c")
tuple3=tuple1+tuple2
print("Two tuples concatenated",tuple3)
del tuple3
print("Maximum element",max(tuple1))
print("Minimum element",min(tuple1))
print("Length of tuple1",len(tuple1))
|
54a804756ad73d9f1f7edd181abd9d4b618d6b36 | Austin-Faulkner/early_python_programs | /Initials.py | 1,215 | 3.5625 | 4 | # File: Initials.py
# Description: The print() function prints my initials.
# Student's Name: Austin Keith Faulkner
# Student's UT EID: akf354
# Course Name: CS 303E
# Unique Number: 50075
# Professor: Dr. William Bulko
#
# Date Created: 08/31/2019
# Date Last Modified: 09/04/2019
def main():
print(" ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.