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
4b16ebf8b0681f4747caa5060a7f1c9ee35c835a
satyagraha5/CodeJam_Python
/2015/Haricut/scratch.py
311
3.9375
4
def gcd(a,b): if a < b: a, b = b, a while b > 0: a, b = b, a % b return a def lcm(a,b): print("gcd of {} and {} is {}".format(a,b,gcd(a,b))) return int((a*b)/gcd(a,b)) if __name__ == "__main__": print("lcm of {} and {} is {}".format(1,2,lcm(1,2)))
fca4c33f96c85d4d72dba5102701ec41b59bd1de
satyagraha5/CodeJam_Python
/2016/Rank_and_File/Rank_and_File.py
3,913
4.375
4
''' When Sergeant Argus's army assembles for drilling, they stand in the shape of an N by N square grid, with exactly one soldier in each cell. Each soldier has a certain height. Argus believes that it is important to keep an eye on all of his soldiers at all times. Since he likes to look at the grid from the upper l...
0cf1f54f68939245f8369136790848a9369f0971
Sruthisarav/My-computer-science-journey
/Introduction to Computer Science and Programming Using Python/Problem Set 4/Problem-1.py
1,008
4
4
SCRABBLE_LETTER_VALUES = { 'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10 } def getWordScore(word, n): """ Returns the score for a word. Assumes ...
339d7520d0f034774d40064222161a4efe78305e
imesh-herath/Students_Results_Sheet
/Part5.py
2,193
3.59375
4
#Getting varriables result = 0 #Make a List using the marks MARKS_LIST = [[120,0,0], [100,20,0], [100,0,20], [80,20,20], [60,40,20], [40,40,40], [20,40,60], [20,20,80], [20,0,100], [0,0,120]] progress, trailer, retriever, excluded = 0, 0, 0, 0 def results(): #defining a function name results for i in range (len...
201aa4e33cd60c09d00aa22b5ce8433f533f6543
Shogun616/Asteroid-Python-
/bullet.py
587
3.625
4
from circle import Circle from polygon import Polygon class Bullet(Circle): def __init__(self, x, y, rotation): super().__init__(x, y, r=2,rotation=rotation) self.accelerate(5.0) def update_bullet(self, width, height): # Update the position and orientation of the ...
1baefee5843f766f388ef5e3090596d790a8d2e4
Shogun616/Asteroid-Python-
/asteroids.py
5,648
3.5
4
import sys import random import pygame from pygame.locals import * from game import Game from ship import Ship from bullet import Bullet from star import Star from spacerock import Spacerock from spacerock2 import Spacerock2 from spacerock3 import Spacerock3 #from enemyship import Enemyship class Asteroid...
88e84b4fce8e872dfa4dcea4e8622950cca61299
Afrid165/escape2021.git-demo
/fibonachhi.py
350
3.890625
4
from functools import cache @cache import numpy def fibonachhi(n): ````` Function to calculate fibonachhi series through recursion. ```` if n == 0: return 0 if n == 1: return 1 return fibonachhi(n-1) + fibonachhi(n-2) def fib_gen(n): for i in range(n): yield fibonachhi(i) if __name__ == '__main__': fo...
9ffe03358e681158af1452776150deb8057eaa29
violetscribbles/Learn-Python-3-the-Hard-Way-Personal-Exercises
/Exercises 1 - 10/ex9.py
791
4.28125
4
# Here's some new strange stuff, remember type it exactly. # Defines 'days' variable as a string days = "Mon Tue Wed Thu Fri Sat Sun" # Defines 'months' variable as a string. Each month is preceded by \n, which # is an escape character that tells python to create a new line before the # text. months = "\nJan\nF...
7a8b69772d91d10c3d404847fa1a82280c22e614
rafaelmarino/mapreduce_fundamentalsv2
/q2_server_logs/B/q02b_mapper.py
490
3.75
4
# Question 1. Answer B. Mapper. import sys import re def read_input(file): for line in file: # yield line.split('\t') # split line into words yield line # final generator object is a list of lists def main(): # input comes from STDIN (standard input) data = read_input(s...
e93482664aaa43a701dfcb9fda6cd0e80c288ee1
duliodenis/coding_challenge-24
/day/1/2.py
750
4.09375
4
# Part 2 - calculate the fuel for the fuel import math # 1. Open the data file and read each line into a list with open('1-data') as f: lines = [line.rstrip('\n') for line in open('1-data')] # declare the accumulator variable fuel_required = 0 # 2. write a recursive function to calculate the fuel for the fuel de...
319cefb2c402455a8151e918c6814476ca830cbe
cristian15/Progra-2
/Laboratorios/Lab#1 Progra II/Lab01-01.py
1,340
3.625
4
# ----------------------------------------------- # ----- Nombre: Cristian Beltran Concha --------- # ----- Prof: Luis Caro Saldivia ---------------- # ----- Asignatura: Programacion 2 ---------- # ----------------------------------------------- # ----- Descripcion: Sube imagenes desde una carpeta a SQLite # ---------...
a9dade6f943a38622a82cbe8fc8c8de010dd1589
Rolodophone/various-python-programs
/Completed/Illusion.py
205
3.6875
4
import turtle canvas = turtle.Screen() pen = turtle.Turtle() pen.speed(0) pen.hideturtle() pen.up() pen.goto(0,-200) pen.down() x = 200 for i in range(1000): x*=0.99 pen.circle(x,45)
361d9db0d848b177a18fb734d04451616ef06a2a
Rolodophone/various-python-programs
/Completed/String manipulation programming challenges 2.py
689
4.15625
4
while True: string = input("\n\nEnter a string") option = input("Would you like to:\nFind the [N]umber of characters in " "the string\n[R]everse the string\nConvert the string " "to [U]ppercase\nConvert the string to [L]owercase\n") if option == "n": pri...
3f1a281ff40e1403cf921367c6daf230da283bdd
mann2108/Web-Scrapping
/web_scrapping.py
2,720
3.5625
4
''' @author mann2108 **********WEB Scrapping********** Task : downloading all the solution codes from codechef practice section located in 'codechef.com/users/user_name' and store them in 'Problems' directory. Prerequisite Actions : - 1. Install Selenium globally using - 'pip install selenium' If you ar...
e96dc20f9d8e0ecc2f1ec1121406c91311ebb32a
phuonghoangpham/phamhoangphuong-lab-c4e20
/lab3/homework/SE11.py
400
4.0625
4
def is_inside(): x_p=int(input("x coordinate of point: ")) y_p=int(input("y coordinate of point: ")) x_r=int(input("x coordinate of rectangle: ")) y_r=int(input("y coordinate of rectangle: ")) w=int(input("width of rectangle: ")) h=int(input("height of rectangle: ")) if x_r<=x_p<=x_r+w and ...
afadb19c257de9c140a2d570113e5be787b6da8d
phuonghoangpham/phamhoangphuong-lab-c4e20
/lab3/homework/SE7.py
119
3.890625
4
def remove_dollar_sign(): s = input('Input your string here: ') print(s.replace('$','')) remove_dollar_sign()
38ae530edb846a6bef048961fada233d10ec5ecd
xemage/erocon
/Chapter-3-Life-Of-A-Thread/ending-a-thread.py
954
3.859375
4
# Ending threads is deemed bad practice # Best practice in stopping threads # If you require some form of a thread shutdown mechanism, then it is your job to implement # a mechanism that allows for a graceful shutdown as opposed to killing a thread outright. # While threads might not possess a native mechanism for term...
2d780374f4a492b6a6f706bd0563c4dca301fbae
315karenbastida/ProyectoPythonTienda
/proyecto2.py
5,708
3.6875
4
import getpass nombresArticulos = ('Playera color rosa','Sueter azul','Chamarra de cuero','Pantalon de Mezquilla','Juego de Te','Lavadora','Estufa','PC pro gamer 999x') inventario = {} informacionArticulos = [[10,'Nike',150],[5,'Bolo',300],[3,'Cuerox',1200],[6,'Vans',200],[4,'PlayMobil',500],[2,'Coff',10000],[12,'Koffe...
9433f049430dec447778c8e5bf82d4b62c2b9178
Matt-Fisherrr/battleship
/main.py
2,055
3.703125
4
from lib.battleship import Battleship from lib.utils import * import time, sys, random def game_loop(game, automated=False): current_attacker = 1 current_defender = 2 while True: while True: if automated: location = game.get_random_shot(current_attacker) print(f'{current_attacker}: {loc...
347670349ec69bc979e969a7a1160c03837a4897
vanden/code_challenges
/hacker_rank/python_badge_questions/capitalize.py
320
3.796875
4
# https://www.hackerrank.com/challenges/capitalize/problem def solve(s): lastWasSpace = True new = list(s) for i in range(len(s)): if s[i] == " ": lastWasSpace = True elif lastWasSpace: new[i] = new[i].upper() lastWasSpace = False return "".join(new)
fa2a6f0d7045d2b3908a0502f8230fc09c361b1d
vanden/code_challenges
/hacker_rank/pickingnumbers.py
2,359
3.78125
4
#!/bin/python3 # https://www.hackerrank.com/challenges/picking-numbers/problem # This cannot be an optimal solution. def pickingNumbers(a): filtered = [] for num in a: if num-1 in a or num+1 in a: filtered.append(num) nums = sorted(list(set(filtered))) # Can't restrict to f...
cbedd98e3d8fb3c938276f13bbb1e2e728738685
vanden/code_challenges
/hacker_rank/project_euler/pe25_n_digit_fib.py
556
3.671875
4
# https://www.hackerrank.com/contests/projecteuler/challenges/euler025 fibs = [1, 1, 2, 3] def indexOfLeastFibLenN(n): if len(str(fibs[-1])) >= n: for fib in fibs: if len(str(fib)) == n: return fibs.index(fib) + 1 while True: nextFib = fibs[-1] + fibs[-2] fi...
39368ac79dfd4c8d5ab749a7a641ebcf159129e1
vanden/code_challenges
/hacker_rank/height_of_bintree.py
644
4.03125
4
# https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree/problem # Enter your code here. Read input from STDIN. Print output to STDOUT ''' class Node: def __init__(self,info): self.info = info self.left = None self.right = None // this is a node of the tree , wh...
4cf521d5e6b261dbdbc2e7fa41edc50b8052431c
vanden/code_challenges
/hacker_rank/project_euler/pe20_factorial_digit_sum.py
496
3.625
4
# https://www.hackerrank.com/contests/projecteuler/challenges/euler020 factorials = {0:1, 1:1, 2:2, 3:6} def factorial(n): for i in range(4, n+1): if factorials.get(i): continue else: factorials[i] = factorials[i-1] * i return factorials[n] def factorialDigitSum(n): ...
3292568f75fdc36c88e573666ec6760489f7cfd0
vanden/code_challenges
/leetcode/linked_list_cycle2.py
944
3.734375
4
# https://leetcode.com/problems/linked-list-cycle-ii/ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # Runtime: 44 ms, faster than 99.67% of Python online submissions for Linked # List Cycle II. # Memory Usage: 18.4 MB, le...
33672c35f9139ca05016553e99a512dd98ab36a1
vanden/code_challenges
/leetcode/queueReconstructionByHeight.py
576
3.875
4
#!/usr/bin/env python3 # https://leetcode.com/problems/queue-reconstruction-by-height/description/ class Solution: def reconstructQueue(self, people): people = sorted(people, key=lambda x:(-x[0],x[1])) queue = [] for height, count in people : #print(i) queue.insert(...
fbec28d652c0dd4d81a7dcb518c82a4d635c147f
vanden/code_challenges
/leetcode/diameter_of_bintree.py
906
3.65625
4
# https://leetcode.com/problems/diameter-of-binary-tree/description/ class Solution: def diameterOfBinaryTree(self, root): if not root: return 0 throughRoot = (self.maxDepth(root.left) + self.maxDepth(root.right)) leftDiameter = self.diameterOfBinaryTree(root.left) right...
38eaa1dc06dc7d66715ab600c3528068c5a5acdb
vanden/code_challenges
/leetcode/remove_duplicates_from_a_sorted_array.py
3,518
3.71875
4
# https://leetcode.com/problems/remove-duplicates-from-sorted-array/ # Yikes! # Runtime: 10600 ms, faster than 1.00% of Python3 online submissions for # Remove Duplicates from Sorted Array. # Memory Usage: 14 MB, less than 0.99% of Python3 online submissions for # Remove Duplicates from Sorted Array. class Solution...
19415ac8f302e0e4ce868591a06989d1ee813530
study-material-stuff/Study
/Study/Python/Assignments/Assignment 11/Checksum-master/Assignment11_3.py
1,413
3.734375
4
#3. Design automation script which accept directory name and delete all duplicate files from that #directory. Write names of duplicate files from that directory into log file named as Log.txt. #Log.txt file should be created into current directory. #Usage : DirectoryDusplicateRemoval.py “Demo” import datetime; from sy...
974f629117846daae4de8b0e22b1d68407763078
study-material-stuff/Study
/Study/Python/Assignments/Assignment 8/Assignment8_5.py
570
4.28125
4
#5.Design python application which contains two threads named as thread1 and thread2. #Thread1 display 1 to 50 on screen and thread2 display 50 to 1 in reverse order on #screen. After execution of thread1 gets completed then schedule thread2. import threading; def DispNumbers(): for no in range(1,51): prin...
96774bc096c3abe9241d4078f4cfb24103c17fe8
study-material-stuff/Study
/Study/Python/Assignments/Assignment 2/Assignment2_5.py
269
4.0625
4
def ChkPrime(num): ret = True; for x in range(2,int(num/2)+1): if(num % x == 0): ret = False; break; return ret; num = int(input("Enter the num")); if(ChkPrime(num)): print(num ," is Prime Number"); else: print(num ,"is not Prime Number");
2fb056ddefd2368f9947f213e92627b9e09071e1
study-material-stuff/Study
/Study/Python/Assignments/Assignment 4/Assignment4_1.py
238
4.28125
4
#1.Write a program which contains one lambda function which accepts one parameter and return #power of two. powerof2 = lambda num : num * num; num = int(input("Enter the number :")); print("power of the number is ",powerof2(num));
632595f3769677c4c183937435caea247f81388e
study-material-stuff/Study
/Study/Python/Assignments/Assignment1/Assignment1_7.py
145
3.6875
4
def ChkNum(num): if(num%5 == 0): ret = True; else: ret = False; return ret; no=int(input("Enter the number")); print(ChkNum(no));
df7d157de66869224a7e5089d07dd1bb850e68a4
study-material-stuff/Study
/Study/Python/Assignments/Assignment 2/UserModule.py
315
3.703125
4
import ArtthmaticModule as math num1 = int(input("Enter the num1")); num2 = int(input("Enter the num2")); print("Addition ",math.Addition(num1,num2)); print("Subtraction ",math.Subtraction(num1,num2)); print("Division ",math.Division(num1,num2)); print("Multiplication ",math.Multiplication(num1,num2));
beafbc1a17dcb2830c9640c50595aef635deff1b
study-material-stuff/Study
/Study/Python/Assignments/Assignment 4/Assignment4_3.py
1,025
3.875
4
#3.Write a program which contains filter(), map() and reduce() in it. Python application which #contains one list of numbers. List contains the numbers which are accepted from user. Filter #should filter out all such numbers which greater than or equal to 70 and less than or equal to #90. Map function will increase ...
350115f6b3f56133565cc02cf2c0f86c26380a81
study-material-stuff/Study
/Study/Python/practise/5.py
546
3.71875
4
# boy and girl height def Check(boy,girl,blist , glist): bret = True; if boy > girl: print("No"); return b = [] blist.sort() glist.sort() for i in range(len(blist)-1): if glist[i] > blist[i]: bret = False; break; if bret == True: print("YES") else: print("NO") for i in rang...
f983b534343a2d5dc7654a330e6d58b91372c31f
study-material-stuff/Study
/Study/Python/Assignments/Assignment 9/Assignment9_4.py
551
3.921875
4
#4.Write a program which accept two file names from user and compare contents of both the #files. If both the files contains same contents then display success otherwise display failure. #Accept names of both the files from command line. import filecmp; import sys; def Accept(): filename1 = sys.argv[1]; file...
8d07c12136d2831cc08935bb89266ddb6f62c947
gumityolcu/Binari
/Code/syllabliser.py
3,972
3.875
4
""" Türkçede kelime içinde iki ünlü arasındaki ünsüz, kendinden sonraki ünlüyle hece kurar: a-ra-ba, bi-çi-mi-ne, in-sa-nın, ka-ra-ca vb. Kelime içinde yan yana gelen iki ünsüzden ilki kendinden önceki ünlüyle, ikincisi kendinden sonraki ünlüyle hece kurar: al-dı, bir-lik, sev-mek vb. Kelime içinde yan yana gelen üç...
d023f2fe5bfb44a3ca32176ad557542eeaf0883b
Devil-Rick/Advance-Task-6
/Inner and Outer.py
506
4.1875
4
""" Task You are given two arrays: A and B . Your task is to compute their inner and outer product. Input Format The first line contains the space separated elements of array A . The second line contains the space separated elements of array B . Output Format First, print the inner product. Second, p...
8c6cffbd6c9a833aeee99a3f112c6fc301e9f9ac
Mike28e/TicTacToe
/pythonGame.py
2,132
3.703125
4
import sys import os class ttToe: __tableTop = '' __tableMid = '' __tableBot = '' __tableSplit = ('-----------') __playGame = True def __init__(self): for t in range(0,3): self.__tableTop += (' | | \n') self.__tableMid = self.__tableTop self.__tableBo...
2264eebf246360a40855b8367ec2478788ab9d95
Aledeosma18/Simulation
/Sprint_3_Deliverables/Ticket_Problem.py
2,409
3.828125
4
""" Alejandra De Osma CMS_380 Sprint 3 Ticket Problem """ #IMPORTS from random import random def seat (empty_seat = [x for x in range(100)]): #returning a random seating seat_1 = (int)(random() * len(empty_seat)) #random number that selects a random spot in empty_seats #returns the seat return(empt...
2a6e06e292da0af408dd44c1ff89bac9727600db
Aledeosma18/Simulation
/Sprint_4_Deliverables/M_M_1.py
5,733
3.796875
4
""" Alejandra De Osma CMS_380 Sprint 4 M/M/1 PROGRAM: This program will simulate a M/M/1 queue. """ # IMPORTS import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt from random import random import math from math import log #--- Generate an exponential random variate # # Input: mu, ...
4d9802ad76c0d52714c52ba68b16a3b2596941fa
CarsonForsyth/Algorithms
/Strongly_Connected.py
2,418
3.9375
4
# Find Connected Components # By Carson Forsyth # From Professor Mingfu Shao # CMPSCI 465 @ PSU, FA2020 # Traverse graph in reverse postlist order counting connected components. from typing import List # Declare global variables. num_connected = 0 post_list: List[int] = [] visited_vertices = [] # Depth first searc...
739801e91877bde2fb60cb77b8b54d0c5d5fbee4
wen-3/python_practice
/Ch7_FunctionAndModule/practice7.py
9,442
3.875
4
# 1. 自訂函式 # 1.1 攝氏轉華氏 def tem(c): f = c*1.8 + 32 f = round(f, 1) return f c = int(input("請輸入攝氏溫度:")) print(f"華氏溫度為: {tem(c)} 度") # 1.2 公斤轉英鎊 def weight(kg): pound = kg * 2.2 pound = round(pound, 1) return pound kg = int(input("請輸入體重公斤數:")) print(f"你的體重為:{weight(kg)} 鎊") # 2. 數值凾式 # 2.1 學生均分蘋...
273018c3cc507811b01e7999cfbc7dc3d252a02c
wen-3/python_practice
/practice/2020_08_21/03_practice.py
560
3.625
4
import numpy as np import numpy.random as random num = np.arange(1,51) print(num) print('陣列總和:',num.sum()) a = random.randn(10) print(a) print("最大值:",a.max()) print("最小值:",a.min()) print("總和:",a.sum()) m = np.ones((5,5), dtype = np.float64) mm = m*3 print(mm) # type is array print(mm * mm) # 陣列元素各自相乘 mm_new = np...
67efeb8cc289f60faf463cc6399c3b8d182e54c4
tomtom0516/python-cookbook-3rd-edition
/02 String and Text/B17html.py
203
3.546875
4
s = 'Elements are written as "<tag>text</tag>".' import html print(s) # Elements are written as "<tag>text</tag>". print(html.escape(s)) # Elements are written as &quot;&lt;tag&gt;text&lt;/tag&gt;&quot;.
1ac686009fed6338619b8c4ac1f848302d317e97
tomtom0516/python-cookbook-3rd-edition
/08 Classes and Objects/H17__new__.py
771
3.765625
4
# Use for deserializing JSON # For example, receive data = { 'year': 2012, 'month': 8, 'day': 29 } # Use this technology can change it into object import time class MyDate: def __init__(self, year, month, day): self.year = year self.month = month self.day = day @classmethod def to...
15f9b7627a0baaf3147ae2e3c2e3570606186b44
GEEGABYTE1/BiDirectionalLinkedList-Functions
/functions.py
2,564
3.625
4
from double_ll import DoubleLinkedList class Functions: def __init__(self, lst): self.lst = lst def every_second_node(self, counter=0): self.counter = 1 current_node = self.lst.get_head_node() while current_node: if current_node.get_value() != None and self.counte...
c1108c9ae69f08de277b80fbba0d450c245fe081
mygoal-javadeveloper/Dataquest.io
/Machine Learning Introduction/Calculus For Machine Learning/Finding Extreme Points-159.py
565
4.15625
4
## 3. Differentiation ## import matplotlib.pyplot as plt import numpy as np x = np.linspace(-5,6,110) y = -2 * x + 3 plt.plot(x,y) plt.show() ## 6. Power Rule ## slope_one = 5 * (2 ** 4) print(slope_one) slope_two = 9 * (0 ** 8) print(slope_two) ## 7. Linearity Of Differentiation ## slope_three = 5 * (1 ** 4) - ...
186c6f5635b29d29b1fc9985e2bb23da2a5267ab
mygoal-javadeveloper/Dataquest.io
/Probability and Statistics/Statistics Fundamentals/Sampling-283.py
3,423
3.640625
4
## 3. Populations and Samples ## question1 = 'population' question2 = 'population' question3 = 'sample' question4 = 'population' question5 = 'sample' ## 4. Sampling Error ## import pandas as pd wnba = pd.read_csv('wnba.csv') print(wnba.head()) print(wnba.tail()) print(wnba.shape) #boolval = (wnba['Games Played'] >= ...
a397d1bb9b25da1ce4627b78dac0440bb5bb7fe1
leegunha/TIL
/python/02_string.py
467
3.859375
4
'''String 조작하기 1. 글자합체 #글자 삽입''' name = "토니토니" age = 20 text = "안녕하세요 제 이름은 {}입니다.".format(name) print(text) f_text = f"안녕하세요 제 이름은 {name}입니다. 나이는 {age}살 입니다" #fstring print(f_text) #3. 글자 자르기 text_name = text[:10] print(text_name) text_split = text.split(" ") for i in range(0, len(text_split)): print(text_s...
1a47b86096e8c669ac3f17111001d3c65195b1cc
richardtvu/data-structures-algorithms
/grokking-algos/practice-scripts/exercise_4_3_recursive_max_attempt_1.py
1,084
4
4
# Takes in a list and the current max, which starts at the smallest negative number. def max(list, currMax): # If the list is empty, then the max of that list is 0. if len(list) == 0: return currMax # If the list has only one element and it's greater than the current max, then that element is the...
fd23bebe9b59b0662fb89bf10dc4b4cc5b796b2e
TokenYangForever/python_test
/easy_test/findMinAndMax.py
513
3.953125
4
def findMinAndMax(L): if len(L) == 0: return (None, None) minVal = L[0] maxVal = L[0] for val in L: minVal = min(val, minVal) maxVal = max(val, maxVal) return (minVal, maxVal) if findMinAndMax([]) != (None, None): print('测试失败!') elif findMinAndMax([7]) != (7, 7): print('测试...
79003f8e854d1dbe2e8596ecf8690c7ce3f03797
AikVant/Python-stack-queue
/07-Askisi 19.py
809
3.65625
4
#-*- coding: utf-8 -*- ##19. Γράψτε μία συνάρτηση σε python η οποία θα δέχεται ##ως όρισμα μία λίστα από αριθμούς (πιθανόν καθένας από ##αυτούς να εμφανίζεται περισσότερες από μία φορά) ##και θα επιστρέφει μία λίστα όπου κάθε αριθμός ##εμφανίζεται μόνο μία φορά δηλαδή θα αφαιρεί ##τυχόν διπλοεγγραφές import...
e9ff6b17552a2cc278d5817ce0ced6ef730cc144
ilakya-selvarajan/Python-programming
/mystuff/4prog2.py
353
4.21875
4
#a program that queries the user for number, and proceeds to output whether the number is an even or an odd number. number=1 while number!=0: number = input("Enter a number or a zero to quit:") if number%2==0 and number!=0: print "That's an even number" continue if number%2==1: print "That's an odd number" ...
5fa1581c49e22d5d23d4179a4c88fa2699673ac0
ilakya-selvarajan/Python-programming
/mystuff/lcm.py
199
3.609375
4
def LCM(firstNumber,SecondNumber): k=0 for i in range(1,SecondNumber+1): for j in range(1,firstNumber+1): if i*firstNumber==j*SecondNumber: k=k+1 if k==1: print i*firstNumber
90d39f337f902c128b891b88f645104aac93eb92
ilakya-selvarajan/Python-programming
/mystuff/prog5.py
215
4.0625
4
#a program that queries a string and an integer, and then outputs the string repeated the given number of times string=raw_input("Give a string: ") number=input("Give a number: ") output=string*number print output
1ebb06bc074b37920bc82735566bb4de5b215aec
ilakya-selvarajan/Python-programming
/mystuff/6prog2.py
428
4.0625
4
# A function that calculates and returns the average of all items in the list m. from __future__ import division #To output the decimal value def average(m): sumOfList=0 #Initialising a variable named sumOfList for i in range(0,len(m)): sumOfList+=m[i] #Adding each number in the list in sumOfLis...
876eb77d4a81863b5d478f37827c0298a4270cf2
ilakya-selvarajan/Python-programming
/mystuff/7prog6.py
440
4.125
4
#A function which gets as an argument a list of number tuples, and sorts the list into increasing order. def sortList(tupleList): for i in range( 0,len(tupleList) ): for j in range(i+1, len(tupleList) ): if tupleList[j][0]*tupleList[j][1]<tupleList[i][0]*tupleList[i][1]: temp=tupleList[j] tupleList[j]=t...
4e65a752dbbac9250c941c0ab63c00ecbf11c77f
ilakya-selvarajan/Python-programming
/mystuff/2prog6.py
302
4.03125
4
# To find the index of the second occurrence of string B in string A. string1 = raw_input("Give the string A:") string2 = raw_input("Give the string B:") a = len(string2) b = string1.find(string2) d=a+b c = string1[b+a:] print c print "The index of the 2nd occurrence of B in A is", c.find(string2)+d
eee40d974a515868c2db25c959e1cfa303002d00
ilakya-selvarajan/Python-programming
/mystuff/8prog4.py
433
4.21875
4
# A function to find min, max and average value from __future__ import division def minMaxAvg(dict): sum=0 myTuple=() myValues= dict.values() #extracting the values for values in myValues: sum+=values avg=sum/len(myValues) #Calculating the average myTuple=(min(myValues),max(myValues),avg) #Return...
8104f5f0ef5cc5a1210ce49d3c007ebb7302abbe
reactive-firewall/NetworkTrace
/code/analyze_pcap.py
3,399
3.625
4
#! /usr/bin/env python def parseargs(): """"parse the arguments""" import argparse parser = argparse.ArgumentParser(description='Decodes the content of a pcap file', epilog="Usually used to extract the file data from the a network trace (pcap) file. Remember last option wins.") parser.add_argument('-i', '--in', de...
317226597c2088e12a0b2551b4495d5f3f170f66
horacefung/Slack-Bot-Youtube
/slack_webserver.py
3,329
3.625
4
#!/usr/bin/python3 # Flask is a webserver library from flask import Flask, request, render_template # We will use the requests library to to issue a request to Slack # and the json library to parse it import requests import json SLACK_URL = "https://slack.com/oauth/authorize" # Edit this file to add your own client...
2600172fbc0223edb28af3000ea79adc68a81210
luisauribe/Python-languaje
/listas.py
1,310
4.15625
4
+---+---+---+---+---+---+ | P | y | t | h | o | n | +---+---+---+---+---+---+ 0 1 2 3 4 5 6 -6 -5 -4 -3 -2 -1 mi_lista = [17, 39, "Laura", True] print(mi_lista) # Asigna un valor nuevo al indive 1 mi_lista[1] = 7 print(mi_lista[:]) # Accede al indice 1 e imprime desde el 1 hasta el 3 omitiendo ...
12a89096fd6ad6bab15da2f113bd6d6067292380
luisauribe/Python-languaje
/ejercio_1.py
335
4.15625
4
num_1 = int(input("Introduce un numero: ")) num_2 = int(input("Introduce otro numero: ")) def devuelve_max(num_1, num_2): if num_1 > num_2: print("El número más alto es: ", num_1) elif num_1 < num_2: print("El número mas alto es: ", num_2) else: print("Son iguales") devuelve_max(nu...
17ca2751641b6e26fe6f0e9ce4b4b464efad7c16
sadsirko/LabsPA
/lab1/merge2file.py
1,928
3.546875
4
import os def toStr(arr): str1 = " " #print('a') return(str1.join(arr)) def merge2ser(str1,str2): str1 = str(str1)[:-1].split(' ') str2 = str(str2)[:-1].split(' ') if str1[len(str1) - 1] == '': str1.pop(len(str1) - 1) if str2[len(str2) - 1] == '': str2.pop(len(str2) - 1) ...
462a4a783376ff66befd6589bfca4de3521d1c73
jdh7/ScramSolver
/ScramSolve.py
5,308
3.703125
4
import copy print("Welcome to Scram Solver. This program requires numerical conversions of picture halves found on individual scramble square picture pieces and returns the solved puzzle."\n) print("Determine the four sets of pairs on the scramble square pieces and assign each half an integer f...
e97d339deb9c310bd05afe7137deac29f6d642aa
AaronBabian/AIBattleShip
/Packages/player.py
1,827
3.875
4
from typing import Iterable, List from Packages.user_input import user_input, MoveError import abc from . import board class Player(abc.ABC): def __init__(self, other_players: Iterable["Player"], blank_character: str, player_number) -> None: self.player_number = player_number self.name = self.get_...
d44b94f3d3d353f87f5a1dcd223a41ebfb5e8df6
StephenLockard/Python-Projects
/unit3/Unit3.py
647
3.953125
4
input_strings = [] def user_input(): new_string = '' while new_string != 'quit': new_string = input("Input a string, or type 'quit' to exit: ") if new_string != 'quit': input_strings.append(new_string) user_input() def stupid_case(string): ret = "" i = True for char...
d18b74049c8e38ce38dd7c75d6e56be5736ef132
StephenLockard/Python-Projects
/unit2_submission3/unit3_submission2.py
4,196
4.125
4
class DVD: # Constructor def __init__(self, title, dvd_type, cost): self.title = title self.dvd_type = dvd_type self.cost = cost # Return self._title instance variable def get_title(self): return self.title # newTitle def set_title(self, new_title): ...
9ff84cb0bfb0afbe16a13c4c3bc4d1c36ebbcbc7
sla000/mdfs
/src/neighbour.py
444
3.625
4
class Neighbour: def __init__(self, ip, port, gid): self.ip = ip self.port = port self.gid = gid def __str__(self): return '%s:%u:%s' % (self.ip, self.port, self.gid) @staticmethod def fromStr(nghStr): tmp = nghStr.split(':') assert len(tmp) == 3 i...
2fdcf0efee3027cce66a53003c5f95506ba6aa20
cdmcar/learning
/project_euler/largest_prime_factor.py
470
3.53125
4
#The prime factors of 13195 are 5, 7, 13 and 29. # #What is the largest prime factor of the number 600851475143 ? primes = [] factors = [] def isPrime(num): for l in range(2,100,1): if l != num: if num % l == 0: return False break return True for i in ran...
06a4706eb833fda97f657f70c8b11c36612c0940
rumrog/python_file_handling_lab
/employees.py
1,653
3.890625
4
import csv class Employee: def __init__(self, first_name, last_name, hourly_rate, hours_worked, amount_due): self.first_name = first_name self.last_name = last_name self.hourly_rate = float(hourly_rate) self.hours_worked = float(hours_worked) self.amount_due = float(amount_due) def values(self...
68b01adeba8e433530175f0c39a80c5c336d1ce3
thinboy92/HitmanFoo
/main.py
2,562
4.21875
4
### Animal is-a object (yes, sort of confusing) look at the extra credit class animal(object): def __init__(self, type): self.type = type def fly(self): print "This %s can fly" %(self.type) ## Dog is-a animal class Dog(animal): def __init__(self, name): # class Doh has-a __init__ that accepts self an...
0f0e2a6d1c50883306069a69420fcd0ddbf6bf4d
ignitethevibe/VentureScroll
/venture/tutorial.py
1,899
4.03125
4
# - Tutorial Level class pLevel(): # This is a generic super-class to define a level # Create a child class for each level with level specific info def __init__(self, player): # Constructor. Pass in a handle to player. Needed for when moving platforms # collide with the pla...
02a009df6f7c555a54db88342142c559b505a7b1
seulshine/Alpygo
/Algorithm/Python/튜플_예슬.py
337
3.890625
4
def solution(s): answer = [] s = s[2:-2] s = s.split("},{") s.sort(key=lambda x: len(x)) for i in s: temp = i.split(',') for j in temp: if int(j) not in answer: answer.append(int(j)) return answer s = "{{2},{2,1},{2,1,3},{2,1,3,4}}" p...
4836ba9a48e1bc8dca1e010e4414049ee55675d7
ksu-is/MyMoney-ExpenseTracker
/MyMoney.py
4,329
3.625
4
import sqlite3 #Function to initialize a database def init(): conn = sqlite3.connect("spent.db") cur = conn.cursor() sql = ''' create table if not exists expenses ( amount number, category string, message string, date string ) ''' cur.execute(sql) con...
03bc0cf52a337355dc9d829995465da3778f8531
bulsaraharshil/MyPyPractice_W3
/class.py
1,071
4.40625
4
class MyClass: x = 5 print(MyClass) #Create an object named p1, and print the value of x class MyClass: x=5 p1=MyClass() print(p1.x) #Create a class named Person, use the __init__() function to assign values for name and age class Person: def __init__(self,name,age): self.name = name self.age = ...
1f468a2055ef8548a517fb5333f574737a2da217
bulsaraharshil/MyPyPractice_W3
/lambda.py
768
4.5
4
#lambda arguments : expression #A lambda function that adds 10 to the number passed in as an argument, and print the result x = lambda x:x+5 print(x(5)) #A lambda function that multiplies argument a with argument b and print the result x = lambda a,b:a*b print(x(5,6)) #A lambda function that sums argument a, b, and c...
0f8b85652189ac466a4d986d3aa74b864af2bfa2
mtaquia/AirportsInTheWorld
/myAirports.py
3,333
3.75
4
import csv import sqlite3 import time import urllib initial = time.time() print 'Starting the program ...\n\n' print 'Downloading airports.csv from the Internet\n' fhand = urllib.urlopen('http://ourairports.com/data/airports.csv') texto = '' count = 0 for line in fhand: print line texto += line count += 1 with op...
6cbfec6af344d88d32ed8a1e85b01796f37e7372
drcinalli/PYcodes
/knapsack/branch_bounds.py
3,599
3.921875
4
#coding: utf-8 from collections import deque class SimpleQueue(object): def __init__(self): self.buffer = deque() def push(self, value): self.buffer.appendleft(value) def pop(self): return self.buffer.pop() def __len__(self): return len(self.buffer) class Node(obje...
9dd47539dcdc3afad510620168599ce0c7b3a8bd
drcinalli/PYcodes
/pacman multiagent fuzzy intersec/multiAgents FUZZY old e errado.py
25,565
4.15625
4
from util import manhattanDistance from game import Directions import random, util from game import Agent class ReflexAgent(Agent): """ A reflex agent chooses an action at each choice point by examining its alternatives via a state evaluation function. The code below is provided as a guide. You are we...
3eff078a56b297d48eb83b2286c74614488e3eb3
drcinalli/PYcodes
/pacman multiagent/Exemplo bom de multiagent real multiAgents.py
65,646
3.578125
4
from util import manhattanDistance from game import Directions from neural import NN import random, util from game import Agent class ReflexAgent(Agent): """ A reflex agent chooses an action at each choice point by examining its alternatives via a state evaluation function. The code below is provided a...
b10f63c68a06d6624ed214a3cc6be391540a2b97
chronologie7/killps
/killps.py
2,198
3.671875
4
#!/usr/bin/env python3 import psutil import sys import re def psListFunc(psName): pslist = psutil.pids() psListMach = [] for psid in pslist: p = psutil.Process(psid) if psName in p.name().lower(): psListMach.append({p.name(): psid}) return psListMach def...
1f7949af51592e2b62b1a8d228faecb631023684
CalamariDude/youtube
/Intro to Multiprocessing - Python/mp_tutorial.py
732
3.65625
4
import multiprocessing from multiprocessing import Process import time class Chef(Process): def __init__(self): Process.__init__(self) def cook_chicken(self): chicken = [0] * 10000000 for cell in chicken: cell = 1 return chicken def run(self): #do s...
91c579cb8bdf4ee5e1a68c7f5c37da13160123aa
itburman0/Cap-Tech-IE-709-
/Partial Functions.py
380
4.03125
4
#multiplies 2 times 4 from functools import partial def multiply(x,y): return x * y # create a new function that multiplies by 2 dbl = partial(multiply,2) print(dbl(4)) #Ending Exercise from functools import partial def func(u,v,w,x): return u*4 + v*3 + w*2 + x p = partial(func,5,6,7) ...
56c7c1fce5511087507872949759d22b8104b7aa
RidwanA123/quadratic-solver-python
/QuadraticSolver.py
2,182
3.984375
4
solve1 = 0 solve2 = 0 from math import* #libraries import re print("Welcome to a quadratic solver! To solve, you need to enter your equation below in this format with proper spaces: ax + bx + c = 0 and variables must have a 1 beside them not just the variable itself") print("Put a 0 if there if c is non existen...
e8b317b15db57cc23a82865e2badc84fb918d0af
mgoldberg240/Misc_Projects
/15puzzle/game.py
1,999
3.578125
4
# Created by Matt Goldberg on July 11 2018 import numpy as np import os def clear(): os.system('cls' if os.name=='nt' else 'clear') clear() class grid(): def __init__(self,size): self.size = size self.grid_array = np.arange(size**2) self.rand_array = np.random.permutation(self.grid_array) self.grid =...
05b966e36f645377d3bdd659fe01d4351531d6e2
WilliamBorelli/Python3-Challenges
/distanciadoispontos.py
316
3.9375
4
import math x1 = int(input("Digite o primeiro número: ")) y1 = int(input("Digite o segundo número: ")) x2 = int(input("Digite o terceiro número: ")) y2 = int(input("Digite o quarto número: ")) d = math.sqrt((x1 - y1) ** 2 + (x2 - y2) ** 2) if d >= 10: print("longe") else: print("perto")
e42b70c7d1d2a3284808ef118eedfb1a1a90d63e
BI4HUU/WEB
/py.py
2,703
4.28125
4
print("Показать ето в консоль") name = 8 # переменная input("1") # Предлагает ввести даные # Преобразовать тип даных int(name) # В число str(name) # В строку float(name) # В число с точкой del name # Удалить переменную name += 80 # Условные операции ten = 10 if ten == 1: print("ok1") elif t...
f3134648ca47a2f04d258ce8a54da863a241e792
usman-tahir/python-problem-solving
/introductory-snippets/strings.py
207
3.8125
4
print("Usman") my_name = "Usman" print(my_name) print(my_name[3]) print(my_name * 2) print(len(my_name)) print(my_name.upper()) print(my_name.center(10)) print(my_name.find("m")) print(my_name.split("m"))
98f15884dda7114a0ffd5f67c7e315321100625a
usman-tahir/python-problem-solving
/object-oriented-programming/logic.py
2,746
3.546875
4
class LogicGate: def __init__(self, n): # The label identifies the logic gate self.label = n self.output = None def get_label(self): return self.label def set_label(self, n): self.label = n def get_output(self): self.output = self.perform_gate_logic() ...
97c612ea6798f9cdfcdd18ef0d302cd6ca032900
Dhulipallanaveena/Check-Permutation
/Check Permutation.py
558
3.78125
4
from sys import stdin def isPermutation(string1, string2) : n1=len(string1) n2=len(string2) if n1!=n2: return False a=sorted(string1) string1=" ".join(a) b=sorted(string2) string2=" ".join(b) for i in range(0,n1,1): if string1[i]!=string2[i]: return False ...
8fdbe01a6176568addcfe99fa3eafbf386c740f0
dindamazeda/intro-to-python
/lesson3/homework/3.third_task.py
1,606
4.40625
4
# TREĆI ZADATAK # Dat je niz imenica u nasumičnom redosledu. # Napisati program koji će da grupiše imenice u novu listu na osnovu početnog slova tj. da ih poređa po redosledu # Međutim ima jedan uslov - prve imenice u novoj listi moraju da počinju sa slovom 'm', a nakon toga treba da ide po alfabetu # Videti primer isp...
06dc005308c02f4950075b21aa04fec50a073fc7
dindamazeda/intro-to-python
/lesson3/homework/6.sixth_task.py
1,038
4.15625
4
# ŠESTI ZADATAK # # Napisati program koji će da uzme dve liste i od njih napravi dictionary gde će elementi prve liste biti ključevi, a elementi druge liste vrednosti # ### primer ### # # voce = ['banane', 'kivi', 'limun', 'lubenica', 'grejpfrut', 'jabuke', 'ananas'] # # cene = [127.5, 119.8, 220.3, 84.4, 255.8, 65.3, ...
0c1e3c615df5d832a4f875b51a8ec27a25dddfa8
dindamazeda/intro-to-python
/lesson4/homework/5. frequency-in-paragraph.py
2,916
4.25
4
# PETI ZADATAK # Napisaćemo program koji utvrđuje frekventnost slova u srpskom jeziku nad datim tekstom # Potrebno je ispisati rečnik sa slovom i procenat (udeo) tog slova u odnosu na ukupan broj slova # npr. ako je dat tekst -> patka je slatka, program treba da zna sledeće: # u tekstu ima 13 slova (razmaci se ne račun...
36b2d60352a9e55abb53d30f25e98319383dadc0
dindamazeda/intro-to-python
/lesson3/exercise/7.element-non-grata.py
542
4.28125
4
# We have a list of sweets. Write a program that will ask the user which is his least favourite sweet and then remove that sweet from the list ### example ### # sweets = ['jafa', 'bananica', 'rum-kasato', 'plazma', 'mars', 'bananica'] # program: Which one is your least favourite? # korisnik: bananica # program: ['jafa'...
1dab9f0603dfaad5c376e7cff416e028e507143e
dindamazeda/intro-to-python
/lesson3/6.list-insert.py
177
3.75
4
alphabet = ['a', 'b', 'd', 'e'] alphabet.insert(2, 'c') print(alphabet) list_of_numbers = [10, 9, 8, 7, 6, 4, 3, 2, 1] list_of_numbers.insert(-4, 5) print(list_of_numbers)
cd20c43d46dcd1ebebd7932b2cba4c728350c2f9
dindamazeda/intro-to-python
/lesson4/8.set-theory.py
484
3.703125
4
products1 = {'keks', 'banane', 'brasno', 'kafa', 'mleko'} products2 = {'kafa', 'sok', 'brasno', 'koka-kola', 'pecivo', 'hleb', 'testenine'} products_intersection = products1.intersection(products2) print(products_intersection) products_diff = products2.difference(products1) print(products_diff) products_union = pr...
8d04606dee15e8b0cba7a43bdeb9ba0b8135c645
dindamazeda/intro-to-python
/lesson3/homework/2.second_task.py
879
4
4
# DRUGI ZADATAK # Dat je niz brojeva. Napisati program koji će ispise najmanji i najveći broj iz niza # niz_brojeva = [15, 116, 54, 30, 21, 41, 65, 7, 105, 135, 173, 56, 197, 56, 136, 83, 97, 130, 184, 112, 83, 157, 189, 24, 28, 127, 166, 99, 37, 114, 3, 123, 160, 97, 152] # # Second Task # a list of numbers is given. ...