blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
df52146365ced13a5494976c3751799d07cb57fb
abin7-alpha/Solutions-think-python
/chapter11/exercise10.py
1,011
4.03125
4
def rotate_letter(letter, number): alphabets = "abcdefghijklmnopqrstuvwxyz" location = find_location(letter, alphabets) if location + number > 25: return alphabets[location + number - 26] return alphabets[location+number] def find_location(character, string): location = 0 for i...
375120b2d78bfc6f24665a930084f9258284ddcb
abin7-alpha/Solutions-think-python
/chapter5/exercise3.py
510
3.671875
4
def check_fermet(a,b,c,n): if n < 2: print("holly smokes fermet was wrong") else: print("that doesnt work") def multi(h): i = h z = h * i def recursion(h, n): if n <= 0: return else: multi(h) recursion(h, n-1) print(z) def ...
91b3b5bb58a116c049cb98e3c9cfa082f3465918
abin7-alpha/Solutions-think-python
/chapter8/exercise10.py
99
3.78125
4
def palindrome(a): if a == a[::-1]: return True print(palindrome("malayalam"))
628bc1c1864ca61754f3518abedbd2fc2a5e0fbc
abin7-alpha/Solutions-think-python
/chapter6/distancbtwpoints.py
461
3.578125
4
import math def jdistance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 print('dx is', dx) print('dy is', dy) return 0.0 def idistance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 print('dsquared is: ', dsquared) return 0.0 def distance(x1, y1, x2, y2): ...
18a56761663e1202e10e77d40b4a6cfb5cd47763
JordiDeSanta/PythonPractices
/passwordcreator.py
1,600
4.34375
4
print("Create a password: ") # Parameters minimunlength = 8 numbers = 2 alphanumericchars = 1 uppercasechars = 1 lowercasechars = 1 aprobated = False def successFunction(): print("Your password is successfully created!") aprobated = True def printPasswordRequisites(): print("The password requires:") ...
d5058b8c1c94a910ae05c9414ffcc3dbd5c705e0
mfroemmi/Datenverarbeitung_GUI
/main.py
2,281
3.5
4
import tkinter as tk from tkinter.filedialog import askopenfile import pandas as pd import numpy as np data = pd.ExcelFile("leer.xlsx") x = pd.read_excel(data) filex = pd.read_excel(data) root = tk.Tk() def klick(x): print(x) def einlesen(): excelfile = askopenfile(parent=root, mode="rb", title="Wähle Excel...
6f4855fb389c935a78245665ca794517bbc6977e
ETorres95/Hoja-de-Programacion
/Ejer 10.py
294
3.765625
4
c = int(input('Cuantas memorias RAM Usadas Vendio? ')) print('El Costo por memoria RAM Nueva es de $20') print('El descuento por NO ser nueva es del 60%') s = c*20 print('El costo final SIN descuento es:',s) d = ((c*20)*0.60) print('Y el descuento total es:',d) print('El Costo Total es:',s-d)
8b785cece995be2e4974be50a35a776d4731291b
SinglePIXL/CSM10P
/Testing/10-9-19 Lecture/lists.py
640
4.09375
4
# A sequence is an object that holds multiple items of data , # Stored one after the other. # A list is an object that contains multiple data items. List is a sequence. # Lists are mutable, which means that their contents can be changed during # the runtime. # List is a dynamic data structure # This means list can shr...
56cb3d4f201bc628a42708bc9b6219155db2d204
SinglePIXL/CSM10P
/Testing/9-4-19 Lecture/inRange2.py
194
3.6875
4
print('Number\t\tSquare\t\tCube') print('-------------------------------------------') for num in range(1,11): square = num**2 cube = num**3 print(num, '\t\t', square, '\t\t', cube)
f5d0083ec84fa8790f64e2f4eae5f442d99f2a91
SinglePIXL/CSM10P
/Testing/8-28-19 Lecture/quadrent.py
270
3.953125
4
x = int(input('Enter a value')) y = int(input('Enter a value')) if x>0: if y>0: print('Point is in I quad.') else: print('Pint is in IV quad') else: if y>0: print('Point is in II quad') else: print('Point is in III quad')
736fbfee5775cb351f4ee8acabeb5321c0a38c84
SinglePIXL/CSM10P
/Homework/distanceTraveled.py
451
4.3125
4
""" Alec distance.py 8-21-19 Ver 1.4 Get the speed of the car from the user then we calculate distances traveled for 5, 8, and 12 hours. """ mph = int(input('Enter the speed of the car:')) time = 5 distance = mph * time print('The distance traveled in 5 miles is:', distance) time = 8 distance = mph * time print('The di...
b9a0374bd4aa221725419d6788fae1f41cf37476
SinglePIXL/CSM10P
/Testing/10-9-19 Lecture/index.py
194
4.03125
4
# Another way to access each individual element in a list is # using index. # Index in python starts from 0 to one less the length of the list. num = [10,20,30,40,50,] print(num[0],num[3],num[])
18dab9e4479e3b9d4bdd6c7dda25d242afe0fdfe
SinglePIXL/CSM10P
/Testing/9-23-19 Lecture/returnMultiValues.py
208
4.09375
4
def getName(): first = input('Enter first name: ') last = input('Enter last name: ') return first,last def main(): fname,lname = getName() print('The full name is:', fname, lname) main()
e7acd1abad675af9ccd1b1b8bddc11884020ea8b
SinglePIXL/CSM10P
/Testing/10-7-19 Lecture/errorTypes.py
982
4.125
4
# IOError: if the file cannot be opened. # ImportError: if python cannot find the module. # ValueError: Raised when a built in operation or function recieves an argument # that has the right type but an inapropriate value # KeyboardInterrupt: Raised when the user hits the interrupt key # EOFError: Raised one of the...
505205601e20a1174d491f1b4e3c21860f9dc792
SinglePIXL/CSM10P
/Testing/8-28-19 Lecture/nestedIf.py
143
3.875
4
x = 19 if x>5: print(' Above five, ') if x > 10: print(' and also above 10! ') else: print(' But not above 10 :( ')
1f3d840b535599d3347bc382856721836f0cf981
SinglePIXL/CSM10P
/Homework/randomNumbersFileWrite.py
545
3.96875
4
# A program that writes a series of random numbers to a file. # Each random number should be in the range of 1 through 100. # The user specifies how many random numbers the file will hold. import random def main(): outfile = open('randomNumbers.txt','w') randomPasses = int(input("How many random numbers do ...
288f685744aa6609b795bf433a18ea2ffbb24008
SinglePIXL/CSM10P
/Testing/9-13-19 Lecture/throwaway.py
489
4.1875
4
def determine_total_Grade(average): if average <= 100 and average >= 90: print('Your average of ', average, 'is an A!') elif average <= 89 and average >= 80: print('Your average of ', average, 'is a B.') elif average <= 79 and average >= 70: print('Your average of ', average, '...
6e1fb9392f9533ac4803cc93cb122d4ddd85ab52
SinglePIXL/CSM10P
/Lab/fallingDistance.py
874
4.21875
4
# Alec # fallingDistance.py # 9-21-19 # Ver 1.3 # Accept an object's falling time in seconds as an argument. # The function should return the distance in meters that the object has fallen # during that time interval. Write a program that calls the function in a loop # that passes the values 1 through 10 as arguments a...
3e48d398095c6ad45b442b1fb7e4f73e48da4df6
SinglePIXL/CSM10P
/Homework/paintJob.py
1,561
3.796875
4
""" Alec paintJob.py 8-25-19 Ver 1.17 Get wall space to be painted and the cost of paint from the user. Print out the gallons of paint required, the hours of labor, cost of the paint, the cost of the operation, and the total cost """ # Define variables wallSpace = 115 gallonsPaint = 1 hoursLabor = 8 laborCost = 20.00 ...
83177870e88b4d4503bd2d69c76426c8bfdc13f7
TinDang97/hackerrank_solution
/sherlock_and_array.py
742
3.640625
4
#!/bin/python3 # problem link: https://www.hackerrank.com/challenges/sherlock-and-array/problem import math import os import random import re import sys # Complete the balancedSums function below. def balancedSums(arr): left_sum = 0 right_sum = sum(arr) for elm in arr: if abs((right_sum - elm) -...
3335eab1744319b7bc0987d51cbbae7519ffd2d7
josemorenodf/proyecto1python
/reto2/reto2.py
5,222
3.703125
4
import os , time os.system('cls') # 2. Creación de un menú principal y desarrollo de la opción 6 que permite elegir una opción favorita en el menú # Bloque de funciones def menuppal(lista_menu): # Menú principal os.system('cls') print("") print("",str("1."),lista_menu[0],"\n", str("2."),lista_menu[1...
4608d298b61be2a4855e9eefcd57b0da8218784f
edisonArroyave/pythontaller12
/ejercicioedadalumno.py
473
3.796875
4
edadalum=0 cantalu=0 cantedad=0 prom=0 continuar= 'si' while continuar == 'si': edadalum=float(input("digite edad")) if edadalum < 18: cantalu=cantalu+1 cantedad=cantedad+edadalum prom=cantedad/cantalu elif edadalum >= 18: cantalu=cantalu+1 cantedad=cantedad+edadalu...
fd5f05d0b2e420a8330458aefa8cb8303037bc31
S1E9/Leetcode-Sort-Problems
/Intersection of two arrays/code.py
433
3.609375
4
class Solution(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ new_nums1 = [] for k in nums1: if k not in new_nums1: new_nums1.append(k) cross = [] ...
348309109d4ca1f176389fee9b3175e69aac5f42
salonikalsekar/CS555-SSW555_agileMethodologies
/testuserStory08.py
563
3.53125
4
import unittest import userStory08 class Test(unittest.TestCase): def test_age(self): age = (0 is 1) if(self.assertFalse(age)): print("True") def test_two(self): self.assertEqual("23 August 1990","23 August 1990") def test_three(self): age = ...
be89b294417f4bf29dfeda76235afc529325706d
salonikalsekar/CS555-SSW555_agileMethodologies
/testuserstory23.py
371
3.53125
4
import unittest import userStory23 class TestUserStories(unittest.TestCase): def testone(self): list1 = ['Roberts','North','Max'] self.assertNotEqual(userStory23.unique_names_and_birth_dates,list1) def testtwo(self): self.assertTrue(userStory23.unique_names_and_birth_d...
793a1c0370f6f293758a47334d1b7e0d9ae0fb32
MyloTuT/IntroToPython
/Homework/HW4/hw4.2.py
574
3.578125
4
#!/usr/bin/env python3 word_dict = set() fo = open('../python_data/words.txt') fo_2 = open('../python_data/sawyer.txt') for word in fo: word_dict.add(word.rstrip('\n')) print('{word_dict} words in spelling words'.format(word_dict=len(word_dict))) print('\n') fo_2_read = fo_2.read() fo_2_split = fo_2_read.split...
3814fb004735f71e002ed614b91028b8c333893a
MyloTuT/IntroToPython
/Homework/HW5/hw5.2.py
1,152
3.859375
4
#!/usr/bin/env python3 market_value = {} fo = open('../python_data/F-F_Research_Data_Factors_daily.txt').readlines()[6:-2] for line in fo: year = line[0:4] date, mkt_rf, smb, hml, rf = line.split() if year not in market_value: market_value[year] = 0.0 market_value[year] = market_value[year] +...
63251289af0b67420a9371fd8712f22ba470bfad
MyloTuT/IntroToPython
/Class Code/Class1/class1.py
224
3.5
4
#!/usr/bin/env python3 import sys print(sys.version) var1 = 5 var2 = '10' print('var1: ', var1) print('var2: ', var2) xxx = type(var1) print('type var1: ', xxx) print('type var2: ', type(var2)) print(var1 + var2) exit()
7666e2475bde34829937d741f4475b2a1486e666
MyloTuT/IntroToPython
/Class Code/Class2/class2.py
322
3.96875
4
#!/usr/bin/env python3 # aa = input('please enter a positive integer: ') # int_aa = int(aa) # # if int_aa < 0: # print('error: input invalid') # exit(1) # # d_int_aa = int_aa * 2 # print('your value doubled is ' + str(d_int_aa)) cc = 0 while cc < 10: print(cc) print('got it') cc = cc + 1 print('done'...
3afb2cfad546e5b745c2131224224b6c397232ad
MyloTuT/IntroToPython
/Excercise/Ex2/ex2.9.py
133
3.828125
4
#!/usr/bin/env python3 some_input = input('please enter a string to search: ') some_found = msg.count(some_input) print(some_found)
d70b3151b28bb23399f455719fa560a5b0855fa2
MyloTuT/IntroToPython
/Excercise/Ex2/ex2.6.py
232
4.03125
4
#!/usr/bin/env python3 bday = "Happy Birthday to you!" a = 1 while a <= 10: print(bday) a = a + 1 how_many = input("How many times should I greet you?: ") if how_many.isdigit() == False: exit('error202: not a digit')
d1f1e3c5760e32f745a2d798bba26f1c1abb3ca2
MyloTuT/IntroToPython
/Homework/HW1/hw1.py
1,213
4.25
4
#!/usr/bin/env python3 #Ex1.1 x = 2 #assign first to variable y = 4 #assign second to variable z = 6.0 #assign float to variable vsum = x + y + z print(vsum) #Ex1.2 a = 10 b = 20 mSum = 10 * 20 print(mSum) #Ex1.3 var = '5' var2 = '10' convert_one = int(var) #convert var into an int and assign to a variab...
30671b726dce5447ca142ad97d99064fc65adf0d
celikmustafa89/python_solutions
/hackerrank/AP_tripplets.py
826
4.0625
4
# Python program to prall # triplets in given array # that form Arithmetic # Progression # Function to print # all triplets in # given sorted array # that forms AP def printAllAPTriplets(arr, n) : s = []; for i in range(0, n - 1) : # print("when i is"+str(i)) for j in range(i + 1, n) : # Use h...
81eb65591e5f426e80fef949bde1713da2a63b0c
Lancelof2019/neural-network
/neural_network.py
3,487
3.796875
4
import numpy as np import matplotlib.pyplot as plt def sigmoid(x): sig_val=1/(1+np.exp(-x)) return sig_val #input_value=np.random.rand(5,10,4) #print(input_value.shape[1]) #print(input_value) #input_value=np.linspace(-10,9.99,100) #print(input_value) #output_value=sigmoid(input_value) #print(output_value) #p...
f52ae6903a664788d59839c618f7a8aee73d25c4
GingerBeardx/Python
/Python_Fundamentals/coin_tosses.py
713
4.0625
4
import random # Write a function that generates ten scores between 60 and 100. Each time a score is generated, your function should display what the grade is for a particular score def scores_and_grades(cases): count = 1 heads = 0 tails = 0 result = '' while count <= cases: random_num = ra...
ce5015940881770acdbb6fd87af458b35d99c86b
GingerBeardx/Python
/Python_Fundamentals/type_list.py
908
4.40625
4
def tester(case): string = "String: " adds = 0 strings = 0 numbers = 0 for element in case: print element # first determine the data type if isinstance(element, float) or isinstance(element, int) == True: adds += element numbers += 1 elif isin...
a2c485ba03991204912d6dd23b32d8d17daa3c25
GingerBeardx/Python
/Python_Fundamentals/loops.py
340
4.34375
4
for count in range(0, 5): print "looping - ", count # create a new list # remember lists can hold many data-types, even lists! my_list = [4, 'dog', 99, ['list', 'inside', 'another'], 'hello world!'] for element in my_list: print element count = 0 while count < 5: # notice the colon! print 'looping - ', c...
2fc12dd6d7f7b2701b2e1decbea25887057d1485
silversurfer-gr/Python
/BlinkLED.py
1,073
3.875
4
import RPi.GPIO as GPIO import time ledPin = 5 # RPI Board pin17 dauer = 5 def setup(): print("setup ist entert") GPIO.setmode(GPIO.BOARD) GPIO.setup(ledPin, GPIO.OUT) GPIO.output(ledPin, GPIO.LOW) # Set ledPin low to off led print ('using pin%d'%ledPin) # Numbers GPIOs by physi...
5538252bcd657f22538ee14632a806d237d54790
jahosh/coursera
/algorithms1/week2/two_stack.py
1,094
4.125
4
OPERATORS = {'*', '+', '-', '/'} """ Djikstra's Two Stack Arithmetic expression evaluation algorithm """ def two_stack(arithmetic_expression): value_stack = [] operator_stack = [] for string in arithmetic_expression: try: if isinstance(int(string), int): value_stack....
49d87afe33dc3036b23b86692dc71248917878c7
MonilSaraswat/hacktoberfest2021
/fibonacci.py
345
4.25
4
# 0 1 1 2 3 5 8 13 """a , b = 0 , 1 n = int(input("Enter Number of Terms")) print(a,b , end = " ") for x in range(1 , n-1): temp = a+b a=b b=temp print(temp , end = " ") """ def fibonacci(n): a, b = 0, 1 while b < n: print(b, end=' ') a, b = b, a + b n = int(input("Enter the end...
227925521077e04140edcb13d50808695efd39a5
erikseulean/machine_learning
/python/linear_regression/multivariable.py
1,042
3.671875
4
import numpy as np import matplotlib.pyplot as plt import seaborn as sns iterations = 35 alpha = 0.1 def read_data(): data = np.loadtxt('data/housing_prices.in', delimiter=',') X = data[:, [0,1]] y = data[:, 2] y.shape = (y.shape[0], 1) return X, y def normalize(X): return (X - X.mean(0))/X.s...
4bed4015659219a3e7cd01da9eea2e1405d4e485
NgocTanLE/news-translit-nmt
/tools/detokenize.py
449
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import argparse WHITESPACE = '<s>' def main(): args = parse_args() for line in sys.stdin: text = line.strip().replace(args.separator, "").replace(WHITESPACE, " ") print(text) def parse_args(): parser = argparse.ArgumentParser() ...
3f7c9ec4b4a433f6ef81cf3d79ccfc3e256d6f65
Bang207/Virtual-Assistant
/virtual_assistant.py
2,176
3.609375
4
import speech_recognition import pyttsx3 from datetime import date, datetime import random import pywhatkit as kit import snake import flappybird def listen(text): robot_ear = speech_recognition.Recognizer() with speech_recognition.Microphone() as mic: speak(text) print("Mike:...") audio = robot...
52a1ed8605a0ce3e4e827bd1b19fd878fea92887
ASU-APG/decentralized_attribution_of_generative_models
/attack_methods/Crop.py
4,037
3.515625
4
import torch.nn as nn import numpy as np def random_float(min, max): """ Return a random number :param min: :param max: :return: """ return np.random.rand() * (max - min) + min def get_random_rectangle_inside(image, height_ratio_range, width_ratio_range): """ Returns a random rec...
f2e57dfe0fc151345ec419bab4ad6c3d4c08641f
dbarabanov/coursera
/algorithms_2/assignment_3/knapsack_1.py
1,287
3.875
4
#Question 1 #In this programming problem and the next you'll code up the knapsack algorithm from lecture. Let's start with a warm-up. Download the text file here. This file describes a knapsack instance, and it has the following format: #[knapsack_size][number_of_items] #[value_1] [weight_1] #[value_2] [weight_2] #... ...
9973bb94829403465905ae5d34be6ab85427bbb7
dbarabanov/coursera
/algorithms_2/assignment_1/question_3.py
2,235
3.78125
4
#In this programming problem you'll code up Prim's minimum spanning tree algorithm. Download the text file here. This file describes an undirected graph with integer edge costs. It has the format #[number_of_nodes] [number_of_edges] #[one_node_of_edge_1] [other_node_of_edge_1] [edge_1_cost] #[one_node_of_edge_2] [other...
3e02bef3e10b321f56075ba126e192cb849b1faa
dbarabanov/coursera
/algorithms_2/assignment_2/question_1.py
1,885
3.796875
4
#Question 1 #In this programming problem and the next you'll code up the clustering algorithm from lecture for computing a max-spacing k-clustering. Download the text file here. This file describes a distance function (equivalently, a complete graph with edge costs). It has the following format: #[number_of_nodes] #[ed...
d254a5a56999c0a6369a95353716107f7b873d31
feldoe/university
/PycharmProjects/first_project/first.py
1,648
3.796875
4
# Hello World um die pyCharm IDE kennen zu lernen # print("Hello World") """ for i in range(10): print(i) """ """ mysum = 0 for i in range(5,11,2): mysum += i # mysum = mysum + 1 print(i) print("=====") print(mysum) """ # 1.Eine Zahl n einlesen # 2. * # ** # *** # *** mit n = 3 # n = int(input("B...
2d9fac28b2597d4638f6ac893ff0af4d0be74bb1
feldoe/university
/scripts/2019-11-26/hallo.py
589
4
4
""" while(True): print("Hallo Welt") """ """ print("Hallo Welt") s = input("Bitte geben Sie etwas ein: ") print("Sie haben folgendes eingegeben "+s) """ """ Vergleiche von Gleitkommazahlen durch Genauigkeit beschränkt >>> a = 0.3 >>> b = 0.1 >>> c = 0.2 >>> d = b + c >>> a == d False >>> d 0.30000000000000004 """ # ...
d9ef9b31f4ec93a86e65a29160c7b8aa263cfffb
marian3525/Assignment05-07-08-09
/domain/Book.py
1,518
3.9375
4
class Book: """ A book has an id, title, description and author. Its rented state should be set to True when being added to a rental """ def __init__(self, bookID, title, description, author): self.__bookID = bookID self.__title = title self.__description = description s...
03d8c530d1f3a1b3e8d329be2801fa8842580a1a
marian3525/Assignment05-07-08-09
/domain/Rental.py
1,918
3.859375
4
class Rental: """ A rental has an ID, the rented book's ID, the client's ID, the rental date, the due date, and the date in which it was returned """ id = 0 def __init__(self, rentalID, bookID, clientID, rentedDate, dueDate, returnedDate): self.__rentalID = rentalID ...
ec5bdf3ea4b16ae9d43a279719aa6059444675c5
snehith1234/Hacker-rank
/Algorithms/Implementation/Kangaroo.py
462
3.75
4
def kangaroo(x1, v1, x2, v2): # Complete this function if x2> x1 and v2 > v1: out_put ='NO' return out_put if v2 == v1: out_put ='NO' return out_put elif((x2-x1)%(v1-v2)) == 0: out_put ='YES' return out_put else: return 'NO' x1, v1, x...
ac3117aadc6663c4d6638cd64c0c02fb574834d6
redlolgeerf/hackerrank
/sorting/tutorial-intro.py
294
3.578125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- import sys def index(value, size, array): return array.index(value) if __name__ == '__main__': v = sys.stdin.readline().strip() n = sys.stdin.readline().strip() ar = sys.stdin.readline().strip().split() print(index(v, n, ar))
3774e77fdf40df7a2d5e480b4856e8c48074203f
redlolgeerf/hackerrank
/sorting/quicksort1.py
632
3.59375
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- import sys def partition(arr, s): smaller = [] bigger = [] value = arr[0] for x in range(1, s): if arr[x] >= value: bigger.append(arr[x]) else: smaller.append(arr[x]) result = smaller + [value] + bigger result...
21b1770c42e96e1fb2dd1fd222a0681acc50598b
redlolgeerf/hackerrank
/sorting/countingsort1.py
815
3.671875
4
# -*- coding: utf-8 -*- # !/usr/bin/python3 import sys def counting(arr, s): appearences = {} for x in range(100): appearences[x] = 0 for value in arr: appearences[value] += 1 return appearences if __name__ == '__main__': # size = int(sys.stdin.readline().strip()) # array = ...
850a396bed191953c2f14d1ee91d73ad38b5bc47
now123/assignment-6
/pyom.py
2,409
3.59375
4
from tkinter import* import tkinter import os from tkinter import * from tkinter.messagebox import * from tkinter.filedialog import * root=Tk("Text Editor") root.title("Text Editor") text=Text(root) # To add scrollbar scrollbar = Scrollbar(root) scrollbar.pack( side = RIGHT, fill = Y ) def donothing()...
cc081d1883a6b67a3f0eb4d387c5dded69b2e98c
now123/assignment-6
/assignment13.py
992
3.921875
4
#QUE 1 #exception occcured is ZeroDivisionError try: a=3 a=a/(a-3) except ZeroDivisionError: print("error") else: print(a) finally: print("handeled") #QUE-2 try: l = [1, 2, 3] print(l[3]) except IndexError: print("error") finally: print("processed error") #Q...
40fa97fa72a2c3e4dec889402f717dda57a56b11
xiaoqiangcs/LeetCode
/Longest Common Substring.py
651
3.59375
4
class Solution: # @param A, B: Two string. # @return: the length of the longest common substring. def longestCommonSubstring(self, A, B): # write your code here if not (A and B): return 0 lcs = 0 for i in range(len(A)): for j in range(len(B)): ...
d57d910f9aab6a4df3a529764c57e1627e0f7beb
xiaoqiangcs/LeetCode
/Permutations Sequence.py
1,303
3.578125
4
class Solution(object): """ @param n: n @param k: the k-th permutation @return: a string, the k-th permutation """ def getPermutation(self, n, k): sequence = [i for i in range(1, n + 1)] index = 1 for _ in range(1, k): i = 0 for i in range(n - 2, ...
287268e91b82e4b3ddac55dc43ae5b2a6fcf59a6
jjjipark/Intmd-Data-Structure
/lab3/stack.py
1,283
3.75
4
import sys import copy from linked_list import * class Stack: # class constructor def __init__(self): self.l = LinkedList() # push method def push(self, x): self.l.add_at_head(x) # pop method def pop(self): return self.l.remove_at_head() # is_empty method def...
6744e67ef3d055bf0220cf5605267782af255395
Naxalov/test-github
/def15.py
293
3.796875
4
def func_count_even(n): digit1=n%10 n//=10 digit2=n%10 n//=10 digit3=n%10 n//=10 digit4=n%10 digit5=n//10 count_even = (1-digit1%2)+(1-digit2%2)+(1-digit3%2)+(1-digit4%2)+(1-digit5%2) return count_even # n=int(input()) # print(func_count_even(n))
c735b26be8df881b1f2515d13d4b64e45eaec166
aidude/CNN
/pytorch_cnn.py
2,100
3.609375
4
# CNN using pytorch # amritansh import torch import torchvision import load_data import matplotlib.pyplot as plt import numpy as np import torch.optim as optim from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F # functions to show an image def imshow(img): img = img / 2 +...
baf6819302456e4f1e11f6da83b75ad133cf532d
victor1305/Checkio
/Home/Sun Angle.py
669
3.875
4
from datetime import datetime formato = "%H:%M" def sun_angle(time): hhmm = datetime.strptime(time, formato) hours = hhmm.hour minut = hhmm.minute dayMinut = hours * 60 + minut if dayMinut >= 360 and dayMinut <= 1080: angle = (dayMinut - 360) * 0.25 return angle else: return...
68b8a5dd76004f069fa3cec74fc8766231079621
PrajinkyaPimpalghare/Chat-Application-
/ChatUser1.py
5,671
3.609375
4
"""======================================================================================= INFORMATION ABOUT CODE *Coding ISO9001:2015 Standards ========================================================================================== Chat Application with GUI and MultiMessage Feature using Socket programing and Tk...
0d78093f204d2d0e24b0892bacef280c525615e4
simmessa/LPTHW
/ex35.py
1,285
3.6875
4
# @SM some typing on Anne 2 Pro is always good to get hands in shape... from sys import exit import random def gold_room(): print "A room full of gold, how much will you rob?" next = raw_input("> ") if "0" in next or "1" in next: how_much = int(next) else: print "Numbers...
5e7b6515e8f1a6e03bc06854d321b8b0a3648509
simmessa/LPTHW
/ex24.py
709
3.9375
4
# @SM building stamina in python? print "Practice shit" print 'Tab me\t and then return me\n but don\'t \\ double back slash me' poem = """ A Poem don't you like it? It's your fault, nasty scumbag """ print "---------" print poem print "@@@@@@@@@" five = 10 - 2 + 3 - 6 print "five is actually %d" ...
3137188cddf0bdf99b4c693e3ea1dad726775c31
simmessa/LPTHW
/ex11.py
358
4
4
# @SM asking stuff...nicely! print "Your age, please?" age = raw_input() # raw_input gets a string. # input tries conversion, but it's insecure! print "Your height, please?" height = raw_input() print "Your weight, may I ask...?" weight = raw_input() print "So, quite obviously you're %r old, %r high ...
78525ddeccc1829e2f77f14d19a1fb9263387709
kevinjam/Python_Exercises
/dennis.py
206
3.921875
4
num1 = raw_input('Enter the Number') first = int(num1) num2=raw_input('Enter the Num 2:') second = float(num2) num3 = raw_input('Enter the Num 3:') third = float(num3) total =first+second+third print total
04a3ca0582dda44264b588f49b7c032789f35049
Dat0309/Detect-FakeNews-With-TfidfVectorizer
/detect_fakenews.py
1,554
3.640625
4
import numpy as np import pandas as pd import itertools from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import PassiveAggressiveClassifier from sklearn.metrics import accuracy_score, confusion_matrix #read dataset data = pd.read...
80d49356c51999d19dbab53d4209cb70fa24b0c0
vjx/planetaudium
/distance-plot-dia-min.py
935
3.796875
4
# find the day that a planet is the maximum distance from earth # arguments: planetname date # example Jupiter 2015-11-22 import ephem import datetime import time import sys planetaSet = sys.argv[1] # Get planet name, first argument user_input = sys.argv[2] # Get date string, secound argument year_month_day = user...
9b8849b993dfe0586acf0bf8b5cd64a209a7b4e3
multi21bull/crypto-algorithms
/key_finder.py
2,651
3.515625
4
def expansion(): input_file = open('output_xor.txt','r') text = input_file.readlines() output_file = open('expansion_xor.txt','w') ex = [ 32, 1, 2, 3, 4, 5, 4, 5,6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, ...
f9ab8cd4201dc297d6db5d1f0b54ec0cfcfb17a8
CatOctopus/Intro-Comp-Sci
/mooviedingo.py
943
3.8125
4
def moovie_dingo(): total=0 weather=input("Is it raining? ") if weather=="no" or weather=="No": numppl=eval(input("How many people are in your party? ")) for i in range (numppl): age=eval(input("Enter your age: ")) ID=input("Enter if you ar...
319c5cf0229e571a0d6d801622c5b7758c26e6d8
ryan-keenan/CarND
/L1_byoNN/miniflow.py
10,430
4.5625
5
""" In the exercises you will implement the `forward` and `backward` methods of the Mul, Linear, and CrossEntropyWithSoftmax nodes. Q: What do I do in the forward method? A: 1. Perform the computation described in the notebook for that node. - You need the input node values to do this. Here's how you wou...
0686ad6d66e777243752ee191ed5db4655eacec4
misthe/compphysics
/Untitled.py
265
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[9]: def f(x) : return x*x - 5 # In[10]: a=2 b=3 n=0 e=0.00001 while ( b - a > e and n<100): c=(a+b)/2 if f(b)*f(c) < 0 : a=c else: b=c n=n+1 print ('n= ' , n ,'a= ', a , 'b= ', b) # In[ ]:
7da5c181a589c570b14e76fa1ad28b4dd55ab23d
harmanssingh/D03
/HW03_ex06.py
4,283
4.0625
4
#!/usr/bin/env python # HW03_ex06 # (1) Please comment your code. # (2) Please be thoughtful when naming your variables. # (3) Please remove development code before submitting. ############################################################################### # Exercise 6.2 # See 6.1: "write a compare function takes two v...
30ecc9bf7132459229467e22d0dab992ce045149
gx20161012/leetcode
/easy/TwoSumII.py
560
3.609375
4
class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ length = len(numbers) a = 0 b = length - 1 while numbers[a] + numbers[b] != target: if numbers[a] + numbers[b] >...
504f88433b33b092bbdb668d5fa72374ca6990ea
gx20161012/leetcode
/medium/LongestSubstringWithoutRepeatingCharacters.py
705
3.515625
4
class Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ list_s = list() max = 0 for char in s: if char not in list_s: list_s.append(char) if max < len(list_s): max ...
ffd5f499633067eb05272726697e03ca5c75b022
gx20161012/leetcode
/easy/AddDigits.py
452
3.703125
4
class Solution: def addDigits(self, num): """ :type num: int :rtype: int """ ''' if num > 9: return (num-1)%9+1 if num < 10: return num ''' while num // 10 > 0: sum = 0 while num > 0: ...
4b9212bdad3c96974187b704c34081b02a10c859
gx20161012/leetcode
/easy/LengthofLastWord.py
412
3.734375
4
class Solution: def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ s_list = s.split(' ') length = len(s_list) for i in range(length): if s_list[length-1-i] != '': return len(s_list[length-1-i]) else: ...
903f2c5371a318c714202aa290836254957913d0
gx20161012/leetcode
/easy/LongestPalindrome.py
811
3.625
4
class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: int """ dict_s = dict() for i in range(len(s)): if s[i] not in dict_s.keys(): dict_s[s[i]] = 1 else: dict_s[s[i]] += 1 print(dict_s...
f5fd117a9359455e5c1b760d9c9561425cd9e0e0
gx20161012/leetcode
/medium/LetterCombinationsofaPhoneNumber.py
745
3.578125
4
class Solution: def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ list_res = [""] dict_num = {'2':['a','b','c'], '3':['d','e','f'], '4':['g','h','i'], '5':['j','k','l'], '6':['m','n','o'], '7':['p','q','r','s'], ...
a91073c2ac82d4e2edab2dcffd7e7d6ab7a667fa
DuB0k/Statistics
/ex4_interquartiles.py
1,503
3.78125
4
from sys import stdin def calculateMedianOfSortedArray(array): array = sorted(array) arrayLength = len(array) #If N is an odd number -> median = X(n+1)/2 if arrayLength % 2 != 0: median = array[int((arrayLength-1)/2)] #If N is an even number -> median = (X(n/2)+ X((n/2)+1))/2 else: ...
add05d55bbc68ba727fd54c65d927dc8bf72d4ef
Divyanshpundhir/Hello-World
/Issue11.py
226
4.0625
4
while True: try: num = int(input("Enter the number: ")) except: print("Sorry, that entry is invalid") continue else: [print('Hello World') for x in range(num)] break
25eeb52fae13a88c0c32b72be425bc3c516bae6e
martinmatak/AoC18
/day2/part1.py
834
3.875
4
import string fname = 'input.txt' with open(fname) as f: content = f.readlines() content = [x.strip() for x in content] def n_of_any_letter(word, n): """Return true if any letter repeats in a given word exactly n times""" # english alphabet, lowercase (as it is in input file) letters = dict.fromkey...
f8ce7fa856f4a9dfd31172b0e8edcc876b0207d5
Tawfik-Metwally/Python
/8-Buzz.py
120
3.875
4
numero = int(input("Digite um número inteiro: ")) N = numero % 5 if N == 0 : print("buzz") else: print(numero)
0dfb106a879c01b4293147c955cf778d71050c03
L713952864/LH
/python_work/chapter_6/practice_6.2.py
2,193
3.765625
4
""" 字典嵌套 练习 6.4 """ def main(): # 人的信息,将字典嵌套在列表里,为字典列表 Lily = { 'first_name': 'Lily', 'last_name': 'Edward', 'age': 23, 'city': 'LA', } Jeff = { 'first_name': 'Jeff', 'last_name': 'Albert', 'age': 22, 'city': 'New York', ...
595d3c28695bacfba224f9c2892f5499eb3b03af
L713952864/LH
/python_work/chapter_8/practice_8.1.py
789
3.859375
4
"""函数:形参和实参""" def display_message(): print("I HAVE BEEN LEARNING FUNCTION") def favorite_book(title): print("One of my favorite book is " + title + '.') def make_shirt(size, pic = 'I love Python'): print("This shirt's size is " + str(size) + ", and the pic is " + pic + ".") def descr...
6436169bc2616c63d069c94a622e78f90ce78788
L713952864/LH
/python_work/chapter_5/practice_5.1.py
523
3.828125
4
"""if: conditional_test """ def main(): numbers = [2, 4, 9, 34, 18, 17] print('Is there a number 7? I predict True.') print(7 in numbers) print("Is the smallest number 2 in numbers? I predict True.") print(min(numbers) == 2) str1 = 'Angel' str2 = 'Angle' print(str1 == str2...
f091ab1606ccbc3b04f9973e70d726e77aecc15e
L713952864/LH
/python_work/chapter_5/practice_5.2.py
1,938
3.90625
4
""" if语句 练习5.3/5.4节 """ def main(): alien_color = 'red' if alien_color == 'green': print('FIVE points!') elif alien_color == 'yellow': print('TEN points!') elif alien_color == 'red': print('15 points!') pass age = 15 if age < 2: print('you are...
f15b806cef3d9c6085a1664c859e5dde0a4fc551
arya-oss/Arya-Scripts
/games/tictactoe.py
7,453
3.796875
4
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Author: Rajmani Arya TicTacToe Game System vs. Player using Min Max Algorithm Graphical User Interface Implemented in Python Tk ''' from Tkinter import Tk, Label, Frame, Canvas, Button, ALL def min_max_move(instance, marker): bestmove = None bestscore = None ...
23861d7ae2a3071b886cc2ebe17b31e0bf621082
FredrikTEmblem/GameOfLife
/celle.py
874
3.5625
4
class Celle: def __init__(self): self._celle = "doed" # Cellen settes til død til å starte med. def settDoed(self): # Metoden setter cellen til død og returnerer statusen. self._celle = "doed" return self._celle def settLevende(self): # Metoden setter cell...
780c24fd5b63cab288383303d3ac8680691afd18
MicheSi/code_challenges
/isValid.py
1,421
4.34375
4
''' Sherlock considers a string to be valid if all characters of the string appear the same number of times. It is also valid if he can remove just character at index in the string, and the remaining characters will occur the same number of times. Given a string , determine if it is valid. If so, return YES, otherwis...
726802d84749d77a7299472f2d62535a713d59cb
MicheSi/code_challenges
/code_challenges/longest_palindromic_string.py
1,062
4
4
# Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. # Example 1: # Input: "babad" # Output: "bab" # Note: "aba" is also a valid answer. # Example 2: # Input: "cbbd" # Output: "bb" class Solution: def longestPalindrome(self, s: str) -> str: ...
75557a049eacb367b51913167b2de9fe2f435425
JulienLefevreMars/analyseTurbostatData
/Utils/time_information.py
197
3.515625
4
# Python program to convert # date to timestamp import time import datetime def str_to_timestamp(string): return time.mktime(datetime.datetime.strptime(string,"%d/%m/%Y %H:%M").timetuple())
1a9506d249212a4d692aadbce0ab56e8b3564d9a
Dylan-Hong/Stock-Crawler
/Function_def.py
1,133
3.5625
4
# function import pandas as pd def SetTimeString( Year, Month ): return str( Year ) + str( Month ).zfill( 2 ) + '01' def IsBuyMonth( Year, Month, StartYear, StartMonth, Freq ): # 月份差異 / 頻率為0則買進 if ( ( Year - StartYear ) * 12 + ( Month - StartMonth ) ) % Freq == 0: return True else: ...
4968d556dbc2f765f7cb6b40ca9743b1e04ef72b
juancho618/TAI_Project
/Classifier/kappaValue.py
1,897
3.6875
4
import pandas as pd import matplotlib.pyplot as plt # plot library from sklearn import tree from dataProcessing import * # dummy encoding from sklearn.preprocessing import OneHotEncoder # best codification for categorical data df = pd.read_csv('../finalDS.csv', header=0) # print df # preprocess dataset with original ...
e6fb222e3243858abb2429bb06dba32275c54d0f
EmilioMuniz/ops-301d2-challenges
/ops-301d2-challenge-class10.py
780
3.875
4
#!/usr/bin/env python3 # Script: ops-301d2-challenge-class10.py # Author: Emilio Muniz # Date of latest revision: 3/12/2021 # Purpose: Using conditional statements in python. # Declaration of variables: a = int(100...
d8267045c4bd8768fcf9bb15e3fd717fe8a83962
chriswebb31/HybridPSOGP
/Problem.py
983
3.515625
4
import math import pandas as pd import numpy as np class Problem: def __init__(self, train_data, test_data): self.train_data = train_data self.test_data = test_data def defineProblem(self): self.targets = [] self.values = [] data = pd.read_csv(self.train_data) f...
9a026804975d71611228de8b8832c777e9bf81b3
Huzeyfe-dev/Notdefterim
/şifrele.py
951
3.515625
4
# Yazıları şifrelemek için oluşturula bir modüldür. # Henüz sadece sezar şifreleme yapabilir. # # yazar: Huzeyfe Çağılcı """örnek kullanım: sezar("Huzeyfe") Out: 'Mz\x7fj~kj' sezar("Huzeyfe", 6) Out: 'N{\x80k\x7flk' sezar("N{\x80k\x7flk", 6, True) Out: 'Huzeyfe'""" def sezar(yazı, key=5, çöz=False): şifreli_ya...
5b96d9afc1efeddb412ab37b535275e3da05865f
Pergamene/cs-module-project-hash-tables
/applications/histo/histo.py
1,048
3.921875
4
# Your code here def _format_word(word): return word.lower().translate({ord(i): None for i in '":;,.-+=/\|[]{}()*^&'}) def _generate_word_list(file): words = [] with open(file) as f: text = f.read() textArr = text.split() for word in textArr: words.append(_format_word(word)) return words d...