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
bd5e1bdcbb44d58ef5b0aa70a0899124aaec86ca
Ben-C-Harris/AutoTrader-Web-Scrapping-Used-Car-Database
/autoTraderScrapeMakesModels.py
4,965
3.796875
4
import requests import json import pandas as pd ''' Web scraping for website: https://www.autotrader.co.uk/ This Class is for web scraping and writing to PKL file all the makes and models of used cars that AutoTrader currently has listed on its website. To get a closer look at what is happenening within th...
bffcd444827c49ed2730069c1285f293f43c9faa
LOKESH538/NNDL_18K41A0538
/Assignment-2/gradientmultiple.py
841
3.953125
4
from sympy import * import sympy as sym x, y = symbols('x y') diff_x=sym.diff(x**2+y**2+10,x) y=sym.Symbol('y') diff_y=sym.diff(x**2+y**2+10,y) f = lambda x1,y1: x1**2+y1**2+10 print("The gradient/slope/first order derivative of given function for x is : ",diff_x) print("The gradient/slope/first order derivative of ...
70f31cd033697f3c2dfed28e0a08441d3f7455ee
ash3113/kelas_PBO
/aktifitas6/aktifitas6.py
166
3.59375
4
class student : """A class respresenting a student""" def __init__ (self, n, a) : self.full_name = n self.age = a def get_age (self) : return self.age
7dd53f68c7d31dcdd2a430bbc1f9fa4ee93de808
sarah-irfan/Algorithms
/DynamicConnectivity/quick_union.py
968
4
4
# Quick Union Algorithm # The root of q becomes root of p import time class quickUnion: def __init__(self): self.mylist = [] def initiate(self, N): self.mylist = [x for x in range(N)] print (self.mylist) def root(self,p): while self.mylist[p] != p: p = self.m...
fb475119ae1fcca761e88ceb13b820c8dce1ad83
Cielako/Python_exercises
/lista9/zad3.py
1,575
3.59375
4
import numpy import matplotlib.pyplot as plt v0 = float(input("Podaj prędkość początkową w m/s: ")) alfa = float(input("Podaj kąt wyrażony za pomocą stopnii: ")) v0x = v0 * numpy.cos(alfa * numpy.pi / 180) v0y = v0 * numpy.sin(alfa * numpy.pi / 180) g = 9.81 vy = list()#prędkość chwilowa w kierunku pionowym po czasie...
b86b5405461d8c035d28d984db650ad683299e0f
Cielako/Python_exercises
/Lista 1/zad3.py
201
3.703125
4
import math a= float(input("Podaj dlugosc 1 boku: ")) b= float(input("Podaj dlugosc 2 boku: ")) alpha = math.radians(float(input("Podaj kąt w stopniach: "))) pole = a*b*0.5*math.sin(alpha) print(pole)
ffd719509aec235088a39bfb4ab474ded60b0ad6
Cielako/Python_exercises
/lista 3/zad7.py
102
3.9375
4
n = int(input("Podaj n do ciagu fibonacciego: ")) x = 0 y = 1 while y<n: print(y) x,y = y,x+y
2cc4c5556c8828f83f2ba74a15d9cfef32cdf5a2
Cielako/Python_exercises
/Lista 1/zad8.py
114
3.765625
4
a = float(input("Podaj liczbe a: ")) b = float(input("Podaj liczbe b mniejszą od a: ")) Z = b%a Z=Z+3 print (Z)
e42c58fbec19ed092b1d8fdfeb95bdaa231bba87
ivanenko0and/Lab-work-8
/Task 1.3 - 2.3a.py
4,910
3.96875
4
# Алгоритм прямого пошуку підрядка answer = '1' while answer == '1': string, substring = [], [] # string - задана послідовність, substring - шуканий підрядок print("Введіть послідовність (натисніть пробіл для припинення вводу):") while True: # Введення значень n, які будуть додаватись до по...
2eaac5446cce03fc4a58a7601b00cc55eb9e26f8
abshinn/mltools
/ex1_mtcars_linear.py
4,568
4
4
#!/usr/bin/env python2.7 """ mltools Machine Learning Tools Linear regression example using mtcars data set: single variable (+quadratic term) gradient descent and normal equation """ import pdb import mlfeatures import mllinear import numpy as np import matplotlib.pyplot as plt import seaborn as sns # from matpl...
14a39a1022edac0568dcca32662d6a8703a2e18d
Rahmanism/pythonlearn
/04_07_email_check.py
156
3.78125
4
# Chapter 04 - Unit 07 - email check using regex import re email = input() print('WRONG' if re.search(r'^\w+@\w+\.\w+$', email.strip()) == None else 'OK')
1762dadbcd0d7043e8af25dda287dbc338d76648
Rahmanism/pythonlearn
/02_12_current_age.py
859
3.9375
4
# Chapter 02 - Unit 12 - Current Age from datetime import datetime """ Example: Input: 1995/02/03 Output: 23 """ class Age: def __init__(self, birth_date): if (self.check_birth_date(birth_date)): self.birth_date = datetime.date( datetime.strptime(birth_date, '%Y/%m/%d')) ...
2c5e1bb9dbffefca67190acbde858f5c883813a6
Rahmanism/pythonlearn
/01_08_index_words.py
1,033
4.0625
4
# Chapter 01 - Unit 08 - Count of words starting with capital. """ Example: Input: The Persian League is the largest sport event dedicated to the deprived areas of Iran. The Persian League promotes peace and friendship.This video was captured by one of our heroes who wishes peace. Output: 2:Persian 3:League 15:Iran 1...
a1198eea06a7386af6c3421e52b850882cb52c38
LarynQi/leetcode
/easy/removeDuplicatesString.py
647
3.53125
4
# https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/ # https://leetcode.com/submissions/detail/440528892/ # 01/08/2021 19:59 class Solution: def removeDuplicates(self, S: str) -> str: result = "" prev = None for c in S: # print(result) if prev...
4a5cb47d189a8bcdacbcdbec023ce70b30c4c1bc
LarynQi/leetcode
/easy/hammingDistance.py
350
3.65625
4
# https://leetcode.com/problems/hamming-distance/ # https://leetcode.com/submissions/detail/440245607/ # 01/08/2021 03:04 class Solution: def hammingDistance(self, x: int, y: int) -> int: xor = x ^ y count = 0 while xor > 0: if xor & 1: count += 1 ...
e181f560073b52db2a481b3196f858708de58c4a
LarynQi/leetcode
/easy/maxDepthOfN-ary.py
851
3.546875
4
# https://leetcode.com/problems/maximum-depth-of-n-ary-tree/ # https://leetcode.com/submissions/detail/292001490/ # 01/07/2020 00:36 # class Solution: def singleNonDuplicate(self, nums: List[int]) -> int: middle = len(nums) // 2 if len(nums) == 1: return nums[0] elif nums[mid...
69a4ab34221200bdac80494c9d80ddfe7fc2fbd8
LarynQi/leetcode
/medium/reverseLinkedList2.py
888
3.640625
4
# https://leetcode.com/problems/reverse-linked-list-ii/ # https://leetcode.com/submissions/detail/284233317/ # 12/06/2019 18:02 # Memory Limit Exceeded # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def rever...
36249a8d4a7329c77ab8a25f5ff92d96ba0a7a33
LarynQi/leetcode
/easy/flipAndInvertImage.py
611
3.53125
4
# https://leetcode.com/problems/flipping-an-image/ # https://leetcode.com/submissions/detail/442273661/ # 01/12/2021 18:43 class Solution: def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]: for i in range(len(A)): r = A[i] left = 0 right = len(r) - 1...
930aaaa21232d12316e4740573fac3742d7e2971
LarynQi/leetcode
/mock/amazon-onsite-0/zigzagLevelOrder.py
1,048
3.765625
4
# https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ # https://leetcode.com/interview/reports/SW50ZXJ2aWV3U2Vzc2lvbk5vZGU6MTUwNTI4Ng== # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left...
9383175715dce40d8662b5be298b9fa51958acde
LarynQi/leetcode
/easy/getDecimalValue.py
810
3.53125
4
# https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/ # https://leetcode.com/submissions/detail/288186966/ # 12/23/2019 23:39 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def ge...
3a9984569d7bc4bdd16fdacb3aa458d5ea0cc485
LarynQi/leetcode
/medium/distanceK.py
1,028
3.625
4
# https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/ # https://leetcode.com/submissions/detail/435398485/ # 12/27/2020 19:33 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Soluti...
dd18555273758ffea2a84256677f986d4237caa8
LarynQi/leetcode
/easy/diagonalSum.py
437
3.59375
4
# https://leetcode.com/problems/matrix-diagonal-sum/ # https://leetcode.com/submissions/detail/441050589/ # 01/09/2021 23:31 class Solution: def diagonalSum(self, mat: List[List[int]]) -> int: total = 0 n = len(mat) for i in range(n): # print(total) total += mat[i...
37c58e6ff65466b981659db79abeda92d7c0f3f1
LarynQi/leetcode
/easy/isUnivalTree.py
836
3.71875
4
# https://leetcode.com/problems/univalued-binary-tree/ # https://leetcode.com/submissions/detail/284992030/ # 12/10/2019 00:46 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def is...
6493b08a8a06029bb0538eb584cd4959a70a9ee8
LarynQi/leetcode
/easy/maxProduct.py
780
3.5625
4
# https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/ # https://leetcode.com/submissions/detail/442284622/ # 01/12/2021 19:13 class Solution: def maxProduct(self, nums: List[int]) -> int: largest = second = None for n in nums: if largest is None: ...
8c78e89ebd55190f461e2be3267f712c1ee9fdbd
SandeepKiran089/Data-science
/Python_Tutorial_103.py
1,521
4.09375
4
tuple1=tuple(('Sandeep',1,2,3,5,('Books','Mobile','Laptop'))) print(tuple1) addTuple=("Mouse",) tuple1+=addTuple print(tuple1) tuple1=list(tuple1) tuple1.remove("Sandeep") #print(tuple1) tuple1=tuple(tuple1) print(tuple1[5]) t1="Sandeep Kumar".split(" ") print(t1) #salary=int(input("Enter your salar...
5b6557f4a9c122bb2f1991ab3bb063bcafbf3218
univer1988/test
/student.py
411
3.5
4
class Student: def __init__(self,name,major,gpa): self.name = name self.major = major self.gpa = gpa def education_level(self): if self.gpa >= 4: return 'Goood' else: return ('False') class menu: def salat(self): print('salat') ...
aa4ceeda2dbe4f93c76a1e6d9e25c4e1aa6ccc09
jondarrer/advent-of-code-2020
/src/day1/read_input_file.py
469
3.796875
4
def read(filename): '''Reads the file and converts it to an array of numbers''' array = [] # https://realpython.com/read-write-files-python/#iterating-over-each-line-in-the-file with open(filename, 'r') as reader: # Read and print the entire file line by line line = reader.readline() ...
7aae112a05f2c3e9e53b47a45977408bd58b5144
jondarrer/advent-of-code-2020
/src/day4/d4part1.py
1,093
4.0625
4
from functools import reduce import read_input_file def is_passport_valid(passport): '''Determines whether the passport has all the required fields, ignores optional''' return does_passport_have_field(passport, 'byr') and does_passport_have_field(passport, 'iyr') and does_passport_have_field(passport, 'eyr') ...
f818dbe534ff43ca074c0ea9dc1f6a217f54eade
cmdruid/hashcode-2020
/utils.py
2,037
4.03125
4
import os def load_data_dir(directory, extension=".in", delimiter=" ", keymap=False): """ Load all files in a given directory and compile into a data-set. :directory: - The relative path to where files are stored. :extension: - The file extension to look for. :delimiter: - The delimiter to use when s...
412062ae6d10ac91e8803ccf9a4c23dec1a6fd97
YiyiF/Python_Research
/case_studies/language_processing/language_processing.py
4,919
4
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 21 17:44:45 2018 @author: eleve """ text = "This is my test text. We're keeping this text short to keep things manageable." def count_words(text): """ Count the number of times each word occurs in text (str). Return dictionary where keys are unique words and...
049fa6a58dcdfd736b8c7af84fb5628e219a7d45
YiyiF/Python_Research
/case_studies/language_processing/Exercise.py
6,007
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 30 21:06:33 2018 @author: eleve """ # E1 """ Define hamlets as a pandas dataframe with columns language and text. Add an if statement to check if the title is equal to 'Hamlet'. Store the results from read_book(inputfile) to text. Consider: How many translations are there...
2ee6a89f0df13904ae3571dbb04396f36dc8c43e
lineudemonia/python_reference
/code/tracks/tracks_my.py
3,182
3.5625
4
# imports # coding: utf-8 import xml.etree.ElementTree as ET import sqlite3 as SQL # initialize conn = SQL.connect('tracks_my.sqlite') cur = conn.cursor() # set up tables cur.executescript(''' DROP TABLE IF EXISTS Artist; DROP TABLE IF EXISTS Album; DROP TABLE IF EXISTS Genre; DROP TABLE IF EXISTS Track; C...
a62f6b7c638cad6c2c4f6abe020c793ae1d8dc8b
lineudemonia/python_reference
/code/classes.py
700
3.71875
4
# _*_ coding: utf-8 _*_ 'a class module' __author__ = 'Lin Lin' class Student(object): def __init__(self, name, score): self.name = name self.__score = score def print_score(self): print ('%s: %s' % (self.name, self.__score)) def get_grade(self): if self.__score >= 90: return '成绩优' elif self.__score >...
2fbcce0d0701b427b92bb054d168bb6a4403336c
bufubaoni/algorithms
/sort_array/q_sort.py
408
3.828125
4
# 快速排序 def qSort(nums): if len(nums)<2: return nums current = nums[0] left = [i for i in nums[1:] if i<=current] right = [i for i in nums[1:] if i>current] return qSort(left) + [key] + qSort(right) # 将所有小于等于第一个的数放到左边 # 大于第一个数的放到右边 # 然后拼接为一个array # 当只有一个数字的时候结束递归
9b3692c57e7c950796b74702960b98043fbf108e
bufubaoni/algorithms
/merge_sort_linked.py
1,453
3.59375
4
class Solution(object): new = ListNode("-inf") def merge(self, L, R): new = self.new res = new while L and R: if L.val < R.val: new.next = L L = L.next else: new.next = R R = R.next new = ...
38b3e571a1440d2968bcddebe53de429a35a5896
bufubaoni/algorithms
/game-of-life.py
1,389
3.859375
4
from copy import deepcopy class Solution(object): def gameOfLife(self, board): """ :type board: List[List[int]] :rtype: None Do not return anything, modify board in-place instead. """ cp_board = deepcopy(board) x_size = len(board[0]) y_size = len(board) ...
9ebb6aaa7b5932b69dfa7bcea77f9fb6a487f022
showyou/soturon
/toDate.py
366
3.515625
4
def toDate(date): import time,datetime dates = time.strptime(date,"%a %b %d %H:%M:%S +0000 %Y") dt = datetime.datetime(dates[0],dates[1],dates[2],dates[3],dates[4],dates[5],dates[6])+datetime.timedelta(hours=9) return dt if __name__ == "__main__": import datetime date = "Sat Dec 22 01:07:16 +0000 2007" print to...
3f648cd87ff4ba529325731db4ee47321ceb6120
jamochl/python-automation-learning
/misc/guess_name.py
344
4.09375
4
familyNames = ["Bob", "Dillan", "Cherry", "Jenny", "Macey"] while True: # prompt user to guess a name in the family print("Guess a name in the family!") # check name userInput = input() if userInput in familyNames: break # break or continue print("Incorrect!") print(f"Yes, {userInp...
05bc3455e24a19ec8aa28733a2616c46cc3b9fd5
chrispeabody/Class-Assignments
/Spring-2016/cs2001/hw2/main.py
8,544
4.03125
4
"""XY77 Battering Ram A tool for manipulating the backdoor in the XY77 Series Quad-layer Vault. """ def read_int(): """A helper function for reading an integer from stdin :return: The integer that was read :rtype: int """ return int(input('>> ')) def read_bool(): """A helper function for r...
24898ff13df2acadf53316a223c78b83c63e99f3
MorrisWCC/codility
/Lesson13/FibFrog.py
1,176
3.640625
4
# Task score 91 not 100。However time complexity detected is NlogN, some cases are not covered def fibonacciDynamic(n): fib = [0] * (n + 2) fib[1] = 1 for i in range(2, n + 2): fib[i] = fib[i - 1] + fib[i - 2] if fib[i] > n: return fib[i-1: 1: -1] elif fib[i] == n: ...
882c8e81a69687174b45bc5e2724ad9ae947f21d
wshis77/leetcode
/remove-nth-node-from-end-of-list.py
856
3.71875
4
#Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @return a ListNode def removeNthFromEnd(self, head, n): if head == None: return None saveHead = head lengthFromHead = self.length(head) - n if(lengthFromHead == 0): result =...
95914f254d4fc48060ba366c812f85d8e8887e78
wshis77/leetcode
/add-two-numbers.py
1,526
3.609375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @return a ListNode def addTwoNumbers(self, l1, l2): current1 = l1 current2 = l2 carry = 0 result = None current = None while current1 != None and current2 != None: mysum = c...
341c94983b4c607ac54910ba4de5a4645caa2010
Brian-Tomasik/python-utilities
/KeepOnlyChars.py
983
4.09375
4
""" By Brian Tomasik 3 May 2014 This program takes an input file and prints out just the alphabetical (A-Z and a-z) characters in word blocks, one word per line. All non-alphabetical characters are taken to be word separators. The original goal was to get a clean set of words in order to diff two HTML files without di...
9a98411287599030e691a032b78401d7ae8ef4ae
nagavnaga/100-days-of-program
/100 days of coding/datetime_1-3/datetimes_ex2.py
569
3.796875
4
from datetime import date, timedelta, datetime start_100days = date(2017, 3, 30) pybites_founded = date(2016, 12, 19) pycon_date = date(2018, 5, 8) def get_hundred_days_end_date(): """Return a string of yyyy-mm-dd""" end_100days = start_100days+timedelta(days=100) return str(end_100days) d...
f17210bc35ab2ecfb6ac103792a89663fb255886
C0dingMeister/Crossroads
/player.py
442
3.71875
4
from turtle import Turtle NORTH = 90 STARTING_POINT = -280 PACE = 20 class Player(Turtle): def __init__(self): super().__init__() self.shape("turtle") self.penup() self.setheading(NORTH) self.goto(0,STARTING_POINT) def move_forward(self): new...
c10a296bec5a0b72295f275b49f3260a654afc8e
RitaPeixoto/FEUP-IART
/TP1/2/ex2.py
899
3.59375
4
from bfs import * from dfs import * from ids import * # Code from this exercise all made by @skdGT print("---- BFS -----") node, tree = bfs(State2((3, 3, 1), (3, 3, 1), "Start")) print("- Tree -") tree.print_tree() if node is not None: path = find_path(node) print("- Solution -") print_path(path) else: ...
5a388d39dbab1a59a8bf51df96b26eb51192e70e
manojkumarpaladugu/LearningPython
/Practice Programs/largest_num.py
358
4.53125
5
#Python Program to Find the Largest Number in a List num_list = [] n = input("Enter no. of elements:") print("Enter elements") for i in range(n): num = input() num_list.append(num) print("Input list is: {}".format(num_list)) big = 0 for i in num_list: if i > big: big = i print("Largest num...
0e1dfa0c61334091f7f6bbc09e8e72d3c1e7365b
manojkumarpaladugu/LearningPython
/Practice Programs/GeeksforGeeks Archive/vowel_string.py
720
4.5
4
# Program to accept the strings which contains all vowels ''' #method1 def is_string_vowel(string): vowels = {'a','e','i','o','u','A','E','I','O','U'} for char in string: if not (char=='a' or char=='e' or char=='i' or char=='o' or char=='u'): if not (char=='A' or char=='E' or char=='I' or char=='O'...
4655d4a9c07fdc83d990068507bb7a614bee7321
manojkumarpaladugu/LearningPython
/Practice Programs/print_numbers.py
310
4.34375
4
#Python Program to Print all Numbers in a Range Divisible by a Given Number print("Please input minimum and maximum ranges") mini = input("Enter minimum:") maxi = input("Enter maximum:") divisor = input("Enter divisor:") for i in range(mini,maxi+1,1): if i % divisor == 0: print("%d" %(i))
abcd934ceb62f1eebb3e6a2963e0f099fa90eade
manojkumarpaladugu/LearningPython
/Practice Programs/GeeksforGeeks Archive/time_12_24.py
385
3.984375
4
# Python program to convert time from 12 hour to 24 hour format def time_12_24(time_12): hh = int(time_12[0:2]) meridian = time_12[6:11] if meridian == "PM": time_24 = str(hh+12) + time_12[2:5] else: if hh == 12: hh = 0 time_24 = str(hh) + time_12[2:5] return time_24 time_12 =...
acba0af4355e7b9e9313146bd5de8042a4367cf6
manojkumarpaladugu/LearningPython
/Practice Programs/sum_1_100.py
106
3.6875
4
s = 0; count = 100; while count: s += count count -= 1 print("Sum of numbers 1 - 100 is",s)
35b61f8813afb1b2f2fcbed2f6f0e9cb97097503
manojkumarpaladugu/LearningPython
/Practice Programs/second_largest.py
377
4.4375
4
#Python Program to Find the Second Largest Number in a List num_list = [] n = input("Enter no. of elements:") print("Enter elements:") for i in range(n): num_list.append(input()) print("Input list is: {}".format(num_list)) num_list.sort(reverse=True) print("The reversed list is: {}".format(num_list)) p...
c493371a828fe86d7d74a831f3cfccb6d4237dca
manojkumarpaladugu/LearningPython
/Practice Programs/OOPS/string.py
356
3.96875
4
# Python Program to Create a Class in which One Method Accepts a String from the User and Another Prints it class String: def __init__(self): self.string = "" def get_str(self): self.string = raw_input("Enter a string:") def put_str(self): print(self.string) obj1 = String...
2a4a24cc323bc98d2cc0d4f007daec09b8a762ec
manojkumarpaladugu/LearningPython
/Practice Programs/GeeksforGeeks Archive/large_prime_factor.py
440
4.40625
4
# Python Program for to Find largest prime factor of a number def is_prime(num): for i in range(2, (num / 2) + 1, 1): if num % i == 0: return 0 return 1 def find_largest_prime_factor(num): maxi = 0 for i in range(1, (num / 2) + 1, 1): if num % i == 0: if is_prime(i): i...
6fb77fed8433ef037ebbd70be628f2d0d462d480
manojkumarpaladugu/LearningPython
/Practice Programs/GeeksforGeeks Archive/binary_palindrome.py
460
4.15625
4
# Python | Check if binary representation is palindrome def check_binary_palindrome(binary): reverse_binary = "" i = len(binary) - 1 while i >= 0: reverse_binary += binary[i] i -= 1 if reverse_binary == binary: return 1 else: return 0 binary = str(input("Enter a binary umber:"...
c4bd502efe26229b6b92ccc4105ad7c89c6edd90
Rgerritse/DL
/assignment_1/code/train_mlp_numpy.py
5,545
3.953125
4
""" This module implements training and evaluation of a multi-layer perceptron in NumPy. You should fill in code into indicated sections. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import numpy as np import os from mlp_numpy import M...
4773df387c20dccaa487d1bbe336daa63b4bb1c4
tiaedmead/Data_24_repo
/Advent_of_Code/Day_04/day_04.py
631
3.734375
4
# Open the input file file = open("input.txt", "r") # Parse lines data = [x.strip() for x in file.readlines()] def part1(data): valid_passport_count = 0 required_fields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] current = 0 for line in data: if line == " ": if current == l...
c6c8d3cecbb532637f068bb05b0d85573ae68e06
Japkeerat/House-Price-Predictions
/Regressors/Multiple_Linear/backward_elimination.py
1,925
3.765625
4
""" Feature Selection using Backward Elimination property and hence building a model on the selected features. """ import statsmodels.formula.api as sm import numpy as np from sklearn.model_selection import train_test_split as tts from sklearn.linear_model import LinearRegression def be_multiple_lr(feature...
6b1ab5de42507e0b124f66969c5ef523bdd7b588
JonatanMilver/search_engine_v2
/inverted_index.py
3,120
3.5625
4
class InvertedIndex: """ Holds the inverted index dictionary. All operations on inverted index would happen through this class. """ def __init__(self): # {term: [df, {tweet_id: [doc_length, max_tf, number_of_unique_terms, tf_idf, tweet_date]]}} self.main_dict = {} def __getite...
0f832094a0a6bfb3507e120594f87374bd29f54b
sydgarnett/PokemonChooser
/Testing/test2.py
523
3.640625
4
#!/usr/bin/env python3 #test2 import creator2 day=31 month=12 year=76 name="Zony Zarnet" test2= creator2.Creator2(day,month,year,name) print(test2.getFirstName(),test2.getLastName()) print("version 2") print("birthday is:",test2.getDay(),"/",test2.getMonth(),"/",test2.getYear(),"||d/m/y") print(test2.countSet(test2.g...
56b022638dff063eefcda1b732613b1441b0bde3
vinromarin/practice
/python/coursera-programming-for-everbd/Exercise_6-3.py
402
4.125
4
# Exercise 6.3 Encapsulate this code in a function named count, and generalize it # so that it accepts the string and the letter as arguments. def count(str, symbol): count = 0 for letter in str: if letter == symbol: count = count + 1 return count str_inp = raw_input("Enter string:") smb...
e70a3ca8aeb66c993ba550fa3261f51f5c4ea845
PurneswarPrasad/Good-python-code-samples
/collections.py
2,017
4.125
4
#Collections is a module that gives container functionality. We'll discuss their libraries below. #Counter from collections import Counter #Counter is a container that stores the elemnts as dictionary keys and their counts as dictionary values a="aaaaaabbbbcc" my_counter=Counter(a) #makes a dictionary of a print(my_c...
3798ed579d458994394902e490bd4afb781c843d
petr-jilek/neurons
/models/separationFunctions.py
1,055
4.25
4
import math """ Separation and boundary function for dataGenerator and separators. Separation function (x, y): Return either 1 or 0 in which region output is. Boundary function (x): Return value of f(x) which describing decision boundary for learning neural network. """ # Circle separation and boundary functions. # ...
22ac018e8cf86e5960517a70002efe16a38079a6
Slard/dashButton
/Scripts/login.py
1,864
3.8125
4
d = {} def clearPage(): for i in range(0, 45): print() def createDict(x, y): d[x] = y file = open("loginInfo.txt", 'r') username = str(file.readline()) password = str(file.readline()) print(username) createDict(username[0:-1], password) print(d) def main(): global user user = input("Ente...
dc11626d5790450752c98f192d4ddee383b21aae
teebee09/holbertonschool-higher_level_programming
/0x03-python-data_structures/3-print_reversed_list_integer.py
227
4.59375
5
#!/usr/bin/python3 def print_reversed_list_integer(my_list=[]): "prints all integers of a list, in reverse order" if my_list: for n in range(0, len(my_list)): print("{:d}".format(my_list[(-n) - 1]))
414f108f84b8bc52512dd81ee8fe5a9603cc1e18
teebee09/holbertonschool-higher_level_programming
/0x03-python-data_structures/4-new_in_list.py
373
3.890625
4
#!/usr/bin/python3 def new_in_list(my_list, idx, element): "replaces an element in a list at idx without modifying the original list" my_list_copy = my_list[:] "if idx is negative or out of range, return a copy of the original list" if idx < 0 or idx >= len(my_list): return (my_list_copy) m...
5fdf358cac32bc7fea9d0d862a9613d742675043
sanjay-chahar/100days
/pizza-order.py
668
4.21875
4
pizza = input("What size pizza you want to order? S,M and L = ") pepperoni = input("Do you want to add pepperoni ? Y or N = ") cheese = input("Do you want add extra cheese? Y or N = ") price = 0 if pizza == "S": price += 15 if pepperoni == "Y": price += 2 # print(f"Pizza price is £{price}") eli...
05c46c818f6440f484fc83655577c21c4c80826a
ysy2025/daily
/Algorithm/NC7动态规划.py
878
3.75
4
def maxProfit(prices): # write code here size = len(prices) a = [[0 for col in range(size)] for row in range(size)] print(a) # 动态规划 for i in range(size): print(a) for j in range(i, size): if i == j: a[i][j] = 0 # 如果当前价格小于买入价格,收益为0;反之计算收益 ...
29740e7b9b691fbb5acac9fd2b6b2216fb13f012
idatya/core-python
/com/sh/core/python-basic.py
5,790
4.125
4
''' Created on 05-Feb-2019 @author: impadmin ''' print("Hello, World!") print("---------------------------") if 5 > 2: print("Five is greater than two!") #This condition will not be pass if 5 < 2: print("Five is less than two!") print("---------------------------") """This is a multiline docstring.""" print("mul...
a201e71769649030e9ece6330cf4be05b50eb0c3
liviu-/miniskripts
/miniskripts/rescale_mark.py
1,021
3.96875
4
#!/usr/bin/env python3 """ Calculates rescaled mark using hardcoded intervals Usage example: $ ./rescale_mark.py 50 Your mark should be 65.0 """ import sys if len(sys.argv) != 2: print("Please use your mark as the only argument") sys.exit() else: try: old_mark = int(sys.argv[1]) exce...
6d0e4f2a9704b24bec3836c5911f90683b0ba1be
TomAPU/book_exercises
/csforall/hw0pr1.py
1,856
3.796875
4
# CS5 Gold/Black: Lab 0 # Filename: hw0pr1.py # Name: # Problem description: The four fours challenge! # add several more lines similar to this one so # that you compute 16 of the 21 values from 0 through 20 using exactly four # fours. You should use Python's arithmetic operations: # + addition # - subtrac...
87b3f93ec90e8e91da8e45f356a8d060190e1ce3
TomAPU/book_exercises
/data-structures-and-algorithms-using-python/chap2/textbased_reversigame.py
687
3.5
4
# Not done yet from reversigamelogical import ReversiGameLogic gl = ReversiGameLogic() while True: gl.draw() turn = gl.whoseTurn() if turn == 0: win = gl.getWinner() print 'Winner is Player %d' % win+1 break if turn == ReversiGameLogic.PLAYER1: play = '#' else: ...
bb347971be1b26ae3ac46fcaeb16f36425598bd4
TomAPU/book_exercises
/data-structures-and-algorithms-using-python/chap2/myarray.py
8,638
3.53125
4
import ctypes class Array: def __init__( self, size ): assert size > 0, "Array size must be > 0" self._size = size PyArrayType = ctypes.py_object * size self._elements = PyArrayType() self.clear( None ) def __len__( self ): return self._size def __getitem__...
42f8c44cfe2a09498d77f699f7f2483b10745183
Jaspreet1997/mainfile.py
/mainfile.py
1,154
3.65625
4
import logging import time import unittest logging.basicConfig(filename="emp.log", level= logging.INFO,format='%(levelname)s:%(message)s', filemode='w') logger = logging.getLogger() begin = time.time() print(f" Strating time of the program {begin}") class Testarithmetic(unittest.TestCase): def test_addition(s...
812a2f4bcda6caac15e4f07701146346b83defef
sbliven/dotfiles
/pymol/alignxml_to_selection.py
7,751
3.515625
4
""" Defines the pymol commands selectAlignment, displayAlignment, and displayAlignmentBlocks """ from xml.dom.minidom import * from pymol import cmd, stored #Pymol functions def selectAlignment(alignFile, name1=None, name2=None): """usage: selectAlignment, [name1, [name2]] Defines two new selections based...
4a4c9eb5d19396aa917b6ea5e9e74ab168b7287d
jramos2153/pythonsprint1
/main.py
2,176
4.40625
4
"""My Sweet Integration Program""" __author__ = "Jesus Ramos" #Jesus Ramos # In this program, users will be able to solve elementary mathematical equations and graph. name = input("Please enter your name: ") print("Welcome", name, "!") gender = input("Before we start, tell us a bit about your self. Are you male or fe...
282ce1232a8420b3446a7dd47a4bb635751b85d6
mohira/remote-pair-poker
/two_cards.py
791
3.5
4
from typing import List from card import Card from hand import Hand from rank import Rank from suit import Suit class TwoCards: def __init__(self, cards: List[Card]): self.card1 = cards[0] self.card2 = cards[1] @property def hand(self) -> Hand: if self.is_pair(): retu...
3b2f8860d2bb78bb49ed33a5dcce1ae1eec42bed
heikowagner/thebigdatablog
/jupyter_notebooks/optimal_limits/streamlit_app.py
1,531
3.703125
4
import streamlit as st import utils import matplotlib as plt import yfinance as yf st.write(""" # Stockmarket Oracle At what price should i buy or sell my stock? """) choices = ["^GDAXI", "^DJI", "GC=F", "BTC-EUR", "META" ,"AMZN","DTE.DE"] selected_stock = st.selectbox("stock", choices) st.set_option('deprecation.s...
6ebd6eb0ed341877f87942cd9d247258d080af7d
fernandosergio/Documentacoes
/Python/Exercicios Coursera/Semana 6/O JOGO.py
3,353
3.96875
4
def computador_escolhe_jogada (n,m): if n <= m: return n else: if n % (m+1) > 0: return n % (m+1) return m def usuario_escolhe_jogada (n,m): x = int(input("Quantas peças vai tirar? ")) if x > m or x < 0: while x > m: x = int(input("Valor inválido!...
a59614475981c532d86b10b6c2dee8abdabcf612
fernandosergio/Documentacoes
/Python/Exercicios Guanabara/ex020.py
402
3.609375
4
"""Tanãnã.""" from random import choices, shuffle #NOQA a = input('Digite o nome do primeiro aluno: ') b = input('Digite o nome do segundo aluno: ') c = input('Digite o nome do terceiro aluno: ') d = input('Digite o nome do quarto aluno: ') lista = [a, b, c, d] # print(f'A ordem de apresentação será {choices([a, b, c ,...
964e4ce72ab404d14b7a6646a9c23a1e34f2d615
fernandosergio/Documentacoes
/Python/Exercicios Coursera/Semana 3/Exercicio1_1.py
127
4
4
numero = int(input("Digite um número: ")) divisao = numero % 2 if divisao == 0: print("par") else: print("ímpar")
10ae837d22e8dd5b2f3becce8d22aa1cb0df301a
fernandosergio/Documentacoes
/Python/Exercicios Coursera/Semana 2/Exercicio_1 2.py
272
3.796875
4
nota1 = int(input("Digite a primeira nota: ")) nota2 = int(input("Digite a segunada nota: ")) nota3 = int(input("Digite a terceira nota: ")) nota4 = int(input("Digite a quarta nota: ")) soma= nota1+nota2+nota3+nota4 media= soma/4 print("A média aritmética é", media)
614dcefde41a4b7d064f8248fceb4a7d3204e60e
fernandosergio/Documentacoes
/Python/Praticando/Utilização da linguagem/while encaixado desafio.py
675
4.3125
4
#usuario vai digita uma sequencia de numeros #imprimi o fatorial do numero digitado #while sem função #entrada = 1 #while entrada => 0: # entrada = int(input("Digite um número natural ou 0 para parar: ")) # i = 1 # anterior = 1 # while i <= entrada: # mult = anterior * i # anterior = mult # ...
8f96bee3040c74b91918e143bd2e95742fc21dac
fernandosergio/Documentacoes
/Python/Exercicios Coursera/Semana 4/Exercicio1_1.py
206
3.859375
4
entrada = int(input("Digite um número natural: ")) i = 1 anterior = 1 while i <= entrada : mult = anterior * i anterior = mult i = i + 1 if entrada == 0: print(1) else: print(mult)
bab53a097c37d76bcd6be33c61b1b57a7722542a
fernandosergio/Documentacoes
/Python/Praticando/Utilização da linguagem/while encaixado 2 desafio.py
334
3.953125
4
n = int(input("Digite um numero maior que 1: ")) fator = 2 mult = 0 x = 0 while n > 1: while n % fator == 0: mult = mult + 1 n = n / fator x = x + 1 if mult > 0: print("fator =", fator,"multiplicidade =",mult) if x == 1 : print("Número primo") fator = fator + 1 ...
6ee579e28b4f4e5b44bb820522851be1aaa4dbf8
fernandosergio/Documentacoes
/Python/Exercicios Guanabara/ex015.py
274
3.84375
4
dias = int(input('Quantos dias foram alugados? ')) km = float(input('Quantos kilometros foram rodados? ')) pd = 60 pkm = 0.15 valor = (pd * dias) + (pkm * km) print(f'O carro foi alugado por {dias} dias e rodou {km:.1f}Km.') print(f'O valor do aluguel é R${valor:.2f}.')
8ad7d4b1aeac6d73d996db51a9395980a1d12a2d
aaravzen/Synthy
/piCode/dumb.py
476
3.765625
4
def get_next(x, y): if x == 3 and y == 3: return 4, 0 if x == 11 and y == 3: return 0, 0 elif x == 3: return 0, y+1 elif x == 11: return 4, y+1 else: return x+1, y def all_buttons(): currX = 0 currY = 0 while True: yield currX, currY ...
06f51bde337c4f60bae678ada677654c4bab7afd
ramjilal/python-List-Key-concept
/shallow_and_deep_copy_list.py
1,400
4.53125
5
#use python 2 #first simple copy of a list, List is mutable so it can be change by its copy. x = [1,2,3] y = x # here list 'y' and list 'x' point to same content [1,2,3]. y[0]=5 # so whenever we will change list 'y' than list 'x' would be change. print x #print -> [5,2,3] print y #print -> [5,2,3] #...
cae67c23a375d0154bc4e12db2743a8a8ab9ca77
kaushik-mac/py-wiki
/pywiki/pywiki.py
3,529
3.609375
4
'''01001011 01000001 01010101 01010011 01001000 01001001 01001011 00100000 01000111 01010101 01010000 01010100 01000001''' # '''import all modules needed''' from tkinter import Button, Label, Listbox, PhotoImage, Tk ,Text from tkinter.constants import ACTIVE, END, SINGLE import wikipedia from py_module import ...
00c319cb96b7c226943266109c4e48c723fc4ff5
bhargavpydimalla/100-Days-of-Python
/Day 1/band_generator.py
487
4.5
4
#1. Create a greeting for your program. print("Hello there! Welcome to Band Generator.") #2. Ask the user for the city that they grew up in. city = input("Please tell us your city name. \n") #3. Ask the user for the name of a pet. pet = input("Please tell us your pet's name. \n") #4. Combine the name of their city a...
db2364d8b76aed94a16b80bb24dc6ae8a6d29a25
xhuanl/UnicornTrackingPython
/src/point.py
1,087
3.765625
4
''' Point class to represent the points. Created on Jul 1, 2017 @author: xhuan ''' import re class point(): def __init__(self): self.cords = [] self.distanceSquare = 0 def parse(self, inpt): try: matcher = re.search('\\((.+)\\)', inpt) ...
bbd10f1eaa208783607329c29278ad8b1ae5fb53
niv26222/binary-Search
/binarySearch.py
856
4
4
# This program binary search method in python def binary_search(arr, f, l, v, sorted_ar = False): if not sorted_ar: arr.sort() if l-f < 0: return -1 else: mid_element_i = (f+l) // 2 if arr[mid_element_i] == v: return mid_element_i elif ...
88be09ca140093831eb67d377b508e1d4b7c3602
fberrabah/TheAmericanDream
/conf/requete.py
710
3.59375
4
import sqlite3 def create_connection(db_file): """ create a database connection to the SQLite database specified by the db_file :param db_file: database file :return: Connection object or None """ conn = None try: conn = sqlite3.connect(db_file) except Error as e: ...
2e97b1e62b2ef842a3e1dabcd845ec689e9d7ca8
Lhogeshwaran/practise
/recommended_sequence.py
3,433
3.796875
4
D = {"able", "ale", "apple", "bale", "kangaroo"} S = "abppplee" # Edge-cases D.add("thisistocheck") # Words longer than S. D.add("abppp") # Multiple correct words. ### D = {"no", "possible", "words"} # No combinations. # Word longer than S can be automatically ignored. #E = {x: len(x) for x in D if len(x)<=len(S)}...
38fde217c92e039a8094f52143fcae548090c337
cmvandrevala/agile_forecasting
/forecast.py
1,389
4.03125
4
import random import matplotlib.pyplot as plt # We are going to use a Monte Carlo simulation and Takt times # to estimate the total time needed to complete a set of stories # (let's call the set of stories an epoch). # First, go out and collect the actual Takt times from stories # in previous sprints. This should be ...
c578afebbd36de51fc138dda0da1ea015f40b7cc
flyingtimes/dashboard_finance
/.ipynb_checkpoints/run-checkpoint.py
503
3.890625
4
import sqlite3 con = sqlite3.connect("DEMO.db") cur = con.cursor() sql = "CREATE TABLE IF NOT EXISTS test(id INTEGER PRIMARY KEY,name TEXT,age INTEGER)" cur.execute(sql) data = "1,'Desire',5" cur.execute('INSERT INTO test VALUES (%s)' % data) # ②:添加单条数据 cur.execute("INSERT INTO test values(?,?,?)", (6, "zgq", 20)) # ③:...
0494e444eaadab8afcf83a6dfe4baac3b411db11
Miroslav11/Python_OOP
/polymorphism.py
838
3.984375
4
class Animal: def __init__(self, name, like_to_eat, like_to_do, in_love): self.name = name self.eat = like_to_eat self.do = like_to_do self.love = in_love def __str__(self): return "{} likes to eat {}, likes to {} and he is in love in {}".format(self.name, self.eat, self.do, self.love) class Dog(Animal)...
c2de15138318c2ca056a13de948450b0a1a6ff6c
Miroslav11/Python_OOP
/bookmarker.py
980
3.640625
4
import tkinter as tk import webbrowser def learn(event): webbrowser.open_new_tab("http://cleverprogrammer.com/courses/enrolled/130834") def github(event): webbrowser.open_new_tab("https://github.com/Miroslav11") def cant_touch_this(event): webbrowser.open_new_tab("https://youtu.be/otCpCn0l4Wo?t=13") window = tk....
dace6f89d2ee58ec4f0a5ff3e30215048d06f3fe
preetising/if_else
/Gs.py
201
3.578125
4
s=int(input("enter the s")) if s<=10000: GS=s+(s/100*20)+(s/100*80) print(GS) if 10000>=s<=20000: GS=s+(s/100*25)+(s/100*30) print(GS) if s>=20000: GS=s+(s/100*30)+(s/100*95) print(GS)
18171b0523bb9456974b625a1831ac7d78991576
preetising/if_else
/grade.py
304
3.984375
4
priya=int (input(" enter the marks")) if priya >=90 : print("grade A") elif priya >=80 : print (" grade B") elif priya >=70 : print ("grade C") elif priya >= 60 : print(" grade D") elif priya >= 40 : print (" grade E") elif priya >= 40 : print("grade F") else: print ("enter the vaild marks")