blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
89acbe8d001a6c30b34a0575ed35ca0ebde77b6b
Dzhevizov/SoftUni-Python-Fundamentals-course
/Exercise Basic Syntax, Conditional Statements and Loops/05. Can't Sleep Count Sheep.py
104
3.796875
4
count = int(input()) sheep = 1 while sheep <= count: print(f'{sheep} sheep...',end='') sheep +=1
5e4b0447b2ad2a040ee57276cf4bd226417d6be4
qmnguyenw/python_py4e
/geeksforgeeks/algorithm/medium_algo/1_17.py
11,789
3.6875
4
Maximize count of corresponding same elements in given permutations using cyclic rotations Given two permutations **P1** and **P2** of numbers from **1 to N** , the task is to find the maximum count of corresponding same elements in the given permutations by performing a cyclic left or right shift on **P1**. ...
2868ebd3c5b7fc2cc3f6d9df8b6da152ef120cd3
Ulises-Rosas/Fasta-to-Dictionary
/fast_to_dic.v.2.py
1,952
3.875
4
def fas_to_dic(x): ##fasta file is read file = open(x) ##all lines are stored in a variable file_content = file.readlines() ##an empty variable is created to store lines without the ##newline metacharacter symbol (i.e. "\n") seqs_list = [] ##Given this fo...
00219c44cadfa178fd8793cdaca2b8595bde5f28
rubiyadav18/Dictinory_questions
/logical question of hachrank.py
262
3.796875
4
def fun(words): a = {} for word in words: s = "".join(sorted(word)) if s in a: a[s].append(word) else: a[s] = [word] return list(a.values()) words=["eat","tea","tan","ate","nat","bat"] print(fun(words))
a5284a2e08de9135c4b64c91c88f4c76a6d62638
jiabin1122/UITest
/utils/randomUtils.py
298
3.59375
4
# -*- coding: utf-8 -*- # @Author: Jiabin import string import random def generate_random_string(count=10): random_string = ''.join(random.sample(string.letters.lower() + string.digits,count)) return random_string def generate_random_int(min, max): return random.randint(min, max)
c7a30bf508f9efc7d1b8419583fd5c5f081f1706
sunoh/korea-OSS-study
/MIT600/PS02 Using Bisection Search to Make the Program Faster.py
664
3.703125
4
balance = 999999 annualInterestRate = 0.18 monthlyPayment = 0 numMonth = 12 remaining = balance lb = balance / 12 ub = balance * (((1+(annualInterestRate /12))**12) / 12) while True: remaining = balance monthlyPayment = (lb+ub)/2.0 for month in range(numMonth-1): remaining -= mont...
5c8cf9e1b9dde05fa0ab11e47342c736cb5b06c3
denyszamiatin/Monopoly2
/player.py
4,130
3.578125
4
import random import field import observers class Player: """ """ def __init__(self, name, color, bank): """ """ self.name = name self.color = color self.bank = bank self.position = 0 self.previous_position = 0 def roll_dice(self): """...
c7f894ef078102f223c0ba493cb6289263c007cf
qinglujinjin/CS161_Assignment10QL
/reverse_list_QingLu.py
269
3.953125
4
#Author: Qing Lu #Date: 11/06/2019 #Description: Define function to reverses the order of elements in list def reverse_list(lst): """function to reverse elements in a list""" lst.reverse() return lst print(reverse_list([7, -3,12, 9])) #this is a note
5679d54ddaf75c6542baefec30025ac40fed202d
xwang38/groceryPath
/bfs.py
5,131
3.546875
4
row=40 col=40 class Vertex: def __init__(self,x_pos, y_pos, element): self.xPos=x_pos self.yPos=y_pos self.element=element self.visited=False def get_element(self): return self.element def set_element(self, element): self.element=element def get_pos(se...
9723e0d4478647bbeac0cf9950e00c7dce2b2769
Sindhu-dot-R/Python_excercise
/Fibonassi_series.py
336
4.25
4
def recursive_fibo(n): if n <= 1: return n else: return(recursive_fibo(n-1) + recursive_fibo(n-2)) Num = int(input("enter a positive integer ")) if Num >= 0: print("Fibonacci sequence are:") for i in range(Num): print(recursive_fibo(i)) else : print("please enter a p...
13fbc3ed5e4168fbb59ee015c3b7e6c2fb2455e1
banjin/everyday
/questions/fab.py
2,770
3.6875
4
#!/usr/bin/env python # coding:utf-8 """斐波那契数列 """ def fabltion(n): if n < 2: return 1 return fabltion(n-2) + fabltion(n-1) def fabltion2(n): a, b = 0, 1 while n: yield b a, b = b, a + b n -= 1 def fabltion3(n): """斐波契纳数列1,2,3,5,8,13,21............根据这样的规律 编...
3f47a758d55f22406f6469b0cedb49667e7badae
jarechalde/BioInformatics
/Assignment_1/Tournament.txt
1,385
3.71875
4
#In this script we will implement the tournament method to find the maximum and minimum of a number list arr = [1,3,4,76,43,2,4,7,8] maxmin = [None,None] maxminl = [None,None] maxminr = [None,None] def findmaxmin(arr,arr0,arr1): #If the array has only one element, its the maximum and minimum at the same time if a...
86fed104d1f7778afca91ce7c09dbeba279b349f
vijonly/100_Days_of_Code
/Day1/band-name-generator.py
180
3.5625
4
print("Welcome to Band Name Generator.") city = input("What's name of city you grew up in?\n") pet = input("What's your pet name?\n") print(f"Your pet name could be {city} {pet}")
02d38b7b4ce5458b118e4da89c2c7218f17fcabf
Raj-1337/guvi
/pro4_10.py
113
3.546875
4
x = [i for i in input()] t = ['d', 'h', 'i', 'n', 'o'] if sorted(x) == t: print('yes') else: print('no')
7ad30d074e9cad179c5af3520b23c72ae7642d87
dnewbie25/Python-Quick-Reference
/Example Exercises/Basic Exercises/7_Seeing_The_World.py
788
4.3125
4
places_to_visit = ['Japan', 'Germany', 'UK', 'Alaska', 'Canada', 'France'] print(places_to_visit) # Prints the original list print(sorted(places_to_visit)) # Sorted alphabetically, without modifying the original list print(places_to_visit) # The original list print(sorted(places_to_visit, reverse=True)) print(place...
c7c53aa23a476c731bdc278a1949cdff97dd2530
ymougenel/advent-of-code
/2022/day9/main_test.py
553
3.5
4
import unittest import main class main_test(unittest.TestCase): def test_input_example_1(self): data = main.read_file("inputs/part1.example") self.assertEqual(13, main.solve_part1(data)) def test_input_1(self): data = main.read_file("inputs/part1.input") self.assertEqual(6175,...
799e669f1c76035ddec4a74d1d679915fc7f79a4
pujkiee/python-programming
/player level/power.py
205
3.8125
4
def ispower(n,base): if n==base: return yes if base ==1: return no temp=base while (temp<=n): if temp ==n: return yes temp*= base return no
8a36dbd4b2c51883409297f1b67d851ded474c7a
glucn/Python-Practice
/Lynda_Programming Foundation Real-World Examples/Exercise Files/Ch06/06_01_queues.py
606
3.984375
4
""" A Queue of Groceries to Put Away """ # create a new queue object import queue q = queue.Queue() print(q.empty()) # put bags into the queue q.put('bag1') print(q.empty()) q.put('bag2') q.put('bag3') # get bags from the queue in FIFO order print(q.get()) print(q.get()) print(q.get()) # q.get() # c...
ec4082086b5f4cbd431bed42a46b5b43be0cadd8
anpadoma/python_receptury3
/R02/podstawianie_wartości_za_zmienne_w_łańcuchach_znaków/example.py
688
3.5
4
# example.py # # Podstawianie wartości za zmienne w łańcuchach znaków # Klasa przeprowadzająca bezpieczne podstawianie class safesub(dict): def __missing__(self, key): return '{%s}' % key s = '{name} ma {n} wiadomości.' # (a) Proste podstawianie name = 'Gucio' n = 37 print(s.format_map(vars())) # (b) B...
80772db67541b8aa6d77cbb57edcc1d8c4b9bbdd
aabhishek-chaurasia-au17/python_practice
/list/list-exercise/positive_numbers.py
317
4.09375
4
# Python program to print positive numbers in a list """ Input: list1 = [12, -7, 5, 64, -14] Output: 12, 5, 64 Input: list2 = [12, 14, -95, 3] Output: [12, 14, 3] """ def find_positive(a): for i in a: if i > 0 or i == 0: print(i , end=" ") list1 = [12, -7, 5, 64, -14] find_positive(list1)
819369bb02537b696c5d5979fffbdf624f5d36c5
jazib-mahmood-attainu/Ambedkar_Batch
/W3D4 - python 7/preeti.py
81
3.5
4
n = int(input("Enter a number")) for i in range(n): for j in range():
7acb039cc76a7880f0cc92691b445ea94f2f851a
kuangzipeng/Advanced-Programming
/Homework & Practice/Week4_homework/geometry/volume/cube.py
142
3.625
4
def vol_cube(): len = float(input("请输入立方体的边长:")) vol = len*len*len print("立方体的体积是:",vol)
b9e88d4bf7929751327b818843554b4a7a10f420
andernasc/Python-Desaf-Exerc
/Curso em Video - Python/modulo01/desaf-aula07/desafio12-aula07.py
259
3.5625
4
# DESAFIO 12 - AULA 07 - CALCULANDO DESCONTOS PORCENTAGEM 10% preco = float(input("Qual é o preço do produto? R$ ")) desc = preco - (preco * 10 / 100) input("O produto que custava R$ {:.2f} , com o desconto de 10%, custará R$ {:.2f}".format(preco, desc))
a52b300f570ff68910f8ae60cc9bcb8b014a0034
Daransoto/holbertonschool-machine_learning
/math/0x00-linear_algebra/102-squashed_like_sardines.py
1,701
3.703125
4
#!/usr/bin/env python3 """ This module contains the functions matrix_shape, deepcopy, and cat_matrices. """ def matrix_shape(matrix): """ Function to get the shape of a matrix. """ temp = matrix shape = [] while type(temp) == list: shape.append(len(temp)) temp = temp[0] ret...
1b946cee75ccae94eba31665c5a994585b95434f
lyswty/nowcoder-solutions
/2019校招真题编程练习/快手/字符串排序.py
178
3.734375
4
from queue import PriorityQueue m = int(input()) heap = PriorityQueue() for i in range(m): s = input() heap.put(int(s[-6:])) while not heap.empty(): print(heap.get())
b6c24f98119f02383487f4c7ee5812af48270393
aratijadhav/Python
/sum_multiply_6.py
624
4.21875
4
#sum function to add all element in given list def Sum1_Function(list1): add = 0 for val in list1: add = add + val return add #Mult function to multiply all elements in given list def Mult_Function(list1): mul = 1 for val in list1: mul = mul *val return mul if __name__ ...
dd31535b794f3ebe110e38f297ce271de33761d2
sctu/sctu-ds-2019
/1806101005朱强/lab04/test01.py
272
3.921875
4
def reverse_str(input_str): stack = [] target = [] for ch in input_str: stack.append(ch) while len(stack) != 0: ch = stack.pop() target.append(ch) return target if __name__ == '__main__': reverse_str('Hello,World!')
b184e673440bd7a5d33c2bf3b53d95c7a4b445c1
Programmer-Admin/binarysearch-editorials
/Foo Bar Qaz Qux.py
1,475
4.0625
4
""" Foo Bar Qaz Qux LOOK AT OTHER EDITORIAL Three cases: If there is only one unique color: return the length of the string. Now it gets funky. If the frequency are all even or all odd, the answer will be two. Here's my best explanation as to why. At each iteration, we remove one from the frequency of two colors, and...
ce9d13146abf1d263d1592ee2f791c6e0a545ff1
thapadipendra/awesome-python-script
/net_cut.py
2,655
3.65625
4
#!/usr/bin/env python # this program used to cut internet connection in any network. import scapy.all as scapy import netfilterqueue #previously we become middle of connection snd sniff data using two py file # we can also modify packet and can redirect to different path to fake websit or to download backdoor etc # s...
8007715da412f4abe1b30c5746970eb463cc3d06
marvincosmo/Python-Curso-em-Video
/ex087 - Mais sobre matriz em python.py
1,766
4.21875
4
""" 87 - Aprimore o desafio anterior, mostrando no final: A) A soma de todos os valores pares digitados. B) A soma dos valores da terceira coluna. C) O maior valor da segunda linha.""" # Minha resposta: """ matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] pares = terceira = maior = 0 for l in range(0,3): for c in range(0...
1fcd69b844fbf468fbe02f84e687c24053cf562a
ideaOwl/rltoolkit
/RLtoolkit/Quickgraph/graph.py
31,286
3.84375
4
# <html><head><title> Graph.py Source Code </title></head><body><pre> """ Source Code for graph.py, a quickgraphing tool for for Python. See http://rlai.cs.ualberta.ca/RLAI/RLtoolkit/graph.html for <a href=graph.html>documentation</a>. The function graph will draw a graph in a window, with each data line given a ...
2dacc8a5236216d8901875a86b59479197674ad1
Wyrd00/holbertonschool-higher_level_programming
/0x03-python-data_structures/7-add_tuple.py
335
3.828125
4
#!/usr/bin/python3 def add_tuple(tuple_a=(), tuple_b=()): alist = list(tuple_a) blist = list(tuple_b) for i in range(2): alist.append(0) for j in range(2): blist.append(0) sum1 = alist[0] + blist[0] sum2 = alist[1] + blist[1] retur...
221bc3ec443f7c6ff0d0bddb8b3665347a9815d8
Kids-Hack-Labs/Summer2020
/solutions/week03/app.py
752
3.90625
4
''' Kids Hack Labs Summer 2020 - Week 03 code TaskA: Create an app entry point file ''' #1. Game module import (NOT pygame) from game_env import Game #2. Main function definition # 2.1. Create a Game-type variable # (Remember to pass setup parameters) # 2.2. Call the run() function in the variab...
90e96e8773c38e761b62b184c4df89d90a3832a2
CodingGimp/learning-python
/morse.py
959
4.0625
4
''' Let's use __str__ to turn Python code into Morse code! OK, not really, but we can turn class instances into a representation of their Morse code counterparts. I want you to add a __str__ method to the Letter class that loops through the pattern attribute of an instance and returns "dot" for every "." (period) and ...
6f328eef16460332ae33e776d633acd0e4318a3d
asmitde/TA-PSU-CMPSC101
/Spring 2017/Homework/Homework3/Q4.py
1,869
4.03125
4
# Question 4 - Find repeated number # Asmit De # 04/28/2017 ######################################## Solution 1 ######################################### # Input n n = int(input('Enter n: ')) # Enter list data user_input = input('Enter the list: ') nums = [int(n) for n in user_input.split()] # Initiali...
bca372788ed1dfe3e92776525d1e3dbfa210e7ad
AllenGFLiu/geektime
/queue/circle_queue.py
1,667
3.765625
4
# 循環队列特性: # 队列最大的特性就是先进先出,后进后出,最形象的比喻就是排队 # 使用數組實現的非循環順序隊列,會存在數據搬移的問題,均攤時間複雜度為O(1) # 使用循環順序隊列可以避免數據搬移,因為是一個環 # # Author: AllenGFLiu # ##################################################### class CircleQueue(): """基于数组的队列,存储的元素个数是固定的。 head指针指示数组内第一个存储元素的位置 tail指针指示数组内最后一个存储元素位置的后边一位 循環隊列的隊空判定條件是head == ...
400f99f20b4b74cc80e31a70d2b7a7d14122898c
gaoyunqing/MetReg
/MetReg/data/data_preprocessor.py
4,853
3.625
4
import numpy as np import sklearn.preprocessing as prep class Data_preprocessor(): """a class for preprocessing data. Implement basic preprocessing operation, including normalization, interplot, outlier preprocessing, wavelet denoise. # (TODO)@lilu: outlier preprocess # (TODO)@lilu: wavelet den...
d394322dec981c8a5fe79875595d58c3134517b5
si21lvi/tallerlogicaprogramacion
/68.py
615
3.71875
4
contadorpositivo=0 contadornegativo=0 contadorpares=0 contadorimpar=0 multiplosdeocho=0 y=int(input("ingresa el numero")) x=int(input("ingresa el numero")) for i in range(y, x+1): if i>0: contadorpositivo=contadorpositivo+1 if i<0: contadornegativo=contadornegativo+1 if i%2==0: contadorpa...
c4ad5840422ab62362245296af78e3a37b48a74e
csusb-005411285/CodeBreakersCode
/integer-to-english-words.py
6,498
3.53125
4
# concise class Solution: def __init__(self): self.units = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten'} self.teens = {11: 'eleven', 12:'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18:...
026e2b3003ba8e2b8ba0305edb7c8e9a2e471beb
PatrickNyrud/projects
/pirate/config.py
1,841
3.609375
4
import os import sys class config: def __init__(self): self.file_dest = "config\\" self.config = "config.txt" self.keywords = "keywords.txt" self.upcomming = "upcomming.txt" self.isRunning = True while self.isRunning: os.system("cls") print("----------WELCOME-----------\n\n" "1. Edit Movies...
6936d415229cd9008d354abbec89804d09282339
ryoman81/Leetcode-challenge
/LeetCode Pattern/10. Heap & Priority Queue/215_med_kth_largest_element_in_an_array.py
3,298
4.0625
4
''' Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array's leng...
572c2c8e6da47783312554464ccbe4e905cad602
jyanko/script-exercise
/python/cs_adjacentElements.py
1,218
4.25
4
#!/usr/local/bin/python3 ################################## # TASK #4 # # Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. # # Example # # For inputArray = [3, 6, -2, -5, 7, 3], the output should be # adjacentElementsProduct(inputArray) = 21. # # 7 ...
92035e7c4b2a6643723ca46945c7e9d5c823a865
saifhamdare/shortcutstopython
/strfunc.py
140
4.0625
4
print('enter your name') name=input('name') print('enter your age ') age=int(input('age')) print('hello',name,'your age is '+str(age))
f0aa4f4ad9e8605df5c175a15288c848b72f5d4a
csun87/dworp
/dworp/observer.py
4,094
3.59375
4
# Copyright 2018, The Johns Hopkins University Applied Physics Laboratory LLC # All rights reserved. # Distributed under the terms of the Modified BSD License. from abc import ABC, abstractmethod import logging import time class Observer(ABC): """Simulation observer Runs after each time step in the simulati...
8097210dbbd14099bac36c6fa599fe8c7ed459fd
zhaox12134/datamining_project
/title_analyse.py
1,202
3.53125
4
#文章标题同样涵盖了极大的信息,通过比对以进行判断 import json with open("train_pub.json") as file1: pub = json.load(file1) with open("train_author.json") as file2: author = json.load(file2) dict_writer_title = {} def get_title(): for name in author: for writer in author[name]: for article in author[name][write...
3555664eaf9d833c609208d396daba3f6246daee
daideep/Training_Work
/List.py
654
4.09375
4
#Write a function removeFirstAndLast(list) that takes in a list as an argument and remove the first and last elements from the list. # The function will return a list with the remaining items. def removeFirstAndLast(numbers): new = numbers new.pop(0) # if not new: # return new new.pop(-1) ...
920ac39be6c4b94f1e53a6a1a66b6731ffe65152
pty902/Resume
/Algorithm/Recursive Call/Hanoi/hanoi_1.py
328
4.0625
4
def hanoi(n, from_pos, to_pos, aux_pos): if n == 1: print(from_pos, "->", to_pos) return hanoi(n-1, from_pos, aux_pos, to_pos) print(from_pos, "->", to_pos) hanoi(n-1, aux_pos, to_pos, from_pos) print("n=1") hanoi(1,1,3,2) print("n=2") hanoi(2,1,3,2) print("n=3") hanoi(3,...
48b7ec084bfb7244ca62fbcdaee593790540cda5
felipelfb/Python-Katas
/5 kyu/find_the_unique_string.py
1,127
4.28125
4
# There is an array of strings. All strings contains similar letters except one. Try to find it! # find_uniq([ 'Aa', 'aaa', 'aaaaa', 'BbBb', 'Aaaa', 'AaAaAa', 'a' ]) # => 'BbBb' # find_uniq([ 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ]) # => 'foo' # Strings may contain spaces. Spaces is not significant, only non...
fce7e455ae6ea606f591ec34378b8122ca004e8e
bcbarr/homework
/pypoll.py
2,930
3.625
4
import csv import os #variables total_votes = 0 khan_votes = 0 correy_votes = 0 li_votes = 0 tooley_votes = 0 #find the data election_data = os.path.join('Resources', 'election_data.csv') #read the file with open(election_data) as csvfile: # CSV reader specifies delimiter and variable that holds co...
5fbc8bd6aaf9faa5b685a6ee9149beb2413b20fc
hvauchar/Tkinter-Database-Management
/back.py
1,983
3.578125
4
import sqlite3 def connect(): conn=sqlite3.connect("polio.db") cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTs polio (id INTEGER PRIMARY KEY , name TEXT , address TEXT , phone_number INTEGER, Age INTEGER , Dose TEXT , V_id INTEGER)") conn.commit() conn.close() def insert(name,addr...
f6a9c5d9b288af2d37418834927a439c450d3cc0
lnmunhoz/courses
/Python Para Zumbis/Lista de Exercícios III/exercicio03_lucas-nogueira-munhoz_01.py
98
3.96875
4
n = int(input("n: ")) while n < 0 or n > 10: print("Numero Invalido") n = int(input("n: "))
325d470b5cb552b82a9500dc16d148f3c0fc947f
tyrelkostyk/CMPT145
/Ass_08/a8q4.py
1,675
4.09375
4
## Tyrel Kostyk, tck290, 11216033 ## CMPT145-04, Lab Section 04 ## a8q1.py import treenode as tn import treefunctions as tnfun ## NOTE: # I may have misinterpreted the question; I thought that an ordered node was only # ordered if the root was larger than the SUM of the values in the left subtree, # rather than all t...
cc2481540a9d2e073cb5580f0b834f3da1eaf03c
AAUCrisp/Python_Tutorials
/Mads/Intro_exercises_2/Exercise_6.py
267
3.75
4
list1 = ["John", "Jenny", "Barbara"] list2 = ["Green", "Red", "Blue"] Length = len(list1)-1 Length2 = len(list2)-1 tal = int(input('Indsæt tal mellem 0 og {} \n'.format(Length2))) def badfunction(): list1[Length] = list2[tal] print(list1) badfunction()
24df4895a44641801388f14a17b105ff0608f2ed
tstwine/PythonCodeChallenges
/prob3.py
457
4.21875
4
# Write a program that gives the user only three tries to guess the correct pin of the accont. tries = 1 #count = 1 #start off the count pin = 1201 userInput = int( input("Please enter your pin:") ) while userInput != pin and tries <= 3: userInput = int( input("Please re-enter your pin:") ) if userInput == pin: ...
06fb505b1c09bab81a6014edd7037bda12cb1648
Mattnigma/Learning2Code
/Guess the Number Game.py
909
4.03125
4
#!/usr/bin/env python3 #importing stuff from random import seed from random import randint seed() highnumber=1000 chances=10 print("Guess the number between 1 and "+str(highnumber)+"! You have "+str(chances)+" chances!") guessvar = randint(1,highnumber) def get_valid_input(): stab=input("\n") while stab.isdi...
b3abf52708ddf77fa5b8e7841603bcacef1807de
ssbagalkar/PythonDataStructuresPractice
/DP-aditya-verma-playlist/MCM/03_evaluate_expression_to_true_boolean_parenthesization.py
4,009
4.25
4
""" Problem Statement: Evaluate Expression To True-Boolean Parenthesization Recursion Given a boolean expression with following symbols. Symbols 'T' --- true 'F' --- false And following operators filled between symbols Operators & ---boolean AND | --- boolean OR ^ --- boolean XOR Count the num...
c86445a912d7b1cc8c62b58b0834d20f3c63aee1
sindhugudivada/algorithms
/coding_dojo/algos/chapter1_fundamentals/jan-29-2018/linkedlist_toarray.py
429
3.53125
4
from node import Node def createlist(arr): dummy=Node(-1) current=dummy count=0 for i in arr: current.next=Node(i) current=current.next count=count+1 return (dummy.next,count) def createarray(ll): head,count=ll arr=[0]*count while(head): arr[count-1]= head.data count=count-1 head...
82ec22c60a696d9ba16c289fd0eb1b46458672fd
ceden95/self.py
/for_loop2.py
819
4.125
4
#the program creates a list of two numbers- the first is the number of numbers, the second is the number of letters.) def main(): my_str = input("type a sentence with mumbers and letters: ") count_list = numbers_letters_count(my_str) print(count_list) def numbers_letters_count(my_str): """th...
52f507f262a7f29d7f4e7a6f3878f5f5d5e08b4d
jac08h/CurrencyConverter
/main.py
1,698
3.515625
4
from typing import Optional, Tuple from urllib import request from urllib.error import HTTPError import json ConversionData = Tuple[float, str, str] with open("programming/python/currency_converter/freecurrencyapi_key.txt") as fp: key = fp.read().strip() def parse(query: str) -> Optional[ConversionData]: pa...
f3de14b6c24bbc20f2cbb76dfb1b04d2d19d0837
VirenS13117/Reinforcement-Learning
/Ex0/Assignment1/Simulation.py
2,788
3.9375
4
from Assignment1 import Action, State from random import random import matplotlib.pyplot as plt class Simulation: def __init__(self, grid, policy): self.grid = grid self.policy = policy def plot_cumulative_rewards(self, trial_rewards): average_bar = [] for i in range(len(tria...
c27eaf38175745a2e7e6eb4999c39f950b84c257
kharyal/leetcode
/binary_search/binary_search.py
600
3.609375
4
class Solution(): def binary_search(self, arr, num, start, end): if len(arr)==0: return -1 if end == start and arr[start]==num: return start elif end == start: return -1 if end<start: return -1 mid = (start+end)//2 ...
4f16ff2a5eaf87189ce302db1b26b45bf240c0e9
abhinavsp0730/python-ds
/data_structures/strings/swap_commas_and_dots.py
525
3.53125
4
""" Question : Swap commas and dots in a String Examples: Input : 14, 625, 498.002 Output : 14.625.498, 002 """ # This propler can be solved via two popular ways # Using replace() def Replace(str1): str1 = str1.replace(', ', 'third') str1 = str1.replace('.', ', ') str1 = str1.replace('third', '.') return str1...
ae21d3f933cba836a7089cf6f0cd61a781250be5
88b67391/AlgoSolutions
/python3-leetcode/leetcode977-squares-of-a-sorted-array.py
336
3.765625
4
from typing import List class Solution: def sortedSquares(self, A: List[int]) -> List[int]: B = sorted(A, key = abs) # sort by absolute values res = list() for elem in B: res.append(elem*elem) return res # below is testing sol = Solution() print(sol.sortedSquare...
b2e2d09f20264bf2d79aeaef7501ec6227a36a1c
WINKAM/Classification-Metrics-Manager
/classification_mm/classification_mm.py
15,548
3.609375
4
def precision(tp_count, fp_count): """Computes Precision (Positive Predictive Values, PPV). Precision is the fraction of examples labeled positive that are correctly classified among true positive and false positive classifier results. Precision = tp_count / (tp_count + fp_count). If tp_count of fp_...
7083ba87dd5e685f61f3dbb89e9c3528f674ee18
HebertSam/PythonAssignments
/PythonBasic/findChar.py
224
3.6875
4
def findChar (x, y): newList = [] for i in x: if y in i: newList.append(i) print newList word_list = ['hello', 'world', 'my', 'name', 'is', 'Anna'] char = 'o' findChar(word_list, char)
6695096f785b015491cf9c6241bb7d8f3d4a0bb5
mcleavey/insight
/src/main.py
10,868
3.59375
4
from user import * from datetime import datetime from collections import OrderedDict import sys, logging def translate_time(date, time): """ Translates date and time to timestamp Inputs: date: string in year-month-day format time: string in hour:minute:second format Output: datetime ...
1febd9845413e4f85f31417e6b45260666a771e2
KGeetings/CMSC-115
/In Class/Palindrome.py
388
3.984375
4
def cleanUp(x): x = x.lower() for punc in " ,.!@#$%^&*()-=_+{}[]|;:'": x = x.replace(punc, "") return x def isPalindrome(s): s = cleanUp(s) if s == s[::-1]: return True else: return False a = input("What is your word? ") if isPalindrome(a): print("Yay! You...
80459809491d2a2602dd63f5e33314808e32ac44
katerhydron/PYTHON
/HelloWorld.py
1,535
4.28125
4
#!/usr/bin/env python #my first python scrit def wrapper(numberOfWordsInLine): #my first python scrit multiplier = 10 print "Hello World"*multiplier print ("the world" " " "is beatutiful") print (2.3 + 8) #printing strings first = "This" second = " Is" third = " Fucking" forth = " Awesome" print ("%s%s%...
381e20e3433a2b7edbc2dfcd1976184320b8ac58
0kVegas/Python-projects
/Failed hangman.py
1,775
4.09375
4
# -----Imports----- import random # -----Global Variables------ global attempt_count global guess_letters global correct_letters global wrong_letters global wrong_letter_guess_count # -----Potential Words----- potential_words = { 1: 'cat', 2: 'dog', 3: 'bird', 4: 'banana', 5: 'animal', 6: 'loc...
3f936e5b556510ab35efa0898a83bce0cabeb5b3
tripathysamapika5/dsa
/linked_list/doublyLinkedList.py
5,336
4.09375
4
class Node: def __init__(self, value): self.value = value self.prev = None self.next = None class DoublyLinkedList: def __init__(self): self.__size = 0 self.__head = None self.__tail = None def insertStart(self, item): ''' This method inserts an ...
2d5c1d615d8d84d760cca1c5604fe5ff4d024d90
kanishkaverma/leetcode
/grokking/sliding window/max_contignous_subarray_negative.py
370
3.828125
4
def maxSubArray( arr): maxsum, currentSum = arr[0], 0 for end in range(len(arr)): currentSum += arr[end] if currentSum < 0: currentSum= 0 if currentSum > maxsum: maxsum = currentSum; return maxsum def main(): print(m...
0ec541346ba66538c7326df30985b6fd859f89e3
KJRG/JBA-DuplicateFileHandler
/Topics/Args/Theory/main.py
500
4.34375
4
# You can experiment here, it won’t be checked import sys # first, we import the module args = sys.argv # we get the list of arguments if len(args) != 3: print("The script should be called with two arguments, the first and the second number to be multiplied") else: first_num = float(args[1]) # convert a...
83f742dffec26bba6a192403fd8538ec11dec2fc
rppy/course
/for_intro.py
155
4.125
4
# iterating through a list for item in [1, 2, 3, 4, 5]: print(item) print() # iterating through a range (generator) for i in range(6): print(i)
5391bbb659c2d7e408a6db4bb09b68347d29d435
LoralieFlint/learning-python
/BuiltInFunctions.py
500
4.21875
4
# built in python functions phrase = "Hello World" # put to upper case print(phrase.upper()) # puts to upper case then checks for upper case and returns boolean print(phrase.upper().isupper()) # checking the length of a string print(len(phrase)) # finding a character by index on a string to get the character return...
9955d78de624887980fa43ad7832bde09fe888b8
elenaborisova/Python-Fundamentals
/15. Text Processing - Lab/02.repeat_strings.py
98
3.546875
4
words = input().split() result = "".join(map(lambda word: word * len(word), words)) print(result)
f3e86664b2c7e1bd827daf0dc0812e2da96c4464
sccheah/LIN127
/hw1/hw1.py
2,091
3.578125
4
import nltk # returns tuple of total # of words and # 10 most frequent words def get_inaugural_data(filename): words = nltk.corpus.inaugural.words(filename) portrait_freq = nltk.FreqDist(words) return (len(words), portrait_freq) # performs the same operation as get_inaugural_data, but user uses own fil...
198ef03af9578a1eb1e1b8df281cb7b9321f16e3
theshuv/python-Basics
/shubham vohra/q1.py
146
3.984375
4
dic={} def func(n): for i in range(1,n+1): dic[i]=(i*i) print(dic) n=int(input("ENTER THE NUMBER : ")) func(n)
49127c565d177515cbdbaff5428538d82374329e
vsdrun/lc_public
/backtracking/401_Binary_Watch_slow.py
2,132
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right. For example, the above binary watch reads "3:25". Given...
fdcd5b8f618b3c33fd56585aaf184b85b29f7654
lbassett/Leet-Code-Challenges
/GroupAnagrams.py
680
3.96875
4
#Challenge: Group Anagrams # Given a list of strings, return a list of lists where all the strings that are # anagrams are grouped together def groupAnagrams(strs): """ :type strs: List[str] :rtype: List[List[str]] """ tupdict = {} for word in strs: charcount = [0]*26 ...
e84dfa7c42443b836f817c91a05c74b84c5cc189
jrperlic/data-structure-tutorial
/code/2-example-solution.py
345
3.703125
4
from collections import deque def mystery1(ll): for i in reversed(ll): print(i, end=" ") print("") def mystery2(ll): for i in range(0, len(ll), 2): print(ll[i], end=" ") for i in range(1, len(ll), 2): print(ll[i], end=" ") ll = deque([1, 2, 3, 4, 5]) mystery1(ll) # 5 4 3 2 1...
3b8cfde0be63249d01ee55d6baebe3ef7d5b7495
arpiagar/HackerEarth
/implement-trie-prefix-tree/solution.py
2,654
4.09375
4
#https://leetcode.com/problems/implement-trie-prefix-tree/ class Node: def __init__(self,val,endNode=False, childMap=None ): self.val = val if childMap: self.childMap = childMap else: self.childMap = {} self.endNode = endNode class Trie(object): def __i...
87580e955d8a1b483b52465055bbe749bb135ec8
nikita-chudnovskiy/ProjectPyton
/00 Базовый курс/034 Кортежи (tuple)/03 Кортеж явл не изм Объектом.py
1,157
3.90625
4
a = (99,2,3,5,False,[100,200,300],'hi',5,99) print(a.index(99)) # есть ли в списке 5 да под индексом 1 встречающийся элемент print(a.count(5)) # Сколько раз # a[1]=100 не подд изм print(a[4]) a[5].append(400) print(a) # Но в самом кортеже есть список его можно изменить внутри # А зачем нам кортежи print() # Нагляд...
7b097bfc96f883685a60f7d8137fb3b267aaa3fd
ZandbergenM/Week_3_Zandbergen
/Chapter_ 5_Week_3_Zandbergen.py
1,641
4.25
4
#Week 3 Module_Zandbergen #5.1 import time epoch = time.time() #Need to convert to the time of day in hours, minutes, and seconds #Need to determine days since epoch #epoch is in SECONDS def current_time(x): total_hours = x // 60 // 60 #takes dividing by 60 twice to get minutes then hours to get TOTAL number of hours...
47cf8e30bafd8e37d20025765ec29732b3e4db46
luckyparakh/dsa
/pythonds/ch5/coin_change_dp.py
1,918
4.5625
5
# -*- coding: utf-8 -*- ''' With DP A classic example of an optimization problem involves making change using the fewest coins. Suppose you are a programmer for a vending machine manufacturer. Your company wants to streamline effort by giving out the fewest possible coins in change for each transaction. Suppose a cu...
b4268f6e410c1de4866db65f0a0ee319644d6733
codeAligned/interview_challenges
/factorial/factorial.py
201
3.921875
4
def factorial(n): if n >= 1: numbers = list(range(1,n+1)) answer = 1 for number in numbers: answer *= number return answer else: return None
4885eafe85d9447007dead4ac92d7df28035e4e0
yhhaohao555/AlgorithmCHUNZHAO
/Week_06/翻转字符串中的单词3.py
458
3.609375
4
class Solution(object): def reverseWords(self, s): def reverse(word): letters = list(word) i, j = 0, len(letters) - 1 while i < j: letters[i], letters[j] = letters[j], letters[i] i += 1 j -= 1 return "".join(lett...
955851e7943d507b85b87a4c3a92b54e89e988f1
bas20001/b21
/8-7.py
717
3.75
4
def make_album(singer,album_name,album_amount = ''): describe_album = {'musician':singer,'album':album_name} if album_amount : describe_album['album_amount'] = album_amount else : describe_album = {'musician':singer,'album':album_name} return describe_album while True: print("make your own album on it"...
2f615971956b1471e6a8b1d00f32c7cb862eb9f5
Krish695/C-100
/car.py
575
3.578125
4
class Car(object): def __init__(self,model,color,company,speed_limit): self.color=color self.company = company self.speed_limit= speed_limit self.model=model def start(self): print("started") def stop(self): print("stoped") def accele...
ea107ac66e9a3868db9a3dce9245549f56aa5032
BennyAharoni/python_digital
/Lesson1/targil2.py
360
3.984375
4
num = 5 print("Your number is: " + str(num)) print(type(num)) num = num + 2 print(num) num2 = num * 10 print("Your number is: " + str(num)) num = int(input("Enter number: ")) print("Alafim = " + str(num // 1000)) print("Meot = " + str((num % 1000) // 100)) print("Asarot = " + str((num % 100) // 10)) print("Ahadot = " +...
1e85887334cb3d5913e1b11338a50bdca4a14d7b
CarlosCruz10/Mi-proyecto
/Mi-proyecto/time.py
2,035
3.984375
4
from time import sleep import datetime NIGHT_STARTS = 19 DAY_STARTS = 7 HOUR_DURATION = 1 def write_file_and_screen(text, file_name): with open(file_name, "a") as hours_file: hours_file.write("{}{}".format(text, "\n")) print(text) def main(): current_time = datetime.datetime....
4362c37ac7d6bd55441de398f7b108e612101aee
keepforever/udemy-python-tutorial
/old/blockchain-S4L64.py
3,251
3.96875
4
# Keyword argument example allows us to declair vars in any order # or ommit and revert to devalut vals. def keyword_args_example(name, age): print("hello " + name + "aged " + age) # keyword_args_example(age="33", name="Brian") # Define blockchain variable as an empty list blockchain = [] # Function to get last ...
caae49de4c389a404f93ab8fa566628e0940cb4d
raghuprasadks/pythontutoriallatest
/gui/registrationformwithdb.py
2,666
3.609375
4
import sqlite3 conn = sqlite3.connect('registrationnew.db') print("Opened database successfully") conn.execute('''CREATE TABLE REGISTRATIONS (NAME TEXT NOT NULL, EMAIL TEXT NOT NULL, MOBILE INT NOT NULL, PWD TEXT NOT NULL)'''...
48134a6835cb0309d7ed55db1f7ca340f24ff74d
matheusquei/array
/listas3.py
445
3.921875
4
usuarios = [input("Digite o primeiro usuario: "), input("Digite o segundo usuario: "), input("Digite o terceiro usuario: ")] for user in usuarios: if user.lower()=="admin": print("Olá administrador, temos relátorios à observar") elif user.lower()=="user": print("Olá usuario seja bem vindo") ...
067f87f012f6b4e26ea2bcb51f23ab8107e6c555
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/luke/s08/circle.py
1,260
3.734375
4
import math import functools @functools.total_ordering class Circle: def __init__(self, radius=0): self._radius = radius @classmethod def from_diameter(myclass, diameter=0): return myclass(diameter / 2) @property def radius(self): return self._radius @property ...
39b877f7b60c0337d0afd32e765f59d5e9d41bbd
edenuis/Python
/Code Challenges/countInversions.py
1,152
3.96875
4
#Challenge: Count inversions in an array # Inversion Count for an array indicates – how far (or close) the # array is from being sorted. If array is already sorted then # inversion count is 0. If array is sorted in reverse order that # inversion count is the maximum. # ...
55335314e3d4e1ee2b9fe1ccbb2e7bb4c43aec36
Alexandr-94/overone_ez
/third_lesson/task_6.py
167
3.828125
4
s = str(input('введите больше 2 символов' )) print(s[::3]) print(s[1]+s[-1]) print(s.upper()) print(s[::-1]) print(s.isdigit()) print(s.isalpha())
19c6ce9821366d560f4c60d80ab5394eb42b5d06
poi0905/Scientific-Computing
/hw2/dss02.py
351
3.5625
4
# Use DSS to optimize function of two variables from scipy import optimize def f1(x): return x[0]**2-2*x[0]+x[1]**2-4*x[1] f2 = lambda x: x[0]**2-2*x[0]+x[1]**2-4*x[1] def banana1(x): return 100*(x[1]-x[0]**2)**2+(1-x[0])**2 banana2 = lambda x: 100*(x[1]-x[0]**2)**2+(1-x[0])**2 x0 = [0, 0] xopt = optimize...
d3c43f259dd2b6d5f4539e7d4516e86ffa415ca9
parkersell/HackPsu2021
/YouTube.py
1,465
3.765625
4
# Retrieves relevant data from the YouTube search history or watch history .html files of the Google Takeout .zip file. import urllib.parse import html # Returns a list of string data points from the search-history.html file of a user's YouTube data. def searchHistory(filePath): # Getting the important data from ...
2ec0063350d63117236e344afc8b66dc83e95108
pulavartivinay/CSES_problemSet_solutions
/Counting_Rooms.py
1,993
3.5625
4
def DFS(start): queue = [] queue.append(start) visited_list[start] = "True" while queue: s = queue.pop(0) row = int(s/m) column = int(s%m) for action in adjacent_list[s]: if action == "up": if row-1 >=0 and building[row-1][column] =...
a91136d3ae4f411caa813dd508250f3690c97840
HaochenGou/Database
/mini_project1/291 miniproject01-03.py
9,331
3.703125
4
import sys import sqlite3 import datetime from random import randint def __register_birth(self): valid_inputs = False while not valid_inputs: try: # Gather mother's info m_f_name = input("Mother's first name: ") m_l_name = input("Mother's las...