blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
d26e73df3437e21444298b5f78e64287586f9768
codio-gcse-2014/teacher-python-1
/09-iteration2/play.py
76
3.640625
4
# Start writing your code in here x=0 while x < 5: print('looping')
58a7675d02def03928820465524247a960363b60
tasfia-makeschool/superhero
/superheroes.py
14,222
4
4
import random class Ability: ''' Instantiate instance properties. name: String max_block: Integer ''' def __init__(self, name, max_damage): self.name = name self.max_damage = int(max_damage) ''' Return a value between 0 and the value set by self.max_damage.''' #...
a593fd22c372db0091f8af77e6f9c35339eb391c
SiyabongaThwala/My-Kata
/app/SplitStrings.py
338
3.84375
4
def splitStrings(string): EvenString = '' if len(string) % 2 != 0: EvenString =''.join((string,"_")) else: EvenString = string splitPoint = 2 SplittedList = [(EvenString[item:item+splitPoint]) for item in range(0,len(EvenString),splitPoint)] print(SplittedList) splitSt...
d9d704c8ade112bf815c86c6daf8ef08e76d0c39
abbibrunton/python-stuff
/Python stuff/edit_file.py
242
3.609375
4
file = open("filename.txt", "r") # file.seek(0) lines_needed = "" file.seek(0) file.readline() lines_needed += file.read() file = open("filename.txt", "w") file.write("this is a new line \n") file.write(lines_needed) file.close()
eaedd06f930c8972196936e2a7ef94a359cd1222
muditabysani/BFS-2
/Problem1.py
2,816
3.890625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution: def isCousins1(self, root: TreeNode, x: int, y: int) -> bool: # Time Complexity : O(n) where n is the number...
43babfe7fa12f77705bc6d459548c2efac9f7ee3
zhang402115/Natural-Language-Processing-with-Python
/py_nlp/src/ch1_2.py
5,868
3.671875
4
#!/usr/bin/python # -*- coding: utf-8 -*- from nltk.book import * def lexical_diversity(text): return len(set(text)) / len(text) def percentage(count, total): return 100 * count / total #think of a text as nothing more than a sequence of words and punctuation sent1 = ['Call', 'me', 'Ishmael', '.'] sent1 lexic...
f5c76c24fbaddcdd2f134496d5986b8df712fc6e
sunbee/PyHardWay
/lightroomContainerSize.py
5,365
4.125
4
# coding: utf-8 # In[1]: import pandas as pd import numpy as np # In[2]: # First, lets test the ability of Python to handle very large numbers. # We can test this out by taking the factorial of, say, n=100 # Start with a smaller-sized problem, say, n=10 # Why are there zeros at the trailing end of the number? #...
38be2992aaba593a980c3004c98d351dbb18a030
asset311/leetcode
/arrays/meeting_rooms.py
722
3.859375
4
''' 252. Meeting Rooms https://leetcode.com/problems/meeting-rooms/ Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings. ''' # Sort the meetings by start time. Then traverse meetings one by one, and check if one me...
5b5410d107748312d46ac89d233c1f4f7a10759e
melission/leetcode
/Chellenges/2021/July/Max length of repeated subarrey.py
931
3.71875
4
# https://www.geeksforgeeks.org/longest-common-subarray-in-the-given-two-arrays/ first sol def findLength(nums1, nums2) -> int: a1 = len(nums1) a2 = len(nums2) dp = [[0 for i in range(a1+1)] for i in range(a2+1)] for i in range(a1 -1, -1, -1): for j in range(a2 -1, -1, -1): if nums...
e5ef6efb2e56c7ecdf7ded46a02fcd7dd87bfd11
nicolasenciso/MaliciousURLsDetection
/featureExtraction.py
3,124
3.5625
4
"""la idea principal es tomar una combinacion de features y ver como se comparan en visualizacion con los del paper luego hacer clasificacion para saber como se comportan, y luego se hace una seleccion de best fatures como en el paper domain token length, tld, number of dots in url, symbol count domain, ratios...
1748f55cec1fa19851bb3136be962eba6524fa9a
shyambeer/Algorithms
/longestSubstring.py
455
3.71875
4
import collections def longestSubstring(my_str): max_len = 0 queue = collections.deque() for ch in my_str: if ch in queue: max_len = max(max_len, len(queue)) while queue: ch1 = queue.popleft() if ch1 == ch: break q...
ce9b271facbdce44ba73bcee75ecc818476271c4
lane-marsh/riddle_solvers
/is_this_seat_taken?.py
2,353
4.21875
4
import random """ Riddle: 100 people are waiting to board a plane. The first person’s ticket says Seat 1; the second person in line has a ticket that says Seat 2, and so on until the 100th person, whose ticket says Seat 100. The first person ignores the fact that his ticket says Seat 1, and randomly chooses on...
230b9ca4940ad00be82f8f8676a3a9af832ecfd2
jahokas/Python_Workout_50_Essential_Exercises_by_Reuven_M_Lerner
/exercise_36_sales_tax/freedonia.py
368
3.578125
4
from decimal import Decimal rates = { 'Chico': Decimal('0.5'), 'Groucho': Decimal('0.7'), 'Harpo': Decimal('0.5'), 'Zeppo': Decimal('0.4') } def time_percentage(hour): return hour / Decimal('24.0') def calculate_tax(amount: int, province: str, hour: int) -> float: return float(amount + (amo...
37907a8e786fd8d54806654619d96232d730daa8
TiboSmetKdG/Make1.2.3
/Leeftijd.py
2,662
3.921875
4
# !/usr/bin/env python """ / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄        | Een python script dat het volgende doet:        | 1. vraagt achter je leeftijd        | 2. berekent in welk jaar je geboren bent en dat ook als output meegeeft        | 3. berekent in welk jaar je 50 jaar zal zijn en dat ook als output meegeeft        \__ ...
01fc527090618706f9f40b26065b520cfffb4457
ivovilar1/exercicios
/ex013.py
222
3.65625
4
salario = float(input('Qual é o salario do Funcionario?R$')) aumento = salario*0.15 novo = aumento +salario print('Um funcionario que ganhava R$ {:.2f}, com 15% de aumento, passa a receber R$ {:.2f}'.format(salario,novo))
7416a2d532791cd003080ff3c1f5f0c7c3e84443
SerhiiDemydov/Cursor-HW-Advansed
/HW2-OOP/1_Task.py
2,775
4.28125
4
""" 1.Create a class hierarchy of animals with at least 5 animals that have additional methods each, create an instance for each of the animal and call the unique method for it. Determine if each of the animal is an instance of the Animals class class Animals: Parent class, should have eat, sleep class Animal1(A...
6dd32ff92423c42594a07cc8d23036abdd6d7419
devashish9599/PythonPractice
/s.py
397
3.609375
4
a=input("enter the string") l=input("enter the second string") z=len(l) b=input("enter the character to be searched in first string") count2=0 c=input("enter the character to be searched in second string") x=len(a) count=0 for i in range(0,x): if(a[i]==b): count=count+1 print count,"times is",b for j...
0d37a6301df6887e786b5eb2264683e715c2f31a
kentnf/noschema
/ns/ndocument.py
3,120
3.71875
4
#!/usr/bin/python3 import copy ''' document is a dict, it includes both dict and list ''' class Document(): def __init__(self, doc): self.doc = doc #self.name = doc['name'] if 'name' in doc else self.name = '' #self.type = doc['type'] if 'type' in doc else self.type = '' #self._id = doc['_id'] if '_id' in...
a7f7d7ce284dd7d0b6cec473a293a1c4ac75ae8c
wangming-0215/python-start
/chapt_07/7-4.py
178
3.8125
4
done = False while not done: fruit = input('Please input some fruit: ') if fruit == 'quit': done = True else: print('You will have', fruit)
ea78b5514c4b9488365b9cbc436927a863bf0ef6
FleeaniCh/python
/second_step/regular_expression/metacharacter/re_08.py
219
4.0625
4
""" $ 匹配目标字符串的结尾位置 """ import re print(re.findall('Jame$',"Hi,Jame")) print(re.findall('Jame$',"Hi,Jame,now")) # ^ 与 $ 同时出现 print(re.findall('^Jame$',"Jame")) # 完全匹配
a6e39f78b4ab2cf83f83ae5c6a2afb3177a176e7
rvalenzuelar/pythonx
/pixels_along_line.py
1,242
3.59375
4
# From: # http://stackoverflow.com/questions/24702868/python3-pillow-get-all-pixels-on-a-line # https://github.com/sachinruk/xiaolinwu/blob/master/xiaolinwu.m def xiaolin(x0, y0, x1, y1,**kwargs): width=kwargs['width'] x=[] y=[] dx = x1-x0 dy = y1-y0 steep = abs(dx) < abs(dy) if steep: x0,y0 = y0,x0 x1,y...
86c553f67c579139db42786afd3f3971ed9a94f8
monil28/Turtle
/spiral.py
250
3.703125
4
import turtle turtle.speed(5) turtle.shape("circle") def hexagon(): for _ in range(6): turtle.forward(100) turtle.left(60) for _ in range(6): hexagon() turtle.forward(100) turtle.right(60) turtle.exitonclick()
7b9d71a9469f8a321e737800d2f772ad2198a358
victor-estrade/RL
/experiment_episodic_compare_agents.py
4,435
3.640625
4
from __future__ import division, print_function import random import numpy as np import matplotlib.pyplot as plt import environments import agents from experiment_episodic import doEpisodes def plotLearningCurves(learning_curves, ax): ''' Plot several learning curves. Args: learning curves - a dict...
a3e0aa69d857fe08e640e3692e976d8c539efe12
isaacjmasindi/Other_Python_Codes
/Built-in Functions/jokes.py
659
3.671875
4
#the random module is imported #jokes is a list that contains the jokes #the random moudle is used with randint to show random jokes of the list from index 0 to index -1 #the random module reseach https://www.w3schools.com/python/module_random.asp import random # the jokes were found on https://www.rd.com/jokes/ ...
8577730df3cef95ddcd8706d14b9a31189d47e72
vector8188/AlgorithmAnalysisPython
/binarySearch.py
558
4.03125
4
def binarySearch(alist, item): first = 0 last = len(alist) - 1 found = False while not found and first <= last: # manipulate mid point here as this is the place # which brings it closer to the solution mid = (first + last) // 2 if alist[mid] == item: found = True else: if alist[mid] > item: # t...
81b701571e60ae9bd5fa07da36ff6829d0878dce
robinklaassen/aoc2020
/day10/solution.py
1,681
3.765625
4
from typing import List, Tuple import numpy as np import networkx as nx import matplotlib.pyplot as plt from utils import read_input def count_diffs(numbers: List[int]) -> Tuple[int, int]: arr = np.array(numbers) diffs = np.diff(arr) num_ones = (diffs == 1).sum() num_threes = (diffs == 3).sum() ...
d3e066c72de2640e8a6e471ba45bf74f848b99b5
ornichola/learning-new
/pythontutor-ru/06_while/17_std_dev.py
965
3.765625
4
""" http://pythontutor.ru/lessons/while/problems/std_dev/ Дана последовательность натуральных чисел x1, x2, ..., xn. Стандартным отклонением называется величина σ = SQRT( ((x1−s)^2 + (x2−s)^2 + … + (xn−s)^2) / (n−1) ). где s = (x1+x2+…+xn) / n — среднее арифметическое последовательности. Определите стандартное отклоне...
7bded2c068fcb4d899c08d6df49912927d8c7a32
mendyk-ja/files_and_exceptions
/questionnaire.py
247
3.796875
4
while True: answer = input("Why do you like programming? Please answer here: ") if answer == 'exit': exit() filename = 'questionnaire.txt' with open(filename, 'a') as file_object: file_object.write(f"{answer}\n")
40a3ab0d18cddcf1d8910d218b0f8550851b2840
pdhhiep/Computation_using_Python
/triangle_integrals/triangle_xy_integral.py
3,954
3.734375
4
#! /usr/bin/env python # def triangle_xy_integral ( x1, y1, x2, y2, x3, y3 ): #*****************************************************************************80 # ## TRIANGLE_XY_INTEGRAL computes the integral of XY over a triangle. # # Location: # # http://people.sc.fsu.edu/~jburkardt/py_src/triangle_integrals/trian...
6c9b3d69ab1330839a85b0e90dc53576db9476ed
PBJ21033/cse210-student-hilo
/hilo/game/drawer.py
1,897
4.1875
4
import random class Drawer(object): def __init__(self): """ Class constructor. Args: self(Drawer): Instance of the Drawer class Attributes: new_card(int): New card drawn thats value player is guessing old_card(int): Old card thats value was assigned by previous ne...
5333c32732ebf134a3bb9cd90e2f4070d4d1b600
samuelkahn/Datascience205
/HW4/top_users.py
922
3.5
4
"""Find users who have edited more than 2 pages. This program will take a CSV data file and output tab-seperated lines of user -> number of page edits To run: python top_users.py page_users.txt Output: "108" 3 "11292982" 3 "372693" 10 "8889502" 5 """ from mrjob.job import MRJob import sys cl...
82d8e8891fd7d71aa8c324cf3901dbb0f2cac30e
pedrolucas27/exercising-python
/list03/exer_06.py
188
4.03125
4
#Faça um programa que leia 5 números e informe o maior número. maior = 0 for n in range(1,6): x = int(input("Número:")) if x > maior: maior = x print("Maior - ",maior)
c3fce05e4353c5fbdd1a034cbddb4506cdd4bb19
nidhiatwork/Python_Coding_Practice
/30DayLeetcodeChallenge_May/Week1/7_isCousins.py
995
4
4
''' In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. Two nodes of a binary tree are cousins if they have the same depth, but have different parents. We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree. ...
74889169722a5ce8e63f5ccecfcc9d63720ad32f
mauriycf/proyectos
/python-curso/python3/condicionales.py
233
3.8125
4
#Inicializacion de Variables x = int(input("Ingresa un entero, por favor: ")) if x<0: x = 0 print('Negativo cambiado a cero') elif x == 0: print('cero') elif x == 1: print('simple') else: print('Mas') input()
cec61ef65247a32c5c93be82f44178b348613713
hongyesuifeng/python-algorithm
/quick_sort.py
695
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 8 21:48:44 2017 @author: admin-ygb """ def quick_sort(lists, left, right): if left >= right: return lists low = left high = right key = lists[left] while left < right: while left < right and lists[right] >= key:...
51b6566738612d19bcb8c7f2e274ff6f65ed8dff
10102006/Python
/Learning/29_Decorators.py
2,161
4.875
5
''' **Summary** Decorator is a type of class which is used for cleaning up a function or decorating it. Two ways to use a decorator is following: *** Make a function which takes an arguement function. Format the param function inside that main function.(decorator) *** Make another function which needs to de...
38e654825eef2f5015baec6aa8bf73173b00541c
pzqkent/LeetCode
/234.py
1,359
3.859375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def isPalindrome(self, head): if head == None: return True # import math current = head list1 = [] while current:...
a8289fddde575a8ed4fa667d14f47248411f7053
Lousm/Python
/01_py基础/第2周/day03/test07.py
385
3.65625
4
class A(): def __new__(cls,*args,**kwargs): if not hasattr (A,'instance'): print("没有") cls.instance=super().__new__(cls) # return super().__new__(cls) return cls.instance def __init__ (self ,name): self.name=name print("调用init方法") a=A('小明') b=A('小...
1e458b21d9fcea7a60dcd308b3d2922ef9de1587
nderkach/algorithmic-challenges
/python_powerset.py
419
3.890625
4
def int_to_set(x, s): subsets = [] k = x index = 0 while k > 0: if k & 1: subsets.append(s[index]) k >>= 1 index += 1 return subsets def powerset(s): total_sets = 1 << len(s) all_subsets = [] for k in range(total_sets): all_subsets.append(int_...
581f91d3bbe6176b79346d27c3248397ce891770
Nikame/Udemy-Abid-Malik-python-scripting
/5-Numbers.py
937
3.8125
4
import sys # Numbers in Python 2 # There are 4 types of numbers in Python 2 # Types of numbers: int, long, float, complex # Whole numbers: int, long a = 28 # This is a perfect number print(type(a)) # What is the max limit of a integer value print(sys.maxint) b = 9223372036854775807 print(type(b)) c = 92233720368547758...
596eb3c5c0eded8db26c4466f9843674a9bd1bf4
BrookeEB/Python-Project
/WalkingDeadTriviaQuiz.py
4,297
4.375
4
### This code outputs a Trivia Quiz based on the AMC's Walking Dead TV show. For each question, there are 5 options. Only one option is correct. ### This code uses classes, loops, if and else statements as well as the random function to run the Trivia Quiz. import sys import random def Greet(hello): name = raw_i...
d7d37789530b7ce6ed27790e364bab261cc748d1
ChetverikovPavel/Python
/lesson2/task5.py
1,885
3.75
4
my_num_list = [57.8, 46.51, 97, 25, 39.7, 92.15, 57.13, 19.08, 46, 11.02, 75] # Задание A i = 0 while True: if i + 1 == len(my_num_list): print(f"{int(my_num_list[i])} руб {int((my_num_list[i] * 100 % 100)):02d} коп", end='\n\n') break else: print(f"{int(my_num_list[i])} руб {int((my_nu...
83a1900ca0f1c56323b991e13674daf1b0e8aac2
s3604730/TonyAssignment2-ai1901-connectfour
/connectfour/agents/agent_student.py
41,516
3.671875
4
from connectfour.agents.computer_player import RandomAgent import random class StudentAgent(RandomAgent): def __init__(self, name): super().__init__(name) self.MaxDepth = 3 def get_move(self, board): """ Args: board: An instan...
312f77a942736587bf395275bd0bc501269dd88d
hakubishin3/nlp_100_knocks_2020
/ch03/28.py
1,024
3.609375
4
""" 28. MediaWikiマークアップの除去 27の処理に加えて,テンプレートの値からMediaWikiマークアップを可能な限り除去し,国の基本情報を整形せよ. """ import pandas as pd import re """ https://github.com/upura/nlp100v2020/blob/master/ch03/ans28.py """ def remove_mk(v): r1 = re.compile("'+") r2 = re.compile('\[\[(.+\||)(.+?)\]\]') r3 = re.compile('\{\{(.+\||)(.+?)\}\}...
735dc3ff2951ac5a1869eff884700fecc06066d6
MariaTrindade/CursoPython
/01_Entrada e Saída/01_Dir e Help.py
445
3.78125
4
''' Dir >>> Retorna atributos, funções e metodos Help >>> Retorna a documentação ''' # print(help(print)) # Retorna a documentação da função print # print(help(range)) # Retorna a documentação da função range nome = 'Aline' print(dir(nome)) # Retorna todos os metodos que podem ser utilizados com este tipo de dado ...
646ef342b4254d0d0083b64898add5756ca141d4
316060064/Taller-de-herramientas-computacionales
/Clases/Programas/Tarea4/Problema04.py
290
3.875
4
#!/usr/bin/python2.7 # -*- coding: utf-8 -*- ''' Josue Artemio Hernandez Rodriguez, 316060064 Este programa te pide un número y a partir de ese te calcula la suma del enesímo termino de la sucesion de Fibonacci ''' def fib(n): if n < 2: return n else : return fib(n-1) + fib(n-2)
43308e840d93e8ee44cdaeaf35fa5152c6dcb204
liushenghao/pystudy
/实验1/test3.py
124
3.640625
4
year = int(input()) if(year%400==0 or (year%4==0 and year%100!=0 )): print('是闰年') else: print('不是闰年')
ef6e3c8e584b902834ab69f10d38c7f0625c23e5
anushamurthy/CodeInPlace
/Assignment2/nimm.py
760
4.0625
4
""" File: nimm.py ------------------------- Add your comments here. """ PILE = 20 def main(): stones = PILE player = 1 while stones > 0: print ("There are " + str (stones) + " stones left") x = int(input("Player" + str(player)+" would you like to remove 1 or 2 stones? ")) #if x==...
1c134d49cbf85d46f90a6d3f59aa58145335a75a
schamb/text-adventure-ikea
/textadventure.py
446
4.125
4
start = ''' After spending what seems like an eternity looking for the perfect chair in ikea, you realize you are lost. You look around and see you are in a strange room with a door on you left and your right. ''' print(start) print("Type 'left' to go left or 'right' to go right.") user_input = input() if(user_input ...
e1ad554711633d7b6384ca1ffea5ef26dc260405
licong20060541/docs
/python/calcAlpha.py
243
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- num = input('please input float alpha like 0.4: ') result = 256 * float(num) result2 = int(result) print('256 * ' + num + '=' + str(result2)) print(str(result2) + ' to hex is ' + hex(result2) )
cf22d2a1fb8e9f5a08a5f005bed108ca24a51369
ypycff/pythonClass
/PythonDev/Demos/03-FlowControl/ifinrange.py
231
3.828125
4
number = int(input("Enter a football jersey number [1 to 11]: ")) if number == 1: print("Goalie") elif number in range(2, 6): print("Defender") elif number in range(6, 10): print("Midfielder") else: print("Striker")
dc210d0435cb2995064dddd491d6228488075f60
Near-River/leet_code
/141_150/148_sort_list.py
2,943
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Sort a linked list in O(n log n) time using constant space complexity. """ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def sortList(self, head): ...
35de19d901216737a069752711f9341c08c383d7
AncientAbysswalker/Projekt-Euler
/Euler Projekt 035 - Circular Primes/EulerProjekt_35.py
1,396
3.875
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 6 @author: Abysswalker """ from os import path #Is a number prime def isNewPrime(number,primes): for prime in primes: if number%prime == 0: return False return True #Generate primes up to a limit def genPrimes(upper): filepath = path.join(path...
001e0644c5f8d07ca66327f70e6547469eeac3a6
HarrietHarchy/Project_Work
/Pupils_Ages.py
721
3.75
4
#find the oldest and youngest pupil in the class of 4, namely:Sharon, John,Grace,Emmanuel. #Sharon is 12years old, John is 7 years old, Grace is 10 years old and Emmanuel is 6years old.s def biggest(a,y,z,w): Max = a if y > Max: Max = y if z > Max: Max = z if w > Max: Max = w return Max print(biggest(1...
c891215e958f1e569aaf47e6e9e1a719f77ddda5
Mike-droid/IA-ML-Platzi
/Curso_fundamentos_matematicos_para_IA/vectores.py
194
3.546875
4
import numpy as np v=np.array([1,1,2]) #!vector 1 u=np.array([0,2,1]) #! vector 2 lin = v*u print(lin, lin.sum()) #!lin muestra el vector de resultado y lin.sum resultado lineal #[0 2 2] 4
6e3e202ff628b5216da5de32ea233e858b27084d
dpm530/Python_Stack
/Python/Fun with Functions/multiply.py
140
3.78125
4
def multiply(arr,num): i=0 while i<len(arr): arr[i]=arr[i]*num i+=1 return arr print (multiply([2,4,10,16],5))
860fdf1bd0036e0c745fdac099a7da0a27280828
clem-hub/Python-Task-2
/task2.py
925
4.21875
4
# User Data Validation import random import string first_name = input("Enter First Name:\n") last_name = input("Enter last Name:\n") email = input("Enter Email:\n") # def random_password(length=5): length = 5 random.choice(string.ascii_letters) a = ''.join(random.choice(string.ascii_letters)for i in range(length)) ...
465e852a0754ffe5d743526b0f9680aa1143437b
kohstephen/xylophone-dropzone
/mingus_exercises/1_2.py
242
3.609375
4
''' Created on Jan 6, 2017 @author: stephenkoh ''' import mingus.core.notes as notes note = str(input('Please enter a note: ')) if (notes.is_valid_note(note)): note = notes.to_minor(note) note = notes.diminish(note) print(note)
6341dcd163e64d6ed7cd424d5727d2e8c3955090
jakecruise/allchaptersreview
/8.4.py
282
3.703125
4
file_handle = open('romeo.txt') list_of_words = list() for line in file_handle: words = line.split() for word in words: if word in list_of_words: continue else: list_of_words.append(word) list_of_words.sort() print(list_of_words)
78db5842d9223ed412de6ddaf268a8710ad955ec
rodrigomverissimo/daily-programmer-solutions
/solutions/challenge_393/challenge_393.py
1,475
4.5
4
""" link: https://www.reddit.com/r/dailyprogrammer/comments/nucsik/20210607_challenge_393_easy_making_change/ The country of Examplania has coins that are worth 1, 5, 10, 25, 100, and 500 currency units. At the Zeroth Bank of Examplania, you are trained to make various amounts of money by using as many ¤500 coins as p...
2b71aa617d40dafb449aa57b4a7a4c51254f2ba9
terrifyzhao/educative
/2_two_pointers/2_remove_element.py
755
3.796875
4
# 移除arr中的key元素 def remove_element(arr, key): next = 0 for i in range(len(arr)): if arr[i] != key: arr[next] = arr[i] next += 1 return arr[:next] def remove_element2(arr, key): l = 0 for index, num in enumerate(arr): if num != key: arr[l] = num...
e6d00547ff35c6f7c99ede0405c85ae56652a5bc
show2214/atcoder
/atCoderBeginnerContest168_c.py
319
3.71875
4
import math if __name__ == "__main__": A, B, H, M = map(int, input().split()) angle = 0 small = (H * 60 + M) * 0.5 big = M * 6 if small > big: angle = small - big else: angle = big - small cos_c = math.cos(math.radians(angle)) print(math.sqrt(A**2 + B**2 -(2*A*B*cos_c)))
4051701b9af5bb02fcefd9e308b053d27342727f
cmestradap/Prueba_Ultracom
/Polinomio.py
1,029
4
4
class Polinomio(): def __init__(self): self.__grado=1 self.__x = float #variable self.__coeficiente = 1 #coeficiente que acompaña a la variable self.__polinomio = float def suma(self,valor): re...
8c13cefec167ce28853cfcc3436af05acf96a0e3
rajeevdodda/Codeforces
/Contests/Div#636/b.py
340
3.703125
4
t = int(input()) for i in range(t): n = int(input()) if (n // 2) % 2 == 1: print("NO") else: print("YES") even_list = list(range(2, n + 1, 2)) odd_list = list(range(1, n - 1, 2)) odd_list.append(sum(even_list) - sum(odd_list)) print(" ".join(str(x) for x in e...
5ecbbb66ef728589f7f653850ab65511f445e1cb
brandongeren/AmazonReviewMining
/organize.py
1,022
3.5
4
#This code read a json dataset and sort all the json objects to the respect #year file #must be run with a python version less thatn 3.0 import json def parse(path): o = open(path, 'r') j= o.readlines() elements = 0 for line in j: jsonObject = json.loads(line) date = jsonObject['review...
e3270ec808016c8a7228b7e8902e5e352dc922d2
siddhantshukla-10/SEE-SLL
/2/2b/app1.py
657
3.8125
4
import pandas as pd from pandas import Series, DataFrame import numpy as np import matplotlib.pyplot as plt import seaborn as sns stud = pd.read_csv('StudentsPerformance.csv') print(stud.head()) print(stud.info()) print(stud.describe()) stud1 = stud.drop(["lunch","test preparation course"],axis=1) print(stud1.head(...
b78d337c17543d615083891180b876ab37385f5d
jackneer/my-leetcode
/no56_merge_interval.py
637
4.03125
4
def merge(nums): remove_index = [] for i in range(len(nums)): if i not in remove_index: for j in range(i + 1, len(nums)): if nums[j][0] >= nums[i][0] and nums[j][0] <= nums[i][1]: if nums[j][1] > nums[i][1]: nums[i][1] = nums[j...
679294e85316b4f467838126f81e1bc19a919ab9
good-boi-huan/drawing-stuff
/main.py
1,283
4.28125
4
import turtle def circle(radius, color): z.color(color) z.begin_fill() z.circle(radius) z.end_fill() def star(length, color): z.color(color) z.begin_fill() for i in range(5): z.forward(length) z.right(144) z.fillcolor(color) z.end_fill() def polygon(length, sides, color): angle = 360...
f2d3c9e00cf473d0c5a8933c29dbc18165f09a6d
HyoungSunChoi/BaekJoon
/브루트 포스/7568번. 덩치.py
391
3.625
4
''' 두 명의 덩치가 (x,y) (a,b) x>a, y>b 일 때 1, 2보다 크다. 키와 몸무게 하나만 큰 경우에는 크다고 말할 수 없다. ''' res=list() n=int(input()) for _ in range(n): a,b=map(int,input().split()) res.append((a,b)) for i in res: rank=1 for j in res: if i[0]<j[0] and i[1]<j[1]: rank+=1 print(rank,end...
f84447fd18d3e0185e0adb4e9e89e800711bed6a
shinesac/pythonproject
/stock_value.py
5,526
4
4
import csv import math from datetime import datetime # feature 1: connect to external API and use data in program- import yahoo finance API data, program uses the data from this API to make calclations import yfinance as yf # feature 2: create list, which is used in the program later- favorites list is created and ...
0ce925414af40adc07ac18e88c63790212e7d16e
diegoaleman/ciu-old
/algorithms/other/longest-repeated-subsequence.py
290
3.546875
4
def LRS(l): screening = set() result = [] for letter in l: if letter in screening: result.append(letter) else: screening.add(letter) return''.join(result) if __name__ == '__main__': l = "AGGVGBTABEBCDD" print(LRS(list(l)))
be3f39bf2bad4b4a1f7a6ebf88f6d4622733a7bf
huyngopt1994/python-Algorithm
/leet-code/divide_and_conquer/easy/power.py
235
3.703125
4
def fast_power(a, n): if n == 1: return a else: x = fast_power(a, n // 2) if not (n % 2): # even return x * x else: return x * x * a print(fast_power(4, 4))
456b4b17dd73f67c3dd1807110385635bf914168
jz33/LeetCodeSolutions
/211 Add and Search Word - Data structure design.py
1,892
3.6875
4
''' 211. Add and Search Word - Data structure design https://leetcode.com/problems/add-and-search-word-data-structure-design/ Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only l...
4767200f6df37dbba968678eb44666c6a59b2ef4
haonanli/leetcodePractice
/problem_2.py
1,121
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/8/2 11:26 下午 # @Author : Haonan # @File : problem_2.py # https://leetcode-cn.com/problems/add-two-numbers/ # 链表 每个位置对应值相加 """ 1、定义链表结构 2、定义链表起始结点 3、每个位置链表对应值的运算(加减乘除),运算结果放入链表结点对应值中,同时将上一个结点的指针指向当前链表 """ class ListNode: def __init__(self, x): ...
6a6be1ce368a81f92e340650fcdf48796f873dae
binghe2402/learnPython
/Mooc 陈斌数算/作业/h7_3.py
1,842
3.609375
4
# import random nums = list(map(int, input().split())) nums_liter = list(map(int, input().split())) merge_liter = [] insert_liter = [] def merge_sort(nums): nums = nums[:] def merge(nums1, nums2): nums = [] i = j = 0 while i < len(nums1) and j < len(nums2): if nums1[i] < ...
8eeb0161f7915cb21670f02c4e144602d108cfbe
rmontique77/sweet-sensations
/Python_Programs/ifstatements.py
427
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 31 22:29:43 2016 @author: raj """ name = " " while name.upper() != "JIM": name = input('What is your name? \n') if name.upper() == 'RAJEEV': print('You da one ' + name.capitalize() + ' XOXOXOX') elif name.upper() == "FAHAD": ...
5a5aadac2eb4294efd7552ca6661b9bc2529d048
DwightJay/SP2018-Python220-Accelerated
/Student/lesson01/dance_party.py
1,704
3.90625
4
''' Jay Johnson - Lesson01 - Assignment01 - Comprehensions Dance Party //// v1.0 sorting isnt that efficent need to add top 5 or 10 //// ''' import pandas as pd music = pd.read_csv("featuresdf.csv") #music = sorted(music) #print(music) music.head() music.describe() music.name music.artists music.loudness dance = [...
507fc5f6d1907a50e71cf5161e5ca3bedc155e2e
HiteshTetarwal/hackerrank
/middle_element_linked_list.py
858
3.875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def length(self,data): curr=data total=1 while curr.next!=None: total=total+1 curr=curr.next return tota...
fbf417eec73622de9d5eb811c71f69bf5233fd71
EngelbertCP/9013104_TareasLFP
/Tarea 2/script_json.py
305
3.53125
4
import json with open('data_json.json') as file: data = json.load(file) for cliente in data['clientes']: print('Nombre:', cliente['nombre']) print('Apellido:', cliente['apellido']) print('Edad:', cliente['edad']) print('Monto:', cliente['monto']) print('')
dbd86b442816b681478d7dc2125a56e2bc25ee0c
turo62/exercise
/sandbox/new.py
658
3.71875
4
colo = [] col = open("colors.txt", 'r') for line in col.readlines(): colo.append(line.strip()) def main(): search_l() def search_l(): color = input("Enter a color: ") i = 0 length = len(colo) if colo.count(color) > 0: print(colo.count(color)) while i < length: if co...
9d31956687cfb778535e00181f2de44f0a10fa66
Nalipp/cs_concepts
/udemy/python_for_data_structures_algorithms/linked_lists/has_cycle.py
571
4
4
class Node(object): def __init__(self, value): self.value = value self.nextnode = None def cycle_check(l): s = l f = l while f.nextnode and f.nextnode.nextnode: s = s.nextnode f = f.nextnode.nextnode if s == f: return True return False a = N...
2bf1dd5cf6d1005a6e999d487aaef3b50e5f43f4
CameronSprowls/PythonClientServerTCP
/src/Client.py
3,061
3.640625
4
""" Homework 2 Client Cameron Sprowls """ # Imports import socket import os class Client: @staticmethod def main(): """ Connects to a server and retrieves a file that is requested through a directory """ # Prompt the user for the IP and the port of the server they wish to co...
a8b504fe33329f26c20896ec646ad1824b7b876d
Eliandry/snake
/learn/geek brain.py
238
3.90625
4
def error(numbers): if numbers==13: raise ValueError() else: return numbers **2 i=int(input()) try: result=error(i) except ValueError: print('несчастливое число') else: print(result)
e2ddb3832c86fc86dc729e02276f0c8fec914add
ThomasGrafCode/EF_WF_Informatik
/Programmieren_in_Python_1/Exercise_2_Code/quadratic_equation.py
1,475
3.546875
4
from numpy import sqrt # importiere die Wurzel-Funktion def solve_quadratic_equation(a, b, c): """ berechnet (falls sie exisiteren) die Loesungen / Loesung der quadratischen Gleichung ax^2 + bx + c = 0 fuer beliebige reelle Zahlen a, b, c """ # quadratischer Fall (quadratische ...
925a50b2e1007e5ffe34f903f76a5de5cb33c6d4
RomanSPbGASU/Lessons-Python
/L4/L4W1.py
2,647
4.03125
4
# class MyClass: # def __init__(self): # self.value = 23 # self.list = [2, 3] # # # obj = MyClass() # print(type(obj)) # print(obj.value) # obj.value = 45 # print(obj.value) # print(obj.list) # dictionary = {obj: 1, "ghbvth": 2} # print(dictionary) # print(dictionary[obj]) # l = list(dictionary.keys...
c47e3a08cadb4a51b49cbe7a79f020cd27ac42df
QuestionC/euler
/Euler32.py
607
3.65625
4
result_set = set() def ispandigital(x, y, z): full_str = str(x) + str(y) + str(z) return ''.join(sorted(full_str)) == "123456789" for x in range (1, 10): for y in range (1000, 10000): z = x * y if ispandigital(x, y, z): result_set.add(z) print (str((x, y,...
fbe7854231fcbe9c3cd364d6f3d974ba7c1fc34e
tnakaicode/jburkardt-python
/graphics/corkscrew_plot3d.py
1,911
4.28125
4
#! /usr/bin/env python3 # def corkscrew_plot3d ( ): #*****************************************************************************80 # ## corkscrew_plot3d makes a plot of a 3D curve that looks like a corkscrew. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 April 2...
3672fc471b9e71048633b0f9cae0c12ae9c74380
Antohnio123/Python
/Practice/d.shamin/hw_4/hw_4.3.py
327
3.515625
4
#3. Реализовать алгоритм сортировки выбором. arr = [12, 0, 3, 600, 24, 2, 3, 7, 43] lng = len(arr) new_arr = [] for k in range(lng): i = 0 for j in arr: if min(arr) == j: arr.pop(i) new_arr.append(j) break i += 1 print(new_arr)
d02f9a6c43b5554738e37fc3fed8cf0a0793dc5e
benbendaisy/CommunicationCodes
/python_module/examples/306_Additive_Number.py
2,820
4.3125
4
from typing import List class Solution: """ An additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. ...
abb8b9d2a67f02e76f5edfa1471de45357f9292e
SilvaGus/VisaoComputacional
/ProjetoVisao/Codigos/KNN/Rascunho/letranum.py
1,907
3.90625
4
import cv2 import numpy as np # Let's load a simple image with 3 black squares image = cv2.imread('images/shapes_donut.jpg') cv2.imshow('Input Image', image) cv2.waitKey(0) # Grayscale gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) # Find Canny edges edged = cv2.Canny(gray, 30, 200) cv2.imshow('Canny Edges', edged) c...
3c26f60b5d785b46ef6ef931451edf444d6cdf89
gabrieldcpadilha/Python_120_Exercicios_CursoEmVideo
/Mundo 02 - Estruturas de controle/Aula 14/calculo_do_fatorial_com_while.py
387
4.15625
4
""" Faça um programa que leia um numero qualquer e mostre seu fatorial. EX: 5! = 5x4x3x2x1 = 120 """ num = int(input('Informe um numero inteiro: ')) contador = num fatorial = 1 print(f'Calculando {num}! = ', end='') while contador > 0: print(f'{contador}', end='') print('x' if contador > 1 else ' = ', end=''...
fd0ec3823777e1947b684ea4ff735e9b133efebd
pritam-acharya/Miscellaneous-Projects-Files
/pythonEX4/Random CHOICE.py
210
3.890625
4
import random films = [] n = int(input("Please enter the number of films:")) for i in range(0, n): films.append(input(" ")) film2watch = random.choice(films) print(f"I think you should watch {film2watch}.")
b9fc54854ec669e359115b49156da5727c54b5d6
pragatij17/Python
/Series/number_of_one's.py
116
3.703125
4
# Random: 1,11,111,1111,11111,111111...n n=int(input("No of times 1:")) for i in range(1,n+1): print("1"*i,end=" ")
062b2a2c8bd2dc5b81a0abccd69b60d4ff9e2487
milamao/coding-exercise
/leetcode_148.py
1,721
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: # Solution 1: O(n) space, O(nlogn) time def sortList1(self, head: Optional[ListNode]) -> Optional[ListNode]: # loop though the linked lis...
94a3b2dba8e9502d46a6970c1a0471fe6ec7f70c
karina-marques/programming-exercises
/lesson1/theory/basic_operations.py
1,157
4.15625
4
# Basic operations in python # Assignation: assign a value to a variable # You can think of a variable as a box, it holds the value you put inside of it # Python does not need to declare the type of a variable in advance x = 5 # x contains 5 after this instruction x = "Marco" # x contains the string "Marco" after thi...
be80810e4c9772d689dac3437cbb3391c1b6f9fd
rhnsct/100-Days-of-Code
/B8_Snake_Game/game_view.py
344
3.53125
4
from turtle import Turtle COORDINATE = 375 class Box(Turtle): def __init__(self): super().__init__() self.hideturtle() self.color('white') self.pu() self.goto(-COORDINATE, COORDINATE) self.pd() for _ in range(4): self.forward(COORDINATE * 2) ...
d08c5a78542d0980d248bcb08b56f7f9b188bdd3
dpage02/coding_for_beginners
/making_lists/dict.py
498
4.25
4
# storing data info = {'name':"Bob", "ref": 'Python', 'sys':'Win'} print("info:", type(info)) print('Dictionary:', info) # displaying a single value referenced by its key print('\nReference:', info['ref']) # displaying all keys within the dictionary print('\nKeys:', info.keys()) # deleting one pair from dict, add ...
450948b90b522a706d2b802fba4e50627534ec0a
michaelgbw/leetcode_python
/base/myBinaryTree.py
1,718
3.75
4
####python自带的:https://blog.csdn.net/qiwsir/article/details/36715163 class Node: def __init__(self,item=None,left=None,right=None): self.item = item self.lchild = left self.rchild = right class myBinaryTree: def __init__(self, root=None): self._root = root def add(sel...
ca160bd0970bba9d1a41857ded835e9deec92c85
MengZhou11/Python-crawler-topMovies
/test/testRe.py
683
3.65625
4
#正则表达式 学习 #正则用来判断字符串是否符合一定标准 import re #方法1:有个具体的规定 #AA是正则表达式 来验证其他的字符串 pat = re.compile("AA") #search字符串是被校验的内容 显示找到的位置靠前的 print(pat.search("ABCAADDCCAAA")) #方法2: 没有模式对象 m = re.search("asd", "Aasd") print(m) #方法3:找到所有符合规定的字符串 放到一个[]list里面 print(re.findall("a", "ASDaDFGAa")) print(re.findall("[A-Z]","ASDaDFGAa")) ...
748636b8948c1933744205ea7998adc4f1d0ae7f
kevinfal/CSC120
/Assignment7/long/rec_reverse.py
1,001
4.1875
4
""" File: rec_reverse.py Author: Kevin Falconett Purpose: provides rec_reverse() which reverses a linked list recursively """ from list_node import * def rec_reverse(head): """ Reverses a Linked List :param head: :return: """ # empty if head is None: return None ...