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
fe40e8644f98b8c2ebf6fedd95938c4dc95175d1
lukeyzan/CodeHS-Python
/LoopandaHalf.py
474
4.21875
4
""" This program continually asks a user to guess a number until they have guessed the magic number. """ magic_number = 10 # Ask use to enter a number until they guess correctly # When they guess the right answer, break out of loop while True: guess = int(input("Guess my number: ")) if guess == magic_number: ...
2a2a424cb6e104c0924c7f3176469d520ff2c232
lukeyzan/CodeHS-Python
/CircleinaSquare.py
292
3.84375
4
left(90) penup() backward(100) radius = int(input("Rad")) def draw(r, d, s): pendown() circle(r, d,s) right(90) begin_fill() color("Red") for i in range(4): forward(radius * 2) left(90) end_fill() color("Blue") penup() forward(radius) begin_fill() circle(radius) end_fill()
ff9aadd96f91907b4630ef6d673e59be2ad811fe
lukeyzan/CodeHS-Python
/Rectangle,Part2.py
148
3.8125
4
length = 10 width = 5 area = length * width perimeter = length * 2 + width * 2 print("Area = " + str(area)) print("perimeter = " + str(perimeter))
730137310f76e85ff99baeb1ebe6ed360f8e0529
lukeyzan/CodeHS-Python
/FirstCharacter.py
179
3.53125
4
def first_character(chars): return chars[0] def all_but_first_character(chars): return chars[1:] print first_character("hello") print all_but_first_character("hello")
29d7191ddb8dffd32b0a1bdb30793c9e984c1e59
lukeyzan/CodeHS-Python
/FourCorners.py
374
3.84375
4
speed(10) penup() setposition(-200, -200) square_length = int(input("Square Size: ")) def draw(d): pendown() for x in range(4): forward(d) left(90) penup() draw(square_length) setposition(200, 200) right(180) draw(square_length) setposition(200, -200) right(90) draw(square_length)...
503b687730dfeb2da24a631d757893112bde773b
lukeyzan/CodeHS-Python
/MaxInList.py
270
3.890625
4
def max_int_in_list(_list): maxi = _list[0] for index, value in enumerate(_list): if(value > maxi): maxi = value return maxi my_list = [5, 2, -5, 10, 23, -21, 22] biggest_int = max_int_in_list(my_list) print biggest_int
c520323582f747438a521a48086ddd968589cfe4
lukeyzan/CodeHS-Python
/Rating.py
426
3.734375
4
rating = (int(input())) def draw(): right(180) color("green") left(45) forward(100) right(90) forward(50) if (rating == 9): draw() elif (rating >= 6): color("yellow") pensize(5) forward(50) elif (rating >= 1): left(45) pensize(5) color("red") forward(50...
a03d1ae13f68bdd4e03ba2c8cf7b2ed9f63cf87f
lukeyzan/CodeHS-Python
/Part1,RemoveAllFromString.py
210
3.921875
4
def remove_all_from_string(char, word): word.find(char) final_string = word.replace(char, "") return final_string printString = remove_all_from_string("l", "hello") print printString
1204ebc4eda25f9be8b79c1233e31e7fbf1d788e
lukeyzan/CodeHS-Python
/LengthofUser'sName.py
88
3.84375
4
name = input("Enter your name: ") print "Your name has " + str(len(name)) + " letters."
1c9155a5dd16fff0538cfb0091b7c02218318f47
jameswhitney/encrypt
/encryption.py
5,932
4.25
4
####################################################### # This is an exercise in creating a simple Encryption # # class that encapsulates a encryption method # # as well as a decryption method. These methods use # # a modified version of a Ceaser Cypher for both the # # encryption method and the decyrption m...
beecc0d260812f4f968500aff84370a23e7f8339
sp0rg/python-challenge
/PyPoll/main.py
3,821
3.625
4
import os import csv #defines input file and path election_data_csv = os.path.join("..","Resources", "election_data.csv") #defines output path and file name output_data_csv = os.path.join("pyPoll_output.csv") #set up lists voterList = [] countyList = [] candidateList = [] #Open file, identify header, create lists w...
1249cb7a7eaded9f451010160c55d422d9827ec0
sujinkay02/algorithms
/Lab10.py
2,430
3.8125
4
import urllib from edge import * from graph import * def dijkstra(G, s): # create lists to record shortest paths and vertex predecessors # for each vertex v, set the shortest path length to infinity and predecessors to null shortest = [float('inf') for vertex in range(G.getSize())] pred = [None for ve...
9b6be19d68d52e92d8f9dd93e68a1c17ecbf7d01
PrathushaKoouri/Binary-Search-1
/FirstAndLastIndexOfAnElement_7.py
1,755
4.0625
4
# Time complexity - O(log(N)) # Verifying 3 conditions of binary search but with a twist when the mid is equal to target, # then check for first and last index of that number def firstIndex(nums, target): # function to calculate firstIndex low = 0 high = len(nums) - 1 while low <= high: ...
974253760dad2c38817a0045b97032caf7dc7cf3
sherwinsamson1/8Puzzle
/iddfs.py
2,326
3.53125
4
from PuzzleClass import PuzzleState #implementation of function "Iterative_deepening_DFS" # ~ 4-5 minutes to do all 100 puzzle cases class iddfs: def __init__(self, p): self.puzzle = p def solve(self): for depth in range(100): explored = set() # reset...
07fdc5405e015121bcf29439afa98d3b09143f19
naxolorca/MCOC-Nivelacion
/20082019/000845.py
251
3.734375
4
def function4(x):#defino una funcion con un parametro print x #printea indentado print "still in this function" #printea indentado return 3*x # devuelve 3*x f = function4(4) #la variable f tiene el valor de la funcion con el parametro 4 print(f)
06d76c4795bbbe199232b3645892ab37bacb37ff
naxolorca/MCOC-Nivelacion
/23082019/001259.py
320
3.734375
4
given_list3 = [7,5,4,4,3,1,-2,-3,-5,-7] total = 0 i = 0 while True : #loop infinito if given_list3[i] <= 0: #rompo el ciclo total += given_list3[i] # sumo los negativos i += 1 #aumento el contador if i >= len(given_list3): # condicion para que el contador no pase a la lista break print total # muestro el total
6b5044784fb818b653771c5c5f4f941c7ecc68b3
naxolorca/MCOC-Nivelacion
/29082019/020111.py
989
3.640625
4
#multi dimesion import numpy as np #muestro nan print np.nan + 6 print np.sum([1,np.nan,9]) print np.nansum([1,np.nan,9]) a = np.array([1,2,3]) print np.sum(a) #es una funcion print a.sum() # es un metodo a = np.arange(24).reshape(6,4) print a.shape print a.mean(axis=1).shape #quierso saber si estoy viendo ...
e22347c9aed6fe4110d3dff721713d764eca991f
anbergem/INF1100
/calculator.py
2,088
3.890625
4
from scitools.std import StringFunction, linspace, zeros from matplotlib.pyplot import plot, show class Calculator: ''' ''' def __init__(self, a, b): self.a, self.b = a, b #def __add__(self, other): # return self.a + self.b + other.a + other.b def add(self): '''Calculates the sum of a and b''' return self...
228becb6e8c8532a9171f3335512df709282fba7
Yanqin25/AndrewNgMacheLearn
/work/machine-learning-ex2/ex2_py/mapFeature.py
626
4.09375
4
import numpy as np def mapFeature(X1, X2): '''Feature mapping function to polynomial features''' # # MAPFEATURE(X1, X2) maps the two input features # to quadratic features used in the regularization exercise. # # Returns a new feature array with more features, comprising of # X1, X2, X1.^2, X2.^2, X1*X2, ...
a456dc38e22d4b81eb51cd6fc3a53a5ad6429360
Yanqin25/AndrewNgMacheLearn
/work/machine-learning-ex1/ex1_py/gradientDescentMulti.py
904
3.875
4
import numpy as np from computeCostMulti import computeCostMulti def gradientDescentMulti(X, y, theta, alpha, num_iters): '''updates theta by taking num_iters gradient steps with learning rate alpha''' # Initialize some useful values m = y.size# number of training examples J_history = np.zeros(num_iters) ...
faaf805e36b8ff53138f3f7706d26592d549c17d
Yanqin25/AndrewNgMacheLearn
/work/machine-learning-ex1/ex1_py/gradientDescent.py
1,060
4
4
import numpy as np from computeCost import computeCost def gradientDescent(X, y, theta, alpha, num_iters): '''updates theta by taking num_iters gradient steps with learning rate alpha''' # Initialize some useful values # ====================== YOUR CODE HERE ====================== # Instructions: Perfor...
8a616ae5e4750f28050706409ff4268445cd8598
dgavieira/listas-python-super
/Lista_6_aula_15_06/L6_q2.py
303
3.640625
4
d = {} for i in range(0,2): mes = str(input("insira mês \n")) temperatura = float(input("insira temperatura \n")) d.update({mes:temperatura}) print(d.values()) print(d) temp = list(d.values()) tam = len(temp) soma = sum(temp) med = soma/tam print("temperatura média: {}ºC".format(med))
4dc9501c252c42c326c15b9a2f8bdfc68d4a2a69
dgavieira/listas-python-super
/Lista_8_aula_17_06/L8_q5.py
89
3.71875
4
A = {"green","blue"} B = {"blue","yellow"} C = A | B print("{} | {} = {}".format(A,B,C))
062e3367961971eccf4337651052eb7e0a0ba6a0
dgavieira/listas-python-super
/Lista_3_aula_10_06/L3_q2.py
294
3.765625
4
idade = 0 altura = 1 cont = 0 while altura != 0: idade = int(input("Insira a idade")) altura = float(input("Insira a altura")) if idade > 18 and altura < 1.6: cont = cont + 1 else: print("Parada") print("Existem {} alunos maiores que 18 anos com altura inferior a 1.6".format(cont))
19b044e3a8f5cfc2dde0672d16f8d191eddc34da
dgavieira/listas-python-super
/Lista_1_aula_08_06/L1_q2.py
132
4.03125
4
pi = 3.14 raio = float(input("Insira o raio")) area = pi*(raio**2) print("a área é igual a {: .2f} metros quadrados".format(area))
86fbb5c2555d118bbe115ac6b8270f013657e7cd
gediztosun/Fibonacci
/fibonacci_py.py
147
3.703125
4
num = int(input()) a = 0 b = 1 print(a, end = ', ') for c in range(num-1): print(b, end = ', ') b += a a = b - a print(b);
310dd37f969897a088d323a5d550a35684ad637d
cukejianya/code-contest
/30DaysOfCode/day02.py
151
3.59375
4
M = float(raw_input()) T = int(raw_input()) * .01 * M X = int(raw_input()) * .01 * M print "The final price of the meal is $%d." % (round(M + T + X))
69b48a93a2d20d4c936e016a7fccfe18b23094ec
cukejianya/code-contest
/LeetCodeWeeklyContest150/last_substring_in_lexical_order.py
341
3.546875
4
class Solution: def lastSubstring(self, s): if s == "": return "" highest_letter = max(list(s)) highest_substring = "" for pos, letter in enumerate(s): if letter == highest_letter: highest_substring = max(highest_substring, s[pos:]) ret...
458d3e5dd0806dca9dc46653bb3469a9ab449a35
wdkang123/PythonOffice
/10-pandas_compute/pandas_compute.py
2,339
3.9375
4
import pandas as pd # 统计运算基础 df = pd.DataFrame( [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], columns=["col1", "col2", "col3", "col4"] ) print(df) print("=====") ''' col1 col2 col3 col4 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 ''' # mean 方法用来求某一行或列的平均数 result = df.mea...
5d8604dbf2496c623f81462050ca889d9f7db449
shteken/monty-hall-problem-analysis
/monty_hall_adjusted.py
955
3.703125
4
import random def simulate_monty_hall_adjusted(n=1000): def monty_hall(): doors = [True, False, False] # generate doors random.shuffle(doors) c1 = random.randint(0,2) chosen_door = doors[c1] # choose first door doors.pop(c1) c2 = random.randint(0,1) # the host reve...
89856584daada23125ac008d63b1cb60315829f0
oicatalana/solucions_oicat_2018
/concurs_classificatori2/pb6.py
498
3.53125
4
from PIL import Image, ImageDraw def dist(x1, y1, x2, y2): if x2 == -1: return 0 return (abs(x1 - x2) + abs(y1 - y2))%256 n = int(input()) m = int(input()) xr = int(input()) yr = int(input()) xg = int(input()) yg = int(input()) xb = int(input()) yb = int(input()) img = Image.new('RGB', (n, m)) dib = ImageD...
8a3f7ca77adb2af2213bd58c550b0ea05fd4f0a0
MickMelon/EmotionRecognition
/er_processor.py
8,742
3.515625
4
import cv2 as cv import glob import numpy as np import math import crop_face from PIL import Image import sys import time # The emotions defined for emotion recognition. EMOTIONS = ["neutral", "anger", "sadness", "happy", "fear", "surprise", "disgust"] # The OpenCV HAAR Cascade Classifiers used for face and eye detec...
9d30544488b10e8f322719fb17d3f06448de9583
DanialAroff/ALGO-Project
/Q2.py
1,029
3.546875
4
import time from geopy.geocoders import Nominatim from number2 import ADistance # this function is needed because list can't directly accept three values # def edge(a, b, cost): # return a, b, cost # print(time.strftime('%Y/%m/%d %I:%M:%S %A\n')) start = time.time() geolocator = Nominatim(user_agent='WIA2005_As...
b6022282081e1a6ee19e5f22ba58a6f499749576
cadmus698/python
/fraction_conversion.py
590
4.03125
4
whole_number = input("Enter the whole number.\n") numerator = input("Enter the numerator.\n") denominator = input("Enter the denominator.\n") if int(whole_number) > 0: a = int(whole_number) * int(denominator) b = int(a) + int(numerator) print(str(b) + "/" + str(denominator)) elif int(whole_number) == 0: ...
08fc0d2748e6a37a559ef85270638cd7063d829e
cadmus698/python
/median.py
644
4
4
a = int(input("Enter the first number\n")) b = int(input("Enter the second number\n")) c = int(input("Enter the third number\n")) if a>b>c: print(b) elif a>c>b: print(c) elif b>c>a: print(c) elif b>a>c: print(a) elif c>a>b: print(a) elif c>b>a: print(b) elif a == c == b: print(a) else: ...
a9baa2ad3a186b3c888769cb83975a076c2e2da5
aliciaalbo/word-count
/wordcount.py
541
3.625
4
# put your code here. # iterate through text with for loop # create key = words values = count def word_counts(text_file): test = open(text_file) counted_words = {} for line in test: words = line.rstrip().split(' ') for word in words: counted_words[word]=counted_words.get(word,0...
93710e90cfea424c03494eb346c33cdd6f821a51
codocedo/mincovmin
/ae_libs/boolean_tree.py
4,902
4.15625
4
from __future__ import print_function class BooleanTree(object): ''' BooleanTree that maintains a list of boolean array lists The leaf can be either None, False or True. None, means that no element has been stored in that position. False and True indicates whether the element stored in that positio...
f3d05dd17d5cb979d751713abea1d922e630528b
nguthrie/cognixia-python
/fibonnaci.py
286
3.625
4
def fibo_less_than_n(n): N0 = 0 N1 = 1 previous_fib = N0 current_fib = N1 while current_fib < n: print(current_fib) tmp = current_fib current_fib = current_fib + previous_fib previous_fib = tmp fibo_less_than_n(10000)
3708afb6e55c5588bf3e7ef895023879612706b8
nguthrie/cognixia-python
/warm_up_questions.py
157
3.6875
4
# for i in range(1, 8): # print(i) # print() # j = 1 # while j <= 7: # print(j) # j += 1 # x = 0 # while (x < 100): # x += 2 # print(x)
990dbc5ae8a6d06bd99fda08c36d30b0a8df3ac0
bandjay/python-programming
/Insertion_sort.py
612
3.796875
4
def ins_sort(k): for i in range(1,len(k)): #since we want to swap an item with previous one, we start from 1 j = i #bcoz reducing i directly will mess our for loop, so we reduce its copy j instead while j > 0 and k[j] < k[j-1]: #j>0 bcoz no point going till k[0] since there is ...
3e51d34b4f65d05c75713448fd8a7439475989ac
wltsysterm/pythonlearning
/20180128.py
3,068
3.921875
4
#!/usr/bin/env python #coding=utf-8 #每个代码块每行缩进要一样 ''' if False: print(11111111111); else: print(22222222222); ''' #控制台输入 '''print(input('pleas input something and end with enter key.\n')) print('Python语句中一般以新行作为为语句的结束符。但是我们可以使用斜杠( \)将一行的语句分为多行显示') ''' #换行输出 '''print('contents', end='!@#$%^&*') #end就表示print将如何结束...
b442de7f645c32da7eed4726124eab4b17c49bab
aayushkedawat/Mark1
/file2.py
323
3.828125
4
fd = "myname2.txt" fd2= "file2.txt" file = open(fd, 'w') name = input("Enter your name\n") file.write(name) file.close() file = open(fd, 'r') text = file.read() file2= open(fd2,'w') file2.write(text) file2.close() file2= open(fd2,'r') text2=file2.read() print(text+ " (From first file)") print(text2+" (From second file)...
e0b678ca1310dab98b1e1a1e246b96e2363acc0e
ITMO-Photonics/laboratory-1-sombrelle
/lab1-1.py
213
3.96875
4
import math R = int(input("Write R: ")) L = int(input("Write L: ")) def calculate (R, L): cylinder_volume = math.pi * L * R * R return ("cylinder_volume: " + str(cylinder_volume)) print(calculate(R,L))
ee0b3b6f5814da645bd730d9028def184022db92
arm-out/ProjectEuler
/Problem_055.py
663
3.515625
4
def isPalindrome(n): s = str(n) for n in range(1, int(len(s)/2) + 1): if s[n-1] != s[-n]: return False return True def reverseNum(n): s = str(n) newNum = "" for i in range(len(s)): newNum += s[len(s)-1-i] return int(newNum) lychrelNums = 0 for i in range(1, 1...
c42a3152dc088682ac7dc6814603304ca3a700d5
arm-out/ProjectEuler
/Problem_037.py
1,127
3.5625
4
def isPrime(n, cache = {2: True}): if n in cache: return cache[n] if n == 1: cache[1] = False return False if n % 2 == 0: cache[n] = False return False p = 3 while p < (n ** 0.5) + 1: if n % p == 0: cache[n] = False ...
95c61c51dc728cd005c233d5460f0a12750353e9
Elena-Syvokaite/python-exercises
/4-divisors.py
312
4.0625
4
# Create a program that asks the user for a number and # then prints out a list of all the divisors of that number. user_num = int(input('Type in a number: ')) x = list(range(1, user_num+1)) divisorList = [] for num in x: if user_num % num == 0: divisorList.append(num) print(divisorList)
7cc6f2bbc14fb84576b82aab18f76f29ead2fcdd
bbabrich/AIFinalProject
/ABLineScraper/ABLineScraper.py
1,188
3.59375
4
# open up our files readF = open("limsAsChars.txt", "r") writeA = open("ALines.txt", "w") writeB = open("BLines.txt", "w") limerick = [] for line in readF : # print(len(line)) if len(line) >= 3 : # hit a real line limerick = limerick + [line] # so add that line to our current limerick elif len(line) < 3 : # hit a...
5da3533ba3248219638dece04a14ebd0ff19a846
divyanshvinayak/My-Python-Scripts
/eigen.py
501
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 25 12:00:00 2019 @author: divyanshvinayak """ import numpy as np rows = int(input('Enter rows: ')) cols = int(input('Enter columns: ')) arr = list(range(rows)) print('Enter elements in the matrix row-wise') for i in range(rows): arr[i] = list(m...
72339160e7adba6341466281c43c4f94a5b54cd3
divyanshvinayak/My-Python-Scripts
/polycurvefit.py
776
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 25 12:00:00 2019 @author: divyanshvinayak """ import numpy as np n = int(input('Enter the degree of curve to be fitted: ')) N = int(input('Enter the number of points: ')) print('Enter values of x and y in space separated form') x = [0 for x in rang...
25c3b7ff372a5cde8ba49a39d77e2e12b14f694c
deepakuniyaliit/RestApiFlaskPractice
/5. Authentication Using JWT/security.py
2,828
3.84375
4
''' In Flask applications we can use either sessions or tokens depending on the application we are creating to implement login/logout functionality. 1. Sessions are best suited to applications where you're serving web pages with Flask—i.e. making extensive use of render_template 2. Tokens are best suited to APIs, whe...
9a77ccb222d0bb5b35ddc6e0124f43e88ff82659
deepakuniyaliit/RestApiFlaskPractice
/8. User Sign Up Functionality/sqlite3_queries.py
589
3.8125
4
import sqlite3 connection = sqlite3.connect('data.db') cursor = connection.cursor() create_table = "CREATE TABLE users (id int, username text, password text)" cursor.execute(create_table) user = (1, 'deepak', '123') insert_query = "INSERT INTO users VALUES (?, ?, ?)" cursor.execute(insert_query, user) users = [ ...
312a6d67c228c81a4365681d8b116c5502ce5df8
LiamHooks/hw2p
/main.py
1,338
4.34375
4
# Author: Liam Hooks lrh5428@psu.edu # Collaborator: Seulki Kim svk6271@psu.edu # Collaborator: Angela Bao ymb5072@psu.edu # Collaborator: # Section: 2 # Breakout: 2 def getGradePoint(letter): if letter == "A": return 4.0 elif letter == "A-": return 3.67 elif letter == "B+": return 3.33 ...
54ce8482cbb71bf9bc9d2e54d1ef4e8c4197951d
jopinta/holbertonschool-higher_level_programming14
/0x0A-python-inheritance/4-inherits_from.py
270
3.546875
4
#!/usr/bin/python3 """inherited (directly or indirectly) from the specified class""" def inherits_from(obj, a_class): """really true or false""" if type(obj) != isinstance(obj, a_class): return False else: return (issubclass(obj, a_class))
c73b7de8a5fceb04ce125f74dc0b350fd4b445c9
ydelgadom/non_physics
/sommelier_app/mysqldb/mysqldb_util.py
440
3.734375
4
import json def convert_to_json(dict_): """ convert string to json """ output = {} for key in dict_: try: output[key] = json.loads(dict_[key]) except: output[key] = dict_[key] return output def convert_list_to_json(list_): """ convert string to...
96e7c015287128835e9446e63c610089f405d101
hudginsm/Lycus-Code
/playing_around.py
149
4.09375
4
print("hello world") x = complex(input("Enter number ")) print(x) x = float(input('Enter a number in decemal form: ')) print('your number is: ', x)
3d33e068612f7b1b068ad89babc191eed3d634ed
khan-s-code/alevelcms
/Task2.11.py
1,182
3.890625
4
class Toy: def __init__(self,name,iD,price,minimum): self.__name = name self.__iD = iD self.__price = price self.__minimum = minimum def Setname(self, n): self.__name= n def SetiD(self, r): self.__iD= r def Setprice(self,p): self.__price=p ...
3c667e7ee2cad72eef1e7263735ab406094cbdc0
deepanshu12tt/relation
/pastlife.py
824
3.828125
4
from tkinter import * import random import tkinter.messagebox as tsmg f=["Tiger","Lion","Cow","Dog","Donkey","Cat","Wolf","Leopard","Elephant","buffalo","deer","Rat","Giraffe","Sqirrel","Pocupine","Fox","Kangaroo","Cheetah","Hyena","Jackal","Panda","Hippopotamus","Rhino","Zebra","Monkey","beer"] def find(): choice=...
b93534b5a153c26d6329056a3a697df5165a7ccc
jokabovski/Petnica-letnji-2018
/prvi zadatak 4.7.2018.py
735
3.609375
4
class PrimeGenerator: def __init__(self): self.Sieve(10000) def get(self): return self.primes[self.index] def next(self): self.index += 1 def Sieve(self, rng): sieve = [True for _ in range(rng+1)] sieve[0:1] = [False, False] for star...
34d69c220b1408a144b5f7a6cebb0c46053f67a4
tyler274/CS1
/midterm.py
10,912
3.90625
4
# Tyler Port # tport import random import sys import string # Problem 1.1 # 1. not using triple quotes to specify a multiline string/docstring. # 2. semicolon instead of colon for the 'for' block. # 3. inconsistent indentation/spacing for scope. # 4. not using the equality operator '==', used '=' instead. # 5. did no...
62afa396175c831a69f275dc131298c798699288
zslari/Airbnb_Database_Project
/main.py
5,800
3.671875
4
from dataset_options import DataSet home_currency = "" conversions = { "USD": 1, "EUR": .9, "CAD": 1.4, "GBP": .8, "CHF": .95, "NZD": 1.66, "AUD": 1.62, "JPY": 107.92 } def print_menu(): """ Display the main menu text. """ print("Main Menu") print("1 - ...
2e4d716798afd6e737492f33e56165a5de790aaf
rsaravia/PythonBairesDevBootcamp
/Level3/ejercicio4.py
418
4.4375
4
# Write a Python function using list comprehension that receives a list of words and # returns a list that contains: # a. The number of characters in each word if the word has 3 or more characters # b. The string “x” if the word has fewer than 3 characters low = ['a','este','eso','aquello','tambien'] lor = [len(x) if...
6e438a337feb8ef59ca8c8deae05ea6bfcbe1c13
rsaravia/PythonBairesDevBootcamp
/Level1/ejercicio10.py
543
4.28125
4
# Write a Python program that iterates through integers from 1 to 100 and prints them. # For integers that are multiples of three, print "Fizz" instead of the number. # For integers that are multiples of five, print "Buzz". # For integers which are multiples of both three and five print, "FizzBuzz". l = [x+1 for x in ...
b14596fbfe3d5f75908fb3b3c5e5b6427e05657a
rsaravia/PythonBairesDevBootcamp
/Level1/ejercicio8.py
197
3.953125
4
# Write a Python function to remove an item from a tuple. # tuple define tt = ('a','b','c','d','e') # set elemento to remove (zero based index) index = 1 tt = tt[:index]+tt[index+1:] print (tt)
4dede77eda3a32526ee3674097de275f61009350
rsaravia/PythonBairesDevBootcamp
/Level4/ejercicio3.py
866
3.734375
4
# Create a decorator that makes sure that all function arguments where it's applied # will match the regex on the regex exercise above import functools def decorator(func): @functools.wraps(func) def wrapper_decorator(*args, **kwargs): args_repr = [repr(a) for a in args] kwargs_repr = [f"{k} = ...
08cdc161a9c86ac6fd9d96f9c403ef1ea6454d88
rsaravia/PythonBairesDevBootcamp
/DataScienceWPython/7.DataFrameElements.py
468
3.59375
4
# Dictionary keys is Column Names import pandas as pd # A serie city_revenues = pd.Series( [4200, 8000, 6500], index=["Amsterdam", "Toronto", "Tokyo"] ) # A serie city_employee_count = pd.Series({"Amsterdam": 5, "Tokyo": 8}) city_data = pd.DataFrame( {"revenue": city_revenues, "emplo...
6df115c121bc6def978b821161c13086303246b8
JTT233/GitHub_python
/pythonPractise/dict.py
196
3.828125
4
print("hello world !") my_dict = {'aa':10, 'bb':20} my_list = list(my_dict.items()) print(my_list) i = 0 while i < len(my_list): print('key:',my_list[i][0], 'value:',my_list[i][1]) i += 1
dbed271bbc78de86b767f76ab03b640392f8d06b
AlekseyIljin/Python_IT-Academy
/Projects/task5/test.py
3,575
3.796875
4
import unittest from task5.interpreter import Digit class TestDigit(unittest.TestCase): def test_to_string_for_correct_interpretation(self): expected = "Восемьсот пятнадцать" result = Digit("815").to_string() self.assertEqual(result, expected) def test_to_string_for_correct_unit_inter...
879e0d8acf496b641cd13ed5b2d3f7811bd143f9
saurabhkawli/PythonHackerRankCodes
/StrongPassword.py
634
3.671875
4
numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" count=0 main=0 password="g1A!" for i in password: if i in numbers: count+=1 break for i in password: if i in lower_case: count+=1 break f...
e970c39d91da8cf98923ba5efd18af3324cd0937
ARRETdaniel/Python-for-Everybody-Specialization
/8.4_ex.py
298
3.875
4
fname = input ('Enter file name: ') try: file = open (fname) except: print ('Erro.') quit() st1 = list() for line in file: line = line.rstrip() line = line.split() for i in line : if i not in st1: st1.append(i) st1.sort() print(st1)
fcbde9c8c2e1add8ad7b622e23ea5d5799e8039e
ajithpmohan/datastructure-and-algorithms
/module III/stack_html_tags.py
767
3.9375
4
#In HTML tags exist in both opening and closing forms(<html>,</html>) and must be balanced to properly describe a web document. Write a program that can check an HTML document for proper opening and closing tags. import re from stack import Stack def tags(file): tag=Stack() balanced=True index=0 f=open(file...
caf2459563f9a998cd6f7011447e814334b1e098
ajithpmohan/datastructure-and-algorithms
/module V/Searching/recursion_binary_search.py
413
4
4
def binary_search(lists, item): if len(lists) == 0: return False else: midpoint = len(lists) // 2 if lists[midpoint] == item: return True elif item < lists[midpoint]: return binary_search(lists[:midpoint], item) else: return binary_search(lists[midpoint + 1:], item) lists = [0...
5df3fa2d2ab2671f2302a582e95716d6a57dc09e
mariebotic/reference_code
/While Loops, For Loops, If Else Statements, & Boolean Operators.py
2,947
4.53125
5
# WHILE LOOPS, FOR LOOPS, IF ELSE STATEMENTS, & BOOLEAN OPERATORS #______________________________________________________________________________________________________________________________________________________________________________# import random while True: user_input = input("Please enter a number be...
72901a0628e66b6afc0057895b14f17229d77b58
Edwin-J/WebProgrmming
/0403/11.py
228
3.8125
4
num = 10; range_num = range(1, num + 1); i = 1; sum = 0; for i in range_num : sum += i; print("Summary in for : ", sum); sum = 0; i = 1; while i <= num : sum += i; i = i + 1; print("Summary in while : ", sum);
11dde4bc2fbdab4062b3e6b2877ca8764ba764c9
Edwin-J/WebProgrmming
/0403/5.py
187
3.6875
4
num = int(input("정수 입력 : ")); sum = 0; cnt = num; while True : if cnt == 0 : break; sum += cnt % 10; cnt //= 10; print("각 자릿수의 합 : ", sum)
907699a4d0faa18eadd167b1c7a117a02e5d1d39
Edwin-J/WebProgrmming
/0411/Exercise 5.1.py
327
3.828125
4
cnt = 0 tot = 0 while True: num1 = input('Enter a number:') if num1 == 'done': break; try: num2 = int(num1) except: print ('Error : Invalid input') continue; cnt += 1 tot += num2 print ('Count = ', cnt,' Sum = ', tot, ' Ave = ', (tot /...
d2183d0ec9e541374002bba40a61b786400e9ff0
Edwin-J/WebProgrmming
/0403/9.py
168
3.515625
4
inNum = int(input("수를 입력하세요 : ")); num = range(1, inNum + 1); sum = 1; i = 1; for i in num : sum = sum * i; print("팩토리얼의 합 : ", sum);
18aae261c58c28769ba0d4138483b5eb1dc7b6c6
madi/solar_radiation
/date_to_gregorian.py
727
3.546875
4
# coding: utf-8 __author__ = "Margherita Di Leo" __license__ = "GPL v.3" __version__ = "0.1" __email__ = "dileomargherita@gmail.com" import os import datetime def date2greg(day, month, year): """ Converts day of the year, given in dd, mm, yyyy into gregorian date. Month can be alternatively given as 'J...
5eba59c9464b0dbd103c5c85a01f1cee7a7b8d2b
mfurak/utils
/time_diff.py
918
4.0625
4
#!/usr/bin/env python3 import datetime time_format = '%H:%M' while(True): try: first_h = input("first hour: ") first_m = input("first minute: ") second_h = input("second hour: ") second_m = input("second minute: ") first_time = datetime.datetime.strptime("{}:{}".format(firs...
c487725dc1fc7d7d45012a2d003a242099b7d867
sukhvir786/Python-Day-8
/FH2.py
180
3.796875
4
""" How to write numbers in file """ def FH2(): F1 = open("File2.txt","w") for i in range(1,21): i = str(i) F1.write(i+"\n") F1.close() FH2()
3a4c61a77de20b307b23e776c40b93c9d8fb7613
sukhvir786/Python-Day-8
/SET_4.py
185
3.90625
4
""" remove and discard method in sets """ A = set() A.add(7) A.add(3) A.add(1) A.add(9) print("A:",A) #A.remove(11) A.discard(11) print("A:",A) A.discard(1) print("A:",A)
5b0b217cb0b2b4ef16066e9f2eb722347a7445ba
emjwalter/cfg_python
/102_lists.py
1,058
4.625
5
# Lists! # Define a list with cool things inside! # Examples: Christmas list, things you would buy with the lottery # It must have 5 items # Complete the sentence: # Lists are organized using: ___variables____????? # Print the lists and check its type dreams = ['mansion', 'horses', 'Mercedes', 'flowe...
4cd98053e49db7a5422d7ec0c410325f228dd5d2
emjwalter/cfg_python
/104_list_iterations.py
707
4.34375
4
# Define a list with 10 names! register = ['Bob', 'Billy', 'Brenda', 'Betty', 'Brian', 'Barry', 'Belle', 'Bertie', 'Becky', 'Belinda'] # use a for loop to print out all the names in the following format: # 1 - Welcome Angelo # 2 - Welcome Monica # (....) register = ['Bob', 'Billy', 'Brenda', 'Betty', 'Brian', 'Bar...
53edf0a368585fbfe66ac1ba46d343e08ef624e7
YashashreeKolhe/InformationSecurity
/111508041_Assignment3/111508041_Server_Client/Server.py
1,507
3.78125
4
#!/usr/bin/python3 import socket def decrypt(password): flag = 0 for char in password: if flag == 0: decryption_line = char flag = 1 first_char = ord(char)%10 else: decryption_line = decryption_line + chr(ord(char) + first_char) first_char = ord(chr(ord(char) + first_char))%10 return decryption_...
34350fec6bb4cbfbe7fa2ed13addc61365f889f2
AnneHS/WorkspaceContactNetworks
/code/test.py
445
3.546875
4
import timeit testcode = ''' def list_remove(): list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] list.remove(8) ''' testcode2 = ''' def list_comprehension(): list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] remove=[8] new_list = [x for x in List if x not in remove] ''' print(timeit.timeit(stmt=testcode, number=20000...
e566025e93ca3dd34e3255769b3553e0f5be7265
KataOra/Python-Crash-Course-2nd-edition-Exercises-My-Work
/3.9.py
331
3.5625
4
goscie = ['tata', 'babcia', 'tesciowa', 'pawlikowska'] print(f"Serdecznie zapraszam na obiad {goscie[0].title()}!") zaproszenie = 'Serdecznie zapraszam na obiad' print(f"{zaproszenie} {goscie[1].title()}") print(f"{zaproszenie} {goscie[2].title()}") print(f"{zaproszenie} {goscie[3].title()}") len(goscie) print(l...
04b85d6b48de80604837f2ff49f198ab595bf39c
KataOra/Python-Crash-Course-2nd-edition-Exercises-My-Work
/3.10.py
506
3.84375
4
europe_countries = ['polska', 'niemcy', 'wlochy', 'hiszpania', 'francja', 'irlandia'] print(sorted(europe_countries)) print(f"Na mojej liście jest {len(europe_countries)} krajów europejskich ") print(f"{europe_countries[0].title()} to moj kraj ojczysty ") print(f"W {europe_countries [-1].title()} mieszkałam 4 lata...
2963c1bebe8df7ebe88d7d54372bb97644a0a795
becpl/data_processing
/mail_file_processing.py
2,630
3.75
4
# Apply the pandas methods and functions along with profiling and interpret your findings from given dataset. import pandas as pd import pandas_profiling as pp from matplotlib import pyplot as plt import seaborn as sns import plotly_express as px df = pd.read_csv("mail_customers.csv") #import dataset into envir...
5cdbf5abe0e31bc8c62c6453cff3be2af0ee8029
theabraxas/Book-Exercises-etc
/learn_python_the_hard_way/ex05.py
704
3.515625
4
name = 'Stewart Olson' age = 27 height_in = 72 # inches height_cm = height_in * 2.54 # centimeters weight_lb = 170 # pounds weight_kg = weight_lb * 0.4536 # kilograms eyes = 'Blue' teeth = 'White' hair = 'Black' print "Let's talk about %r." % name print "He's %r inches, %r centimeters tall." % (height_in, height_cm) p...
4242363ec2e8d7868dc7f0f983575fce20ec6e67
fplucas/countdown
/runner.py
3,101
4
4
# Charlie Conneely # Anagram game import dictionary_parser from rachel import Rachel dictionary = dictionary_parser.parse("words.txt") def main(name): words = dictionary found = True rachel = Rachel() # retrieve array of letters nine_letters = rachel.give_the_letters(9) # convert array to st...
7a79ac0682a01f326d3425a28174271cd78081a5
spacemanidol/CLMS570
/Assignments/hw3/nfa_to_dfa.py
8,916
3.78125
4
import sys import os def is_NFA(fsa): ''' Main things NFA can have that a DFA cant:1. Epsilon,2.More than one transition for each input at each state args:fsa(dict): a dict of lists(where keys are the state where a transition starts) of tuples where (Start State,End State, word/string) returns:is_...
ee9422e8c3398f0fae73489f6079517f2d3396b5
scress78/Module7
/basic_list.py
718
4.125
4
""" Program: basic_list.py Author: Spencer Cress Date: 06/20/2020 This program contains two functions that build a list for Basic List Assignment """ def get_input(): """ :returns: returns a string """ x = input("Please input a number: ") return x def make_list(): """ ...
cb9f447a24d9163ec034f63aa59e68d3ec85ad59
wdlcoke/Python006-006
/week07/homework78_3.py
427
3.875
4
''' 作业三: 实现一个 @timer 装饰器,记录函数的运行时间,注意需要考虑函数可能会接收不定长参数。 ''' import time def timer(func): def inner(*args, **kwargs): start_time = time.time() time.sleep(1) func(*args, **kwargs) end_time = time.time() print(end_time - start_time) return inner @timer def func(a, b): ...
0ae7ca84c21ffaa630af8f0080f2653615758866
VertikaD/Algorithms
/Easy/highest_frequency_char.py
974
4.4375
4
def highest_frequency_char(string): char_frequency = {} for char in string: if char in char_frequency: char_frequency[char] += 1 else: char_frequency[char] = 1 sorted_string = sorted(char_frequency.items(), key=lambda keyvalue: key...
bba44b81a2fff9e50c2689a910c1424495f19b8b
AlexandrErofeevsky/my_python
/HW4/new_list.py
222
3.75
4
#1 for from math import sqrt x = [2,9,16,25] y = [] for i in range(len(x)): y.append(sqrt(x[i])) print(y) #2 map print(list(map(sqrt,x))) #3 generator c=[sqrt(x[i]) for i in range(len(x))] print(c)
4b9ea67a62d7a845421f599663149c512b247b7c
AlexandrErofeevsky/my_python
/table.py
425
4.09375
4
elem = input("Введите атомный номер: ") if elem: nu = int(elem) if nu == 3: print("Это литий") elif nu == 25: print("Это марганец") elif nu == 80: print("Это ртуть") elif nu == 17: print("Это хлор") else: print("Что это??") else: print("Введите значени...
c23a72dac73bf12133525715512b9a6e427f187d
MateuszG/Highway
/game.py
6,017
3.5625
4
""" Highway on Python3 """ from random import randint import pygame from class_car import Car from colors import BLACK, WHITE from dele import close_game from draw_models import coursor from game_events import check_events from game_logic import game_logic from init import start_engine font, clock, screen, SCREEN_WI...
eaae7920f52ac95dab171dbc0da06f2419295a96
afraz-khan/An-Army-of-Hidden-Bots
/p2p/sig_tool.py
1,358
3.59375
4
import hashlib from tkinter import filedialog from tkinter import * from tkinter import messagebox def hash_file(filename): """"This function returns the SHA-1 hash of the file passed into it""" # make a hash object h = hashlib.sha1() # open file for reading in binary mode with open(filename,'rb')...
92753825b350dbc1bf24ab51fe753698e08d49e8
raghavsikaria/LeetCode-31-day-May-2020-Challenge
/9_valid_perfect_square.py
1,723
3.640625
4
########################################################## # Author: Raghav Sikaria # LinkedIn: https://www.linkedin.com/in/raghavsikaria/ # Github: https://github.com/raghavsikaria # Last Update: 9-5-2020 # Project: LeetCode May 31 Day 2020 Challenge - Day 9 ########################################################## ...
9d88ae4478ad6ca988cab8de25ccf322f85f3f11
raghavsikaria/LeetCode-31-day-May-2020-Challenge
/11_flood_fill.py
4,026
3.78125
4
########################################################## # Author: Raghav Sikaria # LinkedIn: https://www.linkedin.com/in/raghavsikaria/ # Github: https://github.com/raghavsikaria # Last Update: 11-5-2020 # Project: LeetCode May 31 Day 2020 Challenge - Day 11 ##########################################################...
61382cd0d7d8cdf8ff480e2db4104aa06ff8ee3b
raghavsikaria/LeetCode-31-day-May-2020-Challenge
/24_construct_binary_search_tree_from_preorder_traversal.py
4,917
3.625
4
########################################################## # Author: Raghav Sikaria # LinkedIn: https://www.linkedin.com/in/raghavsikaria/ # Github: https://github.com/raghavsikaria # Last Update: 24-5-2020 # Project: LeetCode May 31 Day 2020 Challenge - Day 24 ##########################################################...