blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a3d780ba0d331d8cfb4ab4744ca5e72a52e46c16
pjy08062/Winterschool2018
/버튼2.py
238
3.65625
4
from tkinter import * window=Tk() btnList=[None]*3 for i in range(0,3) : btnList[i]=Button(window, text='버튼'+str(i+1)) for btn in btnList : btn.pack(side=TOP, fill=X, ipadx=30, ipady=30, padx=10, pady=10) window.mainloop()
9b93247f815bb4e7d34b5315a7bee02f1e32dc21
Dhivan/Python-All-basics
/class&obj.py
247
3.8125
4
class student: def details(self,name,age): self.name=name self.age=age print('the name is {} age is {}'.format(name,age)) s=student() name=input('Enter name ') age=int(input('enter the age')) s.details(name,age)
7d4b27b0166758cbf9616cb370d81c6b6b7a8d1e
Dhivan/Python-All-basics
/First.py
229
3.5625
4
from tkinter import * root = Tk() def printname(): print('Welcome') frame = Frame(root,width=300, height=300) frame.pack() button1=Button(root,text='click here', command=printname) button1.pack() root.mainloop()
856ff95bf41c2893b19f02dfc920e6c57ada8cf9
collielester86/think-link
/python/wicow_stats/noun_pair_freqs.py
1,435
3.703125
4
#!/usr/bin/env python # encoding: utf-8 """ Count the frequency of each noun that co-occurs with a key noun, but which is not part of the same noun-phrase as that noun. We want nouns that seem to have a subject-verb-object relationship with they keynoun. """ import fileinput import operator as op import nltk impor...
eb646e71880136b0624ab1253cfac575e1c81604
YuliaChornenko/model-classification
/parser/toxic_data.py
1,995
3.71875
4
import pandas as pd class ToxicComments: """ Creating list of toxic comments from default file """ @staticmethod def read_file(file_name=None): """ Reading default file :param file_name: file with toxic comments :return: read file """ fixed_df = p...
e8e552236d727cf005e980829600bc52a20cc74f
fvaldecan/Mock-Python-Interpreter
/input2.py
252
3.90625
4
#Double ForLoop a = 22 b = 11 c = 2 d = c * b first = a / d name = "nicky" *3 print name e = 5 == 5 == 5 f = 5 == 5 == 1 print "Double For loop" for i in range(10): for j in range( 10 ): print "*"* (i+j) print a print b print c print first
71a9c0b288e51cd72b57c6d6aa27679be3add042
ravernhe/python_random_stuff
/Algo/binary_search.py
505
3.703125
4
#!/usr/bin/python # -*-coding:utf-8 -* def binary_search(x, sorted_list): if len(sorted_list) == 1: return False half = len(sorted_list)//2 if x == sorted_list[half]: return half if x < sorted_list[half]: return binary_search(x, sorted_list[:half]) if x > sorted_list[half]: ...
5462c5fdcd69d749bd600c8318f3dff86b9781e9
snakespear/GitHub_code
/python_practice/ex4.py
733
3.890625
4
cars = 100 space_in_the_car = 4 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_the_car average_passengers_in_the_car = passengers/cars_driven print("There are", cars, "cars available") print("There are only", drivers, "drivers available")...
27989368586ffa54f5ac5a9599a95b0b3c726709
Raylend/PythonCourse
/hw_G1.py
681
4.15625
4
""" Написать декоратор, сохраняющий последний результат функции в .txt файл с названием функции в имени """ def logger(func): def wrapped(*args, **kwargs): # print(f'[LOG] Вызвана функция {func.__name__} c аргументами: {args}, {kwargs}') f_name = func.__name__ + '.txt' f = open(f_name, "w") ...
00712b16c692eb709c0f76adb4bc374fbecd0e72
Raylend/PythonCourse
/hw_C1.py
993
3.9375
4
""" Пользователь задаёт список чисел, выведите все элементы списка, которые больше предыдущего элемента """ list = [] t = input("Input your first number or a list of numbers in format x, y, z, ...\nThen press ENTER.\n") if len(t) == 1: t = float(t) list.append(t) while t!="": t = input("Enter ano...
d8b7483f9865f27bb583581d5487746833df1d48
Aron-A/python_learn
/Exercícios/Ex_15.py
449
4
4
def desenha(largura, altura): while (largura > 0): n = altura while n > 0: if (n == largura) and (largura > 1 or n > 1): print(" ") else: print("#", end = "") n = n - 1 print() largura = largura - 1 ...
341afb9ce294b6e65e308f0e322d91fe189f79da
Aron-A/python_learn
/Exercícios/Ex_13.py
232
3.734375
4
def vogcons(n): vogal = ["a" , "e", "i", "o", "u", "A", "E", "I", "O", "U"] if n in vogal: print("Vogal") else: print("Consoante") x = input("Digite uma letra: ") vogcons(x)
7d35f00e993320446346889c2a91ef7007fd1592
ranjitharaju/pyyashu
/game1.py
406
4.09375
4
import random a={1:'rock',2:'paper',3:'scissors'} while True: p=input("Your choice rock/paper/scissors:") c=a[random.randint(1,3)] print("You chose:",p,"Computer chose::",c) if(p==c): print("draw") elif(p=="rock"): if(c=="scissors"): print("u win") elif(p=="paper"): if(c=="rock"): print("computer...
d2822cfa674d1c3701c46e6fd305bf665f26ace4
nkpydev/Algorithms
/Sorting Algorithms/Selection Sort/selection_sort.py
1,030
4.34375
4
#-------------------------------------------------------------------------# #! Python3 # Author : NK # Desc : Insertion Sort Implementation # Info : Find largest value and move it to the last position. #-------------------------------------------------------------------------...
83639850939bbc6784df9a5f0062dce0bcca4bfc
daniel2078/Climaduino-web-controller
/settings/climaduino_programming_sentry.py
2,578
3.53125
4
''' This code checks whether the Climaduino parameters should be changed based on day of the week and time of day. It will be triggered at regular intervals. The code will not check for the exact time, but will rather adjust for whatever the interval it is using is. So, if a 5 minute interval is being used, it is 11:0...
dae243bca04bd1b8280263941aed9d73cdd7c463
mktsy/MiniProject-SmartLight
/relay4port/script5on.py
457
3.53125
4
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # init list with pin numbers pinList = [27] # loop through pins and set mode and state to 'high' for i in pinList: GPIO.setup(i, GPIO.OUT) # GPIO.output(i, GPIO.HIGH) # main loop try: GPIO.output(27, GPIO.LOW) print ("ON")...
41bb37210fcca7004f21be255ff40fc47466ad00
SayidDerder/DofusProject
/venv/Include/Utilities/GetNeighbors.py
1,615
4.09375
4
def get_neighbors(state_matrix, x, y): """ For a given cell, computes the neighbors, check if they are valid and returns a list. :param state_matrix: Matrix containing the state of the game :param x: x coordinate of cell of interest :param y: y coordinante of cell of interest :return: List of va...
9b8f6fca950cfe0852fa5daf70666d356000066f
minhtannguyen/SRSGD
/experiments_with_quadratic_function/Optimizer_Compare_DecayingVarianceNoise.py
13,471
3.515625
4
# -*- coding: utf-8 -*- """ Compare different optimization algorithms with exact gradient 1. GD 2. GD + Constant momentum 3. GD + Constant momentum (Pytorch) 4. GD + Constant momentum (Sutskever) 5. Nesterov Accelerated Gradient 6. Nesterov Accelerated Gradient (Pytorch) 7. Nesterov Accelerated Gradient (Sutskever) 8. ...
9197d3d60ded6acd8d76c581de16cc68dc495b5a
ezhk/algo_and_structures_python
/Lesson_2/5.py
691
4.375
4
""" 5. Вывести на экран коды и символы таблицы ASCII, начиная с символа под номером 32 и заканчивая 127-м включительно. Вывод выполнить в табличной форме: по десять пар "код-символ" в каждой строке. """ def print_symbols(pairs_per_line=10): results_in_line = 0 for i in range(32, 127 + 1): print(f"{i}....
332dd6971f3b52129b320f93d189f02a688376fd
ezhk/algo_and_structures_python
/Lesson_3/7.py
1,384
4.34375
4
""" 7. В одномерном массиве целых чисел определить два наименьших элемента. Они могут быть как равны между собой (оба являться минимальными), так и различаться. """ def search_two_min(arr): absolute_min = second_min = None for el in arr: if absolute_min is None: absolute_min = el ...
5fa54b880761ceeeff5b9e622dc7068361097774
ezhk/algo_and_structures_python
/Lesson_3/1.py
520
3.796875
4
""" 1. В диапазоне натуральных чисел от 2 до 99 определить, сколько из них кратны каждому из чисел в диапазоне от 2 до 9. """ def get_init_range(): i = 2 while i <= 9: yield i i += 1 def get_numbers(number): return 99 // number if __name__ == "__main__": for i in get_init_range(): ...
c277bb58a33df34ead39e4ed445d32e4a1f0bf42
ezhk/algo_and_structures_python
/Lesson_1/6.py
666
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 6. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. def get_symbol_by_positiion(pos): init_value = ord('a') return chr(init_value + pos - 1) if __name__ == '__main__': symbol_pos = int(input("Введите номер буквы в алфавите: ")) i...
8fe3f6fd02e6becf608ec08ca42874b842ba6dc2
gaobo816/0809
/test1.py
1,106
3.53125
4
class Person: def __init__(self,name,life_value,gre): self.name = name self.gre = gre self.life_value = life_value def attack(self,emy): emy.life_value = emy.life_value -self.gre return self.life_value class Dog: def __init__(self,name,dlife_vale,dagres): ...
831d9c6295bcca33ed0fee5449775e2579fe7638
VineetPrasadVerma/Hackerearth
/Challenge/JohnAndBuildings.py
395
3.59375
4
def FindCost(C, Height, N): Height = list(Height) C = list(C) total_cost = 0 for i in range(N-1): if Height[i]>=Height[i+1]: total_cost += 0 else: total_cost += C[i] return total_cost # Write your code here N = int(input()) Height = map(int, input().split(...
23cc7b751ee666d2eb0e57ef8fa23f2b21b239ff
VineetPrasadVerma/Hackerearth
/BasicProgramming/BasicOfInputAndOutput/PalindromicString.py
133
4.09375
4
input_string = input() reverse_string = input_string[::-1] if input_string == reverse_string: print('YES') else: print('NO')
333cd5174594e7e613a49787fc4dedf783b2edc0
PyLamGR/PyLam-Edu
/Workshops/25.11.2017 - Python. The Basics - Volume 1 -/Python Codes/6/3_if_elseif_else.py
165
4.25
4
x = int(input("Give a number: ")) if x == 5: print("The number is 5") elif x == 6: print("The number is 6") else: print("The number is neither 5 or 6")
076d47563c9a8852ea3ca389e3abca680676bb52
melvinkoopmans/high-performance-python
/fibonnaci.py
416
4.125
4
def fibonacci_list(num_items): numbers = [] a, b = 0, 1 while len(numbers) < num_items: numbers.append(a) a, b = b, a+b return numbers def fibonacci_gen(num_items): a, b = 0, 1 while num_items: yield a a, b = b, a+b num_items -= 1 if __name__ == '__ma...
d8c00698f2baf4274685c62c4433182cab511656
chanchalsinghla/HacktoberFest2021-9
/implement_a_trie.py
1,923
4.09375
4
class Trie: def __init__(self): """ Initialize your data structure here. """ self.trie = {} self.trie["value"] = False def find(self, h, key): try: ans = h[key] except: return 0 else: return ans de...
15a13e472a6057a0b3e119af3cba7c1038e6edaf
Abhishekjain0112/My_Python_Codes
/HackerRank_programs/Sub string.py
432
3.78125
4
name = input("Enter the String:") x, y = 0, 0 l = len(name) mylist=list() tup =('A', 'E', 'I', 'O','U') for i in range(l): for j in range(i+1, l+1): s=name[i] #print(s) mylist.append(s) if s[0] in tup: x = x + 1 else: y = y + 1 if x > y: print("...
71be18f0e2ead5265dffa730bf3f56291f5ad948
Abhishekjain0112/My_Python_Codes
/TrainingAssigment1/02_p3.py
189
3.8125
4
n = int(input('Enter Number of rows :')) for i in range(0, n): for j in range(n, i, -1): print(' ', end='') for k in range(0,i+1): print('* ', end='') print()
a833dbd9b7e00f11934243080f9683fd9ea65bee
Abhishekjain0112/My_Python_Codes
/TrainingAssigment1/02_p2.py
132
3.765625
4
n = int(input("Enter Number of rows :")) for i in range(0, n): for j in range(1, n-i+1): print(j, end=' ') print()
c331c40d8dba63b4172eaee80c7ce4cf6c1002a5
ebentz73/Python_test
/test.py
227
3.53125
4
try: # Python 2 xrange except NameError: # Python 3, xrange is now named range xrange = range for i in xrange(1, 101): print(i if i % 5 else "Buzz") if i % 3 else ( "Fizz" if i % 5 else "FizzBuzz")
224aa6988f06d6912e7648eb7241ef6214ac1edb
madbeck/projects
/hashmap/hashmap.py
5,831
3.671875
4
#Hashmap implementation (python) ''' ################################################TEST SUITE for hashmap >>> new_map = hashmap() >>> new_map.constructor(10) [None, None, None, None, None, None, None, None, None, None] >>> new_map.boolean_set('bob',1) 1 >>> new_map [[('bob', 1)], None, None, None, None, None, No...
b182a92891ae553fd27aaaa2fd0f654e6d3e0938
mcormc/udacity-ipnd
/python/count_character.py
229
4.03125
4
def count_character(string, target): total = 0 for ch in string: if ch == target: total += 1 return total # This should return 3, since there are three "o"s: print(count_character("bonobo", "o"))
3efd7833a98ba96e292114d979cd76ca7e9aadcd
qpwoeirut/ConnectFour
/main.py
3,289
4.15625
4
ROWS = 6 COLUMNS = 7 EMPTY = '.' PLAYER_ONE = 'B' PLAYER_TWO = 'R' board = [[EMPTY for _ in range(COLUMNS)] for _ in range(ROWS)] def print_board(): # utility function to print the board to console print() print(' '.join([str(n) for n in range(COLUMNS)])) # print column numbers for row in board: print('...
89e34d107352ac4d53f14dfa1b1b0871094b85b0
wardDes/SandwichMaker
/SandwichMaker.py
3,344
3.625
4
import pyinputplus as pyip, time costs = { 'wheat': 0.20, 'white': 0.10, 'sourdough': 0.30, 'tofu': 0.10, 'turkey': 0.20, 'chicken': 0.30, 'ham': 0.40, 'cheddar': 0.10, 'swiss': 0.20, 'mozzarella': 0.30, 'mayo': 0.10, 'mustard': 0.10, 'lettu...
0c1b80b214878c7d27d9a1aca3a7d6ddb0a07cb2
srikanthraju536/code
/scripts/gny07a.py
1,060
3.734375
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: dvdreddy # # Created: 03/11/2012 # Copyright: (c) dvdreddy 2012 # Licence: <your licence> #------------------------------------------------------------------------------...
4e216faa7112377481e2db396167e631b94d6610
srikanthraju536/code
/scripts/iwgbs.py
702
3.546875
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: dvdreddy # # Created: 17/02/2012 # Copyright: (c) dvdreddy 2012 # Licence: <your licence> #------------------------------------------------------------------------------...
046cb14334380ac239796cd65f1d8d1eb7731094
srikanthraju536/code
/scripts/bhishop.py
549
3.515625
4
#!/usr/bin/env python import string def toint(s): return int(s) def get_int(): s=raw_input() return int(s) def get_line_int(): s=raw_input() arr=string.split(s) arr=map(toint,arr) return arr def size(s): return len(s) def main(): while 1: try: s...
8515e351074e62e8e69e9dc17ea2eb6cdc128e0e
farhanaroslan/python-playground
/veggies.py
567
4.03125
4
#Farhana Roslan and Koshi Murakoshi import csv vegetables = [ {"name": "eggplant", "color": "purple"}, {"name": "tomato", "color": "red"}, {"name": "corn", "color": "yellow"}, {"name": "okra", "color": "green"}, {"name": "arugula", "color": "green"}, {"name": "broccoli", "color": "green"}, ] #In the loop, writ...
298b0658d737ee604cc21b1edcdf5ce725dbfef3
colinwd/ctci
/chapter1/question8.py
271
3.84375
4
# Assume you have a method `isSubstring` which checks if one word is a substring of another. Given two strings, `s1` and # `s2`, write code to check if `s2` is a rotation of `s1` using only one call to `isSubstring` (e.g., "waterbottle" is a # rotation of "erbottlewat").
4cb75a34e0f6806c8990bc06079272effbc2451c
patrickdeyoreo/holbertonschool-interview
/0x19-making_change/0-making_change.py
1,161
4.15625
4
#!/usr/bin/python3 """ Given a list of coin denominations, determine the fewest number of coins needed to make a given amount. """ def makeChange(coins, total): """ Determine the fewest number of coins needed to make a given amount. Arguments: coins: list of coin denominations total: total...
703548dbe6d9ab7fc7eb26c7145a4967deb77201
Sakshi-2020/My-Captain-Python-
/file_extension.py
197
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 11 22:13:41 2021 @author: ssing """ fn= input("Input the Filename: ") f = fn.split('.') print ("The extension of the file is : " + f[-1])
4c4662c3f87c4fbc0be7d8322a741df187d2f5b5
Nikita53/python-class
/pie.py
150
4.09375
4
PI = 3.1416 radius = raw_input('enter radius of circle(meters):') area = PI * float(radius) ** 2 print("\narea of circle = %.2f sq. meters" % area)
31d07fd3332e0b6ca050f4ee3df184451287d710
gauborg/code_snippets_python
/14_power_of_two.py
1,220
4.625
5
''' Description: The aim of this code is to identify if a given numer is a power of 2. The program requires user input. The method keeps bisecting the number by 2 until no further division by 2 is possible. ''' def check_power_of_two(a, val): # first check if a is odd or equal to zero or an integer ...
f65d53c042bebae591090aebbf16b3b155e0eee2
gauborg/code_snippets_python
/7_random_num_generation.py
1,416
4.5
4
''' This is an example for showing different types of random number generation for quick reference. ''' # code snippet for different random options import os import random # generates a floating point number between 0 and 1 random1 = random.random() print(f"\nRandom floating value value between using random.random(...
1a43399846eb6fb18cb1d67f98e89a2b48ad6591
itwill009/TL
/prepare for coding test/structure/linkedlist.py
1,380
3.96875
4
# -*- coding: utf-8 -*- """ Created on Mon May 28 17:16:29 2018 @author: cdh66 """ class Node: def __init__(self,item): self.val = item self.next = None class LinkedList: def __init__(self,item): self.head = Node(item) def add(self,item): cur = self.head ...
0fa0b497237955c3d8206973c25f8932b2e383f0
jkamby/portfolio
/docs/trivia/commandLineArguments/twoints.py
657
3.5625
4
# ----------------------------------------------------------------------- # twoints.py # ----------------------------------------------------------------------- import stdio import sys # Accept two +ve integers as command-line arguments. Writes 'Both' if # they are mutually divisible, 'One' if one is divisibl...
7ee6bdfa257c5b815d07d96df0e886826146606c
jkamby/portfolio
/docs/trivia/arrays/transpose.py
669
4
4
# ----------------------------------------------------------------------- # transpose.py # ----------------------------------------------------------------------- import stdio import sys # Transposing a two-dimensional array (of ints). # This program is designed to prompt for input stdio.writeln('Prepare t...
2c17e2b6ed89bebf30bbf9a2f25bb8f0793c0019
jkamby/portfolio
/docs/trivia/modulesAndClients/realcalc.py
1,358
4.15625
4
import sys import stdio def add(x, y): """ Returns the addition of two floats """ return float(x) + float(y) def sub(x, y): """ Returns the subtraction of two floats """ return float(x) - float(y) def mul(x, y): """ Returns the multiplication of two floa...
bf6cbe715b8b69eb6986923928f979b8bfdcdafe
shajia1234/PIAIC_python
/june18.py
1,160
3.765625
4
# #*********ADD SUBTRACT MUTIPLY DIVIDE**************** # a=int(input("enter 1st no.")) # b=int(input("enter 2nd no.")) # def add(num1 , num2): # sum=num1+num2 # print(sum) # add(a,b) # def sub(num1 , num2): # minus=num1-num2 # print(minus) # def mult(num1 , num2): # prdct=num1...
322198418ae857e1cf588edf7202b4c0ec469dff
helenefialko/python_basic_course
/l5_functions/homework/functions_hw.py
2,790
3.65625
4
import os def card_has_errors(): region = os.environ.get('CARD_TYPE', 'Europe') if region == 'China': num = card_has_errors_china() else: num = card_has_errors_europe() return num def card_has_errors_china(): temp_num = [] while True: if len(temp_num) == 3: ...
ac438a71aaa9ce9aa8a1a060e228233cefdb6131
cwroblew/ud036_StarterCode
/media.py
773
3.53125
4
import webbrowser class Movie(): """ This class provides a way to store movie related information Args: movie_title (str): Title of movie movie_storyline (str): Brief description of the story line of the movie poster_image (str): URL of an image to be used for the movie ie poster ...
468f67d5824d3a42ce0d7d5ee80b13c67199c86b
Dianeha/TIL
/00_startcamp/day03/quiz.py
1,983
3.84375
4
# words = input('입력하세요: ') # 사용자의 입력을 받으면 그것이 숫자든 문자든 다 str(문자열)로 받는다 # print(type(words)) # 124d, 하다연, sdfff든 다 str # # words 의 첫 글자와 마지막 글자를 출력하라. # print(words[0], words[-1]) # # 이렇게 쓰는 것은 리스트에서 쓰는 방법 아닌가요? string도 리스트처럼 메모리에 저장 > 리스트뿐 아니라 문자열도 인덱스 접근이 가능하다. # # 문자열은 리스트로 형변환 가능하다 # my_list = list('123456') # ...
e097d14d0842c7f614d200a0ad1364924d06512e
Dianeha/TIL
/Algorithm/patternmatching.py
445
3.546875
4
def BruteForce(p, t): i = 0 j = 0 while j < len(p) and i < len(t): if t[i] != p[j]: i = i - j j = -1 i = i + 1 j = j + 1 if j == len(p): return i - len(p) else: return -1 print(BruteForce("is", "This is a book~!")) def Bmoore(pt, test...
297b0702c3e1bd5059c4d401155898ce4dc0298d
Day2543/Data_Structure
/Caesar_Cipher.py
2,017
3.515625
4
from Lab3 import MyQueue def EnDe(mode,code,text): FinalText = MyQueue() if (mode == 'E' or mode == 'e'): for i in text: if(i != ' '): num = ord(i) + code.deQueue() if num > ord('z') and ord(i) >= 97...
0612db1c4fe32040e402f033d1d12e9173599946
brnjohnson1991/WorkingStuff
/VendingMachineSite/Program2Design.py
1,536
3.625
4
# Bradley Johnson, 010, 2/22/16 # Purpose: Generate a random fraction problem based on a difficulty input # Pre-conditions: Difficulty Input, a "L" or "R" answer # Post-conditions: Random Fractions, a comparison question, and a correct or incorrect statement # display title # ask the user "difficulty?" (1-3...
b5b87e0444e3c59c193d29f14d90f6526568f024
brnjohnson1991/WorkingStuff
/VendingMachineSite/lab 4 practice.py
660
3.828125
4
from graphics import * def main(): win = GraphWin("Triangles", 500, 500) click_prompt = Text(Point(250, 250), "Click three times") click_prompt.draw(win) click_prompt.setSize(20) click_prompt.setFill("blue") pt1 = win.getMouse() circ1 = Circle (pt1, 5) circ1.draw(win) ...
aa154320cffa9bac85743231bc0e5e5a01e5280f
Sguerra1702/Calculadora-Complejos
/vectores.py
5,632
3.75
4
import numpy as np def vectores(): np_vector_1 = [3 + 4j, 2 - 3j, 5 + 8j] np_vector_2 = [5 + 4j, 1 - 9j, 4 + 6j] vector_1 = np.array(np_vector_1) vector_2 = np.array(np_vector_2) print(vector_1) print(vector_2) print("") print("") return vector_1, vector_2 def sumavectores(vector...
d73e431b1d060340e19c996baab44ac656119088
michaelrbock/ctci-solutions
/ch4/4-1-fixed.py
892
3.609375
4
def is_balanced(root): if root == None or (root.l_child == None and root.r_child == None): return True if root.l_child == None: l_height = 0 else: l_height = count_height(root.l_child, 1) # small fix if root.r_child == None: r_height = 0 else: r_height = count_height(root.r_child, 1) return is_balanced(...
d116c100ac210b90344af07285f03a30a1acceae
michaelrbock/ctci-solutions
/ch1/1-7-paper.py
231
3.625
4
def set_zeros(matrix): for i, row in enumerate(matrix): for j, element in enumerate(row): if element == 0: # change row to 0's for k in row: k = 0 # change col to 0's for row1 in matrix: row1[j] = 0
c60646383287e231c961f426aaa146e7cb7bc3b0
gmmack/ProjectEuler
/P6/p6.py
419
3.984375
4
"""Calculates the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum and prints the result. Project Euler #6""" def sum_of_squares (): summ = 0 for i in range(1,101): summ += i**2 return summ def square_of_sums (): summ = 0 fo...
a743debf018b5322b6a681783aa0a009fbfd3b61
karingram0s/karanproject-solutions
/fibonacci.py
722
4.34375
4
#####---- checks if input is numerical. loop will break when an integer is entered def checkInput(myinput) : while (myinput.isnumeric() == False) : print('Invalid input, must be a number greater than 0') myinput = input('Enter number: ') return int(myinput) #####---- main print('This will print the Fib...
b49f2181faed685fb72d09530d2740d42c701044
liulichao1/python-0426
/day03/tuple-test.py
318
4.0625
4
tup = ('Hello','World') print(tup) numbers = (1,) print(numbers) print(len(numbers)) names = tuple(('test','test')) print(names.count('test')) print(names.index('test')) superstars = ['Tom','Jerry'] names = (superstars,'Spike') print(names) names[0].append('Mike') print(names) for name in names: print(name)
6d9bf0a0dda331efeea914b1afdd999db0df82c0
liulichao1/python-0426
/day01/string.py
210
3.9375
4
s = 'Hello, Word!' s = 'hello, Word!' print(s[0]) print(s*3) print(s[4:8]) print('He' in s) print(s.capitalize()) print(s.center(20,'-')) print(s.count('o')) print(s.endswith('!',0,13)) print(s.find(',',10,13))
f21f60d58db7d6c55caf9d962bbf5e4e54165d12
TheRareFox/Socket-programming
/client-1.py
443
3.90625
4
import socket #Creates a new socket my_socket = socket.socket() #Gets the address of the server address = input('Enter IPv4 address of server: ') #Gets the port of the server port = int(input('Enter port number of server: ')) #all the names of the host host = socket.gethostname() #Connects to the server my_so...
6df19549a6ed132b6f3704ff950db87599b80777
TheRareFox/Socket-programming
/game.py
12,727
3.625
4
import random import time class Map: def __init__(self): self.map = [] ran = random.randint(1,19) for i in range(20): a = ['|'] recent = True treasure = True for j in range(18): if j == ran and i == 13: ...
7f7574401f70130f37f3237cd877907693aaec37
ZLester/maximum-compatibility-matrix
/scratch/example2.py
2,577
3.5
4
# A Participant is a member of a group. The participant # has a list of other participants they like and dislike class Participant: def __init__(self): self.group = None self.likes = [] self.dislikes = [] def addToGroup(group): self.group = group def removeFromGroup(group): self.group = ...
a45c6b736f50bc170c61d4fbb5cccc786b342f89
njzapata0602/capture-5-Python-
/Exercise 1.py
169
3.609375
4
#Nick Zapata - ch 5 - ex 1 - 2/15/18 fruit = input('Enter a string: ') index = len(fruit) while index > 0: letter = fruit[index-1] print (letter) index = index - 1
45160bc5073ba2a31baba734a12b6439068b79cc
RaymondUW/Class-Projects-at-UW
/Insomnia and its impact/testingq.py
2,919
3.75
4
""" Mingyang Xue, Coco Cheng CSE 163 AG, AF This file implements test functions for the final project. """ import pandas as pd import matplotlib.pyplot as plt import q1CleanData import q1 import q2 def testq1Num(dt, num): """ Takes in the cleaned dataset dt and the num from q1 Tests q1 by calculating t...
db41fbd8af8497b8223a0d5fe12cd0bfaad064b7
jinxilongjxl/algorithm-diagram
/chapter6/breadth_first_search.py
932
3.65625
4
from collections import deque # 准备数据 graph = {} graph["you"] = ["bob","claire","alice"] graph["bob"] = ["anuj","peggy"] graph["claire"] = ["thon","jonny"] graph["alice"] = ["peggy"] graph["anuj"] = [] graph["peggy"] = [] graph["thon"] = [] graph["jonny"] = [] graph["peggy"] = [] # 定义函数判断是否为销售商 def is_seller(name): ...
e8820945ee5fc464b745d97a54f5a04733794b45
jinxilongjxl/algorithm-diagram
/chapter3/recursion_count.py
230
3.84375
4
def count_element(list): # 基线条件 if list == []: return 0 # 递归条件 else: return 1 + count_element(list[1:]) # 测试 print(count_element([1,2,3])) print(count_element([1,2,3,4]))
e6ebf5a16461af6ea607d48c38b782e141d89f1c
mnaufal121/Map_Filter_Function
/nfom2.py
472
3.8125
4
numbers = ((1, 7), (2, 0), (4, 5)) plus = [] minus = [] devide = [] cubic = [] for x in range(len(numbers)): plus.append(list(numbers[x])) minus.append(list(numbers[x])) devide.append(list(numbers[x])) cubic.append(list(numbers[x])) for y in range(len(numbers[x])): plus[x][y] += 2 m...
cccb7b1963c7a1e211eb2ef7f142e579d17f8787
Ernest-Macharia/Data-Structures-in-Python
/squares.py
74
3.671875
4
squares = [x**2 for x in range(10) ] print("squares are: " + str(squares))
6dc641d3b1e777c33c5ed1cbf1a1753ee97527af
Ernest-Macharia/Data-Structures-in-Python
/indexoflist.py
129
3.75
4
x = ["kiatu", "shuka", "kitabu", "kitanda"] indx = [i for i, k in enumerate(x) if k == "kitabu" ] print("index: " + str(indx[0]))
77b2f5298767983904bb8f15d770a7acf7bb7e61
aojuolaa/WorkMarketExercise
/Friendly_Competition.py
2,163
3.859375
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 16 09:24:56 2016 @author: DEBOLA """ import pandas as pd #read file c=pd.read_csv("NYC_Jobs.csv") #use pandas aggregation function to group by Agency grouped = c['# Of Positions'].groupby(c['Agency']) #sum the result and sort in descending order u=grouped.sum().sor...
2703b1a704fcd51a6675abef900bd8564c3ad4e4
sravanidonthana14/sravani
/Alphabet or Not.py
109
3.984375
4
x=raw_input() if((x>='a' and x<='z')or(x>='A' ana x<='Z')): print(("Alphabet") else: print("No")
f427ee4ead3b36d59b61983fbd336148f06aa7fa
muthu048/guvi
/sum of n number.py
110
3.921875
4
n=int(input()) sum=0 if n>0: for i in range (1,n+1): sum=sum+i print ('the sum is',sum)
34e19fa750992c4512119b1c688628eec5aa91ce
jbartos3/pynet_test
/strex1.py
208
3.65625
4
name1 = 'Huey' name2 = 'Dewey' name3 = 'Louie' name4 = raw_input('Who is the head duck?: ') print '{:>30}'.format(name1) print '{:>30}'.format(name2) print '{:>30}'.format(name3) print '{:>30}'.format(name4)
35fb678edb2369ca09c40eecfb4b8856b5ded353
jlocamuz/Mi_repo
/clase12-08-20/main.py
711
4.15625
4
class Clase(): def __init__(self, atributo=0): # Que yo ponga atributo=0 significa que si yo no le doy valor # A ese atributo por defecto me pone 0 self.atributo = atributo def get_atributo(self): # setter and getter: darle un valor a un atributo y obtener # el valor del...
972a1b992737d16d31e3b2d1492be3f42bd666a2
starcaptain123/Stepic-Lessons
/1/3 Functions, Dictionaries, Files/3_7_3.py
464
3.546875
4
d = int(input()) # кол-во слов в словаре Dictionary = [] # словарь Text = [] result = [] for i in range(d): Dictionary.append(input().lower()) l = int(input()) # кол-во строк текста for k in range(l): List = [i for i in input().lower().split()] Text.extend(List) for i in range(len(Text)): if Text[i] no...
2b356a3847e1f94fe9e8b3d4c7a32b5929967d5d
05anushka/loop
/sevenstar.py
166
3.734375
4
i=1 while i<=4: b=1 while b<7: print(" ",end="") b=b+2 k=1 while k<=4: print("*", end="") k=k+2 print() i=i+1
2cc1d886719e3d3dbd49876f3010d85ddf147b33
Diego8791/bucles_python
/ejercicios_practica.py
16,738
4.1875
4
#!/usr/bin/env python ''' Bucles [Python] Ejercicios de práctica --------------------------- Autor: Inove Coding School Version: 1.1 Descripcion: Programa creado para que practiquen los conocimietos adquiridos durante la semana ''' __author__ = "Inove Coding School" __email__ = "alumnos@inove.com.ar" _...
1e62380b2c9933cfa82f3d7571a3c41e0538303f
kcboggs/OPS301
/Personal/lists.py
186
4
4
friends = ["mochi", "bori", "ally", "brandon", "max"] # to get after index 1 print(friends[1:]) # to get up to print(friends[1:3]) # to modify friends[1] = "fox" print(friends[1])
b018ab7a30564d373c154ec2f298ac332e88adf8
kcboggs/OPS301
/Personal/getting-input.py
170
4.28125
4
name = input("Enter your name: ") # we want to get a input from user print("Hellow " + name + "!") age = input("Enter your age: ") print("you are " + age + " years old")
eea3b413c62201f1a4d5ba654833aca32e535fe5
Workaholicws/Workaholicws
/findReapet.py
1,100
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 6 08:08:51 2015 @author: WangS """ from __future__ import unicode_literals import os # This program is used to find repeat element in TXT. # Check.txt is for original element and mayRepeat.txt is for element include repeat. # Result.txt save the check resu...
9cf2e808ae2b3169759629c1b3b904d4a68bd774
DennyJohnsonp/Lab-Sem-06-Programs
/MT6P1/EX3_3.PY
595
3.5
4
from sympy import Matrix dim_v=3 a=Matrix([[1,-1,0],[2,0,1],[1,1,1]]) r=a.rank() b=a.rref() print(f'Range Space of A is Spanned by First {r} Rows of:\n',b[0]) a_nullspace=a.transpose().nullspace() print('Nullspace of A is Generated by the Columns of:',a_nullspace) lhs= r+len(a_nullspace) rhs=dim_v print('Rank of A: ',r...
8c86875cdd88d2d0382b1e13d2102f7d7c4f7035
jellythewobbly/mars-rover-py
/mars_rover.py
921
3.6875
4
class Marsrover: def __init__(self, xcoor, ycoor, facing): self.x = xcoor self.y = ycoor self.facing = facing def return_coordinates(self): return [self.x, self.y, self.facing] def movement(self, commands): for i in commands: if (i == 'f'): ...
60563127f676d720fd28b3dd5bbe1826aeac6f9a
caelan/TJHSST-Artificial-Intelligence
/Word Ladders/Lab01.py
528
3.546875
4
#Caelan Garrett, 9/10/09, Neighboors # wlist=open('words.txt').read().split('\n')[:-1] # emoticon is like chomp while 1: ustr=raw_input('String (quit): ') if ustr == 'quit': break neigh = 0 if ustr in wlist: for word in wlist: nonmatches = 0 index = 0 for letter in word: if ustr[index]!= letter: ...
913dcacb92d06e1a6b5f3578faf55d42b276333f
capital37/Object-Oriented-Python
/basic_inheritance/basic_inheritance.py
641
3.8125
4
class ContactList(list): def search(self, name): '''return all contacts that contain the search value in their name''' self.matching_contacts = [] for contact in self: if name in contact.name: self.matching_contacts.append(contact) return self.matching_contacts class Contact: #all_contacts = [] ...
0975de3423366a05312087b3b7a440f7beae0817
TomTomW/mayaScripts
/scripts_from_school/problem1.py
4,028
3.53125
4
'''Thomas Whitzer 159005085''' import math class Point: def __init__(self, x = 0, y=0): self.x = x self.y = y def translate(self, s, t): self.x += s self.y += t def rotate(self, angle): x = self.x angle = math.radians(angle) self.x = (x * math.co...
70b3aaa3f15d06d070a3490c0de3b9d8a393af8e
capKopper/maps-drupal-import-automaton
/lib/transport.py
2,181
3.59375
4
"""AlertTransport class.""" import abc import smtplib class AlertTransportInterface(object): """Abstract class definition.""" __metaclass__ = abc.ABCMeta @abc.abstractmethod def send(self): """Send an alert.""" pass class AlertTransportMail(AlertTransportInterface): """Implem...
112f44cb5083c63580ec76da625f1e21abf73a33
antdevelopment1/python104
/guess_the_number_play_again.py
1,190
4.03125
4
import random random_num = 5 #random.randint(1, 10) print("I am thinking of a number between 1 and 10. ") user_input = int(input("Please guess a number? ")) correct_guess = False limit_guess = 3 while correct_guess == False: if user_input == random_num: print("Yay you won!!!") ask_to_play ...
6e2da1b625ccaecb23a96a65b17dd5990e06cc1d
antdevelopment1/python104
/multiplication_table.py
80
3.5
4
for number in range(1, 10): print(number, 'X', number ,'=', number * number)
8fe2316d8b6417057f965117e532e8ad1166ff31
elisangelayumi/Jeu-ConnectFour_Console
/connectfour/case.py
793
3.71875
4
class Case: ''' Classe représentant une case de la grille de jeu. Une case est consitutée d'un attribut Jeton, initialement None. Certaines fonctions y sont aussi implémentées pour permettre un affichage élégant de chacune des cases. Cette classe vous est fournie, vous n'avez pas à la modifie...
529091e9ea0d6a0bf3dca540f4ef487fc118efb5
MReinhart1/LinkedListPython
/LinkedList.py
4,020
4.1875
4
""" --------------------------------- Assignment 3 "Linked list" Student Name: Michael Reinhart Student Number: 20001556 Date Modified : March 17 2017 --------------------------------- """ import urllib.request # Reads in a web page and assigns each row to a node in our linked list def readHtml(): toDoList = Non...
4fc8b327ad4c3c6186bfad23a7ba9ebb6fde6df3
kylegarrettwilson/Python-Madlib
/reusable-lib/library.py
4,763
4.15625
4
# store user inputs and then encapsulate # calc check total # calc overtime total # calc total hours worked each week on average # calc some type of bonus class JobData(object): # this is a data object to hold the items from the form def __init__(self): # initializing function self.__name = '' # t...
07976f5fc9d8f5afe905f255e61cb6079eca0631
SerhiiPodibka/Lv-367.PythonCore
/1012new.py
732
3.515625
4
import pygame pygame.init() gameDisplay=pygame.display.set_mode((500,500)) pygame.display.set_caption("my second game") x=50 y=50 width=40 height=60 vol=5 run=True while run: pygame.time.delay(100) for event in pygame.event.get(): if event.type == pygame.QUIT: run = False keys=pygame...
2c7f65f1e7816d0e259c17932668172825f560f8
SerhiiPodibka/Lv-367.PythonCore
/1212classwork.py
843
4
4
class Figure: def __init__(self, color): self.color=color def get_color (self): return self.color #print("Color is" color ) def info (self): print("Figure") print("Color:"+self.color) class Rectangle(Figure): def __init__(self, color,width=100, height=100): ...
b97a94399afac9b9f793d680ffb01892f041ff25
arononeill/Python
/Variable_Practice/Dictionary_Methods.py
1,290
4.3125
4
import operator # Decalring a Dictionary Variable dictExample = { "student0" : "Bob", "student1" : "Lewis", "student2" : "Paddy", "student3" : "Steve", "student4" : "Pete" } print "\n\nDictionary method get() Returns the value of the searched key\n" find = dictExample.get("student0") print find print "\n\nDict...