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
7bfff88b28253ec0f69e3c93dc01c29be200e71b
zmatteson/epi-python
/chapter_13/13_1.py
1,092
4.1875
4
""" Compute the intersection of two sorted arrays One way: take the set of both, and compute the intersection (Time O(n + m) ) Other way: search in the larger for values of the smaller (Time O(n log m ) ) Other way: start at both and walk through each, skipping where appropriate (Time O(n + n) , space O(intersection ...
af77d80d6b95b5dc847f33ba0783b5fcc7c872d6
zmatteson/epi-python
/chapter_5/5_1.py
1,620
4.21875
4
""" The Dutch National Flag Problem The quicksort algorith for sorting arrays proceeds recursively--it selects an element ("the pivot"), reorders the array to make all the elements less than or equal to the pivot appear first, followed by all the elements greater than the pivot. The two subarrays are then sorted rec...
d3e57c2ec3133003e2d8d5f67c2aee403e3ab0e8
zmatteson/epi-python
/chapter_14/14_1.py
959
4.15625
4
""" test if a tree satisfies the BST property What is a BST? """ class TreeNode: def __init__(self, left = None, right = None, key = None): self.left = left self.right = right self.key = key def check_bst(root): max_num = float('inf') min_num = float('-inf') return check_bst_...
4efb3dc8ac96aef7b014e9d7c4b2a7e06b136072
SergioEV/CodingInterview
/Chapter1/ch1_3.py
339
3.96875
4
#urlify: given a string and the true length of string, write a function that replaces the #" " with "%20" my_dictionary={" ": "%20"} def urlify(string,truelength): i=0 outputstring="" for x in string: if(i<truelength): outputstring += my_dictionary.get(x,x) i+=1 return outputstring print(urlify("how will t...
8ffdf477bef5ae147a6af9da3ce689d3ae7617bc
hgirish/ud120-projects
/decision_tree/quiz10.10.py
457
3.828125
4
def featureScaling(arr): mindata = min(arr) maxdata = max(arr) scaled = [0.5,0.5, 0.5] if mindata == maxdata: return scaled for i in range(0,3): x = float(arr[i]) print("i: {0}, x: {1}".format(i,x)) scaled[i] = (x - mindata)/(maxdata - mindata) print...
3943856748f7c611ab9da7d74ba5f5942c05959d
caniro/algo-note
/IotLecture/Algorithm/ch11_Sort/ex02.py
442
3.953125
4
# 선택 정렬 - 배열 내용을 옮겨서 def findMinIndex(arr): minIdx = 0 for i in range(1, len(arr)): if arr[minIdx] > arr[i]: minIdx = i return minIdx import random before = [random.randint(1, 99) for _ in range(20)] after = [] print('정렬 전 :', before) for i in range(20): minIdx = findMinIndex(bef...
aa2d1102150b129627b4e55a464071cf3ff24878
caniro/algo-note
/Programmers/level1_python/12906.py
534
3.78125
4
# 같은 숫자는 싫어 : https://programmers.co.kr/learn/courses/30/lessons/12906 def solution(arr): answer = [] answer.append(arr[0]) for j in range(1, len(arr)): if answer[-1] == arr[j]: continue answer.append(arr[j]) return answer # 슬라이싱으로 조금 더 깔끔하게. 근데 조금 느림 def solution1(a...
b946996d90a50cdc0fc66ac5d7e1f156e7b73b11
caniro/algo-note
/Programmers/level1_python/12918.py
554
3.6875
4
# 문자열 다루기 기본 : https://programmers.co.kr/learn/courses/30/lessons/12918 def solution(s): if not len(s) == 4 or len(s) == 6: return False for char in s: if char < '0' or char > '9': return False return True # .isdigit() 함수를 통해 숫자로만 구성된 문자열인지 판별 가능 def solution1(s): return T...
bca8fd89e85d698635482d3c599644c3e3817a4b
caniro/algo-note
/Programmers/level2_python/12951.py
313
3.609375
4
# JadenCase 문자열 만들기 : https://programmers.co.kr/learn/courses/30/lessons/12951 def solution(s): return ' '.join(word[0].upper() + word[1:].lower() if word else '' for word in s.split(' ')) # .capitalize() 사용 def solution1(s): return ' '.join(word.capitalize() for word in s.split(' '))
761638b7d6c1d6d3597054590e6b8af7ee99a357
caniro/algo-note
/IotLecture/DataStructure/ch07_Queue/ex03.py
1,647
4.0625
4
# 큐의 일반 구현 - 입력받기 def isQueueFull(): global SIZE, queue, front, rear if (rear == SIZE - 1): return True else: return False def isQueueEmpty(): global SIZE, queue, front, rear if (front == rear): return True else: return False def enQueue(data): global SIZ...
253f0931592a7316f571c6f87ecc989aadffdff8
caniro/algo-note
/Programmers/level1_python/12932.py
336
3.671875
4
# 자연수 뒤집어 배열로 만들기 : https://programmers.co.kr/learn/courses/30/lessons/12932 def solution(n): answer = [] for num in str(n): answer.insert(0, int(num)) return answer # list, map, reversed를 사용할 수 있다. def solution1(n): return list(map(int, reversed(str(n))))
9a70b85f639b6cd15a7f75ebaf759286851ba757
caniro/algo-note
/Programmers/level2_python/42839.py
595
3.734375
4
# 소수 찾기 : https://programmers.co.kr/learn/courses/30/lessons/42839 from itertools import permutations as pm def is_prime(num): if num < 2: return False for i in range(2, int(num ** 0.5) + 1, 1): if num % i == 0: return False return True def solution(numbers): answer = 0 ...
b82987d9c6f64f88c52ec496c73c16a2b5fc1359
seoyeonhwng/algorithm
/이것이_코딩테스트다/성적이 낮은 순서로 학생 출력하기.py
216
3.59375
4
info = {} for _ in range(int(input())): name, score = input().split(' ') info[name] = score # 성적이 낮은 순서대로 정렬 info = sorted(info.items(), key=lambda x: x[1]) print(*[i[0] for i in info])
7a99355a509b1af25f071869fad82c1d38340bae
seoyeonhwng/algorithm
/codility/MaxSliceSum.py
436
3.53125
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") import sys def solution(A): # write your code in Python 3.6 current_sum = 0 max_sum = -sys.maxsize # 최댓값 게속 갱신 # 계속 더하다가 current_sum이 음수가 되면 버린다! for a in A: current_sum = max(a, current_sum ...
718239a3f33f415eeffb92f95bd8da55f578a8a9
seoyeonhwng/algorithm
/BJ/regular_expression/15904.py
185
3.703125
4
import re string = input() string = re.sub('[^A-Z]', '', string) if re.fullmatch('[A-Z]*U[A-Z]*C[A-Z]*P[A-Z]*C[A-Z]*', string): print('I love UCPC') else: print('I hate UCPC')
dc90f157c87bdf54005669731d6bb94ad9485e28
seoyeonhwng/algorithm
/codility/MaxDoubleSliceSum.py
896
3.5
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") import sys def solution(A): # write your code in Python 3.6 sum_l = [0] * len(A) sum_r = [0] * len(A) max_sum = -sys.maxsize # 왼쪽에서부터 더해가면서 최대합을 구한다 # A[X + 1] + A[X + 2] + ... + A[Y - 1] for i in...
40bc2c8894f07e9a40edbf59f727af60ede3435a
seoyeonhwng/algorithm
/이것이_코딩테스트다/팀 결성.py
681
4.09375
4
def find_parent(x): if parent[x] != x: parent[x] = find_parent(parent[x]) return parent[x] def union_parent(a, b): a = find_parent(a) b = find_parent(b) if a < b: parent[b] = a else: parent[a] = b # 팀 합치기, 같은 팀 여부 확인 -> union-find N, M = map(int, input().split(' ')) #...
7487ae2bc143d05d673f6041d377b5e23753b74d
seoyeonhwng/algorithm
/BJ/11403.py
357
3.5625
4
N = int(input()) matrix = [input().split(' ') for _ in range(N)] # 모든 정점에 대한 최단거리이므로 플로이드 와샬 for k in range(N): for i in range(N): for j in range(N): if matrix[i][k] == '1' and matrix[k][j] == '1': matrix[i][j] = '1' for row in matrix: print(' '.join([r for r in row]))
3d25dd97e19198d0a6572ce1f8a2e8d32f39e238
seoyeonhwng/algorithm
/BJ/2828.py
848
3.5625
4
import sys def move_left(b, s, e): # 왼쪽으로 움직여서 포함되도록 count = 0 while s >= 0: if s <= b < e: return count s, e = s - 1, e - 1 count += 1 return sys.maxsize def move_right(b, s, e): # 오른쪽으로 움직여서 포함되도록 count = 0 while e <= N: if s <= b < e: ...
bc351d68ee107d4214017ceb4fa6eedd7f3fca48
seoyeonhwng/algorithm
/BJ/1080.py
765
3.546875
4
def convert(n, m): # (i, j)부터 시작해서 3*3크기의 A의 부분행렬값을 뒤집음 for i in range(n, n+3): for j in range(m, m+3): matA[i][j] = 1 if matA[i][j] == 0 else 0 def check(): for i in range(N): for j in range(M): if matA[i][j] != matB[i][j]: return False return T...
cc723a9b3111b4886ecffad7ad518b4ee46a87d1
seoyeonhwng/algorithm
/leetcode/1491.py
531
3.5625
4
class Solution: def average(self, salary: List[int]) -> float: total = 0 max_s = -sys.maxsize min_s = sys.maxsize for s in salary: total += s max_s = max(max_s, s) min_s = min(min_s, s) total = total - max_s - min_s ...
ca31646e6a95c33b97da2f86d57d8ccf9e14e580
seoyeonhwng/algorithm
/codility/Dominator.py
369
3.5625
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") import collections def solution(A): # write your code in Python 3.6 if not A: return -1 counter = collections.Counter(A) for k, count in counter.items(): if count > (len(A) // 2): ...
6515ca246e3910a972711043daf119f78dee83da
seoyeonhwng/algorithm
/leetcode/1026.py
918
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: answer = 0 def maxAncestorDiff(self, root: TreeNode) -> int: def dfs(node, max_v, min_v): ...
d3613c4d1d57e1a1085c847850520542dbbcf934
seoyeonhwng/algorithm
/leetcode/1008.py
951
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def bstFromPreorder(self, preorder: List[int]) -> TreeNode: root = TreeNode(preorder.pop(0)) ...
a8c404d16848a4aa37ebe909367a3ba306cbf420
seoyeonhwng/algorithm
/BJ/2748.py
175
3.8125
4
def fibonacci(n): dp = {} dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = dp[i-1] + dp[i-2] return dp[n] N = int(input()) print(fibonacci(N))
e293a12eab1e48149876fb98638cdaee70961a38
tdgo/MIS132
/week6_1.py
1,068
3.875
4
# MIS 132 - April 30 # Account class class Account: def __init__(self, balance, name, branch="Istanbul"): self.balance = balance self.owner = name self.branch = branch #print(f"An account has been created with {self.balance} balance.") def deposit(self, amount): self.b...
cad9a59e7ed85cd5f9c7cea130d6589ee7a70bd9
Pyae-Sone-Nyo-Hmine/Ciphers
/Caesar cipher.py
1,362
4.46875
4
def encode_caesar(string, shift_amt): ''' Encodes the specified `string` using a Caesar cipher with shift `shift_amt` Parameters ---------- string : str The string to encode. shift_amt : int How much to shift the alphabet by. ''' ...
0f8f238cca00fe4ccc621969a0c69d5ade3fee04
mariamihaelafainarea/Crisi-MLR
/Mlr.py
735
3.5625
4
import numpy as np from sklearn.linear_model import LinearRegression import pandas as pd # To read data new_model = LinearRegression() def calculate_regression(filename): data = pd.read_csv(filename) # load data set X = data.iloc[:,:-1].values Y = data.iloc[:, -1].values linear_regressor =...
5e3eedb1885b1b5c17ada120d3810365c0a664c4
confucious/puzzle-utils
/python/images.py
1,373
3.515625
4
""" Image manipulation and analysis in python. Use the `pillow` library. https://pillow.readthedocs.io/en/5.0.0/ `pip install pillow` More information https://pillow.readthedocs.io/en/5.0.0/handbook/tutorial.html """ from PIL import Image # Read in file im = Image.open("image.png") # Dimensions of image im.size #...
7858cd22b34d98802deeff465b448f112fe79e14
kazuma-shinomiya/leetcode
/94.binary-tree-inorder-traversal.py
813
3.703125
4
# # @lc app=leetcode id=94 lang=python3 # # [94] Binary Tree Inorder Traversal # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def inord...
00381d04b587eab03039cb304a1396e693403368
CherryWin777/assignment
/cha.3.py
804
4
4
num=int(input("enter a number:")) for i in range(1,13): print(num,"x",i ,"=",num*i) factorial=1 num=int(input("enter a number:")) if num<0: print("factorial does not exist") elif num==0: print("factorial is 1") else: for i in range(1,num+1): factorial=factorial*i print("fac...
8250eadeaffdb192f60877616fae8948f96fcf81
KIMJINMINININN/Python
/Pandas/source/Basic/test15.py
571
3.578125
4
import pandas as pd exam_data = {'이름' : ['서준', '우현', '인아'], '수학': [90, 80, 70], '영어' : [98, 89, 95], '음악' : [85, 95, 100], '체육' : [100, 90, 90]} # df.set_index('이름', inplace=True) df = pd.DataFrame(exam_data) print(df) print('\n') # 특정 열을 index로 만들어주기 ndf = df.se...
6ba44a2e16d9092563f6871b7a975fd3a74cd7ac
amoghasubramanya/Linear_regression-multiple_variables
/MultivariateLR.py
3,251
3.8125
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 1 22:40:43 2017 @author: Amogha Subramanya Linear regression with multiple variables to predict the prices of houses. Suppose you are selling your house and you want to know what a go o d market price would be. One way to do this is to first collect informatio...
23f9836548d18bfbc0f04cb8c3e1d94224f53628
akashm99/100_Days_Python
/day25/main.py
689
3.78125
4
# with open("weather_data.csv") as data: # data = data.readlines() # print(data) # # import csv # with open("weather_data.csv") as data: # data = csv.reader(data) # temp = [] # for row in data: # if row[1] != "temp": # temp.append(int(row[1])) # #print(row) # print(te...
a79fed1a4bdbb1a52748386592af516f0b9b9b55
akashm99/100_Days_Python
/day19/final.py
865
4.03125
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(500,400) bet = screen.textinput("Make bet", "Which turtle will win") color = ["red", "green", "yellow", "blue", "purple", "black"] ypos = [-70, -40, -10, 20, 50, 80] all_turtles = [] for i in range(0,6): tim = Turtle(shape="turtle") ...
f3ceb9fe7137039f77f13979f4bb1c8226be5967
RFMCR/Datacademy
/Semana 1/kilometrosmillas.py
571
3.859375
4
def KMaMillas(): km=float(input("Ingresa los kilometros: ")) print("{} km equivalen a {} millas.".format(km,km*1.609344)) def millasaKM(): millas=float(input("Ingresa las millas: ")) print("{} millas equivalen a {} KM.".format(millas,millas/1.609344)) def main(): opcion = 0 print ("Sele...
341e37e44f66d7836c51f512447de63c1ac1e0dd
ErikSandvikSEA/guided-computer-architecture-iii
/comp_ii.py
2,282
3.796875
4
import sys # the index into a memory array, AKA location, address, pointer # 1, PRINT_BEEJ # 2, HALT # 3, SAVE_REG store a value in a register # 4, PRINT_REG print the register value in decimal # 5, PUSH # 6, POP # think of a big array of bytes, 8-bits per byte memory = [0] * 256 # registers[4] = 37 registers = [0]...
83a97a7b840c3afd7fb1d9da41ee530076654461
polinch/learn-python
/Погружение в Python от Mail.ru/magicfile.py
948
3.578125
4
import os import tempfile class File(object): def __init__(self, file_path): self.path = file_path def write(self, added_string): f = open(self.path, 'a') f.write(added_string) f.close() def __add__(self, other): f = open(self.path, 'r') g = open(other.pa...
23f455f3e1967da6402c696f36e6f6142b15b843
lenertovalucie/python_projects
/project_euler/largest_palindrom_4.py
1,271
4.09375
4
#! /usr/bin/env python3 """ https://projecteuler.net/problem=4 """ import argparse def is_palindrome(n): """ :param n: number :return: True if number is palindrome """ string_n = str(n) return string_n == string_n[::-1] def find_pal(bot, top): """ :param top: start number from whi...
b9d425eeab278432570cc425114d139e6139d19f
CollegeFellow/data-structures
/queue.py
452
3.84375
4
class Queue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) if __name__ == '__main__': q = Queue() q.enqueue(12) q.enqueue(3) pri...
de6be7734a7996f5bbea60637be01ed928b7ddb4
v4vishalchauhan/Python
/emirp_number.py
669
4.28125
4
"""Code to find given number is a emirp number or not""" """Emirp numbers:prime nubers whose reverse is also a prime number for example:17 is a prime number as well as its reverse 71 is also a prime number hence its a emirp number..""" def prime_check(k): n=int(k) if n<=1: return False for i in range(2,n)...
8a5d07c775a00118a7bdc28c01b35738fe4bef73
teteumac/Pyhton
/aula3/exercicio_1_aula_3.py
343
3.5
4
print('exercicio 1: Crie uma funcão que tome um argumento e imprima o valor e o tipo dele. \n') def tipo(x): print(type(x)) tipo(1.2) tipo('coco') tipo(8154984845156262651262165478485) print('------------------------------------------------------X--------------------------------------------------------...
3a7b5f4e19fc4b53bbffc1ac6d144b2fefc9ef9c
gaoyanping/myself
/def.py
1,057
3.5625
4
#-*- coding=utf-8 -*- #定义方法,注意定义完成后一定要用:号,另外函数内的实现都要进行缩进。 def print_two(*args):#表示有多个参数 arg1,arg2 = args #用两个变量去接受输入的两个参数 print "arg1:%s , arg2:%s" %(arg1,arg2) def print_three(*args):#表示有多个参数 arg1,arg2,arg3 = args #用三个变量去接受输入的两个参数 print "arg1:%s,arg2:%s,arg3:%s" %(arg1,arg2,arg3) def print_two_again(arg1,arg...
c68297d913dab4979b50533b0911e77dd592876d
gaoyanping/myself
/raw_input.py
369
3.71875
4
#-*- coding=utf-8 -*- #关于row_input的作用 a = 50 b = 60 c = raw_input("input number:") f = "I Love " #rwa_input()默认的是字符 print "c is %s" %c #将int型转换成字符型 print str(a)+str(b)+c #可以将raw_input()转换成int型的 d = int(raw_input("input number2:")) print a+b+d #加上输入时候的提示 e = raw_input("I love who?") print f+e
723a2484199d0f62cbd8bbc7d2e6a5f0dc52a8ce
Rahul1804/leetcode
/nonrepeatsubstring.py
725
3.859375
4
def non_repeat_substring(s): if len(s) == 0: return 0 window_start = 0 max_len = 0 my_map = {} for window_end in range(len(s)): right_char = s[window_end] if right_char in my_map: window_start = max(window_start, my_map[right_char]+1) my_map[right_char]...
534f424abc2155937f0262940d7a265f558ec76f
Ilyaas-S/Project-3
/task_manager.py
19,062
3.9375
4
#The function to display statistics. def display_statistics(): #read the task overview file f=open('task_overview.txt', 'r') all_lines = f.readlines() #display all the lines in the file for line in all_lines: print(line) f.close() #read the user overview file f=open('user_ove...
0d502926e72ebc305ff74984cc5c61d9a59d237e
sunilpedada/htmlANDjavascripts
/recursion.py
182
4.0625
4
def factorial(n): if n==1: print(n) return 1 else: return n*factorial(n-1) a=factorial(5) print(a) i=2 v=1 e=5 while i<=e: v=v*i i+=1 print(v)
d93806d64c656678e14f85f2a8b2a58a3c792cee
felipeCaetano/TkinterGalery
/Message.py
263
3.5
4
""" Cria uma menssagem sobre o objeto TK. Message é um widget semelhante ao Lable mas que suporta multiplas linhas. """ from tkinter import * root = Tk() message = Message(root, text='Isso é uma mensagem relativamente longa').pack() root.mainloop()
3a9f48607389ee4a7c7cfd547056128f5ee437b8
felipeCaetano/TkinterGalery
/Radiobutton.py
250
3.625
4
""" Cria Radiobutton sobre o objeto TK. """ from tkinter import * root = Tk() radiobutton0 = Radiobutton(root, text='Radiobutton 0', value=0).pack() radiobutton1 = Radiobutton(root, text='Radiobutton 1', value=1).pack() root.mainloop()
bec546bcaee8e9b29b43c77e96785b2397a43731
ibigbug/leetcode
/evaluate-reverse-polish-notation.py
802
3.65625
4
# Link: https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/ class Solution: # @param tokens, a list of string # @return an integer def evalRPN(self, tokens): """ Use stack. An easy problem. Care about the accuracy ! """ import operator as op ...
77b0b588334d274bac7a5d74a2aed8b38fc33a61
julianneperry/python-challenge
/PythonPyPoll.py
1,667
3.6875
4
#import dependencies import csv fileToLoad="electionData.csv" fileToOutput="electionAnalysis.txt" #1 Total number of votes totalVotes=0 candidateOptions=[] candidateVotes={} winningCandidate="" winningCount=0 with open(fileToLoad) as electionData reader=csv.DictReader(electionData) for row in reader...
0f0c7db015d9d75de26154a3eba212f0fa74a43a
kdh7575070/taeha-kang
/자율과제형/4 머신러닝 개인 공부/tf_3-1.py
777
3.546875
4
import tensorflow as tf x_train = [1,2,3] y_train = [1,2,3] #변수설정 W = tf.Variable(tf.random_normal([1]), name='weight') X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) #H(x)=Wx 모델구현, 코스트정의 hypothesis = X * W cost = tf.reduce_sum(tf.square(hypothesis - Y)) #Gradient descent 풀어서 정의해보자 lea...
1289e4cf9e0c451f43bf9c8fa266ae6ee0d55710
turingtei/Python_Tutorial
/lesson_4b_ex5.py
4,943
3.90625
4
# Implementation of classic arcade game Pong # Play pong try: import simplegui except: import simpleguitk as simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / ...
da000de6f1f135b9a391fe05f2f1dab9d5b42d88
turingtei/Python_Tutorial
/lesson_3b_ex2.py
997
4.09375
4
'''Given the solution from the following problem, we again want a counter printed to the console. Add three buttons that start, stop and reset the counter, respectively. ''' try: import simplegui except: import simpleguitk as simplegui # Counter with buttons ###############################################...
f1175f6d8c0a7aa5f726ee7e1cb60b41e0d0a5c3
turingtei/Python_Tutorial
/lesson_4a_03.py
1,229
3.8125
4
'''Math time(t) velocity(v) acceleration(a) position(p) p = v * t Points and Vectors x and y coordinate. Origin is upper left corner (0,0) position and velocity changing with time: p(t) v(t) p(t+1)=p(t)+(1)*(v(t)) p[0] = p[0]+v[0] p[1] = p[1]+v[1] Adding a vector to a points results in a new point. Subtracting two...
112da86c726bd8f3334258910eae937aff2f8db5
ms99996/integration
/Main.py
1,664
4.1875
4
"""__Author__= Miguel salinas""" """This is my attempt to create a mad lib """ ask = input("welcome to my mad lib, would you like to give it a try? enter " "yes or no, the answer is case sensitive: ") while ask not in ("yes", "no"): ask = input("please type a valid input: ") def get_answers(...
292f7e3fb1d833857d14696c270d9d41b7da77dd
mrinal-roy/Geektrust_Submission_Traffic_Problem
/test_create_orbit_func.py
1,083
3.609375
4
import unittest from function.functraffic import * from classfiles.classtraffic import * class TestOrbitCreation(unittest.TestCase): '''It tests creation of two orbit objects using function test_defineOrbit which in turn tests for function defineOrbit. ''' def setUp(self): self.orb_1 = Orbit(...
3c2142ac2ef70d30f366597c29e6313155f7ee2e
songyuanping/syp_muke
/PyThon面向对象基础/访问私有化属性.py
346
3.78125
4
class Person(object): def __init__(self): __age=18 def setAge(self,value): if isinstance(value,int) and 0<value<200: self.__age=value else: print('你输入的数据有问题,请重新输入!') def getAge(self): return self.__age p=Person() p.setAge(220) print(p.getAge())
0f12becaf557cc5c905993cb16afbb6ecf55a641
RickyRRR/pythonProjects
/hello.py
4,677
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a hello module ' __author__ = 'ricky Xu' import sys import logging from io import StringIO import os logging.basicConfig(level=logging.INFO) # print("hello!"); # print(ord('A')); # print(chr(65)) print('rate is %.2f %% ' % 3.14); #占位符 b = '中文'.encode('utf_8') # 转...
848153ea08f53f761f05f9abcb36fc2216c499e1
jeffersonklamas/Learning_repository
/Estudo_de_Python/Exercicios-em-python/eclipse.py
357
3.734375
4
# ---------------------------------------- # Criando eclipses de cores. import turtle col = ("yellow","red","green","blue","white","orange","pink","gray","lilac","purple","brown") t = turtle.Turtle() screen = turtle.Screen() screen.bgcolor("black") t.speed(30) for i in range (150): t.color(col[i%6]) t.forwar...
6c6c326e7b1333ae19bd5e019f9902015435b6ff
jeffersonklamas/Learning_repository
/Estudo_de_Python/Exercicios-em-python/TestesGEral.py
1,593
3.75
4
""" a = int(input("Qual o valor de a? ")) b = int(input("Qual o valor de b? ")) aux = a a = b b = aux print("O valor de a é",a) print("O valor de b1 é",b) s = 0 for d in range(0, 5, 0.1): s += d print(s) a = 60 b = 30 c = b if (b > a) else a print(b) print(c) x = 67 y = 80 x, y, z =1,2,3 print(x,y,z) im...
2751c555e7013b68edf648c2c5523c3218759546
jeffersonklamas/Learning_repository
/Estudo_de_Python/Exercicios-em-python/mediaaritmetica.py
926
4.4375
4
# ----------------------------------------------------- # Exercício desenvolvido por Jefferson Klamas Maarzani # Para as atividades do Curso da UFSCAR disponíveis na # Plataforma do Coursera para o curso de Introdução # da Ciência da Computação com Python # ----------------------------------------------------- # # Enu...
cc2900e3d4536389d9bd059d884098bc147d3e6d
jeffersonklamas/Learning_repository
/Estudo_de_Python/Exercicios-em-python/equacoesde2grau.py
888
4.125
4
#-------------------------------------------- # Cálculo de equações de segundo grau ( Bhaskara) # #-------------------------------------------- import math a = float(input("Digite um valor para A: ")) b = float(input("Digite um valor para B: ")) c = float(input("Digite um valor para C: ")) # Calculo(a, b, c) delta =...
9e25ad7e7af83fa569ce89a5a3a33122812388f2
nathangr/solar-forecast
/combine.py
1,259
3.875
4
import sys # Used to check if all necessary arguments were passed in the Makefile if len(sys.argv) < 3: print('Missing argument(s)') print('Usage: combine.py infile1 infile2') # Store both file that are passed as arguments in the Makefile and that we need to combine together infile1 = sys.argv[1] infile2 = sys.ar...
d6baa2d4320f15ece2bd9d628911145a1b471105
ErenBtrk/PythonSetExercises
/Exercise7.py
237
4.375
4
''' 7. Write a Python program to create a union of sets. ''' set1 = set([1,2,3,4,5]) set2 = set([6,7,8]) set3 = set1 | set2 print(set3) #Union setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) seta = setx | sety print(seta)
7c1c1460a2d133f815ce971962722e24c89f5c33
master-rahul/Terribly-Tiny-Assigment
/Rahul Verma, 11811619.py
1,762
3.5
4
import requests import tkinter as tk root= tk.Tk() canvas1 = tk.Canvas(root, width = 400, height = 300) canvas1.pack() entry1 = tk.Entry (root) canvas1.create_window(200, 140, window=entry1) def num (): count = 0; word = ""; maxCount = 0; words = []; #Opens a file in r...
da1883f6694f2bc8b6f449096c519bf9e6b2e30c
sivaprasadkonduru/Python-Programs
/Dreamwin5/primenum.py
459
4.03125
4
num = int(input("Enter any number: ")) '''for i in range(2, num): if num % i == 0: print("{} is not a prime number".format(num)) break else: print("{} is a prime number".format(num))''' l = [] for j in range(2, num+1): for i in range(2, j): if j % i == 0: #print("{} is ...
ab6cd81f64aa02038cbae0988bb14e5b90731ef0
sivaprasadkonduru/Python-Programs
/Dreamwin5/factorial.py
277
3.84375
4
from app_log import logger num = int(input("Enter any number: ")) logger.info("Number provided: %s" % num) fact = 1 if num == 0 or num == 1: print("Factorial is 1") for i in range(1, num + 1): fact = i * fact logger.info("Factorial of Number %s is %s:" % (num, fact))
546cd33519cea7f759d09ccd11203d44fed2fc4d
sivaprasadkonduru/Python-Programs
/Sooryen_python/question3.py
608
4.125
4
''' Write a function that takes an array of strings and string length (L) as input. Filter out all the string string in the array which has length ‘L’ eg. wordsWithoutList({"a", "bb", "b", "ccc"}, 1) → {"bb", "ccc"} wordsWithoutList({"a", "bb", "b", "ccc"}, 3) → {"a", "bb", "b"} wordsWithoutList({"a", "bb", "b", "ccc"...
b45b33a33627077c7984b736a0627597d706d763
sivaprasadkonduru/Python-Programs
/Dreamwin4/OOPS/classdec_withargs.py
332
3.65625
4
class Decorator: def __init__(self, x): self.x = x def __call__(self, func): def dec_args(a, b): out = func(a, b) return out return dec_args @Decorator(5) def hello(a, b): return a * b '''obj = Decorator(5) print(obj) val = obj(hello) print(val)''' hello...
f07377a946cf79ec440744a992605fe067387322
sivaprasadkonduru/Python-Programs
/trans_expr.py
458
3.8125
4
""" Python program to transform the expression postfix""" def transform(expr): data = [] count = 1 for i in expr[1:]: if i == '(': count += 1 elif i.isalpha(): print(i, end='') elif i == ')': count -= 1 print(data.pop(), end='') ...
85b7f37032052a6820a5e3f262b11ed1f22199cf
sivaprasadkonduru/Python-Programs
/Dreamwin5/functions/fib_gen.py
308
3.578125
4
def fib_gen(n): a, b = 0, 1 for _ in range(n): yield a a, b = b, a+b out = fib_gen(50) '''print(out) print(out.__next__()) print(out.__next__()) print(out.__next__()) for i in out: print(i)''' # generator expressions val = list((i for i in out if i % 2 == 0)) print(val)
e9100ef719d45a22962437858e414764073b8127
sivaprasadkonduru/Python-Programs
/Dreamwin5/nestedfor.py
200
3.6875
4
a = [3, 4, 5] b = [7, 8, 9] #c = [(3, 7), (4, 8), 5, 9] c = [] for i in enumerate(a): #(0, 3) for j in enumerate(b): #(0, 7) if i[0] == j[0]: c.append((i[1], j[1])) print(c)
6b80a6883a8cd5d2330d9d7c1bb505315161c555
sivaprasadkonduru/Python-Programs
/Dreamwin5/prime.py
143
3.671875
4
'''n = 99 if n%2==0: print("even") else: print("odd") ''' a = [1,1,2,2,2,2,3,3,3,4,4,4,4,4,4,4,4,5,5] b = set(a) c = list(b) print(c)
a3a47a78cfb3d684c2197936b316ed4b77faf2d9
sivaprasadkonduru/Python-Programs
/Dreamwin5/dict_swap.py
95
3.828125
4
d = {'x': 1, 'y': 2, 'z': 3} c = {} for key, value in d.items(): c[value] = key print(c)
44b87653d37d29c0ec6dda31a2b97cc0cb0ca1fa
sivaprasadkonduru/Python-Programs
/Dreamwin5/functions/lambda_func.py
246
3.796875
4
"Anonymous functions" """ syntax: lambda <variables>: <expression> """ #l = [3, 4, 5, 6] '''def squares(l): return l * l #l = int(input("Enter a number: ")) val = squares(5) print(val)''' a = lambda x=[2, 3, 4], y=10: x * y #print(a())
a3281383ffdc56fe64ce3aab0e36609e5b5ad167
sivaprasadkonduru/Python-Programs
/Dreamwin5/functions/func_tools.py
430
4
4
"""" Map: syntax: map(func, iterables) """ a = ["Sachin", "sourav", "virat"] b = ["Tendulkar", "ganguly", "kohli"] '''def func(i, j): return i + " " + j c = map(func, a, b) print(list(c)) c = map(lambda i, j: i + " " + j, a, b) s = map(lambda x: x * x, range(5))''' #[("Tendulkar", 9), ("ganguly", 7), ("kohli...
aa636b687f5e92f457943bee9b37070fcda9c4b6
sivaprasadkonduru/Python-Programs
/Dreamwin4/OOPS/abstraction.py
480
4.09375
4
import abc from abc import abstractmethod, ABCMeta class Abstract(metaclass=ABCMeta): #__metaclass__ = ABCMeta # python 2 @abstractmethod def start(self): pass @abstractmethod def drive(self): pass def stop(self): pass class Implement(Abstract): def start(sel...
e67ea284ba09edd9f1551f92890bdd37f3fd3ea4
Bosyi89/Python-test-reto-phase-1
/calculator.py
3,181
4.125
4
name = input('Please, write your name:') while True: operator = input(f'{name.capitalize()} Виберіть операцію з +; -; *; /; //; %; **; round; square of number or/' f'if your want exit please push 0:') if operator == '+': number1 = (input('Please, write first digit:')) number...
eafccf888f21b82129507ff7b7bf2bbb67e58146
DrewAeg/Network-FQDN-Generator
/tools.py
5,996
3.65625
4
# Built-in modules import csv import os import logging import argparse import tkinter as tk from tkinter import filedialog class OpenFile(): """A collection of tools asking users which files to open.""" @staticmethod def gui_ask_open_csv(): defaultextension=".csv" filetypes=(("Comma Separ...
baeaae373e8a6d6fd8f43b6cdc2a0bed8d306c21
shoreya27/justcode
/pattern_0_1.py
403
3.921875
4
num=int(input("Enter value: ")) #for loop c=0 for i in range(1,num+1): if i%2!=0: a=1 b=0 for j in range(1,i+1): print(a,end=' ') c=a a=b b=c else: a=0 b=1 for j in range(1,i+1): p...
0dbf67f54d726d9756794d0a6ccf5f19faf01132
ajeetpandeyy/IMDB-Case-Study
/IMDB Case study.py
5,290
3.515625
4
# coding: utf-8 # # Change in movie genre development trends since 1970 # ### Analysis based on IMDB data set. # In[1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt # Reading the main file # In[2]: data_set = pd.read_csv('IMDB data.tsv', sep='\t',low_memory=False) data_set.head(5) ...
1729501bf92ff6df0dbcfae6d751938126a76820
nerdpollyanna/Natural_language_processing_book_100_knock
/answer5.py
428
3.515625
4
target="I am an NLPer" #引数:リスト def make_N_gram(data): answer = [] for times,i in enumerate(range(len(data)-1)): sub_data=[] sub_data+=data[times:times+2] answer.append(sub_data) return answer #単語N-gram data_list_word=list(target) result=make_N_gram(data_list_word) print(result) #...
58677bf9c69c2e3245242bc27b6576bed2d0db32
nerdpollyanna/Natural_language_processing_book_100_knock
/answer7.py
697
3.515625
4
#07. x, y, zを受け取り「x時のyはz」という文字列を返す関数を実装せよ.さらに,x=12, y="気温", z=22.4として,実行結果を確認せよ. #coding: UTF-8 from string import Template def text_made(x,y,z): #x,y,zを引数にして、「x時のyはz」という文字列を返す #引数:x,y,z 埋め込むパラメータ #戻り値:成形した文字列 #x:時間 #y:"気温”などのtxt #気温等の数位 #s=(str(x) + "時の" + y + "は" + str(z)) #return s ...
67b9e880881a2b231209bafef1f036af80f00e6a
owenmoogk/project-euler
/15.py
1,016
3.953125
4
def recursion(x, y): # this solution is using a recursive method which takes a base case and counts possibilities from there # this takes way too long so we should find a better method. if x == 0 or y == 0: return 1 else: return(solution(x-1, y) + solution(x, y-1)) def backwardCoords(x...
b34401fd28a478f2aa32f9205e44711292715572
owenmoogk/project-euler
/6.py
808
3.84375
4
# The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 3025 # Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 2640 # Find...
423ef1647709d40c843a718e8b741d89862aa57d
wngus9056/Datascience
/Python&DataBase/5.13/Python04_13_StrEx02_김주현.py
517
3.515625
4
a = 'Life is too short, You need Python' print(a[3], a[0], a[12], a[-1], a[-0], a[-2], a[-5]) #ooooo print(a[9], a[10], a[14], a[20], a[-2]) print(a[0:4]) # a의 인덱스 0부터 4까지 출력 print(a[0:2], a[5:7], a[12:17]) # a의 인덱스 0부터2, 5부터7, 12부터 17까지 출력 print(a[19:]) # 인덱스 19부터 끝까지 출력 print(a[:5]) # 인덱스 처음부터 5까지 출...
1f2499d49a317952435eedd14bccf89d06fd581d
wngus9056/Datascience
/Python&DataBase/5.17/Python06_15_SetEx03_김주현.py
213
3.84375
4
#값 1개 추가 s1 = set([1, 2, 3]) s1.add(4) print(s1) #값 여러개 추가 s2 = set([1, 2, 3]) s2.update([4, 5, 6]) print(s2) #특정 값 제거 s3 = set([1, 2, 3, 4]) s3.remove(4) print(s3)
b057dad5c0307597966561d0cf375384f7e22e89
wngus9056/Datascience
/Python&DataBase/5.10/test.py
327
3.53125
4
vAge = 25 result = '성인입니다.' if vAge>= 18 else "청소년입니다." print(result) ''' 귀속회수 = 10 while 귀속회수 > 0: 귀속회수 = 귀속회수 - 1 print("귀속회수가 %d 남았습니다." % 귀속회수) if 귀속회수 == 0: print ("더 이상 거래 불가합니다.") '''
4507aec6ec1541f89c75439cf8174663762e390f
wngus9056/Datascience
/Python&DataBase/5.13/Python04_02_FormatFun02_김주현.py
381
3.6875
4
a = "My name {}".format('Hong') # format으로 주어진 값을 차례대로 가져온다. b = "{0} x {1} = {2}".format(2, 11, 11*2) # {}안에 입력한 숫자대로 format에서 인덱스값으로 가져온다. c = "{b} x {c} = {a}".format (a= 11*2, b= 2, c= 11) # {}안에 변수로 주면 format에서 준 변수를 가져온다. print(a) print(b) print(c)
00b1d32a83c0d4ce5beae77c7ae64b36a3b9703e
wngus9056/Datascience
/Python&DataBase/5.11/Python02_09_ForEx01_김주현.py
297
3.9375
4
test_list = ['one', 'two', 'three'] # test_list에 리스트 형식의 'one', 'two', 'three'를 저장 for i in test_list: # test_list안의 값을 인덱스 0부터 끝까지 반복하며 i 변수에 저장한다. print(i) # test_list 인덱스 0부터 저장된 i값을 출력한다.
83b66ea1b07c407d4206f678afdcd85bd836efb8
wngus9056/Datascience
/Python&DataBase/5.17/Python06_19_DataTypeEx04_김주현.py
213
3.671875
4
a = [1, 2, 3] b = a print('a, b 변경전 = ', a, "/", b) a[1] = 4 print('a[1] 변경후 = ', a, "/", b) c = [1, 2, 3] d = [1, 2, 3] print(id(c)) print(id(d)) c = d print(id(c)) print(id(d))
6194b5bb5293b0e2622db9209159a8f761e5102e
wngus9056/Datascience
/Python&DataBase/5.14/Python05_02_FruitListSample01_김주현.py
932
3.78125
4
while True: number = int(input("^10이상의 수를 입력 하세요. [ Exit : 0 ] : ")) if number == 0: print("종료합니다.") break elif number < 10: print() print("^10이상의 숫자 확인 하세요.") print() elif number >= 10: print("==<< %d번 반복합니다. >>==" %number) ck = [] ck_ct = [] for x in range(1,number+1): if x ...
0ea1187add3cc52f1734902a4bddcbd7c8207f51
wngus9056/Datascience
/Python&DataBase/5.21/HW02Pandas03_01_ClassEx01_김주현.py
380
3.5
4
class Fourcal: def setdata(self, first, second): self.first = first self.second = second a = Fourcal() a.setdata(5,3) print(a.first) print(a.second) print(type(a)) ''' class Fourcal: def setdata(self, first, second): self.first = second self.second = first a = Fourcal() a.setdata(...
5b753bc5c39e69096aae35e5ec87534d3fdee93b
wngus9056/Datascience
/Python&DataBase/6.2/Pandas07_12_reindex01_김주현.py
479
3.515625
4
# coding: utf-8 # Pandas07_12_reindex01_김주현 # In[1]: import pandas # In[2]: dic = {'c0' : [1, 2, 3], 'c1' : [4, 5, 6], 'c2' : [7, 8, 9], 'c3' : [10, 11, 12], 'c4' : [13, 14, 15]} df = pandas.DataFrame(dic) print(df) # In[3]: df = pandas.DataFrame(dic, index = ['r0', 'r1', 'r2']) print(df) # In[5]: ...
493fc7c826f1ccb1031622d41b42404000c1845e
wngus9056/Datascience
/Python&DataBase/5.21/제목 없음1.py
234
3.625
4
# 묵 찌 빠 # 1 2 3 import random while True: computer = [] user_input = input('번호를 선택하세요 : ') computer = random.randint(1,3) if user_input == 1: if computer == 1: print('\tCom : 바위\t/')
c5549cd3dee8f0dbddb7cba857089785eac908c1
wngus9056/Datascience
/Python&DataBase/5.12/Python03_07_ForExp00_김주현.py
217
3.703125
4
a = [1, 2, 3, 4] result = [] for num in a: # a값을 num에 하나씩 저장시켜주고 result.append(num*3) # result변수에 저장받은 num * 3값을 추가(append)해준다. print(result)
312b26864ce04c9afc1514954e4b14f299562edb
wngus9056/Datascience
/Python&DataBase/5.21/Pandas03_13_GawiBawiBo_김주현.py
2,575
3.5
4
# 묵 찌 빠 # 1 2 3 import random def defglobal(): global cwin global uwin global win_total global whowin def defnum1(): if computer == 1: print('\tCom : 바위\t/\tUser : 바위\t\t Draw! 비겼습니다!') elif computer == 2: print('\tCom : 가위\t/\tUser : 바위\t\t You Win! 당신이 이겼습니다!') uwin = uwin +1 e...
41b36d7a1af86a2715b478938bd1319f6b3134ee
wngus9056/Datascience
/Python&DataBase/6.4/Pandas08_03_DataFrameOper01_김주현.py
647
3.84375
4
# coding: utf-8 # Pandas08_03_DataFrameOper01_김주현 # In[1]: import pandas import seaborn # In[2]: titanic = seaborn.load_dataset('titanic') # In[3]: print(titanic.columns, '\n', titanic.shape) # In[4]: df = titanic.loc[:, ['age', 'fare']] # In[5]: print(df.head()) print('-'*20) print(type(df)) # I...
6c7b07706336ee69c854f6ad15bfc08849f45456
pallakrishnamurthy/Personal
/sample_Programs/slot_game_gui.py
2,330
3.890625
4
import tkinter as tk import random intro = """Panther's Den Slot Machine. Welcome to my den! You can win by rolling Ocelots, Jaguars, Boas, Caimans, Macaws or Tapirs. You can also with big with three Ibis. You'll lose a coin for anything else, and if you roll three Scorpions say good bye to 500 coins Good luck ki...