blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
5a60265d56d150d6934174bdfc59481c84073191
Mukesh656165/Listobj
/tricklist4.py
1,364
4.53125
5
#nested list a_list = ['a', ['bb', ['ccc', 'ddd'], 'ee', 'ff'], 'g', ['hh', 'ii'], 'j'] # to access single item which is in this case[a,g,j] print(a_list[0],a_list[2],a_list[4]) #to access [bb,[ccc,ddd],ee,ff] print(a_list[1]) #to access [hh,jj] print(a_list[3]) #to access bb print(a_list[1][0]) #to access [ccc,ddd] p...
a437f616e71c855865c85991a38d2f800c1ec3f1
cloudjun/algo
/leetcode/leetcode/editor/en/[47] Template - Permutations II.py
1,466
3.578125
4
# Given a collection of numbers, nums, that might contain duplicates, return # all possible unique permutations in any order. # # # Example 1: # # # Input: nums = [1,1,2] # Output: # [[1,1,2], # [1,2,1], # [2,1,1]] # # # Example 2: # # # Input: nums = [1,2,3] # Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,...
f1be7abc3fefe23681ea57302dd6ed695616726b
rizkyramadhana26/tictactoe
/tictactoerizky english.py
2,001
3.875
4
def take_player_step(number_of_steps): if number_of_steps % 2 == 1: player = 'X' #X starts first else: player = 'O' position = input('%s chooses ... (example: 5)' % player) while (position not in ['1','2','3','4','5','6','7','8','9']) or (game_matrix[int(position)-1] == 'X') or (game_matrix...
1d9e8d1493628bf21750dcbb88d3730a411fa3ca
samruddhigole/Practice
/array/python/rotateArray.py
215
4.0625
4
array=[34,2,56,7,3,6,1] def rotateArray(array,x): for num in range (0,x): temp=array[0] for num1 in range(0,len(array)-1): array[num1]=array[num1+1] array[num1+1]=temp print array rotateArray(array,3)
73d579994a151103015fa42158dc3e337de59c48
samruddhigole/Practice
/array/python/max_multiplication.py
488
4.09375
4
def max_mult(array): max_no1=array[0] max_no2=array[1] for num1 in range (1,len(array)): if(array[num1]>max_no1): max_no2=max_no1 max_no1=array[num1] elif(array[num1]>max_no2): max_no2=array[num1] max_multi=max_no1*max_no2 print max_no1, print max_no2 print max_multi num_array=list() num=raw_inpu...
1f115c7c4700746f592c3491cbd66ea3ec40893c
mgabelle/my-local-bunch
/password.py
1,688
4
4
import getpass import re isPassword = False capitalLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def checkNumber(text): if re.search(r"\d", text): return True else: return False def checkCapitalLetters(text): if re.search(r"[A-Z]",text): return True else: return False d...
d521ba7274ab50077a43a60d4520bbb0a7367630
johneegeek/pmb
/Program_III/reverse_str.py
341
3.921875
4
# Our reverse string problem in Python import queue def reverse(str): stack = queue.LifoQueue() for x in str: stack.put(x) s = '' while not stack.empty(): s += stack.get() return(s) # Run your function BackwardsStr = ".desrever neeb evah I" print(rever...
088d69ec3a9c740b14c8a651083935a59c620f84
jack19-meet/meet2017y1lab4
/turtle.shapes.py
188
3.6875
4
import turtle turtle.tracer(1, 0) turtle.ht() num_pts = 1000 #number sides to your drawing for i in range (num_pts) : turtle.left(360/num_pts) turtle.forward(1) turtle.mainloop()
792c526926b6d81f5ea0eb32bb87e1415959baa4
yangliu2/cards
/cards/card.py
1,063
4.15625
4
class Card: def __init__(self, suit, value): self.suit = suit self.value = value self.rank = -1 self.name = self.convert_value_to_name(value) def __str__(self): """give back string name""" return f"{self.name} of {self.suit}" def __repr__(self): ret...
f2830a7e69dff4c2f17ccfe660c39764295b6f9c
smajda/tic-tac-toe
/tic_tac_toe/game.py
9,574
3.5625
4
from itertools import repeat from random import choice from textwrap import dedent class GameException(Exception): pass class Player(object): """ A Tic-Tac-Toe player. Belongs to a game and sets a marker of Game.SQUARE_X or Game.SQUARE_O. Uses a "minimax" algorithm to choose best play. ...
633cf9adaadad858607db184e9495e9a69d41937
aZuh7/Python
/oop.py
1,440
4.25
4
# Python Object-Oriented Programming class Employee: raise_amount = 1.04 num_of_emps = 0 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + "." + last + "@company.com" Employee.num_of_emps += 1 def f...
567c3b801b9679d4b30733df891d558e947fb65a
archisathavale/training
/python/basic_progs/min_max_nums.py
904
4.3125
4
#funtion of finding the minimum number def find_min_val(array): # assigning 1st element of array to minval minval=array[0] # traversing through the array for element in array: # to check whether the next element is smaller than the current if element < minval: # if yes assigning that number to minval ...
cee62cc8bd73c1f9be83e55fdc5e4c4ceb920a55
archisathavale/training
/python/Archis/addressbook.py
790
4.1875
4
addressbook={} # Empty Dictionary # Function of adding an address # email is the key and name is the value def add_address(email , name): addressbook [email] = name #print (addressbook) return (email, name) # Function of deleting an address # only key is enough to delete the value in a dictionary def dele_address(...
bc91ec7c7541085ce7afbf245b42985204783f60
archisathavale/training
/python/Archis/division_class.py
510
3.625
4
class division: def __init__(self,numerator,denominator): self.__num = numerator self.__denom = denominator def perform_division(self): if self.__denom == 0: return "Infinity" else: return (self.__num/self.__denom) def __repr__(self): return...
b7cb2ef6779842010756af1e8da37797dee4c4b5
zhuli19901106/codewars
/valid-braces(AC).py
306
3.515625
4
def validBraces(s): lb = set(['(', '[', '{']) rb = {')': '(', ']': '[', '}': '{'} st = [] for ch in s: if ch in lb: st.append(ch) elif len(st) == 0 or rb[ch] != st[-1]: return False else: st.pop() return len(st) == 0
c3ce36cee6724415a97994880adb7963b89a69ec
zhuli19901106/codewars
/tribonacci-sequence(AC).py
177
3.78125
4
def tribonacci(signature, n): a = signature if n < 3: return a[: n] for i in xrange(3, n): a.append(a[i - 1] + a[i - 2] + a[i - 3]) return a
cc2de6ae6f21c1b6088e69db5ea19166f69dbe84
barnzdan/python
/esent_ref/beehive.py
479
3.796875
4
#!/usr/bin/env python class Behave(object): def __init__(self, name): self.name = name def once(self): print "Hello,", self.name def rename(self, newName): self.name = newName def repeat(self, N): for i in range(N): self.once() beehive = Behave("Queen Bee") beehive.re...
f26eee4a135fe39f56e1d0b0bf97d510a0107121
Vivek1907/project-c98
/swappingFile.py
449
3.640625
4
file1 = input("Enter 1st filename:-") file2 = input("Enter 2nd filename:-") def swapFileData(a, b): f1 = open(a, "r") f2 = open(b, "r") text1 = f1.read() text2 = f2.read() print(text1) print(text2) f1.close() f2.close() f1write = open(a, "w") f2write = open(b, "w") ...
25f65cfbcca1c78f41eb518500e8af3fa9ea365b
Gnakhle/MIT-6.00.1x-
/Week One/PSetOne.py
877
3.75
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 16 22:03:13 2017 @author: Gerald """ #Problem 1 s = 'azcbobobegghakl' vowels = 0 for letter in s: if (letter == 'a' or letter == 'e' or letter == 'i' or letter == 'o' or letter == 'u'): vowels += 1 print("Number of vowels: " + str(vowels)) #Problem 2 s ...
e308d45db8020415cd9e2f753c9e765a12938927
trinity652/Breast-Cancer-Detection
/PlotOfScores.py
2,290
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 9 14:08:34 2017 @author: abhilasha The following code enables you to use various classifiers where features and labels are used to train the classifiers. """ import numpy as np import matplotlib.pyplot as plt import csv from sklearn import svm...
bd1a408a63fda354102dae40ed5b212b3b6b4731
Yoanna-P/pythonFundamentals
/Lecture 2 - practice.py
2,648
3.640625
4
# Integer operations ''' first = int(input()) second = int(input()) third = int(input()) fourth = int(input()) result = int((first + second)/third) * fourth print(result) # Chars to String first = input() second = input() third = input() result = first + second + third print(result) # Elevator n = int(input()) p...
e1e1a9291585e330acaa0f0b52a4affa4d568a9f
s3748430/Python
/module7/7.7.py
954
4.03125
4
phone_book = [] choice = 1 while choice ==1: print("1. Show phone book | 2. Search phone book | 3. Add new entry") choice = int(input("What do you want to do ?")) if choice == 1: for ele in phone_book: print(ele['name'], "-----------", ele['phone_number']) elif choice == 2: ...
f5dc33616f84ff1c1d5428edb8859788ab4414d5
s3748430/Python
/module7/ex1.py
276
3.9375
4
list_of_animal = ['ant', 'dog', 'cat','lion','tiger'] print("Number of animals:", len(list_of_animal)) find = input("I wanna find:") if find in list_of_animal: print("There is a %s in the list of animal"%find) else: print("There is no %s in the list of animal"%find)
8068bf2a0af73d29c2f9912c9b440b485e43ce39
s3748430/Python
/module5/ex4.py
157
4.125
4
num_list = [1,2,3,4,5,6,7,8] total_even_num = 0 for num in num_list: if num % 2 != 0: continue total_even_num += num print(total_even_num)
385efb50fd1726fe30be76ca08ff8a8b6859ca59
blurrrb/randomStuff
/turtle/t.py
690
3.703125
4
from turtle import Turtle from time import sleep from math import ceil,pi fward = 4 lt = 10 color = ['red', 'blue', 'yellow', 'green', 'pink', 'violet', 'brown', 'orange'] n = len(color) d = 0 perD = 360/n turtles = [] for col in color: temp = Turtle() temp.color(col) temp.width(5) temp.left(d) ...
93d48b9b89f9ebaabe098bf46fcea589a96cd384
GuySK/6001x
/minFixPaymentCent.py
2,218
4.125
4
# This program calculates the minimum fixed payment to the cent # for cancelling a debt in a year with the interest rate provided. # minFixPaymentCent.py # def annualBalance(capital, annualInterestRate, monthlyPayment): ''' Calculates balance of sum after one year of fixed payments. Takes capital, interst r...
7cec22ce1e0d966ba7d63d5bcb72dcdb556143f0
GuySK/6001x
/semordnilapSimple.py
273
3.734375
4
def semordnilapSimple(str1, str2): ''' Simple version of semordnilap. Assumes both strs not null with length > 1 No need of recursion here. ''' if str1[0:].upper() == str2[-1::-1].upper(): return True else: return False # end of code
e19161d4378b326e7c2e9f2c0a570d1952f9fd2b
GuySK/6001x
/PS6/Answer/reverseString.py
524
4.46875
4
def reverseString(aStr): """ Given a string, recursively returns a reversed copy of the string. For example, if the string is 'abc', the function returns 'cba'. The only string operations you are allowed to use are indexing, slicing, and concatenation. aStr: a string returns: a reversed...
99f3f78002f89ac7ae5acf04735346e078780d32
GuySK/6001x
/recursiveLength.py
198
4.25
4
def recursiveLength(x): ''' Finds the length of an integer greater than 0 recursively ''' if x == 0: return 0 else: return 1 + recursiveLength(x/10) # end of code
4e7410fee77d106caab46c92cb6e9d978bfb4376
GuySK/6001x
/PS6/Answer/buildCoder.py
661
4.40625
4
def buildCoder(shift): """ Returns a dict that can apply a Caesar cipher to a letter. The cipher is defined by the shift value. Ignores non-letter characters like punctuation, numbers, and spaces. shift: 0 <= int < 26 returns: dict """ import string lowcase = string.ascii_lowercase ...
2d9b308bb95891e46a2f5d6cf8b9a46e7f18e54b
GuySK/6001x
/PS4/Answers/bestWord.py
839
4.28125
4
def bestWord(wordsList): ''' Finds the word with most points in the list. wordsList is a list of words. ''' def wordValue(word): ''' Computes value of word. Word is a string of lowercase letters. ''' SCRABBLE_LETTER_VALUES = { 'a': 1, 'b': 3, 'c': 3, 'd':...
31d73be99547e7c3450449fe98f23a471d4d1203
PaulLaliberte/CSCI3104-Algorithms
/program_assign2/programming_assignment_2_kit/practiceFile.py
1,768
3.75
4
"""Practice file for program assignment 2""" def free_time_intervals(interval_lst, T): missing = [] interval_lst.sort() #O(nlogn) print(interval_lst) x = 0 if interval_lst[0][0] > x: missing.append((0, interval_lst[0][0])) #...
09057189f4ed963cbd5a21f617599dc78e5c927b
PaulLaliberte/CSCI3104-Algorithms
/written_assign1/p2_binaryseach.py
711
3.953125
4
"""Binary search algorithm for finding "peaked" element""" def recursiveFindMax(array, left, right): mid = (left+right)/2 if array[int(mid)] > array[int(mid-1)] and array[int(mid)] > array[int(mid+1)]: return array[int(mid)] elif array[int(mid)] > array[int(mid-1)] and array[int(mid)] < array[int(...
28046d0fee3d16e9c23bd855114a08e4df194320
woojungjang/Tensorflow
/neuralnet/minist20171229.py
1,726
3.609375
4
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np import matplotlib.pyplot as plt mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # # img_row = 28 # img_column = 28 # batch_xs, batch_ys = mnist.train.next_batch(1) # print(type(batch_xs)) # print(batc...
213697adf2ca92e3b258fa29e44c4e72ad099288
baileywickham/programmingCompetition
/lightpurple.py
663
3.546875
4
families = {} famcount = 0 people = int(input()) connections = [input() for _ in range(people)] people_c = int(input()) checks = [input() for _ in range(people_c)] for c in connections: if c.split(" ")[2] in families and c.split(" ")[1] in ["mother", "mom", "father", "dad", "brother", "sister", "daughter", "son"]: ...
729694f504ae898c7bdd14cfd27ca9a54ea12035
mpmsax-estudo/PHP
/python/pythonBrasil/1-estruturaSequencial/exercicio2.py
180
4.21875
4
#!/usr/local/bin/python3 n = float(input("Digite um número\n")); if n >= 0 or n <= 0 : print ("O número digitado foi " + str(n)); else : print ("Favor informar um número");
709f97876dc119e5b94ace9a6be7025c08199688
col-s/ShoppingTest
/tests/test_shopping_cart.py
4,955
3.703125
4
import unittest from shopping.shopping_cart import ShoppingCart from shopping.shopping_item import ShoppingItem class ShoppingCartTest(unittest.TestCase): """Unit tests for Shopping Cart""" def setUp(self): self.shopping_cart = ShoppingCart() self.apple = ShoppingItem('apple', 0.15) s...
488b55bd8c01a823507870727ec559b5125cffe4
romaolucas/polc-exp
/classifiers/multi_svm.py
2,856
3.5
4
import numpy as np import sklearn.datasets as datasets import sklearn.model_selection as model_selection from sklearn.base import BaseEstimator from classifiers.svm import SVMLearn from classifiers.kernelFactory import KernelFactory class MultiSVMLearn(BaseEstimator): ''' Implementation of SVM for multiple cla...
28cbca131958bdc701128c26a600f5dd2156534e
Zakiwil/Hangman
/HangMan1.py
6,570
3.5625
4
from turtle import * from random import randint import time import math wordList = ['abate', 'zaki is amazing','xylophage', 'blandishment','abdicate','abduct',\ 'boisterous', 'dawdle', 'discursive', 'nebulous', 'pungent',\ 'Adversarial', 'Demur', 'Irreconcilable', 'Surmount',\ 'Val...
73c326d39cdc3e90e5bbedc0eddc531c3d0c3203
bonbonben/LeetCode
/Python/To Lower Case.py
424
3.578125
4
# Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. class Solution: def toLowerCase(self, str: str) -> str: res = [] gap = ord('a') - ord('A') for c in str: if ord(c) >= ord('A') and ord(c) <= ord('Z'): re...
131e50266d90572245edf2e9baa05e1a5b8ed93a
bonbonben/LeetCode
/Python/Ugly Number II.py
784
3.921875
4
# Write a program to find the n-th ugly number. # Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. # 1 is typically treated as an ugly number. # n does not exceed 1690. # Input: n = 10 # Output: 12 # Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. ...
bda4d95a01065d351f7b58a45c4d505e2ab983cd
bonbonben/LeetCode
/Python/Longest Common Prefix.py
1,911
4.09375
4
# Write a function to find the longest common prefix string amongst an array of strings. # If there is no common prefix, return an empty string "". # Input: ["flower","flow","flight"] # Output: "fl" # Input: ["dog","racecar","car"] # Output: "" # Explanation: There is no common prefix among the input strings. # hori...
4f454069aab45a699ece5d58c03fcf0de018e430
bonbonben/LeetCode
/Python/Sort List.py
1,377
4.03125
4
# Sort a linked list in O(n log n) time using constant space complexity. # Input: 4->2->1->3 # Output: 1->2->3->4 # Input: -1->5->3->4->0 # Output: -1->0->3->4->5 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: ...
61cfa7194596322198d0cc599890c75740d6220d
bonbonben/LeetCode
/Python/Palindrome Number.py
816
4.09375
4
# Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. #class Solution: # def isPalindrome(self, x: int) -> bool: # if x < 0: # return False # # <object_name>[<start_index>, <stop_index>, <step>] # if x == int(str(x)[::-...
1280ea9c80652c71f04b7153717f48401c3a16ab
wiolaSzczepanik/Exercise
/ex_26.py
604
3.84375
4
def add_sufix(word): last_letter_index = -1 one_before_last_index = -2 consonant = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'X', 'Z', 'W', 'Y'] if word[last_letter_index] == 'e': if word[one_before_last_index] == 'e': ret...
558e998c3e90a107055dba38f27a51223f3378a0
brian-debellu/rt704
/script.py
322
3.71875
4
#!/usr/bin/python3 import random #TACHE 1 num = random.randint(0,10) #print(num) num2 = random.randint(0,10) #print(num2) total1 = num + num2 print("Result task 1:", total1) #TACHE 2 num = random.randint(0,10) #print(num) num2 = random.randint(0,10) #print(num2) total2 = num - num2 print("Result task 2:", total2...
f5a1a973c174d1c8da7ecc240f4ed251c1ecf131
naraharikr/dojos
/missing_alphabet/py/first_missing_alphabet.py
372
3.515625
4
import unittest def first_missing_alphabet(inputString): # Find the first missing alphabet character return -1 class Fma_tests(unittest.TestCase): def test_single_character(self): inString = "b" expectedMissing = "a" foundMissing = first_missing_alphabet(inString) self.assertEqual(expectedMissing, foundMis...
49519ad88af0f0399e5bcf0b466874d996de6366
DanielLenz/AdventOfCode2020
/day09/day09.py
2,364
3.609375
4
from typing import List, Set, Deque, Optional, Tuple from collections import deque import itertools as it RAW = """35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 309 576""" def part1(lines: List[int], len_history) -> Optional[int]: past_products: Deque[Set[int]] = deque() # Initial fill ...
b7ad04164b3666013629a850339e60e83ffd6401
bilal-u/python_code-practics
/pattern_right_angle_triangle.py
262
4.09375
4
n=int(input("Enter a positive integer greater than orequal to 3")) for i in range(1, n+1): # num = 1 a="*" b=" " for j in range(n, 0, -1): if i >= j: print(a, end=' ') else: print(b, end=' ') print("")
a09853362f7f11e1d35e4ec67a822edc4c7a22cc
bilal-u/python_code-practics
/sum-every-third-integer.py
270
3.90625
4
#Write a program using while loop, which prints the sum of every third numbers from 1 to 1001 ( both 1 and 1001 are included) import math #math.ceil(x) sumin=0 i=1 N=1001 qt=N/3 n=math.ceil(qt) #tolterm=res/2 while (i<=n): sumin=sumin+(3*i-2) i=i+1 print(sumin)
2a3c36e00a1c64046f54ec0b5eea485731062e0c
bilal-u/python_code-practics
/longest_word_of_string.py
207
3.9375
4
def find_longest_word(some_string): str_new=some_string.split() count=0 #lon for x in str_new: if len(x)>=count: count=len(x) temp_word=x return temp_word
dc553263619b7e58131a84ead50c08077a5b0178
alinaromanenko/new_project
/main.py
2,766
3.796875
4
def month(schedule): '''Вывод таблицы расписания''' print('{:>10}'.format('| '),end = '') for i in range(1, 32): print(' {:^14} |'.format(str(i)+' декабря'), end = '') x = 9 print('') for i in range(4): date = str(x)+':00' print('{:<8}| '.format(date), end = '') f...
cf2655a535f9faec54a5cdea9a80291fa48a6467
vikasnarwaria/CtCI_PYTHON_SOLUTIONS
/MODERATE/ctci_problems.py
58,596
4.09375
4
from bitstring import BitArray from collections import namedtuple, deque, Counter import math import random # Problem 16.1: Number Swapper: Write a function to swap a number in place (that is, # without temporary variables). ''' Algorithm: 1. First is to use (a+b) to store in a/b. 2. Second is to ...
c88846d43fe8c210c1d0476dcc9d7305a656abfc
LuziaAm/Python
/aulas_python/ListasAninhadas.py
166
3.515625
4
#LISTA ANINHADA list1 = [1, 2, 3] list2 = [4, 5, 6] list3 = [7, 8, 9] matriz = [list1, list2, list3] print(matriz) print(matriz[0]) print(matriz[0][0])
04c453a0bf5319d395a1fab887b2e77a21cba755
LuziaAm/Python
/aulas_python/String.py
658
4.03125
4
nome = "Hello World" print(nome) print(len(nome)) print(nome[-1]) print(nome[:-1]) print(nome[::-1]) print(nome[::2]) print(nome + ' Concatenar!') print(nome[10]*10) print(nome.upper()) print(nome.lower()) print(nome.split()) print(nome.split('W')) #FORMATAÇÃO num = 13.5555 print('Numero: %r St...
6f019190ae04e2eba35b7ef5da729140972fdc41
ColtW27/Command_line_book_search
/test_get_book_data_methods.py
2,390
3.609375
4
import unittest from get_book_data import list_authors_in_string, get_authors, get_title, get_publisher, get_book_to_add_search_list_number, get_list_number_for_book_replacement from sample_test_data import test_volume class TestGetBookDataMethods(unittest.TestCase): def test_list_authors_in_string(self): ...
2c84d4cc959321b696c39cf619449ad6defb3070
atharvvv/python-practice
/occ.py
282
3.828125
4
import operator str = input("Enter a string ") print("String is " ,str) count = {} for x in str: if x in count.keys(): count[x]+=1 else: count[x]=1 sorted_d = dict(sorted(count.items(), key=operator.itemgetter(1), reverse=True)) print(sorted_d)
cec85a8e1acb2412389030e89ec6722bd9c83fbb
Mariappan/LearnPython
/codingbat.com/list_2/centered_average.py
977
4.125
4
# Return the "centered" average of an array of ints, which we'll say is the mean average of the values, # except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, # ignore just one copy, and likewise for the largest value. # Use int division to produce the fin...
c59f438015c567c2c1d92aca082fae5db795d12c
Mariappan/LearnPython
/Excercises/counting.py
1,130
3.828125
4
#!/usr/bin/python import re class Time(): def __init__(self, time): pattern = re.compile(r'(\d+):(\d+)([ap]m)') match = re.search(pattern, time) hr = int(match.group(1)) hr = hr if hr != 12 else 0 self.hours = hr self.minutes = int(match.group(2)) self.time...
da23d9fa4aab466d0d441f816a2e9db70a944f20
fander2468/pythoncrashcourseproblems
/chapter3/greetings.py
259
3.53125
4
names = ['johnny', 'joanna', 'shawn', 'jose', 'chris'] message = 'My favorite friends name is' print(message, names[0].title()) print(message, names[1].title()) print(message, names[2].title()) print(message, names[3].title()) print(message, names[4].title())
d199252c8b681516978b92c79dfcd90052241bdd
fander2468/pythoncrashcourseproblems
/chapter2/hello.py
140
3.796875
4
#May 20, 2020 Fernando S. Anderson - A simple Python program that print a message to the screen mesage = 'Hello Python Crash Course reader!' print(mesage)
0f691485f403702ea151573fc6c4c7a9d874da94
fander2468/pythoncrashcourseproblems
/chapter5/favorite_fruits.py
321
4.03125
4
favorite_fruit = ['bananas', 'oranges', 'pears', 'mangos'] if 'bananas' in favorite_fruit: print('I really like bananas') if 'oranges' in favorite_fruit: print('I really like oranges') if 'pears' in favorite_fruit: print('I really like pears') if 'mangos' in favorite_fruit: print('I really like mangos'...
a526ae92ee3666ac8c88727bc73172ecd80dd728
fander2468/pythoncrashcourseproblems
/chapter8/user_albums.py
692
4.09375
4
def make_album(artist_name, album_title, number_of_tracks = ''): album = {'person_name': artist_name, 'record_name': album_title} if number_of_tracks: album['number_of_tracks'] = number_of_tracks return album while True: print('Enter musician name: ') print('Enter p to quit') musician =...
5db59fc492b8eb7133cda95d87cce420951bcdb6
fander2468/pythoncrashcourseproblems
/chapter3/shrinking_guest.py
1,247
3.875
4
favorite_guest = ['Marcus Aurelius', 'Albert Einstien', 'Jeshua Ben Joseph'] favorite_guest.insert(0, 'Queen Nefertiti') favorite_guest.insert(2, 'Bruce Lee') favorite_guest.append('Steve Jobs') print('Great ' + favorite_guest[0] + ' I invite you to meet to discus your era.') print('Hello ' + favorite_guest[2] + ' I in...
8b6cacf7686af2990cd2ae2dd6c42ba8b10a34fd
fander2468/pythoncrashcourseproblems
/chapter7/dream_vacation.py
448
3.9375
4
vaction_spots = {} active = True while active: user = input('Please enter your name: ') location = input('Please enter a spot you woulr like to visit: ') vaction_spots[user] = location repeat = input("Are there any other users:(yes/no) ") if repeat == 'no': active = False print('Here ...
33f331aed6e62690f0960dfa14432846926b2ad7
hanshihai/pythonHello
/graph/yax2.py
618
3.75
4
import turtle min = -80 max = 80 def main(a): c = -1 / a p1 = a * max p2 = a * min c1 = c * max c2 = c * min turtle.goto(max, 0) turtle.goto(min, 0) turtle.goto(0, 0) turtle.goto(0, max) turtle.goto(0, min) turtle.goto(0, 0) turtle.color("green") turtle.pendown() ...
fb34e12093d490028e1667a24b81ee588e27140a
hanshihai/pythonHello
/turtleSample.py
1,044
3.984375
4
import turtle def thread(max_length): length = 1 turtle.color('red', 'yellow') turtle.begin_fill() while length < max_length: turtle.forward(length) turtle.right(90) length += 5 turtle.end_fill() turtle.exitonclick() return def initPosition(left, up): print("i...
e36bca09ee18731f52f02069cb42786d281348d7
eastflag/python
/hello.py
221
4.03125
4
age = 27 if age < 21: print('No beer for you') elif age > 21: print('OK') else: print('same'); name = "LDK" if name is "AAA": print("AAA"); elif name is "BBB": print("BBB"); else: print("other")
50f4313d5a90067dc60f50000a74548d0ffad72f
eastflag/python
/list.py
369
3.828125
4
foods = ['beacon', 'tuna', 'ham', 'beef'] # for f in foods: # print(f) # print(len(f)) # for x in range(5, 10, 2): # print(x) # buttcrack = 5 # # while buttcrack < 20: # print(buttcrack) # buttcrack += 1 magicNumber = 26 for n in range(100): if n is magicNumber: print(n, ' is magic ...
b2d2ffb1ea21eb0306e2dac852ab787ec9a020ba
dapivei/analisis-numerico-computo-cientifico
/temas/IV.optimizacion_convexa_y_machine_learning/algoritmos/Python/algorithms_for_uco.py
8,757
3.8125
4
import math import numpy as np from numerical_differentiation import gradient_approximation, \ Hessian_approximation from line_search import line_search_by_backtracking from utils import compute_error def gradient_descent(f, x_0, tol, tol_backtracking, x_...
6629a00f0535f27c2b5f2b61285d3ace2003120d
jasonweibel/HyperStream-Python
/Lesson 7 - Rotate Colors.py
506
3.671875
4
import turtle bob = turtle.Turtle() bob.speed(0) flag = True def rotatePinColor(flag): if flag == True: bob.pencolor("blue") else: bob.pencolor("red") return not flag def drawLine(): bob.forward(100) bob.right(30) bob.forward(20) bob.left(60) bob.forward(50) bob.r...
3bd5b189e5a3beb450efad8e39a346d7cd9300c3
lynellf/learing-python
/collections/slices.py
1,944
4.4375
4
# Sometimes we don't want an entie list or string, just a part. # A slice is a new list or string made from a previous list or string favorite_things = ['raindrops on roses', 'whiskers on kittens', 'bright coppeer kettles', 'warm woolen mittens', 'bright paper packages tied up with string', 'cream ...
5fd6323dab3a5e3221775e1be76bab49f7f3f68f
lynellf/learing-python
/python_basics/numbers.py
587
4.34375
4
# Numeric Data three = 1 + 2 print('The number %s' %(three)) # Rounding numbers _float = 0.233 + .442349 rounded = round(_float) print('A number is %s, and a rounded number is %s' %(_float, rounded)) # Converting strings to numbers string_num = '12' int_num = int(string_num) float_num = float(string_num) string_num_t...
ab56a66f168fcba94f4d8a0e90f650b8c073dc65
savvysqrrl3/100Classes
/5dragons.py
1,671
4.03125
4
class Set(object): def __init__(self): self.dragobase = [] def addDragon(self, dragon): self.dragobase.append(dragon) return self def showAll(self): for dragon in self.dragobase: print dragon.name return self class Dragon(object): def __init__(self, name, kind, color, response, legs=4, wings=True,...
3a3fd49f48bc5e473d362fa0ae85f1902d862231
splashell/project_euler_tasks
/2.py
442
3.671875
4
print("Find the sum of fibonacci members below 4 000 000.") fib = [1, 2] num_range = 88888 for i in range(num_range): if i < len(fib): continue first = fib[i-2] second = fib[i-1] fib_num = first + second fib.append(fib_num) fib_sum = 0 for i in fib: print(i) if fib_sum...
4b50befcbfbc46b25e37ef9b7b6f203acc7df21e
kuriako24/kuriako24
/kuriako243.py
176
4
4
num = int(input("Enter a number: ")) if num > 1: for i in range(2,num): if (num % i) == 0: print(num,"False") break else: print num,'->True'
d75db051d1b97a92b7a313753d8ef5ed60432bb9
Dana-Lucas/Data-Science
/Lucas HW6-3.py
2,750
4.03125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 7 23:44:58 2020 @author: Dana """ def index(file,column,row): f = open(file,'r') columns = [] matrix = [] for line in f: # This skips the beginning comments of the file if line[0] == '#': continue ...
201f4d8d8cb9d14c6aac49170a2f7fecbb3cff1a
sadichhhapatil/Inventory-Management-System-ETG
/stocks.py
408
3.53125
4
import json #open the record.json and read all the data from file with open("record.json", "r") as file: txt = file.read() #parse a valid JSON string and convert it into a Python Dictionary. record = json.loads(txt) def addQuantToExistingRecord(record,prod_id): record[prod_id]["quantity"] += 5 ...
a3fdfc65b3340420586f4fa310db842422461899
alishibli97/Data-Intensive-Computing
/spotify_project/spotify_io.py
486
3.6875
4
from pyspark.sql import SparkSession from pyspark.sql.functions import col spark = SparkSession.builder.appName("how to read csv file").getOrCreate() df = spark.read.csv('dataset_with_features.csv',header=True) df_filtered = df.select(col('danceability'), col('energy'), col('key'), col('loudness'), col('mode'), col(...
a5b0aed1c1e8026f9bd4f2a5d02f763e443b6535
arsummers/python-data-structures-and-algorithms
/challenges/ransom_dict/ransom_dict.py
932
3.84375
4
# check if word is in dictionary # print Yes if note can be formed, No if not # case sensitive! which means I don't have to worry about it # put words into separate dicts # since we can't have duplicate keys, each key will have to be numbered # if the number of the key/val pair in the note dictionary is less than or eq...
9164e248c0ed7b1e481fe207edc06b8ddb702215
arsummers/python-data-structures-and-algorithms
/challenges/abs_minimum/abs_minimum.py
775
4.09375
4
""" Given an array of integers, find and print the minimum absolute difference between any two elements in the array. in: arr = [-2, 2, 4] out: 2 algorithm: get all possible pairs using itertools from each pair have base minimum set to the value of the first pair's difference iterate over each pair update minimum i...
a13a3deb0a6c4ebbfad2d5c56b755382f8cb4cef
arsummers/python-data-structures-and-algorithms
/challenges/fizzbuzz_tree/fizz_buzz_tree.py
1,579
3.671875
4
class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None def in_order(self): results = [] def visit(node): # visits left node if node.left: ...
afb15ef4f4409546fd1b2aeb310c875928204aed
arsummers/python-data-structures-and-algorithms
/challenges/fb_challenge/easy/easy.py
1,688
3.828125
4
# problem domain: # write a function that, given a string consisting of a word or words made up from lettters from the word 'instagram', outputs an integer with the number of stickers I will need to buy from collections import Counter def stickers_for(phrase): # do a count to count comparison between the phrase...
ac67a284b0e8e5feb084bbc79e1012a679cd9365
arsummers/python-data-structures-and-algorithms
/challenges/get_edge/graph.py
1,324
3.765625
4
from collections import deque class Graph: def __init__(self): self._vertices = [] def add_vertex(self, value): vert = Vertex(value) self._vertices.append(vert) return vert def get_vertices(self): return self._vertices or None def add_edge(self, vert1, vert2, ...
6ecee9b55b78ce9a47416707d6b009e768f2a24e
arsummers/python-data-structures-and-algorithms
/challenges/tree_intersection/tree_intersection.py
367
3.734375
4
from tree import BinaryTree, Node def tree_intersection(tree_1, tree_2): if tree_1.root == None or tree_2.root == None: return [] tree_1_results = tree_1.in_order() tree_2_results = tree_2.in_order() duplicates = [] for num in tree_1_results: if num in tree_2_results: ...
6203dd89bad719a8003dd573f08865acb6301e10
arsummers/python-data-structures-and-algorithms
/challenges/comparator/comparator.py
1,060
4.3125
4
""" Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided in the editor below. It has two fields: name: a string. score: an integer. Given an array of n Player objects, write a comparator that sorts them in order of decreasi...
642b32bd43d8ae2ed76b0d9f5a3206430afb943f
ShimSooChang/exerciosparatreino
/exercios lacos e lista/7.py
361
3.640625
4
lista = [] vezes = [] for i in range(10): numba=int(input("Type your number: ")) lista.append(numba) print(lista) for i in range(10): counter = lista.count(lista[i]) if counter > 1 and lista[i] not in vezes: vezes.append(lista[i]) for i in range(len(vezes)): print("{} - {} vezes".format(v...
7f32f9eaf26b0a947c691f8d215812d18013e8a1
ShimSooChang/exerciosparatreino
/exercios2/10.py
248
3.953125
4
num = int(input("Digite um número para saber se é primo: ")) cont = 0 x = 0 while x <= num or cont < 2: x += 1 d = num % x if d == 0: cont += 1 if cont <= 2: print("é numero primo") else: print("não é primo")
56a0beff4f815c27069545f3493bc6fb2ea6ed75
ShimSooChang/exerciosparatreino
/para treino/exeparatreino.py
3,572
3.890625
4
janela = [0]*24 corredor = [0]*24 posi = 1 while True: opc=int(input("Digite a opção para escolher a funcionalidade \n 1 = Vender passagem \n 2 = Cancelar passage\n 3 = Mostrar Mapa de lugares \n 4 = SAIR\n: ")) while opc != 1 and opc != 2 and opc != 3 and opc !=4: opc=int(input("Digite somente 1,2,3,...
b937852ce70a3d673ec5d34f7d9b9f6f87a73617
arvakagdi/Basic-Algos
/IterativeBinarySearch.py
1,139
4.25
4
def binary_search(array, target): ''' Write a function that implements the binary search algorithm using iteration args: array: a sorted array of items of the same type target: the element you're searching for returns: int: the index of the target, if found, in the source ...
6234a5ef5c88dc89363250b392c0bc873089fd55
JeffersonDing/CompetitiveProgramming
/CCC/CCC_2021/PREP/j2.py
109
3.546875
4
N = int(input()) k = int(input()) sum = 0 for i in range(k): sum += N N = int(str(N)+"0") print(sum)
58b9de3c84893ff6936ae8073e3f88f18af356ab
MatteoBartoli03/eserciziPython
/2.py
339
3.671875
4
# Variabili x = 100 y = [2, 5, 4, 29] # Lista # Codice for i in y: # Per ogni elemento in y if i % 2 == 0: x -= i else: x += i print(x) for i in y: if i < 5: print('ciao') elif i >= 5: print("arrivederci") elif i == 5: print("bentornato") # Questi if - elif sono nidificati, quindi ne verrà eseguit...
5d70ed1a1550539100a3fcdea99b92527026d090
tjsmith207/Intro-to-Prog
/Stage 2 Projects/S2-4_File.py
4,665
4.375
4
# Lesson 2.4: Making Decisions - If Statements # We'll often write programs that need to make comparisons between values. # We can do comparisons just like we do in math with the < and > signs. # We can also do equality comparisons with != (not equal) and ==. # Comparisons always return a Boolean value (either True or...
737cd2f3252cd3f7f2a20cafe7836b702fd8cc4a
enlambdment/clrs_algorithms
/ch_2/merge_sort_2_3.py
2,322
3.546875
4
import random def merge(ar, p, q, r): # set up new subarray n = r - p + 1 srtd = [None] * n # 0, .., n-1 d = 0 i = p j = q+1 while i <= q and j <= r: if ar[i] < ar[j]: srtd[d] = ar[i] i = i+1 else: srtd[d] = ar[j] j = j+1 d = d+1 # after while loop exits, need to handle # cases where # 1. ...
f0c1b0533e6bb0c63b933a2e7c19c164a63fd116
andres1729/practica-python-1
/4.py
216
3.515625
4
def alfa(numero): resultado = 0 for j in range(1, 5): resultado += numero +2 final = beta(resultado) return final def beta(numero): return numero/2.0 print(alfa(2))
8c7082b3b49fdd35a5fc076ce53e258515169e15
andres1729/practica-python-1
/eje6.py
146
3.859375
4
x = float(input("Ingresa un dividendo:")) y = float(input("Ingresa un divisor")) if y!=0: print("La división es",x/y) print("Fin del programa")
0a09450a8a03de840383517cd3bbd3d849aefcda
andres1729/practica-python-1
/eje7.py
146
3.84375
4
x = int(input("Ingrese x: ")) if x<10: if x>1000: print("1") else: print("2") else: if x>1000: print("3") else: print("4")
866dcafd2e7ed2e8bb7c44565a91569bc6983e4e
julieoh-2013/practice01
/prom08.py
336
3.609375
4
''' 키보드에서 5개의 정수를 입력 받아 리스트에 저장하고 평균을 구하는 프로그램을 작성하시오 실행결과 : > 1 > 2 > 3 > 4 > 5 평균: 3.0 ''' i=0 lst=[] total=0 while(i<5): num = (int)(input(">")) lst.append(num) total += num i+=1 print("평균: {}".format(total/len(lst)) )
e030ab9fb1bb852ddaf84ccf10408a57eb543912
deek11/practice_python
/CheckTicTacToe.py
950
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This script is used to find a winner of Tic Tac Toe from a 3x3 matrix. """ def main(): mx = [['x', 'x', 'x'], [0, 'o', 0], ['o', 0, 'x']] winner = find_winner(mx) if winner != 0: print "Winner = {0}".format(winner) else: ...
16f1014c570a7fc288f820f38343e2caf8ef3e07
deek11/practice_python
/OddEven.py
286
4.1875
4
def find_odd_even(num): if num % 2 == 0: return True return False def main(): num = input("Enter number : ") if find_odd_even(num): print "{0} is even".format(num) else: print "{0} is odd".format(num) if __name__ == '__main__': main()