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
c7c4b6e6a0c260674afdd1da8272aa30d5e5f792
hihello-jy/portfolio
/2055-실습3-거북이제어.py
337
4.09375
4
#거북이 제어 프로그램 import turtle t=turtle.Turtle() t.width(3) t.shape("turtle") t.shapesize(3,3) while True: command=input("명령을 입력하시오: ") if command =="l": t.left(90) t.forward(100) elif command=="r": t.right(90) t.forward(100) else: command
5f7f389fd301595d75ef96bb67922db3ab6009e7
hihello-jy/portfolio
/2034연습문제1- 두수의 합차곱~.py
245
3.828125
4
x=int(input("x: ")) y=int(input("y: ")) print("두수의 합: ",x+y) print("두수의 차: ",x-y) print("두수의 곱: ",x*y) print("두수의 평균: ",(x+y)/2) print("큰수: ",max(x,y)) print("작은수 : ",min(x,y))
bbda8737a33110a256d8161048191a03428c0616
hihello-jy/portfolio
/문제05- 엘레베이터 프로그램.py
649
3.9375
4
def goDown(): for i in range (current_floor-1,target_floor,-1): print ("현재 %d층 입니다." %(i)) print("%d층에 도착하였습니다." %target_floor) def goUP(): for i in range (current_floor+1,target_floor): print ("현재 %d층 입니다." %(i)) print("%d층에 도착하였습니다." %target_floor) current_floor=int(input("...
c81d31947a5a55aba7db6189877302d48432ee66
hihello-jy/portfolio
/문제09- 문자열의 aeiou개수 세기.py
442
3.71875
4
#소문자! aeiou의 개수를 각각 출력하는 프로그램. #문자열은 영문 알파벳만 입력한다고 가정하자. aeiou=['a','e','i','o','u'] text=input("문자열을 입력하세요: ") found={} found['a']=0 found['e']=0 found['i']=0 found['o']=0 found['u']=0 for letter in text: if letter in aeiou: found[letter] += 1 for k,v in sorted(found.items()): p...
5308b888a4dd93ac9d4c21bd9853a77becb943a9
hihello-jy/portfolio
/2034연습문제2-원기둥부피.py
107
3.578125
4
r=float(input("r: ")) h=float(input("h: ")) vol=3.141592*r**2*h print("원기둥의 부피: ",vol)
268933a63618a04223937184b6e4ac3ef7434170
hihello-jy/portfolio
/if else- 놀이기구 탑승 나이, 키.py
241
4.03125
4
age = int(input("나이를 입력하세요: ")) height = int(input("키를 입력하세요: ")) if ( age >= 10 ) and ( height >= 165): print ("놀이기구를 탈 수 있다.") else: print ("놀이기구를 탈 수 없다.")
956a2bef2795a208453c065a0355496b97b3562a
hihello-jy/portfolio
/2024 변수연습문제7-밭전.py
524
3.546875
4
import turtle t=turtle.Turtle() t.shape("turtle") side=50 angle=90 t.forward(side) t.right(angle) t.forward(side) t.right(angle) t.forward(side) t.right(angle) t.forward(side) t.forward(side) t.right(angle) t.forward(side) t.right(angle) t.forward(side) t.right(angle) t.forward(100) t.right(180) ...
7ef6d3d4d033a58a1caf44dce617424d78fdb25b
SongMunseon/softwareproject-5
/20171631-서필립-assignment2.py
360
4.03125
4
n = int(input("Enter a number : ")) f = 1 while n>=0: for i in range(1,n+1) : f *= i print(n,"! =", f) f = 1 n = int(input("Enter a number : ")) if n < -1 : print("Can't execute") for i in range(1,n+1) : f *= 1 f = 1 n = int(input("Enter a number...
46108fef98238e6fe945219751b4f9242f4cc854
ghzwireless/cubeos
/test/integration/jenkinsnode/cistack/binfile.py
6,172
3.546875
4
import os import sys import re import magic from utils import supportedBoards class Binfile(object): """ A binary file object that contains the name, file type, path, target architecture, and target board type. Internal methods include file and path validation, attempts to determine target arch...
3dcc3737c0181da9e03220133464cf926229f5cf
kashifusmani/interview_prep
/arrays/webpage.py
1,709
3.53125
4
class BrowserHistory: def __init__(self, homepage: str): self.homepage = homepage self.history = [homepage] self.current_index = 0 print(self.history) print(self.current_index) def visit(self, url: str) -> None: if self.current_index +1 < len(self.history): ...
029de1a6a99a93e8b0cf273c51675120a3bcaad6
kashifusmani/interview_prep
/recursion/reverse_string.py
213
4.125
4
def reverse(s): if len(s) == 1 or len(s) == 0: return s return s[len(s)-1] + reverse(s[0: len(s)-1]) # or return reverse(s[1:]) + s[0] if __name__ == '__main__': print(reverse('hello world'))
5c2465e7451b82309e5b5f2baf9152268d3014b7
kashifusmani/interview_prep
/arrays/water.py
2,574
3.75
4
#For every element of the array, find the maximum element on its left and maximum on its right #O(n^2) def maxWater(arr, n) : res = 0 # For every element of the array for i in range(1, n - 1) : # Find the maximum element on its left left = arr[i] for j in range(i) : lef...
03ed32a0404db3acf09a90702a8aebd037feeca9
kashifusmani/interview_prep
/stack_queues_deques/parenthesis.py
1,033
3.90625
4
def is_balanaced(input): s = [] for item in input: if item == '(' or item == '{' or item == '[': s.append(item) else: if len(s) == 0: return False popped = s.pop() if item == '}' and not popped == '{': return False ...
09a14e49b6bb2b7944bc5ec177586a40761ca6f7
kashifusmani/interview_prep
/fahecom/interview.py
2,489
4.125
4
""" Write Python code to find 3 words that occur together most often? Given input: There is the variable input that contains words separated by a space. The task is to find out the three words that occur together most often (order does not matter) input = "cats milk jump bill jump milk cats dog cats jump milk" """ fro...
14d1c9d1f4bba9b474b432e180cf7a2f1ae13487
ducanh4531/Think-like-CS
/chapter_3_1.py
5,561
4.5
4
"""first line.""" import turtle """ I. Write a program that prints We like Python's turtles! 100 times for i in range (100): print("We like Python's turtles!") """ # II. Answer a question on runestone # III. Write a program that uses a for loop to print each line is a mon- # th of year """ choosing a list or a...
33ab41836352c8c68c6931db4c415aa2425932e7
emnak/boilerplate-
/src/data_generators/keras_dataset_generator.py
3,252
3.734375
4
import pandas as pd from keras_preprocessing.image import ImageDataGenerator from tensorflow.keras import datasets from tensorflow.keras.utils import Sequence, to_categorical class KerasDatasetGenerator(Sequence): """ Generates images batches from a Keras dataset, for the chosen subset ('training', 'validatio...
fc3ed7d7ae3a68288d07d2b1f56bd9fffda03264
ELLIPSIS009/100-Days-Coding-Challenge
/Day_3/Save_Konoha/save_kohona.py
1,794
3.71875
4
''' Problem :- Save Konoha (SAVKONO) Platform :- Codechef Link :- https://www.codechef.com/problems/SAVKONO Problem statement :- Pain is the leader of a secret organization whose goal is to destroy the leaf village(Konoha). After successive failures, the leader has himself appeared for the job. Naruto is the head of ...
3955d791f137b973ad49f5cf928d4da1ce8562a3
ELLIPSIS009/100-Days-Coding-Challenge
/Day_2/Div.64/Div.64_M-2.py
954
3.625
4
''' Question code :- 887A Platform :- Codeforces Link :- https://codeforces.com/contest/1446/problem/A Problem statement :- Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills. Her problem is following: for given string, consisting of only 0 and 1, tell if ...
3302c9a22c0131ba10cca6acfaf7182aca246b54
danhigham/advent_of_code
/2/run.py
901
3.515625
4
import re f = open("./2/input.txt") raw_data = f.read().split("\n") first_valid_count = 0 second_valid_count = 0 for x in raw_data: if (x.strip()==""): continue value = re.search(':\s([a-z]*)', x).group(1) minOcc = int(re.search('^(\d*)-', x).group(1)) maxOcc = int(re.search('^\d*-(\d*)\s', x...
0cb94a6782ceed0709216733f95d1581c5ebc821
ao9000/tic-tac-toe-ai
/run_game.py
7,054
3.796875
4
""" Pygame based version of tic-tac-toe with minimax algorithm artificial intelligence (AI) game """ # UI imports import pygame import sys from game_interface.color import color_to_rgb from game_interface.templates import game_board, selection_screen, board_information, highlight_win # Game logic imports import r...
56ea49400b82ee1982b4103e4f34c9bee7b5e650
mekdeshub123/cap_lab_5
/five_days_forcast.py
1,191
3.59375
4
#the data request is limited to USA cities only import os import requests from datetime import datetime #retrieve key that stored in envromental variable key = os.environ.get('WEATHER_KEY') #print(key) print('----------------------------------------------') print('\nTHE DATA REQUEST IS LIMITED TO US CITIES ONLY') pri...
b1da56330aaed2070bd2a2cf71e7905f800f11db
LaytonAvery/DigitalCraftsWeek1
/Day4/todolist.py
1,089
4.21875
4
choice = "" task = {} def add_task(choice): task = [{"title": name, "priority": priority}] task.append("") for key, value in task.append(""): print(key, value) # print(task) def delete_task(choice): del task def view_all(): for key, value in task.items(): print(key, value)...
00aec8932d5749f9f5af478ebb9dbeff183a5c11
krizo/checkio
/quests/singleton.py
874
4.125
4
''' https://py.checkio.org/en/mission/capital-city/ You are an active traveler who have visited a lot of countries. The main city in the every country is its capital and each country can have only one capital city. So your task is to create the class Capital which has some special properties: the first created instance...
a4267b4bc3cc1901c8f717b192af77f9feec37b3
yinglingwang07238422/csv2txt
/csv2txt/cmd.py
1,080
3.734375
4
#!/usr/bin/env python # encoding=utf-8 import os import argparse import csv2txt def convert_by_cmd(): # 参数定义 parser = argparse.ArgumentParser(description="Convert a csv file to token separator txt file") parser.add_argument('--version', '-v', action='version', version='%(prog)s version : v'+csv2txt.getVersion(), h...
ef657e61a2dfdac5e44aaa1187aa11c6f6713017
niraj36/test
/fizz_buzz.py
410
3.75
4
def fizz_buzz(start_value, end_value, fizz_value, buzz_value): count = start_value message = count while count <= end_value: if count % fizz_value == 0: message = 'Fizz' if count % buzz_value == 0: message += ' Buzz' elif count % buzz_value == 0: ...
d8f3097c5b0dc01d85ee0b72006d1fdb8b6431e1
VioletM/student-python-graphics
/1.py
744
4
4
from tkinter import * ## Размеры холста: W = 600 # ширина H = 400 # высота ## Диаметр мячика: D = 10 ## Начальное положение мячика: X_START = 150 Y_START = 100 Win=Tk() c = Canvas(Win, width=W, height=H, bg='black') c.pack() ## Отрисовка поля: c.create_rectangle(30, 30, W - 30, H - 30, outline=...
96d924eb36cf0b3e23c5a71d555ee6cd24970c11
Ola752/load-shed
/loadshed/utils/timing.py
2,509
4.03125
4
import timeit import datetime start_time = 0 lap_time = 0 # level 1 lap_time2 = 0 # level 2 def start(): """ Start timing :return: nothing """ global start_time global lap_time global lap_time2 start_time = lap_time = lap_time2 = timeit.default_timer() time_now = datetime.dateti...
81e3eb880ccd149f93bfe2a4bc6c48f86ad745b7
Diogo-Ferreira/astar_he_arc
/City.py
1,079
3.5625
4
""" Ferreira Venancio Diogo IA Class HE-ARC 2016 Class city """ class City(object): def __init__(self, name, x_pos, y_pos): self.name = name self.x_pos = float(x_pos) self.y_pos = float(y_pos) self.connections = {} self.gx = 0 self.parent = None def add_connec...
05c34a6a177cd48e5c8e1f2b05ef5413e2ec9b41
abhishektzr/sangini
/learning-python_Teach-Your-Kids-to Code/saymyname.py
206
3.90625
4
# ask the user for their name name = input('What is your name? ') # print their name 100 times for x in range(100): # print their name followed by a space,not a new line print(name,end = ' rules, ')
f5c9eb271fbd7da172fa9af87960faff1bd5f675
abhishektzr/sangini
/learning-python_Teach-Your-Kids-to Code/fibfunctions.py
267
4.15625
4
def fibonacci(num): print("printing fibonacci numbers till ", num) v = 1 v1 = 1 v2 = v + v1 print(v) print(v1) while v2 < num: print(v2) v = v1 v1 = v2 v2 = v + v1 fibonacci(10) fibonacci(20) fibonacci(500)
b85eddbab124941dcffd5c4918478fc3f9b8837b
abhishektzr/sangini
/learning-python_Teach-Your-Kids-to Code/Click-And-Smile.py
843
3.53125
4
# ClickAndSmile.py import random import turtle def draw_smiley(x, y): pen.penup() pen.setpos(x, y) pen.pendown() # Face pen.pencolor("yellow") pen.fillcolor("yellow") pen.begin_fill() pen.circle(50) pen.end_fill() # Left eye pen.setpos(x-15, y+60) pen.f...
b77b996655f2c3a53acf170a6b4b7f78fc9051ac
abhishektzr/sangini
/learning-python_Teach-Your-Kids-to Code/circlescolour.py
350
3.875
4
import turtle t = turtle.Pen() colours = ["red", "yellow", "blue", "green","orange", "purple", "white", "gray",'pink','light blue','brown', 'light green'] t.speed(20) for x in range(12): t.fillcolor(colours[x % colours.__sizeof__()]) t.begin_fill() t.circle(100) t.end_fill() t.left(30) turtle.textin...
68e086044625f54a75bf362a4dd6d63c4632cff6
NALM98/Homework-Course-1
/HW3/HW1.py
1,689
4.125
4
print("Введите, пожалуйста,три любых числа") a = int(input()) b = int(input()) c = int(input()) #1. a и b в сумме дают c #2. a умножить на b равно c #3. a даёт остаток c при делении на b #4. c является решением линейного уравнения ax + b = 0 #5. a разделить на b равно c #6. a в степени b равно c. #1 if a+b == c: ...
c1820b939c67c0a7587026e6434419e4f7e5667d
filipmihal/ml-coursera-python-coursework
/regression/linear.py
2,071
4.03125
4
import os from abstract import AbstractRegression import numpy as np from matplotlib import pyplot from scipy import optimize class LinearRegression(AbstractRegression): """Linear regression class""" def plot_data(self): index = 0 for feature in self.get_features().transpose(): ...
5e92cdb5639fdf7277da9808d00f3acddcf7c8f6
SwethaGullapalli/PythonTasks
/FolderComparision.py
1,358
3.796875
4
import os import shutil Folderpath1=raw_input("please enter first folder name : ") Folderpath2=raw_input("please enter second folder name : ") needmatchedfiles=raw_input("do you want matched files? ") needmatchedfiles=needmatchedfiles=="yes" donotneedmatchedfiles=raw_input("do you want unmatched files? ") donotneedmat...
2c4041af39e9c050adb9f1aa6352a6b9c25c8436
SwethaGullapalli/PythonTasks
/PrintFileNameHavingPy.py
866
4.375
4
#program to print the file extension having py """give input as list of file names iterate each file name in file names list declare one variable for holding file extension declare variables for index and dot index iterate each character in the file name increment the index by 1 if Character is equal to "." ass...
a3649f42792c2945eccc395db2b53e2a5beeaec1
berkio3x/pyray3d
/vector.py
1,451
3.5
4
import math class Vec3: def __init__(self, x, y, z): self.x = x self.y = y self.z = z def __str__(self): return f'Vec3({self.x},{self.y},{self.z})' def __sub__(self, other): return Vec3(self.x - other.x , self.y - other.y , self.z - other.z) def _...
51b40c1df3d52d3b1089dc01438022dbd506133c
stevenhvtran/Maze-Generator
/listMaze.py
6,337
3.78125
4
from pprint import pprint import random import numpy as np #Generates the grid needed to start a maze def gridGen(x): if x%2 != 0: #Creates the grid being used grid = [[0 for i in range(0,x)] for i in range(0,x)] grid = walls(walls(grid, x), x) return(list(map(list, grid)...
3cd1af446a478f64466a9761c16b7f4d21b834d7
tonyw0527/Python-algorithm-notes
/Implementation/combinationsAndPrimeNumber.py
609
3.828125
4
# 리스트C3 의 조합의 경우의 수를 담은 리스트를 얻는다. # 각 원소의 합이 소수인 것들의 수만 더한다. from itertools import combinations from math import sqrt def isPrime(num): if num < 2: return False for n in range(2, int(sqrt(num)) + 1): if num % n == 0: return False return True def solution(nums): answer = 0...
2d9d781b6bc8ccb022ce86d4ed6f58fadcd2788b
paulan94/CTCIPaul
/4_8_find_common_ancs.py
793
3.890625
4
class Node(): def __init__(self,val): self.val = val self.right = None self.left = None def node_exists(root,node): if root == node: return True if not root: return None else: return node_exists(root.left,node) or node_exists(root.right,node) return ...
327c06d09a8423799688e23faeafdde1468b8ebc
paulan94/CTCIPaul
/AddOrMultiplyRuntimes.py
615
3.75
4
def addRunTimeAlgorithm(arrayA, arrayB): # O(A+B) for a in arrayA: print (a) for b in arrayB: print (b) def multiplyRunTimeAlgorithm(arrayA, arrayB): # O(AB) for a in arrayA: for b in arrayB: print (str(a) + "," + str(b)) if __name__ == "__main__": array...
78d35c7dc69601404fa656ca6991b8586eb71a7f
paulan94/CTCIPaul
/get_len_arr.py
1,140
4.03125
4
# Given a list of n words, the task is to check if two same words come next to each other. # Then remove the pair and print the number of words left in the list after this pairwise # removal is done until no other pairs are present. # # Examples: # # Input : [ba bb bb bcd xy] # Output : 3 # As [bb, bb] canc...
21cc678347d34d1ca41120c9bec17f757cbf6b06
paulan94/CTCIPaul
/4_5_validate_bst.py
483
3.734375
4
class Node(): def __init__(self, val): self.val = val self.left = None self.right = None def validate_bst(mn, mx, root): if not root: return True elif root.val < mn or root.val > mx: return False return validate_bst(mn,root.val,root.left) and validate_bst(root.val,mx,root.right...
41daacddca3128116a92c6a6bd83b0f197444c96
paulan94/CTCIPaul
/binsearch2.py
713
3.96875
4
def bin_search(arr,key,start,end): #we need to check if the end index is greater than 0 because #we need to ensure that end is within the bounds of [0:len(a)-1] if (start <= end): #mid will be start + (end-start)//2 #the first start keeps track of where our lower bound is #and we mov...
34e8dded051c178bc946de223e5ed459837bed4a
paulan94/CTCIPaul
/node.py
840
3.6875
4
class Node: def __init__(self,val): self.val = val self.left = None self.right = None rt = Node(5) rt.left = Node(2) rt.right = Node(6) rt.left.left = Node(1) rt.left.right = Node(3) def contains(root,node): if not root: return False if root == node: ...
d9efef45642933fbdc520bac6a2e4b3785ae26dd
paulan94/CTCIPaul
/4_1_route_nodes.py
515
3.828125
4
class Node: def __init__(self,val): self.val = val self.children = [] def route_exists(a,b): if a.val == b.val: return True elif (not a and b) or (not b and a): return False else: for c in a.children: if route_exists(c,b): return True ...
cd2c876ba236ef81aaf268f832eeb2de7fa66f71
paulan94/CTCIPaul
/8_9_parens.py
398
3.515625
4
def get_parens(n): if n == 0: return [''] else: p_list = [] parens = get_parens(n-1) for each in parens: p_list.append('()' + each) p_list.append('(' + each + ')') p_list.append(each + '()') return set(p_list) print (get_parens(4)) print (get...
dc71001743d53cc6ebc0488cc4e4d3bf975a7d79
paulan94/CTCIPaul
/My HackerRank Solutions/binary_tree_BST.py
953
3.953125
4
#Paul An #is this binary tree a BST? #This program creates an array based on an in-order traversal of the given Binary Tree. #It compares the sum starting at 0. 0 with 1, 2 with 3, up to n-1 with n to see if the sequence is ordered correctly. """ Node is defined as class node: def __init__(self, data): sel...
4a80711d999e08b07361e0891f348ba6a29a3591
paulan94/CTCIPaul
/4_2_create_bst_min_height.py
719
3.703125
4
class Node(): def __init__(self,val): self.val = val self.left = None self.right = None def create_bst_min_height(arr,start, end): if not arr or len(arr) == 0 or end < start: return None else: mid = (start + end)//2 node = Node(arr[mid]) print (node.v...
394f3dafa486af4e54f0097d4c407d9678e48bce
alekseidrumov/HOMEWORK_PYTHON_ADVANCED_NUM_4
/1.py
893
3.875
4
def registration(): login = input("login: ") password = input("password: ") name = input('name: ') with open('file.txt','a') as f: f.write(login+' login '+password+' password '+name+' name ') def login(dict): dict = dict print(dict) login = input("login: ") password = i...
7af10a743dbf3690644d938655353f87a802c16c
JaLeeKi/data-python
/data_presenter.py
1,067
3.921875
4
# Create a new file called data_presenter.py. # Open the CupcakeInvoices.csv. open_file = open('CupcakeInvoices.csv') # Loop through all the data and print each row. for line in open_file: print(line) # Loop through all the data and print the type of cupcakes purchased. for line in open_file: values = line.spl...
3857e9ecf09d236e3e03425c3cfe37b29ab8ad99
AntonioGetsemani/EjercicioDePruebaRecursividad
/Ejercicio1Recursividad.py
198
3.5
4
author = 'Antonio Getsemani' def ConvertirNumero(num): if num == 0: return "" else: return str(num % 2) + ConvertirNumero(num//2) print(ConvertirNumero(8))
7bbf7e4294d9f9a4e6ee7ab9c66f73c67a7a5909
georgePopaEv/python-exercise
/Day2P.py
576
3.765625
4
bani = float(input("Cati bani ai in total? :")) # trecem suma de bani # alegem dobanda dintre 10, 12 sau 15 # vedem la cati o umprumuta sau a cata parte # Calculam cat tre sa plateasca fiecare persoana inapoi dobanda = int(input("Cat este dobanda la care imprumuti?10, 12 sau 15? ")) split = int(input("La cati o...
5e687cca74958a11a30f7b38e0f148898296e314
georgePopaEv/python-exercise
/P9DAY.py
626
3.5625
4
import art print(art.logo) def maxim_from_dictionar(dictionar): max = 0 for i in dictionar: if dictionar[i] > max: max = pers[i] winner = i print(f"Castigatorul este {winner} care a licitat cu {max}") run = True pers = {} while run: name = input("Numel...
fe13a07aade0381d220e30fb2f3eb344a7f63405
saileshchauhan/PythonProgram
/DataStructure/Strings/1_WordFrequency.py
1,730
3.9375
4
''' @Author:Sailesh Chauhan @Date:2021-06-11 @Last Modified by:Sailesh Chauhan @Last Modified time:2021-06-11 @Title: Get length of string count each alphabet frequency and char replacement. ''' #Importing logConfig for error logging import logconfig import logging,re def create_word(): ''' Description: P...
61cb6e042e6b49bf4dea1b95335989c5c66bdcd4
saileshchauhan/PythonProgram
/DataStructure/Lists/3_CopyList_RemoveDuplicates.py
1,944
3.90625
4
''' @Author:Sailesh Chauhan @Date:2021-06-10 @Last Modified by:Sailesh Chauhan @Last Modified time:2021-06-10 @Title: Copy list and remove duplicate element from list. ''' import logconfig import logging,copy def create_list(): ''' Description: Parameters: Returns: ''' try: defaultList...
af00f452c536b5503c79a34286fd1b78b91ddc8e
saileshchauhan/PythonProgram
/DataStructure/Lists/7_CommonItem_From2List.py
1,343
3.53125
4
''' @Author:Sailesh Chauhan @Date:2021-06-10 @Last Modified by:Sailesh Chauhan @Last Modified time:2021-06-10 @Title: Find out common item in both list. ''' #Importing logConfig for error logging import logconfig import logging,re def create_list(): ''' Description: Parameters: Returns: ''' t...
012065e8a85e1ac86c2e563e5df3d7feab87101a
Exodus76/aoc19
/day1.py
759
4.125
4
#day 1 part 1 #find the fuel required for a module, take its mass, divide by three, round down, and subtract 2 #part1 function def fuel_required(mass): if(mass < 0): return 0 else: return (mass/3 - 2) #part2 fucntion def total_fuel(mass): total = 0 while(fuel_required(mass) >= 0): ...
e40fbf76d88da16cb8c9ab18b276cf1595aa8198
yz9527-1/1YZ
/pycharm/Practice/python 3自学/12-读取csv文件.py
626
3.765625
4
# -*-coding:UTF-8 -*- """ import csv with open(r'E:\YZ\data\data1.csv') as csvfile: readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: #print(row) #print(row[0]) print(row[0], row[1]) """ import csv with open(r'E:\YZ\data\data1.csv') as csvfile: readCSV = csv.reade...
380f71e1a17b74229526deb208804f1707dafbb3
llubu/AI
/Project 3/BayesianNet/question3_solver.py
3,782
3.703125
4
class Question3_Solver: def __init__(self, cpt): self.cpt = cpt; self.skip1 = self.createTable1() self.skip2 = self.createTable2() ##################################### # ADD YOUR CODE HERE # Pr(x|y) = self.cpt.conditional_prob(x, y); # A word begins with "`" and ends ...
91f7b60a8fd8f7b3518b40755a12b2cdf3038e5e
llubu/AI
/Project 4/machine_learning/question3_solver.py
2,047
3.859375
4
import math class Question3_Solver: def __init__(self): return; # Add your code here. # Return the centroids of clusters. # You must use [(30, 30), (150, 30), (90, 130)] as initial centroids #[(30, 60), (150, 60), (90, 130)] def solve(self, points): centroids = [(30, 30), (150...
6b72e1414ffa164e5753a0d701ca7b29098fa82c
ChengBinJin/Tensorflow-SungKim
/src/ML_lab_03.py
899
3.6875
4
import tensorflow as tf # import matplotlib.pyplot as plt x_data = [1., 2., 3.] y_data = [1., 2., 3.] W = tf.Variable(tf.random_normal([1]), name='weight') X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) # Our hypothesis for linear model X * W hypothesis = X * W # cost/loss function cost = tf.reduce_m...
83a4be2a2ac283fafb84d62420c65d8d118383ab
yanolsh/dev-sprint2
/chap7.py
613
4.0625
4
# Enter your answrs for chapter 7 here # Name: # Ex. 7.5 import math def fact(k): if k == 0: return 1 else: rec = fact(k-1) result = k * rec return result def estimate_pi(): t = 0 k = 0 factor = 2 * math.sqrt(2) / 9801 while True: num = fact(4*k...
954577d721fc5226cec27b13688bf039cc253360
aiqiliu/algoprep
/15.py
3,761
3.671875
4
# 3sum: # 1. get len # return [] if len<3 # split the list into <= 0 and > 0 # recursion, for every num1 in l1, pair up with num2 in l2. # if (0 - num1 - num2) in num1 or in num2, append the [num1, num2, 0-num1-num2] in result # first iteration: problem - have duplicates class Solution(object): def threeSum(self,...
c1705f2e61d5dc83e340aa1c9452e0731a669174
varinder-singh/EVA4
/S11/drawCyclicCurve.py
1,714
3.5
4
class PlotTheCurve(): def __init__(self, cycle_count, lr_min, lr_max, step_size): self.cycle_count = cycle_count self.lr_min = lr_min self.lr_max = lr_max self.step_size = step_size def setX(self,cycle,cycle_count): list1 = [] mincycleval, maxcycleval = c...
c7befa66246c186a74d3b744cefc83914b3f8dea
Binovizer/Python-Beginning
/TheBeginning/Demos/GuessTheNumber.py
322
3.875
4
from random import randint x = randint(1,100) print("Here We Go...") n = int(input("Guess the number: ")) while(True): if(x == n): print("Yippeee! You Guessed It Right.") break elif(x > n): print("Too Low") else: print("Too High") n = int(input("Guess Again: "...
41aa6417fa2caa63e1be5277d7da7c4be451715a
Binovizer/Python-Beginning
/GUIDemo/CreatingDropDownMenu.py
1,721
3.84375
4
from tkinter import * def doNothing(): print("This started Working") root = Tk() menu = Menu(root, tearoff = False) root.config(menu = menu) submenu = Menu(menu, tearoff = False) menu.add_cascade(label='File', menu = submenu) submenu.add_command(label='New Project', command = doNothing) submen...
eb78d593489b33d1a5cd3cb14268aef27b553962
Binovizer/Python-Beginning
/TheBeginning/py_basics_assignments/50.py
897
4.1875
4
import re student_id = input("Enter student id : ") if(re.search("[^0-9]", student_id)): print("Sorry! Student ID can only contains digit") else: student_name = input("Enter student name : ") if re.search("[^a-zA-Z]", student_name): print("Name can only contain alphabets") else: ...
67372b5d84a298c77462a0979c9e52eafaffe948
Binovizer/Python-Beginning
/TheBeginning/Demos/DateNTimeDemo.py
327
3.546875
4
import time import datetime print(time.clock()) print(time.gmtime()) print(time.localtime()) print(time.time()) print(time.daylight) print(datetime.datetime.now()) print(datetime.datetime.now()+datetime.timedelta()) print("Current Time : "+time.strftime("%c")) print(time.strftime("%x")) print(time.strftime("...
a54f5599368ec0d5a7a425a7cba6efa0795e67ff
Binovizer/Python-Beginning
/TheBeginning/py_basics_assignments/32.py
359
3.875
4
a = [int(x) for(x) in input("Enter numbers : ").split(sep=' ')] #Taking list as an input print("List before sorting : ",a) #Bubble Sort for i in range(0,len(a)) : for j in range(0,len(a)-i-1) : if (a[j] < a[j+1]): temp = a[j]; a[j] = a[j+1]; a[j+1] = temp ...
e9a65f7f1552fb9dc8b79e7f6d8147b7f148874d
Binovizer/Python-Beginning
/TheBeginning/py_basics_assignments/17.py
101
3.84375
4
counter = 1 while (counter <= 3): print(counter) counter += 1 print("End of program")
2edf97fc3e08b52cbe3646a770eacc4800fec38d
Binovizer/Python-Beginning
/GUIDemo/FittingWidgets.py
288
3.9375
4
from tkinter import * root = Tk() one = Label(root, text='One', fg='black', bg="red") two = Label(root, text='Two', fg='red', bg='yellow') three = Label(root, text='Three', fg='red', bg='blue') one.pack() two.pack(fill=X) three.pack(fill=BOTH, expand=TRUE) root.mainloop()
f1ec84bd827159d3638ce26957379c9a20d5ed2b
Binovizer/Python-Beginning
/TheBeginning/py_basics_assignments/33.py
708
4.09375
4
furniture_list = [("SofaSet",20000),("Dining Table",8500),("TV stand",4599),("Cupboard",13920)] fur_name = input("Enter the Name of furniture You want to buy : ").strip() for fur_tuple in furniture_list: if (fur_tuple[0].lower() == fur_name.lower()): price = fur_tuple[1] print("\nFurniture ...
1055bc0e42e910b94362ab9eca8562dd189a4ad7
bocchini/py_todo
/view/add_to_do.py
522
3.6875
4
from controllers.to_do_controller import add_to_do def add(): print('*' * 30, '-' * 4, ' Adicionar uma tarefa ', '-' * 4, '*' * 30) save = False while not save: title = input('Digite o titulo da tarefa: ').capitalize() to_do = input('Digite a tarefa: ').capitalize() want_to_save = ...
ae49e7d82f3936422004eea0e1f73d0f58feb126
messophet/Google
/Algorithms/CTCI/Chapter 1 - Arrays and Strings/35.py
432
3.90625
4
class Stack: def __init__(self): self.items=[] def push(self,item): self.items.append(item) def pop(self): return self.items.pop() def size(self): return len(self.items) def isEmpty(self): return self.items==[] class MyQueue: def __init__(self): self.queue = [] #3 2 1 -stack-> 3 2 1 (LIFO) -stack->...
fae008a799fc1d985d61d7801a196a802ad4f49b
messophet/Google
/Algorithms/CTCI/Chapter 1 - Arrays and Strings/graphs.py
816
3.890625
4
graph = {'A':['B','D'],'B':['C'],'C':['E','F'],'D':[],'E':[],'F':[]} def find_path(graph,start,end,path=[]): path = path + [start] if(start==end): return path if(not graph.has_key(start)): return None #shortestPath = None for node in graph[start]: if node not in path: newpath = find_path(graph,node,end,p...
e21fb99cb9d35f6ee1b5d7bc0b846d7479ed5b20
jiafulow/emtf-nnet
/emtf_nnet/architecture/endless_utils.py
1,615
4.03125
4
"""Architecture utils.""" import numpy as np def gather_indices_by_values(arr, max_value=None): """Gather indices by values. Instead of gathering values by indices, this function gathers indices by (non-negative integer) values in an array. The result is a nested list, which can be addressed by content from...
1c68f6f4f392e6e800af406002a42e343b8811f0
alixoallen/todos.py
/import random.py
367
3.90625
4
import random nome=(input('digite um nome :')) nome2=(input('digite um segundo nome :')) nome3=(input('digite um terceiro nome:')) nome4=(input('digite um quarto nome :')) lista=[nome,nome2,nome3,nome4] nme=random.choice(lista) print("o nome sorteado foi {}".format(nme)) #quase fiz sozinho, nao havia colocado a lista ...
b09f322540e7bbeaec6e9e07238e09374110fbc8
alixoallen/todos.py
/dobro triplo e raiz.py
162
4.03125
4
n=int(input('digite um numero :')) dobro= n*2 triplo= n*3 raiz= n**(1/2) print('o dobro de {} é {}, o triplo é {} , e a raiz é {}'.format(n,dobro,triplo,raiz))
0af2fe8c20ab0c3cd1b7c9282387577f64babe72
alixoallen/todos.py
/conversor de metros, centimetros e milimetros.py
196
3.8125
4
medida=float(input('quantos metros quer converter ?')) cm= medida*100 mm=medida*1000 print('segundo a metragem que escolheu, os centimetros correspondem a {}, e os milimetros a {}'.format(cm,mm ))
50807cca27c1d9b15e8a43d36a3fe2249529c96c
alixoallen/todos.py
/adivinhação.py
327
4.15625
4
from random import randint computer=randint(0,5) print('pensei no numero{}'.format(computer))#gera um numero aleatorio, ou faz o computador """"""pensar""""""""""""""" escolha=int(input('digite um numero:')) if escolha == computer: print('parabens voce acertou!') else: print('ora ora voce é meio pessimo nisso!...
23ffb890a15d4de9ec5686c12cc2476f78c4810c
yupei0318cs/ScrapyWebCrawler
/douban_book/douban_book/utils/threadsafe_queue.py
888
3.640625
4
import queue import threading q = queue.Queue() for i in range(5): q.put(i) while not q.empty(): print (q.get()) q = queue.LifoQueue() for i in range(5): q.put(i) while not q.empty(): print (q.get()) class Task: def __init__(self, priority, description): self.priority...
ce951ed88517fc810a94b560b2c96e86395874f7
lalluz/movie_trailer_website
/media.py
1,239
3.8125
4
import webbrowser class Movie: """ This class provides a way to store movie related information. Attributes: title (str): the movie title storyline (str): a short description of the movie box_art_url (str): a url to a poster image trailer_url (str): a url to a youtube trailer ...
d1e7bdef1bfbdee75db0888035cbee70ddf5875c
nedraki/gym_explorer
/deep_q_network.py
1,979
3.53125
4
import tensorflow as tf from tensorflow import keras from keras.models import Model, Sequential, load_model from keras.layers import Input, Dense, Dropout from keras.optimizers import Adam, RMSprop # Neural Network model for Deep Q Learning """Deep Q-Learning As an agent takes actions and moves through an environmen...
39f15cc411cd352495194da5849953befe4edb07
Recky-krec/Python-BS4
/youtube-searcher-master/youtube-searcher.py
1,365
3.578125
4
#!/usr/bin/python3 import bs4 as bs import urllib.request import re import os def webRequest(url): """Creates a request based in the url""" headers = {"User-Agent":"Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"} req = urllib.request.Request(url, he...
ac1615321ed322852494f2d9e039a2756c8b6a55
mansiagnihotrii/Data-Structures-in-python
/Strings/5_single_edit.py
852
3.8125
4
''' Check whether the strings entered are one or zero edit away. Edits performed are: insert a character, remove a character, or replace a character ''' def single_edit(s1, s2): if s1 == s2: return True if abs(len(s1) - len(s2)) > 1: return False short_str = s1 if len(s1) < len(s2) els...
9eb137a3f310eeb8c6d006bfd72fce5e035e06b2
mansiagnihotrii/Data-Structures-in-python
/Linked List/4_linkedlist_partition.py
851
4.125
4
''' Given a linked list and an element , say 'x'. Divide the same list so that the left part of the list has all the elements less that 'x' and right part has all elements greater than or equal to 'x'. ''' #!/usr/bin/env python3 import linkedlist from linkedlist import LinkedList,Node def partition_list...
af7a3b336d50ddea1a8c4ec76a767f3143fdc44f
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/greedy/largest_permutation.py
2,068
4.09375
4
def largest_permutation(k, arr): """Hackerrank Problem: https://www.hackerrank.com/challenges/largest-permutation/problem You are given an unordered array of unique integers incrementing from 1. You can swap any two elements a limited number of times. Determine the largest lexicographical value array that ...
c696a2980ffe52412000a0f0deda444cea00badf
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/strings/funny_string.py
1,059
4.34375
4
def funny_string(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/funny-string/problem In this challenge, you will determine whether a string is funny or not. To determine whether a string is funny, create a copy of the string in reverse e.g. abc -> cba. Iterating through each string, compa...
131e45b4fcdb5a3ef8a9efa3580a1ac03bda66f6
kcc3/hackerrank-solutions
/python/numpy/min_and_max.py
432
3.9375
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/np-min-and-max/problem Task You are given a 2-D array with dimensions N x M. Your task is to perform the min function over axis 1 and then find the max of that. """ import numpy n, m = map(int, input().split(' ')) array = [] for _ in range(n): a = lis...
0562ecb6074ee2c8d62d863db65a1c5a5325fd66
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/strings/mars_exploration.py
919
4.34375
4
def mars_exploration(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/mars-exploration/problem Sami's spaceship crashed on Mars! She sends a series of SOS messages to Earth for help. Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal r...
ff2f6d4c31e79e2249438839b9e85049e4f2c4e0
kcc3/hackerrank-solutions
/python/python_functionals/validating_email_addresses_with_filter.py
1,146
4.15625
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/validate-list-of-email-address-with-filter/problem""" def fun(s): """Determine if the passed in email address is valid based on the following rules: It must have the username@websitename.extension format type. The username can only contain lett...
10a395af6ac6efa71d38074c2d88adff4665435e
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/bit_manipulation/maximizing_xor.py
932
4.3125
4
def maximizing_xor(l, r): """Hackerrank Problem: https://www.hackerrank.com/challenges/maximizing-xor/problem Given two integers, l and r, find the maximal value of a xor b, written a @ b, where a and b satisfy the following condition: l <= a <= b <= r Solve: We XOR the l and r bound and ...
5dada4e2c555cf79880499431e25a16d8a441ad3
kcc3/hackerrank-solutions
/python/numpy/zeros_and_ones.py
617
3.96875
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/np-zeros-and-ones/problem Task You are given the shape of the array in the form of space-separated integers, each integer representing the size of different dimensions, your task is to print an array of the given shape and integer type using the tools numpy...
6d15fcd0279049189d9a54c882f0b27a46034a59
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/the_grid_search.py
2,824
4.21875
4
def grid_search(g, p): """Hackerrank Problem: https://www.hackerrank.com/challenges/the-grid-search/problem Given a 2D array of digits or grid, try to find the occurrence of a given 2D pattern of digits. For example: Grid ---------- 1234567890 0987654321 1111111111 1111111111 22222...
24ea0ea11b64dd814811282faa67c89274005133
kcc3/hackerrank-solutions
/python/numpy/transpose_and_flatten.py
735
4.0625
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/np-transpose-and-flatten/problem Task You are given a X integer array matrix with space separated elements ( = rows and = columns). Your task is to print the transpose and flatten results. """ import numpy # Initialize array array = [] # Read in the numbe...
6eba8809d2c6d10aadc221ea78cf0d08d458d967
kcc3/hackerrank-solutions
/data_structures/python/stacks/maximum_element.py
1,176
4.34375
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/maximum-element/problem You have an empty sequence, and you will be given queries. Each query is one of these three types: 1 x -Push the element x into the stack. 2 -Delete the element present at the top of the stack. 3 -Print the maximum element in...
54e29a17af6dfcb36c102bba527a588a533d29f3
kcc3/hackerrank-solutions
/python/built_ins/any_or_all.py
548
4.15625
4
""" Hackerrank Problem: https://www.hackerrank.com/challenges/any-or-all/problem Given a space separated list of integers, check to see if all the integers are positive, and if so, check if any integer is a palindromic integer. """ n = int(input()) ints = list(input().split(" ")) # Check to see if all integers in the ...
3cc86ea1557ecd260202121ce31df104a83d1b09
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/taum_and_bday.py
1,606
4.09375
4
def taum_bday(b, w, bc, wc, z): """Hackerrank Problem: https://www.hackerrank.com/challenges/taum-and-bday/problem Taum is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Taum: one is black and the other is white. To make her happy, Taum has to ...
048f4a1843a7cb34f846a62ff3cc70225a74c763
kcc3/hackerrank-solutions
/data_structures/python/stacks/balanced_brackets.py
2,594
4.40625
4
def is_balanced(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/balanced-brackets/problem A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the lef...