blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cb408f11e8a222bbd5a0369c28c8090072e29fd1
LeonLenclos/alan
/brain/logic/alan_logic_adapter.py
6,955
3.828125
4
from chatterbot.logic import LogicAdapter from random import choice class AlanLogicAdapter(LogicAdapter): """AlanLogicAdapter is a superclass for Alan's logic adapters """ def __init__(self, **kwargs): """Optional kwargs : max_confidence A float (from 0 to 1). Default is 1. ...
90b5147d4be493309894c9c229ad07042fe74e27
willy-wagtail/learningdeeplearning
/course_1/src/softmax.py
461
4.125
4
import numpy as np def softmax(x): """ Calculates the softmax for each row of the input x. Argument: x -- A numpy matrix of shape (m,n) """ # Apply exp() element-wise to x. x_exp = np.exp(x) # Create a vector x_sum that sums each row of x_exp. x_sum = np.sum(x_exp, axis=1, keepdi...
db82342befa2da6c0e8749cb0ecd17426bc14f41
paps272003/MDS.Python.Assignment2.1
/Assignment2.1.py
200
4.03125
4
#Program to enter comma separated number from console and convert into List and Tuples values=input("Enter numbers in comma separated format :") l=values.split(",") t=tuple(l) print(l) print(t)
5051d32ac353c12e884d9ac8709b1778d7753d19
BigShow1949/Python100-
/13.py
971
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。 # 程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。 for n in range(100, 1000): i = n / 100 j = n / 10 % 10 k = n % 10 if n == i ** 3 + j ** 3 + k ** 3: print n print...
69439610786c558e6cc54ccce71aa8294917b4a3
BigShow1949/Python100-
/21.py
581
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 题目:猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。 # 程序分析:采取逆向思维的方法,从后往前推断。 today = 1 for day in range(9, 0, -1): yesterday = (today + 1) * 2 today = yesterday print yesterday
a61e93334188206ec3212a638f51bd7dbce75869
emikeladze/PythonLearning
/Dictionary.py
353
3.921875
4
family = {"dad": 60, "mother": 55, "aunt": 50} print(family['dad']) family['uncle'] = 51 print(*family) for key, value in family.items(): print("Ключ - " +key+", значение - " + str(value)) print(list(family.keys())) print(list(family.values())) if 'dad' in family.keys() print('dad') if 50 in family.v...
2263f329e94832f973cb952a9cf99fa960259f88
MartinKayz/LearnPython-WithMe
/numeric.py
835
4.28125
4
# Integer types a = 13 b = 100 c = 66 print(a,b,c) # knowing the type of variable print(type(c)) # floating points x = 33.5 y = 25.8 z = 205.0 print(x,y,z) print(type(z)) # Complex types d = 3 + 5j print(d) print(type(d)) # binary types """ Begin with '0b' """ e = 0b10101 print(e) # hexadecimal types """ Begin with...
3aa0150dbc3fb9efb606d68dee49b99c4d0806ea
Belal1142080/python
/multiUpto1000.py
303
3.828125
4
a=int(input('Enter first number: ')) b=int(input('Enter second number: ')) # if a*b>1000: # print('the result is: ',a+b) # else: # print('the result is: ', a * b) def multiupto100(i,j): if a*b>1000: return a,b else: return a,b z=multiupto100(a,b) print(z)
448c3e2f547238f9765970757c844416fa26c1e0
Admodan/EdX-6.001x_A
/Quiz1Prob6.py
270
3.515625
4
def flatten(aList): newList = [] for i in range(len(aList)): if isinstance(aList[i], list): newList.extend(flatten(aList[i])) else: newList.append(aList[i]) return newList aList = [[1,'a',['cat'],2],[[[3]],'dog'],4,5]
d59f64e7b88adc3a661d41f4e6066cd8570745bb
mam37/nand2tetris
/projects/06/Parser.py
2,659
3.5625
4
class Parser: A_COMMAND = 1 C_COMMAND = 2 L_COMMAND = 3 def __init__(self, src): self.src = src self.reset() def reset(self): self.src.seek(0) self.current = '' self.next = self._getNextCmd() def hasMoreCommands(self): """ returns bool ...
525c947fad2e80fe73601b26321835be1ca58a1f
pst15771219053/PyhonByJoker
/day01.py
2,634
4.03125
4
#print('hello word') # num1=float (input("请输入数字")) # num2=float (input("请输入另外一个数字")) # print(num1 * num2) # # # a = int (input('a = ')) # b = int (input('b = ')) # print('%d + %d = %d' %(a, b, a + b)) # print('%d - %d = %d' %(a, b, a - b)) # print('%d * %d = %d' %(a, b, a * b)) # print('%d / %d = %d' %(a,...
88714ea1d5101c8ab5ca39cd97c5115d11bbdebd
mayaragao/Machine-Learning
/Experimentos/05_Explorar_Visualizar_Boston.py
3,238
3.53125
4
############################################################################## # Experimento 05 - EXPLORANDO E VISUALIZANDO O CONJUNTO "BOSTON" (REGRESSÃO) ############################################################################# import pandas as pd from scipy.stats import pearsonr import matplotlib.py...
8ac7d692da65bc7063e32746dc2e258604729b01
suhani0330/story
/mini project.py
23,405
3.953125
4
import time answer_A = ["A", "a"] answer_B = ["B", "b"] answer_C = ["C", "c"] yes = ["Y", "y", "yes"] no = ["N", "n", "no"] required = ("\n Chooose A, B or C to continue") required1 = ("\nChoose A or B to continue") required2 = ("\nChoose B or C to continue") end2 = ("\nThe story ends here. Thank you for p...
98705746b1d37b1b84d4ab16dddc31e633769c64
ModzabazeR/CP3-Phachara-Chirapakachote
/assignment/FunctionParamExample.py
250
3.859375
4
def addNumber(x, y): print(x + y) def mutipleNumber(x, y): print(x * y) def subtractNumber(x ,y): print(x - y) def divideNumber(x, y): print(x / y) addNumber(10, 25) mutipleNumber(10, 25) subtractNumber(10, 25) divideNumber(10, 25)
f2de887716716dbca9c8bc550be2abae6e3c3817
baldengineers/space-engine
/gravity.py
3,134
3.9375
4
#contains the functions needed to simulate gravity and orbit of two masses def translate(cl,dir_facing,vel,oa,vector): #cl = object class #direction = direction of acceleration of object (in degrees) #vel = velocity of object due to gravity #oa = original acceleration before being affected by gravity ...
82bbfa4e3c38249066bc03545cc901888f5f3247
anassabbah/210CT-
/Question 5.py
928
4.09375
4
//matrices// A ← [[18, 17, 3], [4, 5, 6], [7, 8, 11]] B ← [[5, 8, 1,12], [6,7, 3, 0], [14, 4, 9, 1]] MATRIX ← [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] //pseudocode for addition// for I in range(len(A)): //iterates through rows// for j in range(len(A[0])): //iterates th...
65d9b3c71963518339f56d091a5c7f041b125a16
shivamadlakha/hactoberfest-2020
/python/factorial.py
227
4.03125
4
# Factorial of a number def factorial(n): if n == 1: return n elif n < 1: return ("NA") else: return n*factorial(n-1) num = int(input()) print('Factorial: {}'.format(factorial(num)))
15714fd082e2ea54fcfb7ff98e14634768106422
Mikey955/arithemetic
/final.py
4,076
3.6875
4
from addition import add_function from subtraction import sub_function '''from multipy import mutiply_function from division import division_function from power import power_function from factorial import factorial_function from summation import summation_function from minimal import minimum_function from maximal impor...
2c17158a7a3dc5ec663d86307e584db3e1e161ab
gieailes/2018_advent_of_code
/day2/day2.py
554
3.578125
4
#! python f = open('input.txt', 'r') twice = 0 threetime = 0 for line in f: multiples = {} for letter in line.strip(): if letter in multiples.keys(): multiples[letter] += 1 else: multiples[letter] = 1 once2 = False once3 = False for m in multiples: i...
9806ae0c27851556ad8659e612a3cdf998fa4e0d
BLannoo/Advent-of-Code-2019
/day22/solution.py
11,208
3.640625
4
import re from typing import List, Callable from unittest import TestCase def deal_into_new_stack(cards: List[int]) -> None: cards.reverse() def cut(n: int, cards: List[int]) -> List[int]: return cards[n:] + cards[:n] def deal_with_increment(n: int, cards: List[int]) -> List[int]: num_cards = len(card...
c32bae3ecb94b6f1941623455a8fb2cb96cfb302
Mikhail-93/sre_exam
/task7.py
1,221
3.6875
4
import sys def eratosthenes(n): """ Get all primes from 1 to n. 0 if not prime, else number :param n: :return: [0, 2, 3, ..., n] """ sieve = list(range(n + 1)) sieve[1] = 0 for i in sieve: if i > 1: for j in range(i + i, len(sieve), i): sieve[j] = 0 ...
01794a4b215903327c59405fb4591205006298ee
kaidione/weile
/day13.py
1,815
4.0625
4
# 定义老手机类 class Oldphone: __brand = "" def __init__(self, brand): self.__brand = brand def setbrand(self, brand): self.__brand = brand def getbrand(self): return self.__brand def call(self, phone): print("正在给", phone, "打电话") class Newphone(Oldphone): def call...
47496811218112c381c1ed5bd7d1a717e948d1a6
mrhatman26/Track-and-Trace-Phone-Info-Checker-
/Prototype 2.py
5,647
3.859375
4
import tkinter as t #Import tkinter and set it to t from tkinter import messagebox as m #import the messagebox function from tkinter import phonenumbers as p #import phonenumbers and set it to p from phonenumbers import timezone, geocoder, carrier #import the timezone function from phonenumbers def submit_button():...
db3102315091f6c754d1425542bf2d0ba1cf1aae
sporting/leetcodeHW
/H014LongestCommonPrefix/t01.py
694
3.59375
4
# -*- coding: utf-8 -*- class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ prefix = '' for i in xrange(65535): c = '' for str in strs: if len(str) > i: ...
922fdaeab8297ddc90fcc65f500c6f90be7feca1
sporting/leetcodeHW
/H020ValidParentheses/t01.py
645
3.859375
4
# -*- coding: utf-8 -*- import re class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ h = {'(': ')', '[': ']', '{': '}'} pattern = '[\(\[\{\)\]\}]' collections = re.findall(pattern, s) stack = [] while len(collec...
bd1c57f281e70c1bd30b3babbc8266ed9f442612
sporting/leetcodeHW
/H004MedianOfTwoSortedArrays/t01.py
571
3.671875
4
# -*- coding: utf-8 -*- class Solution(object): def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ num = sorted(nums1 + nums2) medianpos = len(num) // 2 if len(num) % 2 > 0: ...
5bf3d817f3810b1c28ebda15c4a40a35c6f132e0
tygerwang/studytime
/python_reboot/hello.py
568
3.875
4
#!/usr/bin/python #encoding: utf-8 #-*- conding:utf-8 -*- # recive a name #name = raw_input('Please input your name:') name = raw_input('请输入你的名字:') print 'Hello ' + ',' + name # study input inputname = input('please input your inputname:') print 'Hello ' + ',' + inputname print name + '是' + inputname ###study fu...
06ce2a364df170c8b2dcefb9dd79232f97850b05
fernandoflores2002/PythonCourse
/Class_3/Tarea.py
1,783
3.859375
4
#SIMULAR UNA AGENDA DE CALULAR QUE GUARDE NOMBRES Y CELULARES #AGREGAR,ELIMINAR Y MOSTRAR 936962826 #For: recorrer un elemento que es iterable # agregarContacto -> camell case >javascript,java # AgregarContacto -> camell upper case # agregar_contacto -> dic={} def agregar_contacto(nombre): # dic['Alvaro']=['Plas...
bab990943d0f0425925d7cc15d9a2a69e3713b31
Dilschat/PDA-emulator
/PDA.py
3,610
3.5
4
from types import MethodType class State: def perform_step(self, input_item): return input_item in self.acceptable_input class PDA(object): def __init__(self, input_string): self.input = input_string self.current_state = state0 self.stack = list() self.stack.append('...
c81409855d250059cd3582cf08658eda585c3d67
qi-zhang8/Exercises
/quickSort.py
935
4.03125
4
def quicksort(array, begin, end): if begin < end: pIndex = partition(array, begin, end) quicksort(array, begin, pIndex) quicksort(array, pIndex+1, end) return array def swap(array, index1, index2): tmp = array[index1] array[index1] = array[index2] array[index2] = tmp de...
a1a9ba68e03df22a22087660f2f7d95ed05b8333
MadhumithaS2001/Talentio_Programs
/parenthesis_stack.py
984
3.875
4
''' Problem Statement Given an expression string x. Examine whether the pairs and the orders of “{“,”}”,”(“,”)”,”“,”” are correct in exp. Input Format A single string s containing the parenthesis. Constraints 1<=length of string<=1000 Output Format Print "1" if brackets are balanced else print "0". ''' class...
87c29b26743de315c0f8f3c1d08c56ae0b0280fe
tmdwns1101/AlgorithmStudy
/Python/seungjun/2563.py
726
3.5625
4
''' 색종이 크기는 10x10 도화지 크기는 100x100 최대 색종이 수는 100 이하 n : 종이수 시간 복잡도는 O(n) ''' def solution(papers): board = [[0]*100 for _ in range(100)] area_count = 00 for paper in papers: x, y = paper for i in range(10): for j in range(10): if board[y-1-i][j+x-1] == 0: ...
7b85fb518865d342f3af3171f6201e3e20e1dea1
tmdwns1101/AlgorithmStudy
/Python/seungjun/3085.py
1,387
3.53125
4
global n global board def calc(): ans = 0 for i in range(n): cnt = 1 for j in range(n-1): if board[i][j] == board[i][j+1]: cnt += 1 else: ans = ans if ans > cnt else cnt cnt = 1 ans = ans if ans > cnt else cnt f...
66818dfa924db5173e9f89f964ca857e773dfa42
tmdwns1101/AlgorithmStudy
/Python/seungjun/10707.py
360
3.640625
4
def solution(x, y, limit, ext_cost, target): a = target * x b = y if limit >= target else y + ext_cost * (target - limit) return min(a,b) if __name__ == '__main__': x = int(input()) y = int(input()) limit = int(input()) ext_cost = int(input()) target = int(input()) ans = solution(x...
05e0b498421d62468c47e6ee1d62864a7eae46bf
tmdwns1101/AlgorithmStudy
/sw_expert/Python/seungjun/3499.py
701
3.5
4
from collections import deque def perfect_shuffle(cards): pivot = len(cards) // 2 if len(cards) % 2 != 0: pivot += 1 left_cards = deque(cards[:pivot]) right_cards = deque(cards[pivot:]) shuffled_cards = [] while len(left_cards) != 0 and len(right_cards) != 0: left_car...
b4da2f4bdee3f3da99b565ae7268905f7d84949c
bodacea/countryname
/countryname/cleanIndices.py
21,577
3.890625
4
#!/usr/bin/env python # -*- coding: cp1252 -*- ''' This program either: * searches the pycountries database for a country name returns the ISO-3166 3-digit country code for that country, or "---" if it can't find the country Also returns the ISO-3166 name for the country * Searches the data.un.org list of U...
eadbbeb52b30033dd4fe8cdb2daa59a68dec724b
tomhettinger/darwin
/darwin/Environment.py
4,099
4.25
4
""" The Environment class is the environment that the creatures live in. An instance contains the creatures themselves, as well as the rules and conditions that the creatures must survive in. """ import itertools import threading from random import choice, shuffle from Creature import Creature DEATHRATE = 60 # abs...
5790fb1dfbe3545b580257cc9fe44dcfd86b0e12
curioswati/Algorithms
/R.G. Dromey/algo_2_2_1.py
731
3.6875
4
""" A script that prints no of occurences of integer above a particular range. Also prints their frequency and the rate of favours among total. """ def main(lower_limit): passes=0 number_of_entries=0 while True: entry = raw_input("Enter number: ") if not entry: break elif int(entry)>=lower_lim...
6865b66719afb45787b97116d6032c8a50297df0
curioswati/Algorithms
/NAD/secant.py
1,590
4.1875
4
""" The script finds a root of a quadratic equation, It uses false position method for the same. In this method we draw a secant from function value of a to function value of b. Then find the intersection of that chord and assign a new valid interval for a and b. Iteratively following the procedure, we converge to the ...
dc9cfd12924c0aeaae8ac9b1944bca1368cfa7b1
sudipverma/python-tutorial
/rm_ dupli_list.py
319
3.75
4
# WAP to remove duplicates from list def removeDuplicate( li ): newli=[] seen = set() for item in li: if item not in seen: seen.add( item ) newli.append(item) return newli li= list(map(int, input().split())) x = removeDuplicate(li) for i in x: print(i,end=(" "))
29ff5a37743dc677f1d98e84bd114d126948ee9a
joshrdawson/project-euler
/007/007.py
373
4
4
# What is the 10 001st prime number? TARGET = 10001 number = 1 p_count = 0 def is_prime(p): if p == 2: return True elif p % 2 == 0: return False for i in range(3, p / 2, 2): if p % i == 0: return False return True while p_count != TARGET: number += 1 if i...
ee75bf52b51d6967be88602ee135ecb6dfd7fac7
Jzgao04/Year9DesignCS-PythonPM
/SearchSort.py
1,823
4.0625
4
# Python F18 Class 11 Demos intList3 = [-100,9,6,12,34,167,89,45,1000] maximum = max(intList3) minimum = min(intList3) range = (maximum - minimum) print(range) ''' Taking an Integer list and target value as a parameter, return the index of the target value in the list if found else return -1 ''' def LinearSearch(...
44b66ed37044ee1576421e4ef4a5e88d8ff33992
Jzgao04/Year9DesignCS-PythonPM
/PhoneNumberToPerson.py
527
4.15625
4
# Python Fall 18 Class 12 Demo # Read 10 names along with thier phone number and store them in such a way if the user entered the phone number # we should be able to retrieve the Name of the person NameList = [] phoneList = [] for i in range(0, 10): name = input("Enter the name ") phone = input("Enter the phon...
43d3ee43323e360bc3aac30a36168535e14839fc
Jzgao04/Year9DesignCS-PythonPM
/Lexicographically Least Substring.py
165
3.890625
4
string = "Apple" def smallest_alphabet(a, n): min = 'z'; for i in range (n - 1): if (a[i] < min): min = a[i] return min
7cff9929bed68167a00d81c6fde97ed3285c812c
Jzgao04/Year9DesignCS-PythonPM
/LoopDemo.py
960
4.40625
4
#Loop Demo for i in range(0, 6, 1): print(i) #How would the above loop run #We would reach line 27 # i = 0, 0 < 6, True RUN Loop # i = 1, 1 < 6, True RUN Loop # i = 2, 2 < 6, True RUN Loop # i = 3, 3 < 6, True RUN Loop # i = 4, 4 < 6, True RUN Loop # i = 5, 5 < 6, True RUN Loop # i = 6, 6 < 6, FALSE EXIT print("***...
a66ae2a42f314a8fac66c27ad592f53b8a8a30f5
Jzgao04/Year9DesignCS-PythonPM
/SmileWithSimiles.py
204
4.0625
4
import itertools print list(itertools.permutations([1,2,3,4])) #1. Read all inputs #2. Have to print out all possible permutations of the adjective and noun #3. Print in the format: Adjective "as" Noun
a55520f7a2e0c41ca6f421554428c8a94caddc17
prathimatangirala/ChatBot-Python-BackEnd
/CsuData.py
15,633
4.09375
4
import sqlite3 class CsuData: def create_student_table(): #Create table function connect = sqlite3.connect('universitystudent.db') # Connect to the database cursor = connect.cursor() #Get the cursor DB_CREATE_STUDENT_TABLE = 'CREATE TABLE IF NOT EXISTS student(student_id VARCHAR(243) PRIMARY KEY,student_...
25bcb9adf036f718f7cc344e067eb683da2886b8
sinasab/cse5914
/src/brutus-module-weather/brutus_module_weather/tests/humidityQuestion_test.py
935
3.515625
4
import unittest from flask import json from .common import BrutusTestCase class HumidityTestCase(BrutusTestCase): """ Simple tests for the weather module Check that questions about humdity returns the correct answers """ humidQuestions = ['how humid is it', 'is it humid ou...
08975aeb4e0613cddb1c3bb32797b9d3ea95ac3d
SHKlarenbeek/F1M1PYT
/output.py
1,111
3.671875
4
2 + 2 3 * 10 100 - 10 25 / 5 10 / 3 10 // 3 print('Mijn naam is <Stijn>') naam = '<JStijn>' print(naam) print(naam.upper()) print(naam[0:2]) print(naam[::-1]) leeftijd = 21 print('Hallo ' + naam + ' ben je al ' + str(leeftijd) + ' jaar?') leeftijd = leeftijd + 1 leeftijd leeftijd-=1 leeftijd ...
4ccae2ff0ecbddbb0b82f3de49a762602ea958d4
SHKlarenbeek/F1M1PYT
/list.py
456
3.78125
4
# maakt een list FloatList = [1.1, 2.2, 4.4, 8.8, 17.6, 35.2, 70.4, 140.8] # voegt iets achteraan toe FloatList.append(420) # voegt iets toe waar je wilt FloatList.insert(2, 69) # eigen attempt for i in range(len(FloatList)): print(FloatList[i]) # echte manier for element in FloatList: print...
6dba230f0f8bf3f389c39f9cabefe70a3beffb07
exb/movie-recommendations
/movie_recommendations/distances.py
1,219
3.5
4
from math import sqrt def euclidean_distance(data, p1, p2): # get the list of shared items si = {} for item in data[person1]: if item in data[person2]: si[item] = 1 # if there are no shared items if len(si) == 0: return 0 sum_of_squares = 0 for item in data[pe...
595c90724bb1c8c2a22f486c79f0e1dcf8afc613
Devtlv-classroom/strings-basics-shaul615
/exerciseB4.py
880
4.34375
4
# Exercise (medium) # Ask the user for his full name (example: "John Doe"), and check the validity of his answer: # The name should contain only letters. # The name should contain only one space. # The first letter of each name should be upper cased. print("- The name should contain only letters. ") pri...
8e2e7fe313e8b6d9ede0d7c92c5e17c5d3f5130a
Devtlv-classroom/strings-basics-shaul615
/exerciseB1.py
486
4.375
4
# Exercise (easy) # Ask the user for his name, and tell him if the last letter is a vowel or a consonant print("Test your name to see if the first letter is a vowel or a consonant") user_name = input("Please enter your Name: ") vowel_list = "AEIOU" if str.upper(user_name[0]) in vowel_list: print("The first lette...
f47188b2661c1204a59b80dfaf9bfff00cebc00c
ntran/smtp_sauce_main
/smtp_sauce/options/display_options.py
576
3.53125
4
''' Display counter and elapse-time ''' import os ## Display counter ## Params: _c - Indicate if the user type '-c' ## count - The current count def display_counter(_c, count): if (_c) : os.system("printf " + str(count) + "\r") return 0 ## Display time ## Params: _tm - Indicate if the user type '-tm' ## elaps...
e6216bafdfc658e8f273543bc484fc99816c3979
kristen-hyman/python-challenge
/PyBank/main.py
1,641
3.890625
4
# Import Dependencies import os import csv # Import the books.csv file as a DataFrame BankData = os.path.join("budget_data.csv") # Create Lists Data and set Varaibles total_months = 0 month_of_change = [] net_change_list = [] greatest_increase = ["", 0] total_net_profit = 0 net_change = 0 with open(BankData, newlin...
78827aaf80929ac9ffdd177e2929a963ec3de1a1
sammalik009/SchedulingAssignment
/FCFs.py
2,346
3.65625
4
class Node: def __init__(self,n1,ar1,va1,n2): self.name=n1 self.arrivalTime=ar1 self.burstTime1=va1 self.next=n2 def __init__(self,n1,ar1,va1): self.name=n1 self.arrivalTime=ar1 self.burstTime=va1 self.next=0 class Queue: def __init__(self): ...
83e4fceb5e9fb93a5a18864a08b3af913af8a8f9
hrdavidge/georgette_heyer
/machine_learning/pca.py
7,356
3.75
4
# code to test pca # first perform a standard random forest # then do dimensionality reduction performing pca # then re-run the random forest model # note a random forest model is not the best model to use pca on, as a random forest requires a large number of variables # import libraries import pandas as pd import pdb ...
af26c0766a931d8e6be867940e6d16ac72e19309
li-zeqing/learn_python
/ClimbStairs.py
1,058
3.9375
4
#张三爬一段15阶的楼梯 #张三一步最多上3个台阶 #分别用递归法和递推法计算一共用几种方法上15阶楼梯 #递归法 def climb_stairs_back(n): #定义一个字典 # 当处在第1台阶时有1种方法上 # 当处在第2台阶时有2种方法上 # 当处在第3台阶时有4种方法上 A = {1:1,2:2,3:4} if n in A.keys(): return A[n] else: return climb_stairs_back(n-1)+climb_stairs_back(n-2)+climb_stairs_back(n-3) #...
3abdc32b6dfdfc0a15b086850be9e08cc63e0e85
farhanmardadi/basic-python
/casting.py
199
3.5
4
#Mengubah Tipe Data #float to int x = 1.9999 print(x) print(type(x)) y = int(x) print(y) print(type(y)) #string to float x = "4.5" print(x) print(type(x)) y = float(x) print(y) print(type(y)) #string to int
a17c300bb2b947a83adca9066c51e74a341788aa
carrizoXPIO/parcial-tecnicas-programacion
/ejercicio1.py
934
3.671875
4
def soloTieneEspaciosEnBlanco(palabra): for letra in palabra: if letra != " ": return False return True def ejercicio1(palabra): if len(palabra) == 0: return [] if soloTieneEspaciosEnBlanco(palabra): return [] palabrasRotadas = [palabra] vueltas = len(pa...
db18b3950b3ba89dda9860e02fb7edaaf114bfe7
csethna/Telnyx_test
/telnyx/test_processPalindrome.py
417
3.75
4
import unittest from palindrome import processPalindrome class isPalindromeTestCase(unittest.TestCase): # tests for palindromes.py def test_processPalindrome(self): self.assertTrue(processPalindrome(2)) # starts at '2' because there is no base(1) or base(2). see: # https://math.stackex...
2b960433041557386d24062b2d63e05bed75b264
RAHUL-6611/my-Python-repo
/advance_basic/join.py
238
3.890625
4
l = ['mein', 'tum', 'voh'] for item in l: if item is not l[2]: # if using pycharm, directly write 'voh' instead of l[2] print(item, "aur ",end="") else: print(item) # print(" aur ".join(l))
97fe30f0067961651d37634853dd78c2210971b8
RAHUL-6611/my-Python-repo
/advanced python/python_framework/tkinter/button.py
491
3.671875
4
from tkinter import * button = Tk() button.title = "ClickBait" button.geometry("644x333") def hello(): print("Hello, i hacked you") frame = Frame(button, borderwidth=1, bg="grey", relief=GROOVE, pady=15) frame.pack(side=LEFT, anchor="n") b1 = Button(frame, text="Click Now", fg="white", bg="Black", font=55, c...
408a37e770b008c82c40495483c88fc514600de2
RAHUL-6611/my-Python-repo
/fundamentals/p18FunctionandRecursion.py
2,384
4.03125
4
# #Sample # def percent(marks): # p = (((sum(marks))/600)*100) # return p # #1.Rahul # m1 = int(input("Rahul \n: ")) # m2 = int(input(": ")) # m3 = int(input(": ")) # m4 = int(input(": ")) # m5 = int(input(": ")) # m6 = int(input(": ")) # Mark1 = [m1,m2,m3,m4,m5,m6] # Percentage1 = (percent(Mark1)) # ...
7cdcb030fc4234c26a17c2b54003e86e542231b7
RAHUL-6611/my-Python-repo
/advance_basic/3TryandExcept.py
815
4.15625
4
from os import write try: open("advanced python\open.txt") # write("advanced python\open.txt") except Exception as e: print(e) print("dekho bhai yeh nhi ho payega") # ---------------------------------------------3 try: file = open("text.txt", "r") except EOFError as e: print("Sorry, no m...
ca611edf231b00e135acba33df04aa990384565d
RAHUL-6611/my-Python-repo
/OOPs.py/1.py
4,034
3.796875
4
class Employee: # class properties no_of_employee = 0 increment = 1.25 # inital function def __init__(self, fname, lname,salary): # Dunder method self.fname = fname self.lname = lname self.salary = salary # self.email = self.fname + self.lname + "@gmail.com" ...
732a650a1828ddbe87337f0960e36612a6588f18
RAHUL-6611/my-Python-repo
/advanced python/files/tellseeketc.py
757
3.828125
4
# tell : tells you the position where it stop reading # seek : able to restart the reading from the position you input # get : get(key, defaultvalue) if not present then runs defaultvalue f = open('advanced python/files/a.txt') print(f.tell()) # tells about the character position...
ca316d220db0d9e05b1e736dab0c31f2b36c5fa6
RAHUL-6611/my-Python-repo
/fundamentals/p15Rambhagwaan.py
752
4
4
# lists = ['lalu','abdulla','katwa','shaamu','mohabbat','mulla','bulla','hagibullah','shaqal','billu hatela','katrabhai','jimmy','','bhosadkar'] # find_name = input(" : ") # if(find_name in lists): # print("name found") # else: # print("yeh scheme tere liye nahi hai") #---------------------------------------...
f8fcd10818d42595e0f7b0436d2755f30a5b2a70
eutimio16/quizz10
/QUIZZ10.py
368
3.796875
4
__author__ = 'Eutimio' def findthrees(n): suma=0 for i in n: if(i%3==0): suma=suma + i return suma list=[] ans="yes" num=(int(input(print(" give me a number"))) while(ans!="no"): num=(int(input(print(" give me a number"))) list.append(num) print(findtheers(list)) ans=in...
0892fc7243d4c4211d212423f5818bc4516d440e
FSchierok/euler
/p2.py
290
3.5
4
def fib(max): n0 = 2 n1 = 1 n2 = 0 while (n2 + n1) < max: n2 = n1 n1 = n0 n0 = n2 + n1 print(n0) yield n0 FIB = fib(4000000) sum = 0 for i in FIB: if i % 2 == 0: sum += i print(sum + 2) # n0=2 wird sonst nicht beachtet
51864d164d38e001b3aecdf3386a091e394ed1f6
avalok11/Geekbrains
/Geek University Big Data/3_parsing_data/Lesson1/task_2.py
663
3.515625
4
# 2. Изучить список открытых API. Найти среди них любое, требующее авторизацию (любого типа). # Выполнить запросы к нему, пройдя авторизацию. Ответ сервера записать в файл. import requests url = 'https://api.vk.com/method/' get = 'friends.get' token = '30320cae30320cae30320cae75305e26c13303230320cae6d7e406dd13fd49332...
97105df2e44091aab9ad03aabd86e9db0e77d01b
pstauble/LPTHW-Exercises
/ex3.py
228
3.921875
4
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 print "Roosters", 100-25*3%4 print "Now I will count the eggs:" print 3+2+1-5+4%2-1/4+6 print "Is it true that 3+2<5-7?" print 3+2<5-7 print "What is 3+2?", 3+2
333187ae4a804f332491d8599e0ade2bdf0ea92a
Njokosi/python
/LeetCode/Easy/1022. Sum of Root To Leaf Binary Numbers.py
1,919
4.125
4
""" You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13. For all leaves in the tree, consider the...
37253e417426cb3fe0f4f8e061968efd613c5f8e
Njokosi/python
/HackerRank/Interview Preparation Kit/warm up/Repeated String.py
1,363
4.03125
4
""" Lilah has a string, , of lowercase English letters that she repeated infinitely many times. Given an integer, , find and print the number of letter a's in the first letters of Lilah's infinite string. For example, if the string and , the substring we consider is , the first characters of her infinite string. T...
ad23285b66562e4872b7a10eb987a4122681a869
Njokosi/python
/HackerRank/Interview Preparation Kit/warm up/Counting Valleys.py
2,090
4.71875
5
""" An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly steps, for every step it was noted if it was an uphill, , or a downhill, step. Hikes always start and end at sea level, and each step up or down represents a unit change in altitude. We define the following terms: A mo...
e3088b9ab4dd4e3786ccc5ba55c7e2d95441e2ff
Njokosi/python
/LeetCode/Hard/4. Median of Two Sorted Arrays.py
1,050
3.984375
4
""" https://leetcode.com/problems/median-of-two-sorted-arrays/ Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. Follow up: The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanati...
c109b383e035779a7ccfd4f9234ce516545843f2
KaustuvBasak26/Python
/elif/elif.py
185
3.625
4
#!/usr/bin/python var = 100 if var==200: print("1-True") elif var==150: print("2-True") elif var==100: print("3-True") elif var==50: print("4-True") print(var) print("Good Bye!")
373c998aa17b665afa70887fb459ae836f69ed1d
KaustuvBasak26/Python
/errorHandling/errorWithArgument.py
178
3.65625
4
#!/usr/bin/python def temp_convert(var): try: return int(var) except ValueError as Argument: print("The argument doesnot contain numbers\n",Argument) temp_convert("xyz")
9ba48eddce8c3c64b7ce1b333e953503449c60ba
BryantCR/DojoPets
/Ninja.py
834
3.828125
4
from Pet import Pet class Ninja: def __init__(self, first_name, last_name, pet, treats, pet_food): self.first_name = first_name self.last_name = last_name self.pet = pet self.treats = treats self.pet_food = pet_food # walk() - walks the ninja's pet invoking the pet pla...
f7def6daa36accb9be061b0a503e351180ebe2c6
hasstariq/Algorithms
/mergesort.py
2,398
4.125
4
def merge_insertion_sort(X, y): h = 0 i = 0 j = 0 c = 0 if(len(X) > 1): middle = len(X) // 2 a1 = X[:middle] a2 = X[middle:] c = merge_insertion_sort(a1, y) + 1 c = merge_insertion_sort(a2, y) + 1 while(h < len(a1) and i < len(a2)): ...
14c1d3c3f2016299596d5fd8f0129e8c50fd88b7
Shadyaobuya/Opibus-Assessment
/question2_booking_service.py
1,679
4.03125
4
# This is a program that checks for the availability of an e-bike. It returns true if its available and false if not def check_bookings(bookings): booking_list=[] #empty list that holds all the booked time slots not_booked_list=[] #empty list that will store time slots that have...
668fab559eb51b8b2a4ae28e09ec5d4f9749ffb0
Pratikcs50/DataStruture-and-algroithms-program
/Python/Path.py
999
3.796875
4
from collections import defaultdict class Graph: def __init__(self,vertices): self.V= vertices self.graph = defaultdict(list) def addEdge(self,u,v): self.graph[u].append(v) def printAllPathsUtil(self, u, d, visited, path): visit...
dd8f62067ba93437622e6224a4370d43fa4cf9e3
dshuhler/codility_lessons
/codility/8_leader/dominator.py
926
3.625
4
import unittest def is_dominator(candidate, list): count = 0 for val in list: if val == candidate: count += 1 return count > len(list) // 2 def solution(A): dominator_stack = [] for num in A: if dominator_stack and num != dominator_stack[-1]: dominator_st...
b0767823d70568793399ada16d2262014b99b29b
dshuhler/codility_lessons
/codility/7_stacks_and_queues/stone_wall.py
838
3.5625
4
import unittest def solution(H): block_stack = [] current_height = 0 num_blocks = 0 for height in H: if height > current_height: block_stack.append(height - current_height) num_blocks += 1 current_height = height elif height < current_height: ...
354bf073e1e894657424f88f8cb320d3e0d0166e
dshuhler/codility_lessons
/codility/6_sorting/triangle.py
618
3.609375
4
import unittest def is_triangular(triplet): return ((triplet[0] + triplet[1] > triplet[2]) and (triplet[1] + triplet[2] > triplet[0]) and (triplet[0] + triplet[2] > triplet[1])) def solution(A): A.sort() for i in range(len(A) - 2): if is_triangular(A[i: i + 3]): ...
2ab1ca965e199867841cb9a9e3099dc7c176261e
CuongNguyen2809/Assignment2
/turtle_ex2.py
334
3.796875
4
from turtle import* color('blue') for i in range (3): forward(100) left(120) color('red') for i in range (4): forward(100) left(90) color('blue') for i in range (5): forward(100) left(72) color('red') for i in range (6): forward(100) left(60) main...
f175cd54236a21ff94ce8f616560437aed6c8098
inwk6312fall2019/dss-pkpatel729
/ex_10.1.py
140
3.71875
4
num = [[1,4,5], [3], [4, 5, 6]] def nested_sum(p): total = 0 for i in p: for j in i: total += j print(total) nested_sum(num)
1a8c42d352783c57ccf359fcbaf74296fa22330e
Barcol/xDDDDDDDDDDDDDDDD
/src/placed_plants.py
2,037
3.765625
4
import json from math import hypot, cos from typing import Tuple, List, Union class PlacedPlants: def __init__(self): with open("data.json", "r") as outfile: self.__placed_plants_data = json.load(outfile) def add_plant(self, name: str, position: Tuple[float, float]): plant = {"nam...
61523a69160032caa42e0a3129bc4dba1ec1405a
liguoqinjim/py3-labs
/lab039/lab001.py
327
3.5625
4
import time from multiprocessing import Pool def f(x): time.sleep(x) return x * x if __name__ == '__main__': with Pool(5) as p: r = p.map(f, [1, 2, 3]) # NOTICE r是所有进程的返回结果,是一个list # NOTICE r会等待所有执行完毕 print(r) print(type(r))
8743cf9126ce460332c70e412b2c53dbc5199dd3
liguoqinjim/py3-labs
/lab007/lab003.py
202
3.984375
4
str1 = "hello world" str2 = "hello" # 方法一 if str2 in str1: print("包含") else: print("未包含") # 方法二 if str1.find(str2) >= 0: print("包含") else: print("未包含")
cab0a40b2af5cadc2121410e258a3e139fb6578d
liguoqinjim/py3-labs
/lab020/lab001.py
422
3.796875
4
import datetime import time print(datetime.datetime.today()) # 2020-09-24 11:26:52.000288 print(datetime.date.today()) # 2020-09-24 print(datetime.datetime.now()) # 2020-09-24 11:28:04.630825 # 解析时间字符串 tm = datetime.datetime.strptime("2018-01-16 23:44:55", "%Y-%m-%d %H:%M:%S") print(tm.year, tm.month, tm.day) # 2...
30e930ab7c1722540aeb3e69856755b5a5df553b
LuyandaGitHub/intro_python
/Week_2/Exponent/exponent.py
393
4.15625
4
number_1 = int(input('enter a base number')) number_2 = int(input('enter the power number')) def get_exponent(base_number, power_number) : result = 1 # HOW MANY TIMES WE LOOP IIS GONNA DEPEND ON THE POWER WE GET IN FROM THE USER for index in range(power_number) : result = result * base_n...
5aa3052e60b98aa65cea1def62c3716f1f131212
LuyandaGitHub/intro_python
/Week_4/PalindromePrime/palindrome_prime.py
609
3.890625
4
start = int(input('Enter the start point')) end = int(input('Enter the end point')) palindrome_list = [] while(start < end) : start_string = str(start) reverse_string = start_string[::-1] if(start_string == reverse_string) : if(start > 1) : for i in range(2, start) : if((s...
1969ac627b6de524b39b7ab73c231f9cd93a29fa
LuyandaGitHub/intro_python
/Week_8/2048/push.py
9,059
4.09375
4
# THIS FUNCTION MERGES BLOCKS UPWARDS def push_up(board_param): # game_still_going WILL BE USED DO DETERMINE WHETHER THE LOOP SHOULD CONTINUE game_still_going = True while game_still_going: game_still_going = False # THIS WILL LOOP THROUGH THE board_param for col_i in rang...
ed118d64c80539a31f1bea5197ffb1e2e42ee638
LuyandaGitHub/intro_python
/Week_6/caticulus.py
2,761
4.4375
4
# GET THE YEAR TO CHECK year_input = int(input('Enter a year: \n')) # GET THE MONTH TO CHECK month_input = int(input('Enter a month number(1, ..., 12): \n')) # THIS FUNCTION WILL TAKE AN INPUT AND DETERMINE WHETHER IT IS A LEAP YEAR OR NOT def determine_leap_year(year_param) : # A LEAP YEAR HAPPENS EVERY 4 YE...
10cc0032bb019a2050e1f96523c0abb357c33a09
le-emily/Data-Structures-Practice
/Lists/reverse_recur.py
207
3.703125
4
def reverse_linked_list(node, prev=None): if node.next is None: node.next = prev return node root_node = reverse_linked_list(node.next, node) node.next = prev return root_node
2271d5cc951ed3b80ecd01dc0efb8d5cc7770111
le-emily/Data-Structures-Practice
/Lists/loop_detection.py
621
4.09375
4
# given a circular linked list, implement an algorithm that # returns the node at the beginning of the loop def loop_detection(self): # set slow and fast to self.head slow_p = self.head fast_p = self.head # ensure that slow, fast and fast.next is not None while slow_p and fast_p and fast_p.next: ...
4a067b3d5d8df10bc49afd35898d53131dc3c221
alexoleshk/python-project-lvl1
/brain_games/games/prime.py
461
3.921875
4
import random from math import sqrt TASK = 'Answer "yes" if given number is prime. Otherwise answer "no".' MAX_NUM = 20 def is_prime(n): if n < 2: return False counter = 2 while counter <= int(sqrt(n)): if not n % counter: return False counter += 1 return True de...
160c8ff2c4abdd82c4a382699f61385b47297b02
Winnie2031/python0716
/d03/rabbit and chicken.py
172
3.625
4
def calc(x, y): a = 2*x b = y-a rabbit = b/2 return x-rabbit, rabbit chicken, rabbit = calc(83, 240) print("chicken : %d, rabbit : %d" % (chicken, rabbit))
13eed5cb1c4e761295b6a730117586c3ae578dab
baohongfei/learn-python3
/samples/advance/do-list-comprehensions.py
440
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os print([x*x for x in range(1,11)]) print([x*x for x in range(1,11) if x%2 == 0]) print([m+n for m in 'ABC' for n in 'XYZ']) d={'x':'A','y':'B','z':'C'} print([k+'='+v for k,v in d.items()]) L=['Hello','World','IBM','Apple'] print([s.lower() for s in L]) l = l...