blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
79d53a38bbd5724729c41638dfc8755aa0517dd4
thewinterKnight/Python
/dsa/Linked Lists/4.py
1,947
4.40625
4
# How do you reverse a singly linked list without recursion? import copy class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def get_data(self): return self.data def get_next(self): return self.next def set_next(self, new_node): ...
30ff67d5f30f79a7ef343623320227d1d5a46464
maurya20/assignment2
/task3.py
1,062
4.15625
4
str = "i like sam sung samsung mobile ice cream icecream man go mango" dict = str.split() # Making a list of stored dicttionary words. input_string = input("Enter your string:") # Taking a string input from user. out = [] # An empty list...
1d54857b26a727e011993a813cdff4267426222b
Arjun-N-Koushik/NewHack
/set.py
583
3.6875
4
s = set() a = [1,2,3,4] s_from_list = set(a) print(s_from_list) print(type(s_from_list)) s.add(1) s.add(2) s.add(3) print(s_from_list) s1 = s.isdisjoint({4,5,6}) print(s1) # a = 56 # b = 62 # print("Enter your Age..") # age = int(input()) # # c = int(input()) # # if age>100 or age<7 : # print("Ent...
41260a59af5469d2c603a7fe48b26881abcb4b7d
jaysurn/Leetcode_dailies
/Longest_Non_repeating_Substring.py
1,536
4.28125
4
# Goal : Given a string, find the length of the longest substring ( i.e. abcabcbb: abc , bbbb: b ) # Given : Single string # Assumption : String consists only of letters , numbers, and symbols def longest_substr_len( string ): len_max = 0 # Used to record length start = 0 # Used to trac...
b8ca7bc1faed5e8b9bc2ca57677c2b4083e185cc
cookies5127/algorithm-learning
/leetcode/default/24_swap_pairs.py
1,243
3.921875
4
from utils import build_list_node from utils.types import ListNode ''' 24. Swap Noeds in Pairs Given a linked list, swap every two adjacent nodes and return ints head. You may not modify the values in the list's node, only ondes itself may be changed. Example: Given 1->2->3->4, you should return the list as 2-...
9569db4c45da84ff4ba6e948747ad74ad10f72c5
manhar336/manohar_learning_python_kesav
/Operators/Membershipoperators.py
1,242
4.65625
5
'''--------------------------------------------------------------''' # 6. Membership Operators : '''--------------------------------------------------------------''' ''' in and not in are the membership operators in Python. They are used to test whether a value or variable is found in a sequence (string, list, tuple...
622dfcaa9419e0bd470f2aa01b944ea3fbfd849e
Xn-qon7tvkkj/Landscape
/Landscape.py
5,615
3.625
4
import turtle la = turtle.Turtle() tr = turtle.Turtle() ho = turtle.Turtle() su = turtle.Turtle() no = turtle.Turtle() turtle.bgcolor("blue") def wall(side): for size in range(4): ho.forward(200) ho.left(90) def pane(side): for size in range(4): ho.forward(12) ho.left(90) ...
ffe9e6dde703c3b0a782db8d7fcd413e99b97ce3
SylphDev/Actividades_Algoritmos
/prepas_ejercicios/4_semana/prepa_extra.py
9,204
3.796875
4
# Ejercicio Base de Datos class Sirius: ''' Base de datos de estudiantes de la UNIMET ''' def __init__(self): self.database = {} def get_options(self): ''' El usuario ingresa la opcion de lo que desea hacer en la base de datos ''' valid = False ...
dbec152b0e60aa09ce68aa161d19fae6b4bc1645
CarolineXiao/AlgorithmPractice
/TopKLargestNumbers.py
475
3.734375
4
import heapq class Solution: """ @param nums: an integer array @param k: An integer @return: the top k largest numbers in array """ def topk(self, nums, k): if len(nums) <= k: return sorted(nums, reverse=True) heap = [] for i in range(len(nums)): ...
c046a966135ec74290538a7ec5a1d9dda9f85f3d
soufal/python_hand_way
/hand_way/ex4.py
795
4.0625
4
#the num of cars cars = 100 #the space of a car space_in_a_car = 4.0 #the num of drivers drivers = 30 #the num of passengers passengers = 90 #the num of cars are not driven cars_not_driven = cars - drivers #the num of cars are driven cars_driven = drivers #the carpool capacity carpool_capacity ...
de9217cb8194ea4a4391fd55879158664e2666d1
Pluto-Zmy/Python-OJ
/3/D.电商二.py
353
3.78125
4
def get_upper(string): return ''.join([ch for ch in string if ch.isupper()]) bookNum = int(input()) bookList = [input() for i in range(bookNum)] bookListPlus = [] for currentName in bookList: bookListPlus.append([get_upper(currentName), currentName]) sortedListPlus = sorted(bookListPlus, key=(lambda x: x[0])) for i...
c524538d67a999d67afc95e1db3e6089e68d4868
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_85/71.py
3,110
3.71875
4
#!/usr/bin/env python # encoding: utf-8 """ SpaceEmergency.py Created by Graham Dennis on 2011-05-22. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys # def permutations(*iterables): # def permuteTwo(it1, it2): # for o1 in it1: # for o2 in it2: # if is...
1a29d171b6b98d6868948ccb08189b91b1553cff
DimpleOrg/PythonRepository
/GeeksforGeeks/vAnil/03. List Programs/30.py
796
4.25
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 20 17:06:49 2021 @author: ANIL """ ''' Given two lists, sort the values of one list using the second list. Examples: Input : list1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i"] list2 = [ 0, 1, 1, 0, 1, 2, 2, 0, 1] Output :...
0f9ee5d7bb600b486cde447ed22c7a3fbd65ee64
rafaelsaidbc/Exercicios_python
/ex027.py
306
4.03125
4
nome = str(input('Digite seu nome completo: ')).strip() # strip para ignorar possíveis espaços no início da digitação nome_split = nome.split() primeiro_nome = nome_split[0] ultimo_nome = nome_split[-1] print('O primeiro nome de {} é {} e o último é {}!'.format(nome, primeiro_nome, ultimo_nome))
e697bd3df3fed704af8336e1cb0c44ef056430ff
carlonuccio/data-modeling-postgres
/create_tables.py
2,891
3.875
4
import psycopg2 from sql_queries import list_drop_tables, list_create_tables def insert_from_dataframe(hostname, dbname, table, dataframe): """ Insert Rows in a db table from a dataframe :param hostname: Host Database Address :param dbname: Database Name :param table: Table Name :param datafra...
3047addb624844e0c572dabcae31219eee124747
vonzhou/Core-Python-Programming
/chapter8/Continue.py
358
3.984375
4
#P200 def checkPwd(): valid = False count = 3 passwordList = ('123456', 'vonzhou') while count > 0: input = raw_input('Enter password:') for each in passwordList: if input == each: valid = True break if not valid: print 'invalid input password' count -= 1 continue else: print 'Good ...
f2b5bc39e4067be7d6563989ffdf0a3e39e26ec3
majf2015/python_practice
/test_proj/class2.py
505
3.6875
4
class Baseclass(object): def __init__(self,k): self.__k = k self.__v = 1 def printself(self): print self.__k, self.__v def getVelue(self): return self.__k, self.__v class Deriveclass(Baseclass): def __init__(self): Baseclass.__init__(self, "first") a, b =...
eef60905a5d8de48577dabfd070155dac21cd6e6
harshaveeturi/DataStructures_Algorithms_Python
/stacks/linkedlist_stack.py
2,085
4.21875
4
class Node: def __init__(self,element): self.element=element self.next=None class Stack: def __init__(self): self.top=None def push(self,push_element): '''this function pushes the elements in to the stack''' if self.top is None: self.top=Node(push_elemen...
126ab46ee83a568e00dd296229728c5784c53b07
MatejBabis/AdventOfCode2k18
/day5/part2.py
525
3.765625
4
import part1 if __name__ == "__main__": s = part1.read_input("input.txt") results = {} # store the length of reaction string when 'c' is removed for c in "abcdefghijklmnopqrstuvwxyz": results[c] = len(part1.polymer_reaction(s, c)) # find the minimum value in the dictionary minimum_val...
547b5ea2ac7500bad4af65ab23b3a0cbc4518221
zl0bster/LearnPythonProject
/Exersises 20201119 rnd gen.py
2,327
4.03125
4
def lam3(): def makeAdd(n): def addX(x): return x + n return addX def lam31(): makeAdd = lambda n: lambda x: x + n add_5 = makeAdd(5) print(add_5(5)) def lam1(): """ Создать список, в котором каждый элемент – кортеж из двух чисел. Отсортиро...
7525b2e648797a3e62024e6606936c31a89a7c96
rajaupadhyay/Risk_Engine_BAML_Hackathon
/data_formulation.py
5,363
3.5
4
import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlab import math from scipy.stats import norm import random import pandas as pd ''' def plot_bell(mean, variance): sigma = math.sqrt(variance) x = np.linspace(mean-3*sigma, mean+3*sigma,100) plt.plot(x,mlab.normpdf(x, mean, sigma)...
d7d1218a8560abe221fdead0ded0850d603f1e5d
accolombini/A_IC
/FINANCAS/LABORATORIOS/lab101_tax_ret_simples_br.py
1,953
3.671875
4
""" Neste laboratório vamos trabalhar com a taxa de retorno simples de um ativo. REQUISITOS: - para este laboratório precisaremos de alguns módulos Python - será preciso -> numpy - será preciso -> pandas - será preciso -> matplotlib ...
db71c57fba658fd19f3b8a85fef155f61188340b
luckycoolrana03/AI-chatbot-using-python-main
/sorce code.py
2,246
3.90625
4
import pyttsx3 import speech_recognition as sr import wikipedia import datetime import os import webbrowser engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voice', voices[1].id) def speak(audio): engine.say(audio) engine.runAndWait() print("Skynet: ", audio) de...
3f3c22d7ce34e48b06135a223c757ec2756219bd
andrewnvu/DCP
/DCP4.py
339
4
4
#Find the first missing positive in a an array of integers def first_missing_positive(numbers): #gets rid of negative numbers s = set(numbers) i = 1 #if 1 is in the set, increment it until i is not in s while i in s: i += 1 return i myArray = [1,2,4,-2, -5] print(first_missing_...
de32cd87d0f8e6699c03f41f91d70a8519262bda
anneusagi/nganguyen-lab-sc4e18
/Session03/f-math-problem/freak.py
793
3.703125
4
# from random import * # x = randint(0,10) # y = randint(0,10) # cal = choice("+,-,*,/") # if cal == "+": # result = x + y # elif cal == "-": # result = x - y # elif cal == "*": # result = x * y # else: # result = x / y # error = randint(-1,0,1) # print("{0} {1} {2} = {3}".format(x, cal, y, result+...
fd63f7dd9f80ad70f7f4aa0c1ff4a7e078f36724
xiyiwang/leetcode-challenge-solutions
/2021-05/2021-05-20-levelOrder.py
1,271
3.8125
4
""" LeetCode Challenge: Binary Tree Level Order Traversal (2021-05-20) Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Constraints: - The number of nodes in the tree is in the range [0, 2000]. - -1000 <= Node.val <= 1000 """ class Tr...
0ba666b3be4ce7a2fe00d802909e27eb92622f3f
mosfeqanik/Python_Exercises
/turtlewhileloop.py
196
3.734375
4
import turtle turtle.color("red") turtle.speed(5) counter =0 while counter<36: for i in range (4): turtle.forward(100) turtle.right(90) turtle.right(10) counter +=1 turtle.exitonclick()
5bf011dbadac2252cf6c6e6d5a45a39ea32be686
semmani/Lecture2A
/OLACabLayout.py
4,417
3.875
4
#to be completed from the github # Ram is volatile memory i.e temporary # whenver process is finsished, program will beb finished #Saving data somewhere--->Persistence # we perform serialization and De-Serialization class Customer: def __init__(self,name,phone,email): self.name = name self.phone =...
3410910eee41f273757a2d6375bf93a11ec90721
Kvazar78/Skillbox
/15_list1/task_152_2.py
1,077
3.90625
4
# Кратность # # Пользователь вводит список из N чисел и число K. Напишите код, выводящий на экран сумму индексов элементов списка, # которые кратны K. # # Пример: # # Кол-во чисел в списке: 4 # # Введите 1 число: 1 # Введите 2 число: 20 # Введите 3 число: 30 # Введите 4 число: 4 # # Введите делитель: 10 # # Индекс чи...
59c97dea54dfb56aa435ce9cc3d8e953e98beca4
pranter21/Santotomas_estructuras_programacion
/guia5_python/G5_ejercicio3.py
1,842
3.75
4
#!/usr/bin/env python # coding=utf-8 from colored import bg, fg, attr """ @author: Adrian Verdugo @contact: adrianverdugo273@gmail.com @github: adrian273 """ # array para los datos de los trabajadores data_workers = [] total = 0 """ @type = variables para dar estilos """ colors = [bg('blue') + fg(15),...
7a6ed35ca27160a9b5ae03a815df1571239cfec8
ramaranjanruj/Machine-Learning
/ML - Regression - 1.py
3,631
3.90625
4
# Getting all libraries that have dependencies import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model from sklearn.cross_validation import train_test_split # importing the data from csv files train_data = pd.read_csv('kc_house_train_data.csv') test_data = pd.read_csv('...
ae97bd763e6ad580f63f63b8b6d659044dde9814
ThomasHJorgensen/ConsumptionSaving
/consav/misc.py
9,140
3.515625
4
# -*- coding: utf-8 -*- """newton_raphson This module provides misc functions. """ import time import math import numpy as np from scipy.stats import norm from numpy.linalg import svd from numba import njit def elapsed(t0,t1=None): """ time elapsed since t0 with in nice format Args: t0 (double): st...
d2c9173a504c5317ebe0cb37d7064879ff4da658
faterazer/LeetCode
/2032. Two Out of Three/Solution.py
378
3.546875
4
from collections import defaultdict from typing import List class Solution: def twoOutOfThree(self, nums1: List[int], nums2: List[int], nums3: List[int]) -> List[int]: cnt = defaultdict(int) for i, arr in enumerate((nums1, nums2, nums3)): for x in arr: cnt[x] |= 1 << i ...
2924d27c8050b210ea6e5c472a15c57aba6f4c55
rouseguy/learnAlgorithms2
/py_sort.py
325
3.875
4
import os import sys if __name__ == "__main__": fileName = input("enter the file name that has the numbers to sort:") with open(fileName) as f: data = f.readlines() data = [int(d) for d in data] print("Given numbers:", data) sorted_num = sorted(data) print("Sorted numbers:", sorted_...
587cd3144ff3245a867c3d041d9c684026af0494
Mgallimore88/GeneticAlgorithms
/EnuBubbleSort.py
1,480
4.375
4
# Takes an input list of values with positional tag and uses a bubble sort swapping algorithm # to find and return the highest n values in the list. # The inputs are of the fort [(tag_0, value_0), (tag_1, value_1), ...(tag n-1, value n-1)] # # If the 2nd argument # of the input field is left blank, n = full list and th...
8426c6c806e0d7ff8d548b9e83b0cfb8a173a482
Leaaaaaa/learn_python
/day7/使用集合.py
1,090
4.15625
4
#使用集合 def main(): set1 = {1, 2 , 3 , 3, 2,} print(set1) print('Length = ', len(set1)) set2 = set(range(1, 10)) print(set2) set1.add(4) set2.add(5) set2.update([11,12]) print(set1) print(set2) set2.discard(5) #remove的元素如果不存在会引发keyerror if 4 in set2: set2.remove...
5933afe07555d99815fb9c050e09b01d7ebf560c
AndresDuque/Scientific-Programming
/relacion sobre gui/ejercicio3.py
596
3.921875
4
"""Construye un visualizador de matrices.""" from Tkinter import * import random def RGBs(num): # Colores RGB aleatoriso return [[random.randint(0,255) for i in range(0,3)] for j in range(0,num)] def rgb2Hex(rgb_tuple): return '#%02x%02x%02x' % tuple(rgb_tuple) def drawGrid(w,colors): col = 0; row = 0 color...
1b190ab8117d4db4e3d7dc7e31d61ee26da5b48b
syvn/pythonStudy
/fun-build-in/typeConversion.py
1,008
4.09375
4
# 内置方法 类型转换 # int() 将 字符串或数字转换成整数 # 语法 class int(x, base=10) print(int()) # 0 不传入参数时, 得到结果0 print(int(3)) # 3 print(int(3.1)) # 3 # float() 将整数和字符串转换成浮点数 print(float(1)) # 1.0 print(float()) # 0.0 print(complex(1, 2)) # 1 + 2j print(complex('1+2j')) # 1 + 2j '1+2j' + 前后无空格 # str() 将对象转化为适于人阅读的形式 # class str(objec...
e9ca860865168c9a2e13d498a1ba04864a2a4b0a
dohertym19/portfolio-stub
/python/ages.py
111
3.9375
4
if age > 0 and age<=2: print("baby") elif age >2 and age <18: print("child") else: print(adult)
368ae546177730dc625f523d60798536d858e2a0
mikaelgba/PythonDSA
/cap3/Condicionais.py
2,103
4.25
4
if( 3 < 5): print("Saint Seiya!!") if( 10 == 5): print("true") else: print("false") if True: print("True") #Condicionis Aninhadas idade = 5 nome = "Yoda" if(idade >= 5): if(nome == "Yoda"): print("Iti Malia, Baby Yoda!!") else: print("Você não é o Baby Yoda") #Condicional logico AND ...
4682bec9062b50c7a3c356398a56c1f4aa1ae725
richardrtutor/Personal-Library
/main.py
12,957
4.125
4
import os from typing import Optional, Dict from dataclasses import dataclass @dataclass class Book: title: str author: str genre: str def log_sign() -> str: log_action = input("[Log In] or [Sign Up]\n> ").title() while not val_login(log_action): print("invalid action") log_actio...
f8cb8818e2994ca488745e897db6ff05b64bda72
anumoshsad/Interactive-Python-Programming-Coursera
/Project_5_memory.py
1,785
3.59375
4
# http://www.codeskulptor.org/#user42_ZmJ4LHyjgQ_1.py # implementation of card game - Memory import simplegui import random turn = 0 # helper function to initialize globals def new_game(): global state, cards, exposed, prev prev = [-1,-1] turn = 0 state = 0 cards = list(range(8)) + list(range(8))...
e730fc2bb32283d132269f53201a6c52d0625b4a
xloso/m02_preboot
/factorialhechopormiconFor.py
458
4.03125
4
def factorial (x): total = 1 for num in range(2, x+1): total = total * num return total def factorialRecursivo(n): if n>0: return n * factorialRecursivo(n-1) else: return 1 numero = int(input("introduce número factorial: ")) print("el factorial con for de {}, ...
db5b6322896b4d7fda85c1da7fc0dcaf27948195
nebel-dev/leetcode
/位运算/137. 只出现一次的数字 II.py
2,831
3.984375
4
""" 给你一个整数数组nums ,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 示例 1: 输入:nums = [2,2,3,2] 输出:3 示例 2: 输入:nums = [0,1,0,1,0,1,99] 输出:99 提示: 1 <= nums.length <= 3 * 10^4 -2^31 <= nums[i] <= 2^31 - 1 nums 中,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 进阶:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗? 来源:力扣(LeetCode) 链接:https://leetcode-cn.com...
995874c43ae255b35aefe9c88c9064c77bb24426
Damoy/AlgoTraining
/LeetCode/BinarySearchTreeFromPreorder.py
573
3.5625
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def bstFromPreorder(preorder): if not preorder or not len(preorder): return None return util(0, len(preorder) - 1, preorder) def util(start, end, preorder): if start > end: re...
4cc08077aaba1910a4935c84e3bd2b4af5cbec46
shankar7791/MI-10-DevOps
/Personel/AATIF/Python/03-MAR/palinOrSym.py
838
4.1875
4
def palin(string): st = 0 end = len(string)-1 f = 0 while(st<end): if (string[st]== string[end]): st += 1 end -= 1 else: f = 1 break; if f == 0: print("The entered string is palindrome") else: print("The entered string is not palindrome") ...
0939885322d9a139e117d9ab92e7e008fe254a1f
KiD21606/HackerRank
/python/Strings/Text_Wrap.py
353
3.75
4
import textwrap def wrap(string, n): result = '' k = len(string)//n for i in range(k): result += string[n*i:n*(i+1)]+'\n' if len(string)%n != 0: result += string[n*k:]+'\n' return result if __name__ == '__main__': string, max_width = input(), int(input()) result = wrap(stri...
3c513e57d09c1b86e19ef3e57423b3b0d96069f6
Princecodes4115/myalgorithms
/BST/nextNode.py
3,271
3.890625
4
class TreeNode: def __init__(self,val): self.val = val self.left = None self.right = None class Tree: def __init__(self,root): self.root = root def NextNode(root,val): q = Queue() print ("enqueuing root") q.enqueue(root) currentlevel = 1 nextlevel = 0 while(not q.isEmpty()...
5e735b97b62fbb85a86ddc7bc7c9360313fa9025
bkruszewski/iSAPython3
/day4/indeksy_kolekcji.py
460
3.5
4
# czasem chcemy wiedziec, z którym elemeentem mamy doczynienia # chcemy znać jego indeks imie = "Hermenegilda" # tworzymy licznik zawierający indeks aktualnego elementu indeks = 0 for c in imie: print(indeks, c) # musimy pamiętać o aktualizacji indeksu! indeks += 1 # enumerate zwraca dwie wartości: # in...
52aff37ce4867baa08efb00e40f89c36e8ec4034
pauloesantos/EstudoPython
/PythonParaZumbis/Lista1/questao8.py
270
4.09375
4
# Paulo Eduardo Faundes dos Santos # Curso Python para Zumbis # Lista de Exercício 1 # Questão 8 # Converta um temperatura digitada em Fahrenheit para Celsius. C=(F-32)*5/9 F = float(input("Qual a temperatura em Fahrenheit: ")) C = (F - 32) * 5 / 9 print("A temperatura em Celsius é: %.2f" %C)
a33d73821bbfa1bd9d97ff9530bae223acdd8436
shriharshs/AlgoDaily
/leetcode/52-n-queens-ii/main.py
2,182
3.5625
4
""" 1st approach: backtracking - - similar to lc37, lc51 - https://www.youtube.com/watch?v=5v6zdfkImms - basically try every possisbilities within the safe region - for each coordinate, we need to check the whole board to see if it is safe to place a queen Time O(n^4) for each coordinate, we...
8147797c57ac771efb7afc854690ec3ae0991c5e
doraemon1293/Leetcode
/archive/794ValidTic-Tac-ToeState.py
1,277
3.53125
4
# coding=utf-8 class Solution: def validTicTacToe(self, board): """ :type board: List[str] :rtype: bool """ import itertools nx=no=0 for ch in itertools.chain(*board): if ch=="X": nx+=1 if ch=="O": no+=1...
12496c6e969bffd6ecc770ad6804b1626a645286
KevinVega-afk/Matracas13
/NumeroDeVueltas.py
499
4
4
#Programa capaz de calcular el número de vueltas de una llanta en 1 km print("Programa que calcula el número de vueltas de una llanta en 1Km") print("Primero debemos calcular cuantas vueltas dara la llanta en un diametro de 50cm") V = 3.1416 * 50 print("La llanta da", V ,"vueltas") print("Ahora debemos homologar l...
f27a2596b6aa2c969f2993812e554c092df3040c
aliyahyaaamir/practice
/microsoft/fair_indexes.py
642
3.640625
4
def fair_indexes(A: list, B: list) -> int: # Find the number of fair indexes num_fair_indexes = 0 arr_length = len(A) for i in range(1, arr_length): if sum(A[0:i]) == sum(A[i:]) == sum(B[0:i]) == sum(B[i:]): num_fair_indexes += 1 return num_fair_indexes if __name__ == "__ma...
0e3e3015b609abac4518f30111613d6d50844a87
phyupyarko/python-exercises
/ex34.py
227
3.890625
4
animals = ['bear','python3.6', 'peacock', 'kangaroo', 'whale','platypus'] i=0 numbers = [] while i<6: for name in animals: print(f"The first animal is at {i} and is a animals{i}" ) numbers.append(i) i = i + 1
6f2a1d6127c93b6d788d62778f2b703024b43b48
Gurnur/Practice_problems
/remove_element/remove_element.py
1,069
3.953125
4
''' Leetcode 27. Remove Element Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matt...
6c2bfcdab26c28c204b9e247201b531ccebd4ba6
ankitath/python_scripts
/practice13.py
184
3.53125
4
import re name = input("Enter file:") hand = open(name) x=list() for line in hand: y = re.findall('[0-9]+',line) x = x+y sum=0 for z in x: sum = sum + int(z) print(sum)
2ea96ca8ae387081f3d74555c06d9e1db7a32025
ealarap/saturdays-ai
/src/week3-exe/listsintersection.py
571
4.03125
4
#!/usr/bin/python class ListsIntersection: def __init__(self, list1, list2): self.list1 = list1 self.list2 = list2 def getListsIntersection(self): return list ( set( self.list1) & set( self.list2) ) def main(): a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4...
8909a072bde54baccd77d170a7c0956e27df2f02
njlopes/Atividade-Sem03-T2
/Preço.py
189
3.546875
4
preco=float(input("Digite o preço:")) preco_com_desconto=preco * 0.90 preco_com_desconto=round(preco_com_desconto, 2) print("Preço com desconto:", preco_com_desconto)
0bfb93912f43ff416b5e22805efee48f6fd33068
jackle98/Deque-Code-
/quiz.py
466
3.90625
4
from Deque_Generator import get_deque def rec_palindrome(dq): if dq.pop_front()==dq.pop_back() and len(dq)>1: return rec_palindrome(dq) else: if len(dq)<=1: return True else: return False def is_palindrome(character_string): dq = get_deque() for c in cha...
9baa5be30bbfa11a9c4ffe07b3fac05d5e91a742
dzsnowings/girlswhocode
/Python/draw_shapes.py
2,468
4.3125
4
from turtle import * import math # Name your Turtle. t = Turtle() # Set Up your screen and starting position. setup(600, 600) goto(0,0) ### Write your code below: sides = int(input("Enter the number of sides: ")) color = input("Enter the color of your shape: ") print("Your shape will be", color, "and have", sides, ...
fd409c2161d42bf199553f0768d9e5355ffd64fa
niavivek/Python_programs
/all_files/hw9/lab_10_exercises.py
2,110
3.9375
4
from functools import reduce #### Take a list of numbers, square each element my_nums = [1, 2, 3, 4, 5] ### Imperatively squared_nums = [] for num in my_nums: squared_nums.append(num * num) ### Functionally squared_nums = map(lambda x: x * x, range(1, 6)) ### Functionally convert this list to a list of strin...
3e8e5685d1388e245d056d28dbffc5977e410016
d3ming/hackerrank-solutions
/sherlock-and-watson/solution.py
612
3.59375
4
# https://www.hackerrank.com/challenges/sherlock-and-watson/submissions/code/17974688 nkq = input().strip().split(" ") n = int(nkq[0]) # size of arr k = int(nkq[1]) # num of ops q = int(nkq[2]) # num of queries arr = [int(i) for i in input().strip().split(" ")] queries = [] for i in range(0, q): queries.append(int...
e44051a1ea99c5de4231519f95760fb30a8d59d9
siddhant3030/depotruby
/linked_list/single_linked_list.py
6,431
3.953125
4
from operator import truediv class Node: def __init__(self, data): self.data = data self.next_element = None class Solution: def __init__(self): self.head_node = None def get_head(self): return self.head_node def is_empty(self): if(self.head_node i...
942d9e4b1306d7f795e9399e75a487492674ab17
BerilBBJ/scraperwiki-scraper-vault
/Users/D/D/csa2.py
5,312
3.5625
4
import scraperwiki from BeautifulSoup import BeautifulSoup import re url = "http://info.csa.com/political/classcodes.shtml" html = scraperwiki.scrape(url) # scrape_table function: gets passed an individual page to scrape def scrape_table(soup): data_table = soup.find('table',width="84%") #print data_table ...
c72ed2fbfe965e98459c0abee6fbbd259d730857
fenglihanxiao/Python
/Module01_CZ/day3_loop_func/04-代码/day3/48_回文数.py
645
4.125
4
""" 案例:回文数 要求:打印所有3位回文数 回文数:如果一个数字从左侧读和从右侧读是同一个数,则该数字即为。例如121,777 """ # 分析 # 1. 3位回文数从100到999 # 2.回文数特征,百位数字和个位的数字相同 # 3.打印满足特征的数字 # # 求一个数字的百位数字 # x = 789 # print(x // 100) # # 求一个数字的个位数字 # print(x % 10) i = 100 while i <= 999 : # 取出数字的百位和个位进行比较,如果相同就打印 a = i // 100 b = i % 10 # 判断a和b是否相同,如果相同打印 ...
6b2f03fc27c5bb2fbdf5673347719e284b165463
bradchoate/flyingcow
/flyingcow/properties.py
991
3.75
4
class Property(object): """ A way to denote a database property inside a model. Raw value of property is stored in the instance of the Model w/ the property name prefixed with _. """ def __init__(self, name=None, default=None): self.name = name self.default = default def __get_...
58cd8cc7de89aa129a4d2a0e135f653786930b9c
tdavchev/algorithms
/Trees/iterative_inorder.py
1,307
3.640625
4
class TreeNode(): def __init__(self, data): self.data = data self.left = None self.right = None def set_left(self, data): self.left = data def set_right(self, data): self.right = data def iterative_inorder(root): if root == None: return None stack ...
0456a80011c10aecd39b13536c8ea8e1f71c7b7c
AngelLiang/programming-in-python3-2nd-edition
/source/ch01/average1_ans.py
1,226
3.71875
4
#!/usr/bin/env python3 # Copyright (c) 2008-11 Qtrac Ltd. All rights reserved. # This program or module is free software: you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) an...
b74a713408aefee074e4a9a91ccb1e88510edabe
Sandesh-Thapa/Assignment-II-Control-Structure
/q10.py
1,247
4.34375
4
# Write a function that takes camel-cased strings (i.e. ThisIsCamelCased), and converts them to snake case (i.e. this_is_camel_cased). Modify the function by adding an argument, separator, so it will also convert to the kebab case (i.e.this-is-camel-case) as well. def convertStringCase(camel, separator): output = ...
1a1d50cc7ec8ddcd43ae681bd83eafe35b6b8480
Jigar710/Python_Programs
/magic_method/var1.py
189
3.546875
4
class Emp: def __init__(self): self.var1 = "value1" self._var2 = "value2" self.__var3 = "value3" e1 = Emp() print(e1.__dict__) print(e1.var1) print(e1._var2) print(e1._Emp__var3)
ab7ac9f721ee6a9f7bea1fc512cbd7d5c7dc037e
Muscularbeaver301/WebdevelopmentSmartNinja201703
/Kursprojekte/Kursprogramm/Class10-Lottogenerator-Hauptstadtspiel/lottozahlen.py
423
3.9375
4
"""Lottozahlen""" import random def lottozahlengenerator(zahlen): Lottozahlenlist = [] zahlen = min([zahlen,49]) zahlen = zahlen if zahlen <= 49 else 49 while len(Lottozahlenlist) < zahlen: zahl = random.randint(1, 49) if zahl not in Lottozahlenlist: Lottozahlenlist.append(za...
c1337ac1ecf3f799734ca77be17b89138568845b
Jansten/Training
/Python/LinuxAcademy/Python 3 For System Administrators/03 - Strings/hello.py
1,063
4.5625
5
#!/usr/bin/env python3.6 # This is a program that prints "Hello World!" print("Hello World!") # These are some string examples "pass" + "word" # Will print out "password" "Ha" * 4 # Will print out "HaHaHaHa" "double".find('s') # Reutnrs "-1", which means it wasn't found >>> "double".find('u') # Returns "2" >>> "do...
37e5f6ebc022fccc7c04156f88d1a577023eafbe
leighMichaelForrest/problems
/payroll/payroll.py
806
4.03125
4
import sys OVERTIME_FACTOR = 1.5 def payroll(wage, hours): """Determine the gross pay. Hours over 40 pay time and a half plus 40 hours regular time. wage: The hourly wage of employee. hours: The number of hours worked.""" try: wage = float(wage); hours = float(hours) regular = 0; o...
bebf69bfbd74b543b94a2c15f8a6e7eea4b62946
Paalar/TDT4110
/Øving 9/genomdic.py
629
3.890625
4
my_family = {} def add_family_member(role, name): for i in my_family: if i == role: my_family[role].append(name) return my_family my_family[role] = [] my_family[role].append(name) return my_family print("Når du er ferdig med å legge til navn, skriv ferdig.") while True:...
2593aeaf239015183c48861a96af3d1feb21d6d3
Laurensvaldez/PythonCrashCourse
/CH9: Classes/9-5_login_attempts.py
2,622
4.46875
4
# Add an attribute called login_attempts to your User class from Exercise 9-3 class User: """A class to describe a user""" # Create two attributes called first_name and last_name # and then create several other attributes that are typically stored in a user profile def __init__(self, first_name, last_n...
211d6d5dfb2401d0ef5ac3fce1b5eb2a0514935f
GeorgiyDemo/FA
/Course_II/ПП/part1/pract2/task1.py
2,530
3.84375
4
""" Практика 2 Суперэллипс Деменчук Георгий ПИ19-4 """ import tkinter as tk from math import sin, cos, pi # Начальные позиции width = 600 height = 600 root = tk.Tk() # Основной канвас c = tk.Canvas(root, width=width, heigh=height) # Текущие точки, которые отрисованы points_list = [] def drawer(canvas, x, y, a, b): ...
70e0da8f49445c528f53960aa4c9d6a593218b87
tenhobi/BI-PYT
/homeworks/02-random-walk/__main__.py
1,049
3.53125
4
#!/usr/bin/env python3 from random import randint import os from time import sleep # clear window print('\033[2J') # get dimension and center cols, rows = os.get_terminal_size() x = cols // 2 y = rows // 2 print(f'\033[{y};{x}H', end='', flush=True) # initialize data matrix = [[0] * (cols + 1) for i in range(rows + ...
23f2c01dd3ae65b9b1f2d4bfb05515cc45f6fedb
conglb/Hackerank-practice
/reverse-a-linked-list.py
439
3.921875
4
# Complete the reverse function below. # # For your reference: # # SinglyLinkedListNode: # int data # SinglyLinkedListNode next # # def reverse(head): """ Return head of link list reversed """ if head == None: return None before = None cur = head while True: newCur = cur.nex...
b54ed9a030b6bfc9e2c9f3b4ba3ecd9fa7e70e68
Jocelyn9090/CS1301xiiii
/AlignRight.py
1,671
4.75
5
#----------------------------------------------------------- #Write a function called align_right. align_right should #take two parameters: a string (a_string) and an integer #(string_length), in that order. # #The function should return the same string with spaces #added to the left so that the text is "right aligned"...
4efadde2b15d71ce730050414d235c477270fd90
dbdennot8/bc-18-project
/test_cases.py
3,608
3.828125
4
import unittest from dojo import DojoRoomAllocator class TestsForDojoClassMethods(unittest.TestCase): def setUp(self): """sets up an instance of the class Dojo, for use in the tests below""" self.demo = DojoRoomAllocator() def test_can_create_office_and_append_to_appropriate_lists(self): ...
7e1e855ca3bc8d5d6a9609374fc250a70271cdaf
jsinoimeri/Gr11-Python
/Task 4/image_functions.py
13,836
3.90625
4
from ics_image_fast import * from random import * from math import * def inverse(file_name): ''' Takes the picture user inputs and inverses it by substracting each rgb value from 255. For ex: red is 55, the inverse of that is 255-55 = 200 ''' load_image(file_name) #loads the image for...
3f94f29adfd7d61aec077dd6664a5643bf5b4531
Bl4ky113/clasesHaiko2021
/camaraMultas.py
2,592
4
4
''' Codigo de Cámara Multas Debe hacer: - Ingresar varios carros: - Distancia entre ambas cámaras - Velocidad maxima de la calle - El tiempo que se demoro el auto en pasar de una a otra cámara - Placa del Carro - Determinar cuales de estos se merecen multa, curso & ok ''' from linea...
a49b03671632b5b99f099d0be8e39c969c4a0398
innovatorved/python-recall
/py45-ObjectInclapsuation-check-any-object-type.py
771
3.671875
4
# What is Object Introspection ? # find information about any Object class nump: def __init__(self , start , end): self.start = start self.end = end @property def full(self): return f"{self.start} {self.end}" @full.setter def full(self , startend): ...
cbb846583a576fcd44b702e32f4d7d066b9db98c
DariaKnyazeva/project_euler
/problems/p058.py
1,542
4.25
4
# SPIRAL PRIMES """ Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. 37 36 35 34 33 32 31 38 17 16 15 14 13 30 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 23 24 25 26 43 44 45 46 47 48 49 50 It is interesting to note that the...
3197ff7d892b0d81f45522de61ea2e58c51069b9
fvgm-spec/python_repo
/convert_seconds.py
186
3.734375
4
def convert_seconds(seconds): hours=seconds//3600 minutes=(seconds-hours*3600)//60 remaining_seconds=seconds-hours*3600-minutes*60 return hours,minutes,remaining_seconds
3f423794a202d378c065fc3e0e24c7f14bb04ab8
moemaair/Problems
/strings/python/first_unique_char.py
1,597
3.75
4
""" [FindFirstUniqueChar] Return the first non-repeated character in a string. If not found, return null. Assume the string is NOT sorted. """ #Cases """ 1) Empty or None 2) No repeats 3) Single repeat 4) Multiple repeats (return first found?) 5) 1,2,3 length strings """ #Approaches """ 1) Sort string O(n log n),...
57c1dc1452b209af72ec0a7aad7fbbcc8dab5189
moxwel/utfsm-smoj
/Certamen2/Nuevo/cifradoCesar.py
1,186
3.8125
4
entrada = input() mover = int(input()) mover = mover % 26 # s = [] for x in entrada: s.append(ord(x)) # print(s) strin = "" for x in s: # ASCII, ASCII movido, Es mayuscula? # print(x, x+mover, (x >= 65 and x <= 90)) if (x >= 97 and x <= 122): # Si la letra es minuscula # ASCII movido, ...
4a1e8e95cc56d569b3a413c35507e55e61cfafd1
qmnguyenw/python_py4e
/geeksforgeeks/python/medium/22_6.py
6,141
4.53125
5
Applying Convolutional Neural Network on mnist dataset **CNN** is basically a model known to be **Convolutional Neural Network** and in the recent time it has gained a lot of popularity because of it’s usefullness. CNN uses multilayer perceptrons to do computational works. CNNs use relatively little pre-proc...
5119e1cf8d5c1e7bf2f8e8fbe61fa5d71d2c6c9f
ManavGuru/Portfolio
/Python Stuff/string_sort.py
187
3.828125
4
import re def sort_string(phrase): words = phrase.split(" ") words.sort(key = lambda s: s.casefold()) return words input_1 = input("Enter a phrase: ") print(sort_string(input_1))
dfbf6d642c2b05f643bc8199bcb1e8a2ba685dcf
owaishanif786/python
/intro/funcs.py
562
3.65625
4
def contact_card(name, age, car_model): return f"{name} is {age} and drives a {car_model}" #calling args in sequence contact_card("owais", 28, "bonusCar") #if calling out of order then you have to specify name and value contact_card(age=28, car_model="f1", name="owais") #Positional argument follows keyword argum...
0d79021f33f26f7285df71f4928be8cd8de2d8bf
junyechen/PAT-Advanced-Level-Practice
/1048 Find Coins.py
2,644
3.828125
4
""" Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for each bill, she could only use exactly two coins to pay the exac...
379d346cfe6ccfc2c587a1ba89042c5c0fa996af
Gendo90/HackerRank
/Linked Lists/compare_lists.py
1,799
3.5
4
#!/bin/python3 import math import os import random import re import sys class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None def print_singly_linked_list(node, sep, fptr): wh...
1e826c9ac86e3f33059a42898b565801f89ea114
huyngopt1994/python-Algorithm
/green/green-09-recursive/count_numbers.py
462
3.6875
4
# Using recursion to calculate the numbers, 475 => return 3 , 1242 => 4 # stack for input 345 => (345,0) => (345,0) (34,1) => (345,0) (34,1) (3,2) =>(345,0) (34,1) (3,2) (0,3)(!Ping we got this) def count_number(number,counting): if number == 0: return counting else: return count_number(number/...
5564d154d391e7679efc4204a031f9cc6cb62e52
sirasjad/DCS3101
/vigenere_cipher/vigenere_doublekey.py
2,644
3.828125
4
import string class vigenereCipher(): def __init__(self, key1, key2): self.alphabet = [] self.fillAlphabet() self.key = [key1.upper(), key2.upper()] def fillAlphabet(self): for i in range(26): self.alphabet.append(string.ascii_uppercase[i]) def increaseKeySize(...
1639721e64ffaf30ce946cfed8e64f6aa876536f
seanchen513/leetcode
/math/0296_best_meeting_point.py
9,059
4.28125
4
""" 296. Best Meeting Point Hard A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|...
fafb1c9b847bed98b78a8d2bc6d5c2f18a0dc3ef
AKASHDEEP-ROY/sem-2-assignment-2-computation
/prob13.py
1,024
3.5
4
''' Use Euler's method in a Python code to solve the initial value problem t^2y"-2ty'+2y=t^3ln(t) with 1<t<2, y(1) = 1, and y'(1) = 0 with step size h = 0.001. Plot the solution together with the known exact solution y(t) = 7t/4 + ((t^3)/2)ln(t) - (3/4)t^3 ''' #Akashdeep Roy import numpy as np import matplotlib.pyplot ...
93dc561e83363c0223b408587368a0e63c7480b7
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/msmona001/question3.py
361
4.25
4
#Assignment 2 #Question 3 #Onalerona Mosimege import math area = 0 pi = 2 constant = math.sqrt(2) x = 2/constant while x != 1: pi = pi * x constant = math.sqrt(2 + constant) x = 2/ constant print("Approximation of pi:", str(round(pi,3))) radius = eval(input("Enter the radius:\n")) area = (...
649deaf1f486228612ba2f5c5fcdc7f147c48d7c
mattsuri/unit3
/dotDemo.py
339
3.671875
4
#Matthew Suriawinata #3/1/18 #dotDemo.py - how to use loops with graphics from ggame import * RADIUS = 10 red = Color("0xFF000", 1) dot = CircleAsset(RADIUS, LineStyle(1, red), red) for i in range(12 * 2*RADIUS+10): #place row of dots for j in range(12): Sprite(dot, (10 + i*(2*RADIUS+10) ,10+(2*RADIUS...
22b08dd29baec46ca9ac3ae9feb5999163e4290c
ahmedsabie/cifar-object-recognition
/convex_optimization.py
1,007
3.6875
4
from copy import deepcopy class GradientDescent: ALPHA_MIN = 0.0000001 ALPHA_MAX = 1.0 ITERATIONS = 100 def __init__(self, model): self.model = deepcopy(model) def find_min(self): print ('Iteration: Cost') model = deepcopy(self.model) theta = model.get_theta() ...