blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
279c838b1a5ea56275145f29b0b2e241223bb822
RonaldZhao/leetcode-cn
/sources/py/326.py
497
3.828125
4
class Solution: def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ # 首先分析3的幂的特点: 假设一个数Num是3的幂,那么所有Num的约数都是3的幂 # 如果一个数n小于Num且是3的幂,那么这个数n一定是Num的约数 if n < 1: return False maxPower = int(math.pow(3,int((math.log(0x7fffffff)/math.log...
42b7e292c0c66826c9f5174754263d9fdc56eb7d
myoons/TSP-solver
/ACO/graph.py
729
3.703125
4
class Graph(object): def __init__(self, costMatrix, nodeSize): """ costMatrix : N*N size matrix of costs (length of edges) nodeSize : Number of nodes (N) pheromone : amounts of pheromones in each edge / Initialize when Graph is maded eta : Heuristic Information that is u...
acbcaacbd67adac9e79a6afe8620dcc49f98eb86
halkernel/data-structure-and-algorithms
/search-strategies/minmax.py
1,867
3.859375
4
from board_node import Node from copy import deepcopy board = [['X','',''], ['','',''], ['','','']] pos = [[1,2,3], [4,5,6], [7,8,9]] pieces = {'computer':'X','player':'O'} visited = set() computer = 'computer' player = 'player' current = Node(board, pos, None) to_visit = list(...
0775c9ed5db99a0f956905a349a9537dabe873d8
deepa-karthik/Python_assignments
/task2/task2_10.py
1,591
4.1875
4
# Write a program that asks five times to guess the lucky number. Use a while loop and a counter, # such as #counter=1 # While counter <= 5: # print(“Type in the”, counter, “number” # counter=counter+1 # The program asks for five guesses (no matter whether the correct number was guessed or not). If the # correct number...
130868b0d2fa7cadbb821239bdd0dba991daeb4c
migueljrodrigues/EulerProj
/prob14.py
440
3.78125
4
def evenodd(lista,n): lista.append(n) if n == 1: return lista else: return evenodd(lista,n/2) if n%2 == 0 else evenodd(lista,n*3+1) num_max_tam = 0 max_tam = 0 lista = [] #TODO save vars to avoid repetition for i in range(2,1000000): var = i #print i res = evenodd(lista,var) if len(res) > max_tam: max_...
6ab9c1b37d32bd8a9e2bd1e5419ae03b1c3de86d
kaikovacik/School
/seng360/lab1/programming.py
1,513
3.5
4
# Kai Kovacik # September 26, 2018 from Crypto.Cipher import AES # Here's a one line answer for fun (it doesn't close the file though): # print "The key that was used to encrypt is \"" + [(lambda s : ''.join([_ for _ in s if _ != '#']))(key) for key in ('{:#<16}'.format(_.strip()) for _ in open("words.txt", "r").read...
b780c379ff9f0d8c66d7be020f259c4ccdf01acc
Bryce-Liu/my_leetcode
/剑指Offer系列/24_反转链表.py
766
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/5/7 22:49 # @FileName: 24_反转链表.py """ 定义一个函数,输入一个链表的头节点,反转该链表并输出反转后链表的头节点。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 链接:https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof """ # Definition for singly-linked list. # class ListNode: # ...
14e1e56d9e7d46732cc63c02423f098adede1c06
akalamdu/mackleaps-teste
/text sort 2.py
947
3.5
4
archive=open("/home/mackleaps/Documents/entrada.txt","r") a=[] b=[] #copia as linhas do texto para uma lista for x in archive: y=x.split(" ") b.append(y) #copia todos os itens das listas para a primeira for z in b: for w in z: if z==b[0]: break b[0].append(w) #apaga as lista...
0d6214597b2c7fbec896bf4ecd0a8f12aec0cc61
sososeng/DigitalCrafts_Exercises
/python_exercises_1/day_of_week.py
132
3.84375
4
arr = ["Sunday", "Monday", "Tuesday", "Wednesday", "thurdsay", "Friday","Saturday"] day = int(input('Day (0-6)? ')) print(arr[day])
e7eeca2dc7c559b45ce014a580602f25c4e51902
LCLY/Udemy
/pythondjango/python_sandbox/lists.py
544
3.890625
4
# A List is a collection which is ordered and changeable. Allows duplicate members. numbers = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'grapes', 'pears'] print(fruits[1]) print(len(fruits)) # append to list, in javascript we use push fruits.append('Mangos') # to remove from list fruits.remove('grapes') # ins...
0f6d1e8075199d1b3a9d2949c21ae27d9b9ef426
bangalorebyte-cohort8/Python-Basics
/inherit.py
593
3.53125
4
class Base: def __init__(self): print('Base __init__') self.cname = 'Base' def func(self): print('Base func') class A(Base): def __init__(self): print('A __init__') super().__init__() self.cname ='A' #def func(self): # print('A func') class B(Base): def __init__(self): print('B __init__') ...
963877b9936739e738f23a1be02831e36f745a55
utk09/open-appacademy-io
/1_IntroToProgramming/3_Enumerables_Ranges/1_to_initials.py
525
3.9375
4
""" Write a method to_initials that takes in a person's name string and returns a string representing their initials. """ def to_initials(name): x_split = name.split(" ") new_name = " " new_name_array = [] i = 0 while i < len(x_split): m = (x_split[i])[0] new_name_array.append(m) ...
9059ae24dc347edc29b6c0122ed20fac5b214853
areg-pi/Python-course
/functions.py
539
3.703125
4
#Integrated functions n = int('10') a = float('34.6') b = str(15) i = bin(7) #convertir a binario j = hex(15) #convertir a hexadecimal k = int('0b10110', 2) #convertir de binario a entero decimal l = int('0xf', 16) #convertir de hexadecimal a entero decimal m = abs(...
95db5a4fd6bb0bd6d598b03f5c23c79313b5e9c6
fruce-ki/utility_scripts
/mylogs.py
4,750
3.59375
4
#!/user/bin/env python3 """mylogs.py Author: Kimon Froussios Last revised: 27/10/2017 Library for custom logging. XXXstring() functions return formatted strings for custom use by the caller. log_XXX() functions format and record messages to log-files. NOTE: XXXstring() return values are not intended to be passed a...
7d928553d5c8ad155180fee5d2a2444233ff206f
LuisHenrique01/Questoes_Fabio
/fabio_04_11_while_mediaAlunos.py
823
3.75
4
def main(): aprovados = 0 reprovados = 0 while True: matricula = int(input('Matricula: ')) if matricula == 0: break nota1 = float(input('Nota 1: ')) nota2 = float(input('Nota 2: ')) nota3 = float(input('Nota 3: ')) if media_final(nota1, nota2, nota...
70c0fdbc54d4c1e26276c76ebb2a3e4464dac00b
gillc0045/CTI110
/Module5/CTI-110_M5T1_gillc0045.py
347
4.375
4
# Program prompts for a Km distance and converts it to miles. # 26 Jun 2017 # CTI-110 M5T1 # Calvin Gill def main(): Km_to_miles() def Km_to_miles(): Km_to_miles = int(input('Enter distance in kilometers: ',)) miles = Km_to_miles*0.6214 print('The value of ',Km_to_miles,' kilometers convert...
31696f25acf1eb1716118af698cbe7507104d73a
Deependrakumarrout/Small-Assignment
/Simple project/Healthy programmer.py
6,162
4.1875
4
#Healthy programmer #Create a program like this - #3.5 liter of water and 15-18 200 ml k glasses of water and in every 30 min eye exercise and then every #45 minutes you have to do some physical activities. # Water - For water we will make a program that play water.mp3 in this directory # Eyes - For eyes we wil...
509b758747cc5c4168f9889adb3f864f8423586d
StudyForCoding/ProgrammersLevel
/Level2/Lessons12924/12924_njy.py
1,002
3.5
4
# 숫자의 표현 def solution(n): answer = 0 for i in range(1, n+1): if n%i==0 and i%2==1: answer+=1 return answer ''' 정확성 테스트 테스트 1 〉 통과 (0.00ms, 10.2MB) 테스트 2 〉 통과 (0.05ms, 10MB) 테스트 3 〉 통과 (0.04ms, 10.2MB) 테스트 4 〉 통과 (0.04ms, 10.1MB) 테스트 5 〉 통과 (0.02ms, 10.2MB) 테스트 6 〉 통과 (0.01ms, 10.2MB) 테...
b8a3ea0f7bcefc2bd4fbe4217a5aa58dee314351
AtlasHale/kattis
/zero_to_two/roaming_romans.py
165
3.84375
4
miles = float(input()) roman_miles = 1000*(miles*5280)/4854 if(roman_miles - int(roman_miles) < .5): print(int(roman_miles)) else: print(int(roman_miles+1))
a6090bd5acc187673d9053ed3224587a79fc92eb
Slawak1/pands-problem-set
/sumupto.py
1,519
4.09375
4
# Slawomir Sowa # Date 03.02.2019 # Problem no 1. # Write a program that asks the user to input any positive integer and outputs the # sum of all numbers between one and that number. import sys # import system module, which contain sys.exit() function # First we check is provided number is Integer, # Try Except st...
10e0f4285197604f2a59466316d6a03d02170aa5
problemslayers/python
/lpthw/ex04.py
847
4
4
# set cars (int) to 100 cars = 100 # set space_in_car (float) to 4.0 space_in_car = 4.0 # set drivers (int) and passengers (int) drivers = 30 passengers = 90 # cars_not_driven (int) is cars minus drivers cars_not_driven = cars - drivers #cars_driven (int) is drivers cars_driven = drivers #carpool_capacity (float) is c...
647044ddc83266879a67cf292595974130a1ef82
superstealthysheep/crawler
/crawler/main.py
5,671
3.96875
4
import math import random import puzzle #Am I supposed to write .puzzle or not??? class Attack: #Future idea: healing moves could also fit into this class. I'd just need to make it so enemies don't avoid using it on themselves then. def __init__(self, name, base_damage): self.name = name self.b...
9461747c90630b382fd35fb38ed0aabc0efec1cd
finfou/viclearning
/pyscripts/pythoncookbook3/4.11_zip/zipdemo.py
176
3.984375
4
#!/usr/bin/env python a = [1, 2, 3] b = ['a', 'b', 'c', 'd'] for i in zip(a, b): print(i) from itertools import zip_longest for i in zip_longest(a,b,fillvalue=0): print(i)
12cceee27fa8834109c261f3e86125e4d6ea83d8
sid-ut3/watchnews
/Groupe6_Analyse_semantique-master/Article_analysis/Serious_subject/g6_serious_topic_identification_v1_1.py
1,514
3.59375
4
# Group 6 LAFONT Nicolas, QUESNOT Sandy, VAYSSE Robin # Version 1.1 : initial version # !/usr/bin/env python3 # -*- coding : utf-8 -*- from difflib import SequenceMatcher import string import pandas as pd import json import nltk import os from nltk import word_tokenize nltk.download('stopwords') from nltk.corpus impor...
210b2c589cd5002a26f26cff680835a47cce868d
Doaa-Ismael/DesignPatternsImplementation
/Strategy.py
1,213
3.9375
4
from abc import abstractmethod class EntertainmentStrategy: @abstractmethod def entertain(self): pass class WatchingTvStrategy(EntertainmentStrategy): def entertain(self): print('watch tv') class GoForAWalkStrategy(EntertainmentStrategy): def entertain(self): print('go for ...
87836ac889ae8a0404564a4bba105ee46099d4aa
thaisday/Leecode
/053_MaximumSubarray.py
1,208
4.09375
4
# -*-coding:utf-8 -*- """ Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, ...
6134357328af387ad18d0b30dc3c927709432b55
Monisha24J/snake_game
/snake.py
1,280
3.859375
4
from turtle import Turtle UP = 90 DOWN = 270 RIGHT = 0 LEFT = 180 class Snake: def __init__(self): self.segment = [] self.create_snake() def create_snake(self): for i in range(3): self.add_segment(i) def add_segment(self, position): x = 0 tim = Turt...
870c60dfdbf957a1cb8775faf3007f7481261541
gflorianom/Programacion
/Practica6/Ejercicio8.py
458
4.4375
4
"""Biel Floriano Morey - 1 DAW - PRACTICA6 - EJERCICIO 8 Escribe un programa que permita crear una lista de palabras y que, a continuacin, ordene la lista por orden alfabtico. """ print "Cuantas palabras tiene la lista?" p=int(raw_input()) palabras=[] for i in range(p): print "Introduce la palabra: " pa=raw_i...
dbcc15844538042aeca809a20b48fea5e457518d
durmusyasar/Python-Projects
/SıfırdanileriSeviyePythonKursu/67-Ntp-Kumanda.py
2,833
3.578125
4
import random import time class Kumanda(): def __init__(self, tv_durum = "Kapalı", tv_ses = 0, kanal_listesi = ["Trt"], kanal = "Trt"): self.tv_durum = tv_durum self.tv_ses = tv_ses self.kanal_listesi = kanal_listesi self.kanal= kanal def tv_ac(self): if(self.tv_durum ...
673cc951eaee26a32b70489e3482a78098e7b722
teresaochodek/kurs_fabryka_testow
/homeworks/kalkulator2.py
416
3.640625
4
print("witaj w kalkulatorze") a = int(input('podaj pierwsza liczbe: ')) b = int(input('podaj druga liczbe: ')) c = int(input('wybierz rodzaj działania: 1 - dodawanie, 2 - odejmowanie, 3 - mnożenie, 4 - dzielenie: ')) if (c == 1): wynik = a + b elif (c == 2): wynik = a - b elif (c == 3): wynik = a * b elif (...
597dd638005c13cbdd27aea30fbc3a0938ca2567
abtripathi/data_structures_and_algorithms
/problems_and_solutions/recursion/introduction_solution_01.py
115
3.84375
4
def sum_integers(n): if n == 1: return 1 return n + sum_integers(n -1) print(sum_integers(3))
d49e21ed77380072e925dd1ff07735d96a2f0594
nehamehta2110/LeetCode-August-Challenge
/Day2-DesignHashSet.py
1,649
4.125
4
""" Design a HashSet without using any built-in hash table libraries. To be specific, your design should include these functions: add(value): Insert a value into the HashSet. contains(value) : Return whether the value exists in the HashSet or not. remove(value): Remove a value in the HashSet. If the value does not exis...
b9e9182dd474973ed1f784ace50135fa415649b5
ratedRA/python
/DS/hegiht_balanced.py
443
3.625
4
import math class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None def height(root): if not root: return 0 return max(height(root.left), height(root.right))+1 def is_balanced(root): if not root: return True lh = height(root.left) rh = height(root.right) ...
6e16c14110b258412ec48213765dc2f0e80aee75
Alex-Huleatt/easycurses
/life_example.py
2,044
3.609375
4
from easycurses import * from time import sleep def life(): #conway's game of life. try: dc = DrawController() dc.init_screen() dc.full_draw() h,w = dc.size CC = ColorController ic = InputController(dc.get_screen()) def finish_editing_callback(c): #variable...
4a2411f01cb3a59bc54dfe02252b7dc054131fae
gabbycampos/pythonSyntax
/words.py
804
4.4375
4
def print_upper_words(string): """ Will print words in uppercase """ for char in string: print(char.upper()) print(print_upper_words(['I', 'am', 'a', 'list'])) def only_letter_e(words): """ Will only print words that start with 'e' """ for word in words: if word.startswith('e') or word.startswith('E')...
888aa400d2ce6f93fd48af5ff46e8e779c199691
qq1295334725/zheng
/第二周/7-30/121113333.py
533
4.21875
4
""" 座右铭:将来的你一定会感激现在拼命的自己 @project:正课 @author:Mr.Chen @file:121113333.PY @ide:PyCharm @time:2018-07-30 14:47:58 """ class Student(object): def __init__(self, name, age): self.name = name self.age = age def show(self): print('show函数被执行') print(Student('aa', '30')) print('') stu_1 = Studen...
cdd0b7ef50b3b3b343dad69fab5de279fffbe56f
srisaiachyutha/algorithms
/graphs/routingatree.py
1,685
4.25
4
#given the nodes and edges of a un-cyclic graph and making it into the # rooted tree is the main task of this program class Treenode: def __init__(self,data = None): self.val = data self.children = [] def construct_rooted_tree_using_adjacency_list(m,root_index): #this function will be used for ...
a78fbf7bef350dea3c6d57fdeb83cc988120ce5d
gistable/gistable
/all-gists/8848148/snippet.py
554
3.578125
4
def sieve(numbers, n): for i in range(n * 2, len(numbers), n): numbers[i] = False def skip_to_next_prime(numbers, n): n += 1 while n < max and not numbers[n]: n += 1 return n def primes(max): '''generate primes less than max''' max = int(max ** .5) numbers = [False, False] ...
422b6d7557fe14da332f9fce678b99b34350cb05
Reaperpy/Reaperpy-Calculator
/gui/main/calc.py
4,514
3.625
4
from tkinter import * import math import time root = Tk() root.title("Reaperpy0's Calculator (GUI Version)") calc_input = Entry(width=25) result = 0 def calcClick(number): current = calc_input.get() calc_input.delete(0, END) calc_input.insert(0, str(current) + str(number)) def calcClear(): calc_input.delet...
0e90c630dd1edf43e61c2a69289781e8f735a8b4
VLD62/PythonFundamentals
/01.PYTHON_INTRO_FUNCTIONS_DEBUGGING/08.Multiply_Evens_by_Odds.py
342
3.890625
4
def digits_sumator(n): even_sum = 0 odd_sum = 0 for x in n: if x != "-": if int(x) % 2 == 0: even_sum +=int(x) else: odd_sum +=int(x) return odd_sum * even_sum if __name__ == '__main__': number = str(input()) print(d...
bcf6caa2f2ac66e16f4299e0460f5c063f71f9c2
summer-liu/LeetCode-Python
/ExcelSheetColumnTitle.py
252
3.53125
4
class Solution: # @return a string def convertToTitle(self, num): alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' l = len(alpha) r = '' while num: r = alpha[(num-1)%l] + r num = (num-1)/l return r
bc5365cf90e6d46d71ad42de93aca123492822f6
AlexsanderRST/Pygame-Junkyard
/Chubby Dragon Chase/scripts/mouse.py
913
3.625
4
# Criado por Alexsander Rosante (12/03/20) import pygame class Mouse(object): def __init__(self): self.posicao = (0, 0) self.b_esquerdo, self.b_meio, self.b_direito = False, False, False self.b_pressionado = [False, None] # [Está pressionado?, Qual?] self.b_esquerdo...
1dee0cd3dcaa369f7c6acbfad6c0423ca8672257
Veeralishah/Dynamic-CRUD-in-Different-Database-
/db_query.py
11,267
3.90625
4
#-*- coding: utf8 -*- import db_config import MySQLdb as mdb import psycopg2 as pdb import psycopg2.extras import sqlite3 as sdb import sys import warnings ''' MYSQL CRUD ''' # CREATE A NEW TABLE of MYSQL def createTable(con): cur = con.cursor() cur.execute("DROP TABLE IF EXISTS Citizen") with warni...
108fa1ed16d993bcec202d8923fc1a15afcf0ef1
guoyuMao/python_study
/Function.py
1,408
4.03125
4
# def area(width,heigh): # return heigh * width # # print("please input width:") # w = int(input()) # print("please input height:") # h = int(input()) # print("this area is : %d" %area(w,h)) '''不可变对象与可变对象''' #不可变对象 # def changeInt(a): # a = 10 # b = 2 # changeInt(b) # print(b) # #可变对象 # def changeme(list): # ...
44be41220d8044c56951e9422bba443f32ccf553
Taoge123/OptimizedLeetcode
/LeetcodeNew/python/LC_518.py
4,046
3.859375
4
""" You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin. Example 1: Input: amount = 5, coins = [1, 2, 5] Output: 4 Explanation: there are four w...
40794bb6bf28a6a073bbab604d838d941a0210b6
offby1/doodles
/python/collatz.py
1,048
3.515625
4
# https://en.wikipedia.org/wiki/3x_%2B_1_problem import functools import itertools @functools.lru_cache(maxsize=None) def hotpo(x): q, r = divmod(x, 2) if r == 0: return q else: return 1 + 3 * x def cycle_length(starting_value): seen_values = set() for index in itertools.count():...
7d021d31f5a80343c11752a51a79f33726dabdd7
Billiardist94/Billiardist94
/_Generator.py
166
3.796875
4
def count(start, step): while True: print (start) start += step count(int(input('Введите start: ')), int(input('Введите step: ')))
ff258439656425e673a623e9435d75642589ddac
andypaw03/first
/Home Work/dz.py
333
3.6875
4
import random a=input("") def monkey(file): with open(file,"r")as file: b = 'АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя' c="" while True: random.choice(b) c+=b return c print(monkey(a))
7da3633ae3a100ed9a5c8f5e7dc4f58dd26ffbea
Aleksandraboy/basics
/variables.py
1,262
4.28125
4
#naming the file: avoid spaces, avoid upper cases, "_" ca nbe used to separate the words #new_variables.py(python), newVariables (java) # variables: # naming : should not start with numbers, starts with low case, symbols and numbers can be used # nameofthevariebles = value, declaring and setting a vlue for the variebl...
67c2c6eb6f4109802a06b2b04926f01b2e70d16f
UltiRequiem/daily-python-practice
/finished/edabit/very_easy/sum_polygon_angles.py
216
3.953125
4
# Return the total sum of internal angles (in degrees) def sum_polygon(n: int) -> int: return (n - 2) * 180 # sum_polygon_lambda = lambda n: (n - 2) * 180 if __name__ == "__main__": print(sum_polygon(24))
bed7f42d079314eeab7dbf50b1da327dacaaeb28
JoshKallagunta/Lab-3-Capstone
/test_camelCase.py
1,035
3.703125
4
from unittest import TestCase import camelCase class TestCamelCase(TestCase): def test_camelcase_sentance(self): self.assertEqual('helloWorld', camelCase.camelcase('Hello World')) self.assertEqual('myNameIsJosh', camelCase.camelcase('My name is josh')) def test_camelcase_one_word(self): ...
872dea26f2e19da1cee71d966bd85390af956eb1
DanyloTrofymov/LabsPy
/Lab1/Lab1.py
345
3.984375
4
a = float(input("Введите длину ребра куба: ")) while a <= 0: a = float(input("Введите длину ребра куба больше 0: ")) s = 4*a*a v = a*a*a print("Длина ребра " + str(a)) print("Площадь боковой поверхности " + str(s)) print("Объем куба " + str(v))
01db3a632be68a323d1f7a85e5694cf3c932e747
shantanuneema/Trees-2
/buildTree.py
1,513
4.09375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: """ Time Complexicity: O(n) Space Complexicity: O(n) where n are the number of elements in...
bdd239c277fc4dd260500fccb84e1e7631d2491f
yusuchn/codekata
/WorlistFinder/nsw.py
116
3.65625
4
for word in open('file'): word = word.strip() if set(word) <= set(permitted_characters): print(word)
4764dfe06a9e90ab19ee76d11861c865a0ff3d3a
Blossomyyh/leetcode
/RestoreNumberofCycle.py
2,258
3.9375
4
""" Restore numbers on circle Given a list: a,b — a and b is friends [[a, b],[a, c],[c, d],[e, f], [f, g],[f, e],[g, h], [h,b],[h, g]] Now they are going to have dinner together, but everyone wants to seat with their friends Like: a c b d h e g f Output: A sequence t...
cd6424a178c476c46c04405c7b3ffafc0d782cf0
unpreghini/htanh-fundamental-c4e21
/session3/inclass1.py
158
3.65625
4
my_hobbies = ['Python', 'Movies'] print(my_hobbies) your_hobby = input("What is your hobby? ") my_hobbies.append(your_hobby) print(*my_hobbies, sep=", ")
e95ea25de6b7f4b7e97b14c9ddda33d9781fbefe
jefeheyna/Python_Labs
/lab8.py
3,111
4.40625
4
#-------------------------------------------------------------------------------------------------------------------------- # Jeff Hejna # 10/27/14 # Lab 8 # # This program will take a string and find the number of words, the average length of the words, and the proper nouns. # # Algorithm ...
d54017a07f64cabad397aed2874c12daeb46136b
j0rdi/Programacion
/Practica 6 Ejercicios de listas/Practica 6 Ejercicio 6.py
624
4.1875
4
"""Jordi Vidal Palou. Prctica 6. Ejercicio 6 Escribe un programa que permita crear una lista de palabras y que, a continuacin, cree una segunda lista igual a la primera, pero al revs (no se trata de escribir la lista al revs, sino de crear una lista distinta). """ lista= [] print "Dime cuantas palabras tiene tu...
ce9ab906bacac4de007bc1b8fdf3bcdc833a1a7e
frank-quoc/hackerrank_python
/python/strings/designer-doormat/answer.py
604
3.625
4
def createAMat(N,M): if N%2 == 0: return # prints top half of doormat for i in range(1, N, 2): print(('.|.'*i).center(M,'-')) # prints center of doormat print("WELCOME".center(M,'-')) # prints bottome half of doormat for i in range(N-2, 0, -2): print(('.|.'*i).cen...
bb9d58e2980464242fc65a608ba25e3f49bd0944
Monata/CTCI_Python3_Solutions
/CTCI_solutions/5.1_Insertion.py
804
4.28125
4
# Insertion: You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to insert M # into N such that M starts at bit j and ends at bit i. You can assume that the bits j through i have enough space to # fit all of M. That is, if M = 10011, you can assume that there are at least 5 bits be...
0f80c31d85246e23d6d8b0959446379298d69657
Hugo-Leyva/Python_Projects
/python/EV51_lista_turnos.py
650
3.96875
4
"""51 una empresa tiene dos turnos (mañana y tarde) en los que trabajan 8 empleados (4 en la mañana y 4 por la tarde) a)confeccionar un programa que permita almacenar los sueldos de los empleados agrupados en dos listas. b)imprimir las dos listas de sueldos""" sueldos_mañana=[] print("Sueldos Mañana") for x ...
edea0a2bd4487d525d72d74bffb436c6a717ad26
nuria/study
/EPI/8_queue_and_tree.py
2,743
3.734375
4
#!usr/local/bin/python import unittest from collections import deque class node: def __init__(self, data): self.data = data self.prior = None class EmptyQueue(Exception): pass class Queue: # pointer to the head as it is FIFO def __init__(self): self.head = None self.ta...
69fa9ae6e35a7efcfe4be318b938941a78b80852
OleKabigon/test1
/game1.py
2,933
4.1875
4
#Simple Python Game using Classes import turtle import math import random import os #Set up screen wn = turtle.Screen() #create screen object wn.bgcolor("red") wn.title("Simple turtle game") class Border(turtle.Turtle): def __init__(self): turtle.Turtle.__init__(self) self.penup() self.h...
e24c8312f8025438761842499988fdc0ed55978d
NightFaint/leetcode
/python/796. Rotate String.py
495
3.578125
4
#coding:utf-8 __author__ = 'NightFaint' __date__ = '2018/7/20 20:33' class Solution: def rotateString(self, A, B): """ :type A: str :type B: str :rtype: bool """ if max(len(A),len(B))>100: return 'Length is too large' if len(A) !=len(B): ...
77d66e9bd16d38ff7e92e4b0d0bfdde9c13943af
AnantChoudhari06/Python-Codes
/HackerRank/Introduction/Loops.py
160
3.65625
4
if __name__ == '__main__': n = int(input()) for i in range(0,n,1): #Stat, Stop, Increment Step print(i*i,sep="\n") #Prints on new line
4eb7304c4d517e2cb1e44ec6e8d4186bcebaac84
Devinwon/master
/computer-science-and-python-programing-edX/week3-recursion/L5-Problem9.py
531
3.90625
4
# dog / god def semordnilapWrapper(str1, str2): # A single-length string cannot be semordnilap if len(str1) == 1 or len(str2) == 1: return False # Equal strings cannot be semordnilap if str1 == str2: return False return semordnilap(str1, str2) def semordnilap(str1, str2): if len...
bf11ccaaeaf41f58c2754ba5a7821653e5432e73
erldas/2iz6
/15.07.1.py
479
4.125
4
# 1) Попросить пользователя ввести текст. # В результате вывести процент букв в # верхнем регистре (заглавные) и в нижнем регистре (прописные). a = str(input('Napishite chto nibud : ')) print(list(filter(len()(str.isupper, a)))) # data = 'Dastan' , 'Aybek', 'Janara', 'Vasya', 'Arnold', 'Bruce' # filtered_data = li...
05184d931a3e29bc84a14d21c771d730b4ce30e8
BitMatt10111/TPSIT_20-21
/Alberi/alberi01.py
3,523
4.125
4
''' class Node: def __init__(self,data): self.left=Node self.right=Node self.data=data def insert(self,data): #confronta il valore del nodo da aggiungere con il nodo corrente if self.data: if data<self.data: if self.left is None: ...
75ff5dab5aed5e4650364f73ac2a0dbc97fda0d5
ghevcoul/programming-practice
/Reddit DailyProgrammer/228e_alphabeticalOrder.py
782
3.875
4
# Written for Python 3.4 # # /r/dailyprogrammer Challenge #228 Easy - Letters in Alphabetical Order # https://www.reddit.com/r/dailyprogrammer/comments/3h9pde/20150817_challenge_228_easy_letters_in/ from sys import argv def readWords(source): w = [] with open(source) as f: for line in f: ...
b1c6f7bd091271f7cf0ab2285e08e5bd6fc23a3c
justingiardino/Rack_Tool
/GUI_Intro/Lesson4/reimplement_signal.py
628
3.53125
4
#!/usr/bin/python3 #reimplement signal for escape to close the window import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QWidget, QApplication class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setGeometry(300, 300, 250, 150) self.setWind...
bbf263a1fcc9dec184d54309f9aa6db1ba35a070
chinmay29hub/hangman-game
/hangman.py
1,965
4.21875
4
import random name = input("What is your name ? --->> ") print("\n") print("It's time to play Hangman "+name) print("Good Luck\n") words = ['program', 'trees', 'computer', 'python', 'java', 'syntax', # Insert n number of words here 'house', 'linux', 'system', 'science', 'code', 'network', 'pla...
81f50660cd631fc3206d30180b2686373763aa6f
tarcisiolf0/PAA-2019.2
/Aula5_15_10_19/Quick_Sort_v1.py
808
4.09375
4
import random def quick_sort(array, left_index, right_index): if left_index >= right_index: return left = right = pivot = 0 left = left_index right = right_index pivot = array[(left_index + right_index) // 2] while left <= right: while array[left] < pivot: left += ...
5c1f28365feca4dbc5bd89c1eb7f275ebec144d3
Bhardwaj999/algorithms
/trie.py
1,780
3.96875
4
"""A trie (aka prefix tree) is one type of search tree — an tree data structure used to store associative array where the keys are strings. Unlike BST, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated; i.e., the value of the ...
aead0803811cc1e30e21aebf724145000b025cca
fenixchen/pythonstudy
/basic/test_thread_local.py
532
3.640625
4
# -*- coding:utf-8 -*- import threading, time local = threading.local() def thread_func(): print("thread %s" % threading.current_thread().name) local.i = 0 for i in range(5): local.i = local.i + 1 print('thread:%s, i:%d' % (threading.current_thread().name, local.i)) time.sleep(1)...
e5d2d793bd595cf069a1cba577a039e1092d4161
Harakiri604/PGRM-1005
/Week 2.6 - Random Guessing Game.py
235
4.09375
4
import random answer=random.randint(0, 10) guess=input("What number am I thinking (between 0 and 10? ") guess=int(guess) if(guess==answer): print("You got it!") else: print("Sorry, I was actually thinking", answer)
7c5ef9360a4732624c58947c239b766c38cd2e0d
Adonka/Unscramble-Computer-Science-Problems
/Task4.py
2,007
4.125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) #Set can check if the number already exits ...
8f40a514af4f10195ffd856f26f92706bbf03cee
sheucke/PythonBeginner
/app.py
656
4.0625
4
age = 20 # integer price = 19.95 # float first_name = "Sebastian" # string is_online = False # bool print(age) # name = input("What is your name?: ") # print(f"Hello {name}.") # birth_year = input("Enter your birth year: ") # age = 2020 - int(birth_year) # print(f"Your age is: {age}") course = "Python for Begin...
6b1aa77e91cee0b9a58d628cde15ef086c30a533
douglasrodriguess/basic-to-advanced-python-course
/07-collections/exercise/part1/Exercise01.py
358
3.765625
4
A = [1, 0, 5, -2, -5, 7] print(f'O tipo do vetor eh {type(A)}') print(f'O tamanho do vetor sendo conjunto eh {len(set(A))}') soma = A[0] + A[1] + A[5] print(f'O tipo do vetor eh {type(A)}') print(f'A soma eh {soma}') A.insert(4, 100) print(f'O vetor eh {A}') print('Os elementos do vetor em cada linha ...
6d1072d03e46639522daf504fe4e0c26df4dca18
ChaAarlie/Rogue_Like_Python
/Items.py
1,587
3.96875
4
class Item(): """The base class for all items""" def __init__(self, name, description, price, something): self.name = name self.description = description self.price = price class Weapon(Item): def __init__(self, name, description, price, damage): self.name = name s...
883639559ff76c43ceda49ec4d4e7281857a0d8f
Pypy233/Algorithm
/py/algorithm_analysis/anagram.py
1,760
3.921875
4
def anagram_solution(s1, s2): a_list = list(s2) pos1 = 0 still_ok = True while pos1 < len(s1) and still_ok: pos2 = 0 found = False while pos2 < len(a_list) and not found: if s1[pos1] == a_list[pos2]: found = True else: po...
0b8a084fccd00c79d2020326eaed7d245438afff
vicchu/Leetcode-Python
/easy/palindrome-linked-list.py
493
3.703125
4
from typing import Optional # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def genNode(self, node: Optional[ListNode]): while node: yield node.val node = node.next def is...
59a23c1fae389508a8313333b74b81549ad7e9cf
zxy3/wangdao_cpp
/python_study/jupyter/tang.py
383
3.84375
4
# 先把脚本调出来 # 包或者脚本文件 # tang.py是python的脚本文件 tang_v = 10 def tang_add(tang_list): tang_sum = 0 for i in range(len(tang_list)): tang_sum += tang_list[i] # 每执行一步,看一下结果 print(tang_sum) return tang_sum # list tang_list = [1,2,3,4,5] # 执行函数,看下结果 print (tang_add(tang_list))
6539173b858b23d1e0ce6daa4431edc7c0c8761b
svigstol/100-days-of-python
/days-in-a-month.py
1,522
4.21875
4
# 100 Days of Python # Day 10.2 - Days In A Month # Enter year and month as inputs. Then, display number of days in that month # for that year. # Sarah Vigstol # 5/31/21 def isLeap(year): """Determine whether or not a given year is a leap year.""" if year % 4 == 0: if year % 100 == 0: if ye...
6a5f9856b455d35a3df888a5512ffcf5b8bdd8ea
santoshmagar1922/python
/ClusteringExampleWholeSaleCustomer.py
1,302
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 11 16:53:08 2019 @author: smq3434 """ import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # load the data df = pd.read_csv(r"/Users/smq3434/desktop/Python and ML/data/Wholesale customers data.csv") df2 =...
452887653761470ca6a064aff9881e2e2b7d6b66
dan-santos/python
/mundo1/exercicios/ex019.py
196
3.546875
4
from random import randrange nomes = [] for i in range(4): nomes.append(str(input("Digite o nome dx {}º alunx: ".format(i+1)))) print("X alunx sorteadx foi {}".format(nomes[randrange(0, 4)]))
c478677a8f2b761840e8defdd02bb9d2019a55a9
rajan675/Python
/sorted.py
320
3.8125
4
m1=input("Enter the marks of subject 1 ") m2=input("Enter the marks of subject 2 ") m3=input("Enter the marks of subject 3 ") m4=input("Enter the marks of subject 4 ") m5=input("Enter the marks of subject 5 ") myMarks=[m1,m2,m3,m4,m5] print("Marks of student = ",myMarks) myMarks.sort() print("Sorted list= " ,myMarks)
e385e9bfb8a01059b7804f7c869b3ccb40b88af2
Narzon/PythonProjects
/Benford.py
1,529
3.78125
4
# File: Benford.py # Description: Reads a file of population distribution, and prints a count (and relative frequency) of all instances of populations with first digits 1 through 9 # Student Name: Nicolai Antonov # Student UT EID: naa766 # Course Name: CS 303E # Unique Number: 50860 # Date Created: April 2...
c3c6220d334c5ba9533fa544b016b24ee0e81b09
ianmuyumba/python-techcamp
/week_3/oop/class.py
1,047
4.5625
5
""" OBJECT ORIENTED PROGRAMMING """ class Car: # Class Attributes model = "Toyota" all_wheel = True engine_fuel = "Diesel" def __init__(self): # Constructor Method - Invoked automatically when you instantiate an object print("Invoked") # def start_engine(self): # self.enginestarted = True # return f"{...
d0747a3c31cc43e836c86a7a65784f4d46563a38
lostedleo/2048rl
/model/q_learning.py
4,166
3.734375
4
""" This part of code is the Q learning, which is a brain of the agent. All decisions are made in here. """ import numpy as np class RL(object): def __init__(self, actions, learning_rate=0.01, reward_decay=0.9, e_greedy=0.9): self.actions = actions # a list self.lr = learning_rate self.ga...
54d06119ef95edddfa668ba6b192519d8bb745b2
eclemmon/COVID_Sonification
/data_manipulation_methods.py
1,959
4.0625
4
import numpy def linear_to_logistic(lin_input, lin_min, lin_max, logistic_min=-1, logistic_max=1, k=1): """ This function will transform a y input within a chosen linear functions y-min and -max into the the output of a sigmoid function based on a determined logistic functions minimum and maximum as x appr...
82d41544fd955140d3a85c099468a3f04d94ca88
soleilhope/gwcprojects2017
/text_adventure.py
1,919
4.40625
4
start = ''' It's 11:00pm. You are bored out of your mind when suddenly.. Your friend texts you,"Hey! Big party to night you should come!" You know your parents won't let you out.. Should you sneak out? Or ask your parents permission to leave the house? ''' sneak_out = "You snuck out... and went to a party" ask_p...
9b3f6287f10a258e4613af10a0992975f784fd1b
kashifme224/100-Days-ML-Note
/Notebook/utilis.py
3,729
3.796875
4
""" Inlucde code related to how to read data from text and generate batch training data from dataset """ import numpy as np import copy import pickle def batch_generator(arr, batch_size, n_steps): """ Generate a batch of training samples :param arr: shape(none, 1), the whole training data, each int numb...
acbed129cf6da7a72a2156070d63c470dfaf184e
prashantdukecyfi/Chessboard-Detection
/land.py
1,675
3.609375
4
import numpy as np import cv2 import math land_cascade = cv2.CascadeClassifier('cascade15.xml') #Change cascade file name here to run other xml files cap = cv2.VideoCapture(-1) #Change to 0, 1, 2 if -1 doesn't work #The detection algorithm #Don't forget to hold an image of chessboard in front of your camera while (Tr...
cbaec861cf5962eb52e7e6bcc9f914338854504b
AtharvaCM/Hacking_Modules_py
/cryptography/file_encryption.py
1,293
3.90625
4
from cryptography.fernet import Fernet import os def write_key(filename, key): filename, _ = os.path.splitext(filename) new_filename = filename + ".key" with open(new_filename, "wb") as file: file.write(key) def load_key(filename, key): filename, _ = os.path.splitext(filename) new_filena...
c235377445a8c996720ed1b5570e4cea41c92610
guiscaranse/logica
/Segundo Ano/lista 1/15.py
217
3.890625
4
conta = float(input("Insira o valor da conta: R$")) carlos = conta//3 andre = conta//3 felipe = conta - (andre + carlos) print("Carlos pagará R$%d\nAndré pagará R$%d\nFelipe pagará R$%s" %(carlos, andre, felipe))
861e208e781a563dcdbf6479c3f9faee6c24c3da
Jburt4/ComSci-Repository
/Sonar.py
2,759
3.84375
4
import sys import random import time def torps(): print('\nLaunching torpedo.') tx = int((r + 30)/4) ty = int((c + 6)/4) game[tx][ty] = '>>>' print('\nFollowing torpedo using sonar') time.sleep(5) printboard() print('\nFollowing torpedo using sonar') game[tx][ty] = '~~~' tx = int((r + 10)/2) ty = int((c + ...
40974f3f1c68f1bb76df2136e80f646f0decdf4b
pshweta0312/assignment
/que2.py
413
4.375
4
#Write a program which can compute the factorial of a given numbers. #The results should be printed in a comma-separated sequence on a single line. #Suppose the following input is supplied to the program: #8 #Then, the output should be: #40320 def fact(x): if x==0: return 1 else: return x * fac...
73faa0bf19d96d7677c09dd026f5b140945dea84
wojasek12/Ptyhonek
/8RockPaper.py
405
3.515625
4
import random while(True): input = int(raw_input("Podaj co wybierasz: \n1. Papier\n2.Nozyczki\n3.Kamien\n")) random1 = random.randint(1, 3) difference = input - random1 if difference in [1, -2]: print("Wygrales!") continue elif difference in [-1, 2]: print("Przegra...
de35e13de25d45f61477cc98c0f6a0a528fe51e3
kaushikreddy25/firstPythonRepo
/MyPython/SelfLearning/binarySearchDemo.py
653
3.6875
4
pos = -1 def search(lst,num): l = 0 u = len(lst)-1 while l<=u: #for i in lst: mid = (l + u )//2 if lst[mid] == num: globals()['pos'] = mid return True else: if lst[mid] <= num: l = mid+1 else: ...
60d3205b8bf85ab2ddcf51893ccd97a5ab064b03
preethika2308/code-kata
/even.py
110
3.609375
4
fm,sm= (input().split()) fm=int(fm) sm=int(sm) for x in range(fm+1,sm,1): if (x%2==0): print(x,end=' ')