blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e313000d0ee70104ac49026c29e528d2d8754547
Arushi-V/PythonWithCM
/2021.08.05/ques_map.py
469
4.40625
4
# return cube of array using map function. inp = input("Enter array: ") print("type of inp: ",type(inp), inp) inp = inp.split() print("type of inp: ",type(inp), inp) inp_2 = [] for x in inp: inp_2.append(int(x)) print("type of inp_2: ",type(inp_2), inp_2) inp_3 = map(int, input("Enter array: ").split()) print("t...
6cc7e67d4045d505a8c4d91dd42d62011efce42c
jmgamboa/coding-exercises
/easy/trees/sameTree.py
1,008
3.765625
4
# https://leetcode.com/problems/same-tree/ # 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: def isSameTree(self, p_tree: TreeNode, q_tree: TreeNode) -> bool: ...
d1edece5338ee9d658c6803b593945782edf891f
Stefan1502/Practice-Python
/exercise 16.py
909
3.90625
4
# Write a password generator in Python. Be creative with how you generate passwords # - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. # The passwords should be random, generating a new password every time the user asks for a new password. # Include your run-time code in a...
62b5936b4f907a5a672e112ca5a965a6dac0225c
KimDoKy/006793
/introcs-PartialSolutions/1.4/inversepermutation.py
1,214
3.734375
4
#----------------------------------------------------------------------- # inversepermutation.py #----------------------------------------------------------------------- import stdio import sys import stdarray # Accept a permutation of integers from the command line and write the # inverse permutation to standard out...
1b44ab5230c48b00f88d1edbfd7a066759531b32
ChanceRbrts/Senior-Design-Game
/Default/ClassPuzzle2.py
865
3.78125
4
#Now, as you can see, classes have a whole #bunch of functions. The init function is #one that is called to create the object. #ClassPuzzle2 in this case is a subclass, #or a class that builds off a "super" class. #That's what (Solid) and Solid.__init__ does. #Now, this object is stubborn as a Solid #object, but as a M...
6efae1a8f0f00f1c68e2ffda94564098a7ac8903
xiao-xiaoming/DataStructure-BeautyOfAlgorithm
/16.heap/Heap.py
3,471
3.78125
4
# -*- coding: utf-8 -*- __author__ = 'xiaoxiaoming' class Heap: def __init__(self, heap_arr=None, type="max", sort_key=lambda x: x): if type == "min": self.cmp = lambda x, y: sort_key(x) < sort_key(y) else: self.cmp = lambda x, y: sort_key(x) > sort_key(y) if heap_...
d7e942d7dea9767bde940670b5b66eb970f336bb
mhounsom/python-challenge
/PyBank/pybank_main.py
2,259
3.828125
4
import os import csv csvpath = os.path.join(".", "PyBank", "Resources", "budget_data.csv") monthly_revenue_change = [] date = [] total_revenue = 0 total_months = 0 greatest_increase = 0 greatest_increase_month = 0 greatest_decrease = 0 greatest_decrease_month = 0 with open(csvpath, newline = '') as csvfile: ...
3d4d4ab1810ea4a73ac904e6b2d6ef864b651e7c
papalagichen/leet-code
/0024 - Swap Nodes in Pairs.py
896
3.625
4
from ListBuilder import ListNode # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head pre...
70fb5cca07bc4f71654504c674e55597eef6862f
diascreative/VaingloriousEye
/vaineye/ziptostate.py
6,502
3.8125
4
""" Converts zip codes to state codes. Also converts state codes to state names. """ # From data at: # http://www.novicksoftware.com/udfofweek/Vol2/T-SQL-UDF-Vol-2-Num-48-udf_Addr_Zip5ToST.htm def zip_to_state(zip): """Convert the zip or postal code to a state code. This returns None if it can't be converted...
12f7d6752f849764ef414f74a38d57545a17e30c
omegachysis/arche-engine
/demo 003 - Interface Example.pyw
3,122
3.515625
4
#!/usr/bin/env python3 import arche log = arche.debug.log("main") def main(): log.info("starting demo 003") game = arche.Game(width = 1280, height = 800, fullscreen = False, titleName = "ArcheEngine Demo - Interface Example", frame = False, # don't show the ...
ff5f112bd1ce80e7390fa1fb213775ccd3e6cf04
subodhss23/python_small_problems
/find_the_falsehood.py
365
4.0625
4
''' write a function that, given a list of values, returns the list of the values that are False ''' def find_the_falsehoods(lst): new_arr = [] for i in lst: if bool(i) == False: new_arr.append(i) return new_arr print(find_the_falsehoods([0, 1, 2, 3])) print(find_the_falsehoods([""...
7613dfc5d95571789d74b42ba4a2588bb4620cd9
AsmitJoy/Python-Bible
/list comprehensions.py
403
3.96875
4
even_numbers = [x for x in range(1,101) if x%2 ==0] print("There are {} even numbers and they are {} ".format(len(even_numbers),even_numbers)) odd_numbers = [x for x in range(1,101) if x%2 !=0] print("There are {} odd numbers and they are {} ".format(len(odd_numbers),odd_numbers)) words = ["the","quick","brown","J...
91f6f93546e8240aff32445f1e68c11ccfe19d83
wwtang/code02
/tem.py
214
4.25
4
color = raw_input('please select the color: ') if color == "white" or color == "black": print "the color was black or white" elif color > "k" : print "the color start with letter after the 'K' in alphabet"
b9094f11272e7272b4f80ebc4f70280e2917bdf7
kumarUjjawal/python_problems
/one-away.py
909
3.6875
4
# Given two strings write a function to to check if it's one edit or zero edits away. def one_edit_different(s1, s2): if len(s1) == len(s2): return one_edit_replace(s1, s2) if len(s1) + 1 == len(s2): return one_edit_insert(s2, s2) if len(s1) - 1 == len(s2): return one_edit_insert(s2...
a7d99257d530c5d04267b1b979f170020300826c
soulgchoi/Algorithm
/Programmers/Level 3/섬 연결하기2.py
1,046
3.5625
4
def solution(n, costs): parent = {} rank = {} def make_set(v): parent[v] = v rank[v] = 0 def find(v): if parent[v] != v: parent[v] = find(parent[v]) return parent[v] def union(v, u): root1 = find(v) root2 = find(u) if root1 != root2: if rank[root1] > rank[root2]: parent[root2] = root1 ...
644a5841ede807b19d8ca13e4ff26320f5c9b914
AlexAndrDoom/lesson1
/hello.py
309
4.03125
4
print("ПРивет. мир") a=2 b=0.5 print(a+b) a=2.5 b=0.5 print(a-b) a=2 b=2 print(a/b) name= "Alex" b='привет ' x="Hello, {}!".format(name) x=f"Hello, {name}!" print(x) v=input("число") z=int(v)+ 10 print(z) a=int(input()) b=int(input()) print(float(a+b)) d=int(4/3)*3 print(int(d))
9ccb164280db027f0acf217b95223a07249cfa83
melission/Timus.ru
/1607.py
854
3.84375
4
customerPrice, customerProposal, driverPrice, driverProposal = input().strip().split() customerPrice, customerProposal = int(customerPrice), int(customerProposal) driverPrice, driverProposal = int(driverPrice), int(driverProposal) finishPrice = 0 changed = True acc = True if customerPrice > driverPrice: finishPri...
40e814728a51f69746a77108be2b1aab9430fb63
ll996075dd/xuexi
/day-1-4.py
176
3.640625
4
import string s = input('请输入一个字符串:\n') letters = 0 i =0 while i < len(s): c = s[i] i += 1 if c.isalpha(): letters += 1 print ('%d' %letters)
f0560becc21541dfdfa14130878f3a9af9a0b570
hsouporto/Note-Everyday
/Slides_Note/Stanford_Algorithms/PythonCode/Course1/Week1/sortComp.py
3,222
3.9375
4
# -*- coding: utf-8 -*- """ @author: HYJ """ import time ## MergeSort def merge(left, right): result = [] while left and right: if left[0] <= right[0]: result.append(left.pop(0)) else: result.append(right.pop(0)) # 只要 left 或者 right 非空 if left: ...
ddf3e689bcac29fac17f47ff9356d8434173b0a5
Grammer/stepic_python
/23.py
121
3.8125
4
summ = 0 num = 0 while True: a = int(input()) summ += a num += a*a if summ == 0: break print(num)
041c7cecb4f11bafd6833dc6f57185974d29b522
Aradhya910/numberguesser
/numberguesser.py
868
4.125
4
import random number = random.randint(1, 10) player_name = input('What is your name? ') number_of_guesses = 0 print('''Hello! ''' + player_name + " Let's start the game, Press W for instructions. " ) instructions = input('') if instructions.upper() == 'W': print(''' You have to guess a random number be...
843831d46afe9c1a3de0b7491c6fe310693e37ab
stefanFramework/kivy
/coliders.py
592
3.6875
4
from abc import ABC, abstractmethod from characters.characters import Character class CollidDetector: @staticmethod def collides(character1: Character, character2: Character) -> bool: if character1.position.x < (character2.position.x + character2.size.width) and \ (character1.position.x + ...
0a41a13b723da9f471faff33d0e923a4ec1a1175
mokkacuka/datascience
/scatter-plot.py
1,065
4.3125
4
# IMPORT CSV FILE INTO A DATAFRAME # DRAW A PLOT FROM TWO VARIABLES OF DATAFRAME # Import all libraries needed for the tutorial import pandas as pd import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt # Create a Dataframe from a source CSV file df = pd.read_csv('yourFile.csv') df # Round a var...
fb019f1130239371507b68417f1dc8403bbbde46
SwetaAsthana20/ProgrammingPractice
/LeetCode/Easy Module/LinkedList/PalindromeLinkList.py
1,482
3.90625
4
from LinkedListPack.LinkedList import LinkList def get_mid(slow_pointer, fast_pointer): while fast_pointer.next: slow_pointer = slow_pointer.next if not fast_pointer.next.next: break fast_pointer = fast_pointer.next.next return slow_pointer.next def reverse(head): if ...
53fa7d727b412a98b6f6e755e0ba212f26d6e8e2
huynhminhtruong/py
/cp/atcoder/abc_136.py
1,689
3.5
4
import math import os import random import re import sys def sum_numbers(n): res = math.ceil(math.log(n, 10)) s = 1 if math.log(n, 10) % 2 == 0 else 0 for i in range(0, res, 2): k = 10**(i + 1) - 1 if n > k: s = s + 9 * (10 ** i) else: s = s + n - 10**i + 1 ...
12f656bfd1568790f7def2887b527713902fd3e1
joeljoshy/Project
/Collections/Dictionary/Dictionary.py
818
4.3125
4
# Dictionary # Denoted by # dic = {} # Values stored in dictionary by key:value pairs dic = {'name': 'joel', 'Age': 23, 'Height': 6.1, 'Loc': 'EKM'} print(dic) # Supports heterogeneous data # Insertion order is preserved # Duplicate keys not supported # It supports duplicate values # Value can be collecte...
0211f2c2acc3bfd06a7ec9ffe0aa0a1f9bde7af1
weirdkhar/spindrift
/Instruments/gui_plot.py
11,176
3.671875
4
''' AnnotateablePlot Draw and interact with an annotateable plot Author: Kristina Johnson ''' import numpy as np import tkinter as tk import matplotlib.pyplot as plt import matplotlib.patches as mpatches from datetime import datetime as dt import matplotlib from matplotlib.figure import Figure from matplotlib.backends...
4a2dddcee84a7525c6ba2352d52170c2a60ebff4
sol20-meet/sub2p
/Labs_1-7/Lab_6/Lab_6.py
628
3.921875
4
from turtle import * import random import turtle import math class Ball(Turtle): def __init__(self,radius , color , speed): Turtle.__init__(self) self.shape("circle") self.shapesize(radius/10) self.radius = radius self.color(color) self.speed(speed) ball1 = Ball(50 , "red" , 50) ball2 = Ball(50 , "green" ...
82d47b1d2f42d30c9e56f632869b0c475527c85d
imcglo12/Dungeons-and-Monsters
/FirstMenu.py
457
3.953125
4
#This function will display the initial menu options #Imports import MenuSelection as ms #The function def main_menu(): count_1 = 10 while count_1 > 0: option_1 = input("\n\n Please choose an option below\n\n"\ " 1) Create New Character\n"\ " 2) ...
0180e17b6ac705379c8733fc76b763c1d4133afa
melfm/coding-interview-arena
/code/python/maths_questions.py
10,891
4.1875
4
#!/bin/python3 """Maths & Probability Questions.""" import math import numpy as np import sys def divisible_by_r(m, n): """Q: Given two numbers m and n, write a method to return the first number r that is divisible by both - > Least common multiple """ def gcd(m, n): if n == 0: r...
025c740813f7eea37abadaa14ffe0d8c1bedc79d
eric496/leetcode.py
/design/170.two_sum_III_data_structure_design.py
1,116
4.09375
4
""" Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure. find - Find if there exists any pair of numbers which sum is equal to the value. Example 1: add(1); add(3); add(5); find(4) -> true find(7) -> false Example 2: add(3);...
fd8c53ec55048c99cfa0a7a4da6cb565e7806458
paymog/ProjectEuler
/Problems 10-19/Problem14/BruteForce.py
693
3.59375
4
''' Created on Jan 18, 2013 @author: PaymahnMoghadasian ''' from test.test_iterlen import len found_values = {} def find_collatz_length(n): if n == 1: return 1 elif found_values.has_key(n): return found_values[n] else: if n % 2 == 0: return 1 + find_collat...
d0c8dc2d64c55660b08e75b1132de1cf8a9bbe93
LSSTDESC/DC2-production
/scripts/stripe_visits.py
783
3.546875
4
#!/usr/bin/env python """ Take a list of visits and divided them up into num_files by striping through the visit list. E.g., a file with a list from 1-55 with num_files = 10 would get divided up as 1 11 21 31 41 51 2 12 22 32 42 52 3 13 23 33 43 53 4 14 24 34 44 54 5 15 25 55 45 55 6 16 26 66 46 7 17 27 77 47 8 18 28...
b59818c0a7f5f957fb2bbb1190410399f78e7d11
weichuntsai0217/work-note
/programming-interviews/epi-in-python/ch17/Greedy_algorithms_boot_camp.py
530
3.859375
4
from __future__ import print_function def get_min_num_coins_for_change(cents): """ Time complexity is O(1) """ coins = [100, 50, 25, 10, 5, 1] # american coins num_of_coins = 0 for coin in coins: num_of_coins += (cents / coin) cents %= coin return num_of_coins def get_input(hard=False): retu...
ef8f5431d0c0c23d7702482b5fd2160dfcd33641
m-blue/prg105-Ex-16.7-Date-Calculations
/Ex 16.7 Date Calculations.py
938
4.25
4
import datetime def your_age(today, birth): age = today.year - birth.year if birth.month > today.month: age += 1 elif birth.month == today.month: if birth.day >= today.day: age += 1 return age def days_until_birthday(today, birth): if birth.strftime('%j'...
48fd06216c6aaf8ccb0ddc6ceca7fb3c142566eb
seahawkz/python_stack
/_python/OOP/user.py
1,162
3.703125
4
class User: def __init__(self, name, email): self.name = name self.email = email self.account_balance = 0 # deposit def make_deposit(self, amount): self.account_balance += amount # withdrawal def make_withdrawal(self, amount): self.account_balance -= amount ...
b438aca0761f0efbd27083bbe5eee7e1646b6364
sleeperbus/coursera
/Algorithms/Part1/3_sum_brute_force.py
433
3.640625
4
class threeSum: def __init__(self, arr): self.data = arr self.count = 0 def occurance(self): for i in range(len(self.data)): for j in range(1, len(self.data)): for k in range(2, len(self.data)): if self.data[i] + self.data[j] + self.data[k] == 0: self.count = self.count + 1 return self.coun...
ec0a2543a3b520a40b4c3aae57d92a7a7bd0a512
tripathyA5/SD-Project
/sd1.py
470
3.671875
4
import csv import math with open('sdData.csv',newline='') as f: reader=csv.reader(f) fileData=list(reader) data = fileData[0] def mean(data): n = len(data) total = 0 for i in data: total=total+int(i) mean = total/n return mean squareList=[] for number in data: a = int(number)-me...
3b9515786a9eb7f7d1ec73cd4edeeb4c4022d9c9
vdmitriv15/DZ_Lesson_1
/DZ_1.py
712
4.3125
4
# калькулятор отрабатывающий сложение, вычитание, умножение и деление number_1 = int(input("веедите число: ")) number_2 = int(input("веедите второе число: ")) action = input('действие ("+", "-", "*", "/"): ') if action == "+": result = number_1 + number_2 elif action == "-": result = number_1 - number_2 elif a...
6872c426fdcb319e7c70d68a86911a26f7a0372f
harrifeng/Python-Study
/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py
596
3.984375
4
""" Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, and A is now [1,1,2,2,3]. """ class Solution: # @param A a list of integers # @return an integer def removeDuplicates(self, A): ...
220b2bdfdba7a5b59b216155bfdf200fe2c97741
runnersaw/chessAI
/chess.py
52,291
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon May 5 20:23:59 2014 @author: sawyer """ import pygame from pygame.locals import * import sys import time import copy size = (600, 600) all_spaces = [] for i in range(1,9): for j in range(1,9): all_spaces.append((i,j)) class Piece(): def __init__(self, pos...
1ed6a71caebc66136df44815b45e017191e2bb39
jbtanguy/JBTools
/JBTools/evaluate_ocr_results.py
5,433
3.75
4
import os import io import subprocess def get_txt_from_file(file_name): """This function only reads a file and returns its containt. @param: file_name (string): path to the file @return: txt (string): text read in <file_name> """ txt = '' file = io.open(file_name, mode='r', encoding='utf-8') txt += file.read() ...
766dd3499166fafcc2acc49969aad5b8b4c94fa4
tohungsze/Python
/other_python/sort_quick.py
4,073
4.28125
4
""" quick sort """ # find pivot point where everything smaller than it is on the left of it # everything larger than it is on the right # Put everything smaller than the pivot in a list # Put everything larger than the pivot in another # Put everything equal to the pivot in final list # Run quick sort again on the smal...
0b2ff5322d8fecace0fe084077e02c94a5f76208
Adarsh2412/python-
/python6.py
91
3.78125
4
a=int(input("Enter a number")) b=int(input("Enter 2nd number")) c=a+b print(type(a),c)
321a781da1a1a3fed8efe0f610ca44f70f99acef
loetcodes/100-Days-of-Code---PythonChallenge-01
/Day_40_RecursiveListReverse.py
1,074
4.375
4
""" Day 40 - Recursive list reverse Write a function list_reverse(my_list) that takes a list and returns a new list whose elements appear in reversed order. For example, list_reverse([2,3,1]) should return [1,3,2]. Do not use the reverse() method for lists. """ #!/bin/python3 def list_reverse(my_list): """ ...
cb3f5b375355d5760f2f746a65cc758ecf8cf9a0
Asmita-Malakar/PythonProjects
/manage_course_new/course.py
1,192
4.03125
4
#Asmita Malakar #7/11/2021 #Setter method and private variable class Course: def __init__(self, course_code, max_size, enrollment): self.__course_name = course_code self.__size = int(max_size) self.__enrollment = enrollment def add_student(self): if self.__enrollment >= self....
2cb35355081313291659c9865f69abab609c2bb7
vatsan1993/Python-Concepts
/sqliteExample/EmployeeBase.py
537
3.703125
4
class Employee: def __init__(self, first, last, pay): self._first= first self._last=last self._pay= pay @property def last(self): return self._last @property def first(self): return self._first @property def fullname(self): return self.firs...
bad99d29469299ec5cc386dd70061e1325290499
libra202ma/cc150Python
/chap09 Recursion and Dynamic Programming/9_01.py
1,090
4.34375
4
""" A child is running up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs. - same as representing n cents using coins. - whoops, not really. The sequence of hops matters. On the last hop, up to the n-...
e04ce950aaf0bea28e86dc1ef5f94c7452a2de18
jibranabduljabbar/Python-3-Crash-Course
/Complete_Python.py
46,626
4.03125
4
# What Is Python? """ + Python Is a Popular Programming Language. It was created by Guido van Rossum, And Released In 1991. + Python Is a Interpreted Language. + It Is Used For: + 1): Web Development (Server-Side), + 2): Software Dev...
dd5e97d2a15e472764a0fa3a160fb0d5b8484c5e
entrekid/algorithms
/basic/11652/counter.py
336
3.765625
4
from collections import Counter length = int(input()) num_list = [] for _ in range(length): num_list.append(int(input())) num_counter = Counter(num_list) max_num = max(num_counter.values()) key_list = [] for key, value in num_counter.items(): if value == max_num: key_list.append(key) key_list.sort() pri...
00e15bf0e5f128afd98bc2f3865b3395fecb998c
anaCode26/PythonPractice
/Generadores.py
483
3.828125
4
# def generaPares(limite): # num=1 # miLista=[] # while num < limite: # miLista.append(num*2) # num = num + 1 # return miLista # print(generaPares(10)) #------------------------------------------------------ def devuelve_ciudades(*ciudades): for elemento in ciudades: ...
b36554a96c28fbea1b75bd813b393c98f6c7865b
iamsabhoho/PythonProgramming
/Q1-3/MasteringFunctions/ReturnPosition.py
214
4.125
4
#Write a function that returns the elements on odd positions in a list. list = [1,2,3,4,5] def position(): for i in range(len(list)): if i%2 == 0: print(list[i]) return i position()
dc9d12cbfb40e0f1ed7ed91d4736e8fc433c9662
shivanigambhir11/SeleniumPython
/11javaScriptExecuterDemo.py
1,634
3.875
4
#JSE DOM can access any elemenrts on web page just like how selenium does # selenium have a method to execute javascript code in it # let's ee how to access elements with DOM and using selenium from selenium import webdriver driver = webdriver.Chrome(executable_path="/Users/shivanigambhir/Downloads/chromedriver 8.51...
26d0aebf6591c146ef538f681b4ff244c136fd78
HarshithaKP/Python-practice-questions-
/18.py
948
4.15625
4
# Implement a program using CLA for simple arithmetic calculator exmaple: # operand operator operand ie. 10 + 10 / 30 * 20 import sys def addition(num1,num2): summ=num1+num2 print("Sum of two numbers is :",summ) def subtraction(num1,num2): subt=num1-num2 print("Sum of two numbers is :",subt) def multiplication(...
c8d39bd2b8edabc6cbba272cfac0122939b89231
williamgriffiths/Competitive-Programming
/Codeforces/472A. Design Tutorial - Learn from Math.py
322
3.921875
4
n = int(input()) def isPrime(num): for i in range(2,num): if num % i == 0: prime = False break else: prime = True return prime for i in range(n//2,3,-1): if isPrime(i) == False and isPrime(n-i) == False: print(i,n-i) break...
a516b0167364bbc204e2e66b94c5b9cb1f276ad7
masotelof/AComp
/Tiempo/Recorrido_Listas.py
1,407
3.640625
4
import matplotlib.pyplot as plt from random import random from time import time if __name__ == "__main__": # número de ejecuciones iteraciones = 31 # número de iteraciones máximas max_elem = 1000000 # particiones par = 100 size = max_elem/par # Diferentes tamaños para probar num_elem = [ int(size*i) for i i...
349f786e233b1675675d96958b75acc5e4c6b80e
ajit-jadhav/CorePython
/1_Basics/7_ArraysInPython/a3_NumpyArray.py
1,042
4.34375
4
''' Created on 14-Jul-2019 @author: ajitj ''' ########################## Numpy Multi-dimensional array ################################3 ## Program 16 ## create simple array using numpy from numpy import * arr = array([10,20,30,40,50]) # create an array print(arr)#display array ## Program 20 ## creat...
2eeadc9c237f1b5870cd782617cb4bb83e1bcf01
Aasthaengg/IBMdataset
/Python_codes/p02420/s222569418.py
208
3.515625
4
while True: d = input() if d == '-': break h = int(input()) rotate = 0 for i in range(h): rotate += int(input()) move = rotate % len(d) print(d[move:] + d[:move])
7d26553cd027f995ba64a537c54fb436442001fe
manufebie/cs-introduction-to-programming
/assigment_2/alice_n_bob.py
1,840
4.1875
4
import random import os, sys from random import shuffle # The Rules # 1) N stones forming a sequence labeled 1 to N. -> input N stones # 2) Alice and Bob take 2 cosecutive stones until there no consectutive stones left. # the number of the stone left determines the winner # 3) Alice plays first def clear_and_gree...
c4ddae55c811a631d19383cc4e66f5b6f8665c80
rmzturkmen/Python_assignments
/Assignment-14_1-Validate-brackets-combination.py
393
3.6875
4
# Validate-brackets-combination def check(data): cont = True while cont == True: cont = False for i in ["()", "{}", "[]"]: if i in data: cont = True data = data.replace(i, "") return len(data) == 0 print(check("()")) print(check("()[]()")) print...
300c899359a1d4404ebc0af5cb163ba7046c7bdb
silverCore97/pytorch_test_examples
/show_results_gui_table.py
1,052
3.671875
4
import sqlite3 import sys, tkinter # ende function for getting rid of the GUI def ende(): main.destroy() # Verbindung, Cursor connection = sqlite3.connect("ML_data.db") cursor = connection.cursor() # SQL-Abfrage sql = "SELECT * FROM Data" # Kontrollausgabe der SQL-Abfrage # print(sql) # Absend...
9e57cd831b04115cd25922158bd1707dbaf9d1b1
lgc13/LucasCosta_portfolio
/python/practice/personal_practice/lpthw/e22_what_do_you_know_so_far.py
819
4.34375
4
# Learn Python the hard way # Exercise 22: What Do You Know So Far? print "LPTHW Practice" print "E22: What Do You Know So Far?" print "Done by Lucas Costa" print "Date: 01/26/2016" print "Message: you can use 'return' to return something from an equation" print "" random_thing = "variables" pointers_variable = "poin...
f4ff3482374f8c5375a265c465c6e3bfd9b4497d
fiftyfivebells/truck-delivery-optimizer
/ChainedHashTable.py
6,555
3.8125
4
# Stephen Bell: #001433854 import random as r # the number of bytes in an integer w = 32 class HashTable(object): def __init__(self): self.__initialize() # Initializes the internal structure. Sets the size of the hash table to 0, sets the dimension to # 1, gets the random number for hashing, an...
70af260ff5eaa180da241e2d920b5d05b66080c7
AmandaRH07/Entra21_Python
/01-Exercicios/Aula001/Ex2.py
1,265
4.15625
4
#--- Exercício 2 - Variáveis #--- Crie um menu para um sistema de cadastro de funcionários #--- O menu deve ser impresso com a função format() #--- As opções devem ser variáveis do tipo inteiro #--- As descrições das opções serão: #--- Cadastrar funcionário #--- Listar funcionários #--- Editar funcionário #--...
aeab1a7e08d12cfd4123c6f25c3d3fe2960c8ed0
WC2001/wdi
/wdi-1/8.py
172
3.546875
4
def pierwsza(x): i=2 if x==1: return False while i**2 <= x: if x%i == 0: return False i+=1 return True x=int(input()) print(pierwsza(x))
659d98f5d6c965399f3aa5a30f986775438b5229
Cosmo-Not/lesson1
/lesson_exception.py
492
3.546875
4
qa = {"Как дела?": "Хорошо!", "Что делаешь?": "Программирую"} def ask_user(): while True: try: dela = input("Как дела? ") if dela == 'Хорошо': break elif dela in dict.keys(qa): print(f'{qa[dela]}') else: print(f...
058e051fdea1480c3b46ce4352adc391eed9d386
wang-zhe-pro/pycharmcode
/双色球选号.py
1,307
3.859375
4
from random import randrange, randint, sample import random def display(balls): """ 按照题目所要求格式输出列表中的双色球号码 :param balls:双色球号码列表,如[9,12,16,20,30,33 3] :print:输出格式为09 12 16 20 30 33 | 03 :return: 无返回值 """ # 请在此处添加代码 # # *************begin************# s = [] for i in...
e2c0c801c620f80f614819787b90dbc0fdea79c2
devashish89/PluralsightPythonFundamentals
/ItertoolsLibrary.py
1,450
3.796875
4
import itertools # all - AND for list<bool> print(all([name == name.title() for name in ["London", "New York", "United States Of America"]])) #name.title() - all initial letters of words in upper case #any - OR for list<bool> print(any([x for x in range(10) if x%2==0])) # zip - merge lists horizontally mon = [10, 12...
0a70245a06312e49caa022dc9845d0f65cf74813
whoophee/DCP
/leetcode/LRU.py
1,526
3.59375
4
class Node: def __init__(self, key, val): self.key = key self.val = val self.next = None self.prev = None class LRU: def _use(self, key, val): cur = Node(key, val) if not self.ll_begin: self.ll_begin = self.ll_end = cur else: self...
c99c4f855be21d2648f7453930267097ec634330
Jeep123Samuels/Codility_Lessons
/lesson_8/equi_leader.py
2,858
3.984375
4
"""Main script for equi_leader.py""" # A non-empty array A consisting of N integers is given. # # The leader of this array is the value that occurs in more than half of the elements of A. # # An equi leader is an index S such that 0 ≤ S < N − 1 and # two sequences A[0], A[1], ..., A[S] and A[S + 1], A[S + 2], ..., A[N...
cc0e5539384508e94cf01ee1886eeb971d263537
benedict-destiny/triangle-tracker
/triangle.py
793
4.0625
4
while True: print("welcome") A=int(input("enter the the value of side A")) B=int(input("enter the value of side B")) C=int(input("enter the value of side C")) if A==0 or B==0 or C==0: print("0 wacha ufala ushai ona 0 kwa triangle") elif A == B == C: print("the triangle is an equilat...
5a8f30e46f1af69dfe4139bbdce1e3992acb0fe3
hnoskcaj/WOrk
/28.py
218
3.734375
4
i = [[1,2,3],[4,5,6],[7,8,9]] i[1][0] i = [0 for x in range(12)] print(i) j = [0]*12 print(j) i = [[0,0,0]for x in range(3)] print(i) i = [[0]*10 for x in range (10)] print(i) for x in range(len(i)): print(*i[x])
1c9e606feff5ecd06d0b00f893e7e1c6ca9e3fb4
MuhammadSuryono1997/task_python
/009.py
190
3.921875
4
usia = int(input("Masukkan usia : ")) if usia >= 21: print("DEWASA") elif usia >= 13: print("REMAJA") elif usia >= 9: print("BIMBINGAN ORANGTUA") elif usia < 9: print("SEMUA USIA")
dadec2ff51be09b5dd69f11547c44d99c9dbe223
Reidddddd/leetcode
/src/leetcode/python/PathSum_112.py
655
3.71875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class PathSum_112(object): def hasPathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: bool """ def path_sum(node, tmp, su...
30446372af30aabcbcbccbd5219ce066d5476a9c
MrBearTW/TCFST
/Project/datacamp_study/Preprocessing.py
638
3.71875
4
# Import `datasets` from `sklearn` from sklearn import datasets # Load in the `digits` data digits = datasets.load_digits() # Print the `digits` data print(digits) # Import the `pandas` library as `pd` import pandas as pd # Load in the data with `read_csv()` digits = pd.read_csv("http://archive.ics.uci.edu/ml/mach...
b941389af938cb871d26589d640b2e8bcb428fda
wzhy0576/ML
/ex/logicRegression/logicRegression.py
2,294
3.625
4
# -*- coding: utf-8 -*- #ML Andrew-Ng ex1 version1 import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import linear_model def getData(data_frame): #DataFrame to Matrix data_frame.insert(0, 'Ones', 1) #insert in col 0 name Ones value 1 cols = data_frame.shape[1...
a76fa195501ec2696e2e7fe20724c605c093ff0f
chenpeikai/Rice_python
/1/guess_the_number.py
1,441
4.1875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console try: import simplegui except: import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random # helper function to start and restart the game def new...
e3c96282cf434bf8922f9195864d7fc0e0777494
KariimAhmed/Machine-learning-AI
/Linear regression ( gradient descent and normal equation)/sol1_extra.py
3,227
3.890625
4
import matplotlib.pyplot as plt import numpy as np from gradientDescent import * from plotData import * from featureNormalize import * from normalEqn import * #plot data data = np.loadtxt('ex1data2.txt', delimiter=',', dtype=np.int64) X=data[:,0:2] y=data[:,2] m=y.size plt.ion() # turn on plotting interactiv...
2f6c43057eb53ec6f75c50a663e40ee217fe7c82
dom-0/python
/ohwell/global.py
197
3.578125
4
a = 1 b = 2 def fun(x, y): """global a global b""" a = x b = y print ("Within function a = {}, b = {}".format(a, b)) fun(10, 20) print ("Outside function a = {}, b = {}".format(a, b))
4c0615944bf0f5111f857e6a3f2a725ce55dba42
deep0892/Algorithms_Practice
/Leetcode/algorithms-questions/Plus_One.py
988
3.796875
4
# https://leetcode.com/explore/featured/card/top-interview-questions-easy/92/array/559/ """ Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array c...
7abd67ef448d0e7f02ef63094cb1febc66663059
PhD-Strange/infa_2020_PhD_Strange
/lab2_1/turtle_9.py
369
3.90625
4
import turtle import numpy as np pi = np.pi turtle.shape('turtle') turtle.color('red') n = 3 r = 10 def angel(n, m): fi = 360/n while n > 0: turtle.left(fi) turtle.forward(m) n-=1 while n < 13: m = 2*r*np.sin(pi/n) x = (180 - 360/n)/2 turtle.left(x) angel(n, m) turtle.right(x) turtle.penup() turt...
04f91300d880843407c0e1028dfa51b0e544dc07
saturnin13/poetry-generation
/src/RNN_pre_processing.py
1,823
3.796875
4
def extract_characters(shakespeare="shakespeare", combine=True): file = open("data/shakespeare.txt", "r") if shakespeare else open("data/spenser.txt", "r") if shakespeare == "shakespeare": poetry_list_by_line = shakespeare_extract_poetry_list(file) else: poetry_list_by_line = spencer_extrac...
6897d9a77ec7b617009a5b84a5ab00c61ac70192
jayeom-fitz/Algorithms
/CodeUp/Python기초낮은정답률/[기초5-2] 문자열/1754-큰 수 비교.py
759
3.703125
4
""" CodeUp 1754 : 큰 수 비교 https://www.codeup.kr/problem.php?id=1754 """ def swap(n1, n2): return [n2, n1] def comp1(n1, n2): if len(n1) > len(n2) : return True elif len(n1) < len(n2) : return False else : for i in range(len(n1)) : if ord(n1[i]) - ord(n2[i]) == 0 : continue elif o...
f11783d6d1a7830b4327802724b11441045297ac
leebyp/learn-python-the-hard-way
/ex41.py
863
3.828125
4
class : Tell Python to make a new kind of thing. object : Two meanings: the most basic kind of thing, and any instance of some thing. instance : What you get when you tell Python to create a class. def : How you define a function inside a class. self : Inside the functions in a class, self is a variable for the instanc...
fc0a7766f626f88b13b3df993c327f2b18a34400
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mhlsan022/question1.py
735
4.3125
4
'''This program checks whether a string is a palindrome or not Sandile Christopher Mahlangu 4 May 2014''' def palindrome(string): '''This function checks if a string is a palindrome or not using recursion''' if len (string)<=1:#if one word or no words are left in the string and it is a palindrome p...
05a5a1952e06c545ac79d35dd460c426b0fda1a2
behrouzmadahian/python
/TensorflowLearning/02-CNN.py
5,109
4.03125
4
''' A convolutional neural network using Tensorflow. Used data: MNIST database of handwrittern digits. ''' import tensorflow as tf # import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data", one_hot=True) # parameters learning_rate = 0.001...
8cdb41ba9e17ac65fe9d496c02831ed3c663585f
anthonysim/Python
/Intro_to_Programming_Python/cowboyOrder.py
1,290
3.75
4
""" Cowboy Order 1) Create a file with the list '3', '2', '10', '1', '4' named Orders.txt. 2) Take the list of items in Cowboy.txt and calculate the list of items purchased and calculate how much each item will cost plus the grand total. Use Cowboy.txt """ def main(): file = "Cowboy.txt" cowboy = getDat...
125688b9ae21ad67561c0bc76d918bffdd121d45
testowy4u/L_Python_Lutz_Learning-Python_Edition-5
/Part 2/Lutz_Ch_05.py
14,520
4.21875
4
__author__ = 'Rolando' ############################################ #### Part 2: Types and Operations PG 90-315 ### CH 5: Numeric Types PG 133 ############################################ print(40 + 3.14) # Integer to float, float math/result print(int(3.1415)) # Truncates float to integer print(float(3)...
bd62daffc5ee886f2fd2fb215c2a9ffa89d36b72
MacHu-GWU/pyrabbit-python-advance-guide-project
/pyguide/p3_stdlib/c08_datatypes/collections/ordereddict.py
1,459
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Reference: https://docs.python.org/3.3/library/collections.html#collections.OrderedDict """ from __future__ import print_function from collections import OrderedDict import random import sys def maintain_the_order(): """ordered dict iterate items by the order the...
15c4796472646a05c53a7ded01fc8c9845a728a5
810Teams/pre-programming-2018-solutions
/Onsite/1160-Juggling The Ball.py
1,204
3.625
4
""" Pre-Programming 61 Solution By Teerapat Kraisrisirikul """ def main(): """ Main function """ data = {'FOOT': 5, 'LEG': 10, 'HEAD': 15, 'DOWN': 0, 'END LEAW GUN': 0} acts = list() score, down, passed, passed_scr = 0, 0, False, 100 while down < 3: acts.append(input().upper()) if ...
bd858ca8d02a0ac748b70794eb6ead5ba8260a34
joshpaulchan/bayes-spam-filter
/sfilt.py
3,679
3.578125
4
#! /usr/bin/env python3 # Joshua Paul A. Chan # This is an exercise in understanding and implementing the Bayes Theorem as a spam filter. import string class Message(object): def __init__(self, email_to, email_from, body): self.email_to = email_to self.email_from = email_from self.bod...
afb6f9186d50ff22c384d49e2f06c4a2e18b12b1
MattyHB/Python
/EarlyPython/LargerThan50.py
197
4.03125
4
x = 50 y = int(input("Insert Number: ")) if x > y: print("Number is smaller than 50") else: if x ==y: print("Your number is 50") else: print("Number is larger than 50")
e7822cb1ddd920b3fe7d894edc617741180c461f
Anseik/algorithm
/0826_stack/stack3.py
298
3.890625
4
stack = [] stack.append(1) # push stack.append(2) stack.append(3) print(stack) if stack: # len(stack) != 0 # 비어있지 않은지 항상 확인하자!! print(stack.pop()) if stack: # len(stack) != 0 print(stack.pop()) if stack: # len(stack) != 0 print(stack.pop()) print(stack)
e168d6f8c805065bf6291959521ef617c24b8a70
fangzhou/algorithm-practice
/depth_first_search/unique_permutations.py
2,443
3.546875
4
import logging import sys import unittest """ Problem: Given a list of integers, generate all unique permutation series from these integers. The input list may have duplicated numbers. """ def permuter(results, nums, prefix, log): """ DFS based permuter: Args: results: result output list nums: s...
ea8c0e6213edcfd23dec292e42ad38670aab2fbc
thenavdeeprathore/LearnPython3
/Programs/List_Programs/FindListLength.py
376
4.40625
4
# Various ways to find length of the list # 1 test_list = [1, 4, 5, 7, 8] # Printing test_list print("The list is : ", test_list) counter = 0 for i in test_list: # incrementing counter counter = counter + 1 # Printing length of list print("Length of list using naive method is : " + str(counter)) # 2 print(...
c38b4483ec11bd523f7f6e771f4e830b08a28b0d
kamilpierudzki/User-Activity-Classification-Model
/plot_util.py
951
3.53125
4
import matplotlib.pyplot as plt def show_accuracy(history): acc = history.history['accuracy'] val_acc = history.history['val_accuracy'] epochs = range(1, len(acc) + 1) plt.plot(epochs, acc, 'bo', label='Training accuracy') plt.plot(epochs, val_acc, 'b', label='Validating accuracy') plt.title(...
b8b6408914fd0d243fd880ad0c3339f442dd8716
OneCleverDude/shatteredgalaxies
/initialstargeneration.py
10,351
3.53125
4
# # StarSystem Creation # Python 3 project # First python coding attempt # import random import json def spectralclass(argument): # Updated to the table in the VBAM Galaxies Google Doc spectralclass = { 2: "Class O Extremely Bright Blue", 3: "Class B Bright Blue", 4: "Class A Blue-White", ...
ddc96de9135815055997e7833bf7ac5edc7aa6c3
SamBaker95/elephant_vending_machine_backend
/elephant_vending_machine/static/experiment/example_experiment.py
3,811
3.875
4
import random import time def run_experiment(experiment_logger, vending_machine): """This is an example of an experiment file used to create custom experiments. In this experiment, a fixation cross is presented on the center display and the other two displays randomly display either a white, or a black st...
19abf4589b03c1f8dc593bb6b2a446497fe31d72
danielnorberg/aoc2021
/23/day23_part1.py
897
3.5
4
from collections import deque def play(start_cups, n): cups = deque(int(c) for c in start_cups) for i in range(n): current = cups[0] cups.rotate(-1) removed = (cups.popleft(), cups.popleft(), cups.popleft()) cups.rotate(1) destination_label = current - 1 while d...
c482c05b0e8147e6c3edd7c29cbc6a26e0bd8589
randyhelzerman/ng
/python/p.py
2,371
3.5625
4
#!/usr/bin/python import argparse def main(): # find the file to read args = parseArguments() print args returner = parseFile(args.input) print returner if args.start and args.string: stringIterator = iterateString(args.string) success = execute(returner, args.start, stringI...