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
cdfbeaf2c417826e26dc3016f9d42916712fb341
luiscarm9/Data-Structures-in-Python
/DataStructures/LinkedList_def/Program.py
627
4.21875
4
from LinkedList_def.LinkedList import LinkedList; LList=LinkedList() #Insert Elements at the start (FATS) LList.insertStart(1) LList.insertStart(2) LList.insertStart(3) LList.insertStart(5) #Insert Elements at the end (SLOW) LList.insertEnd(8) LList.insertEnd(13) LList.insertEnd(21) LList.insertEnd(34) LList.inse...
4f3c0590a85659b3a8d964c5ccb6986380ee1dff
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_Oiklite01.py
438
3.65625
4
def prime(a): if (a<2): return False for x in range(2,a): if(a%x==0): return False return True def fibo(n): a=[1,1] n1=1 n2=1 for x in range(n-2): n1,n2=n2,n1+n2 a.append(n2) return a def main(): n=int(input("enter number")) f=fibo(n) ...
701df1c454bb30906ad218ca99035800ede33c2e
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_shambashib20.py
546
3.90625
4
import math n=int(input()) n1=1 n2=1 count=0 def isprime(num): if num<=1: return False if num==2: return True if num>2 and num%2==0: return False x=int(math.sqrt(num)) for i in range(3,x,2): if(num%i==0): return False return True ...
afcea4366c6461c636223e156707864be9bc90b1
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_lukasberka.py
797
4.03125
4
import typing def generate_fib(length: int) -> typing.List: fib_seq = [1, 1] if length <= 1: return [] if length == 2: return fib_seq for i in range(2, length): fib_seq.append(fib_seq[i - 1] + fib_seq[i - 2]) return fib_seq def is_prime(num: int) -> bool: if num == ...
ba8ed188cfb738ac44a06bc65eb0b2203c582723
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_RESHU-05.py
748
3.921875
4
def fib(n): #fibonacci series if n==1: return [1] elif n==2: return [1,1] else: a,b=1,1 l=[1,1] for x in range(3,n+1): c=a+b a=b b=c l.append(c) return l def prime(f): # checking number is prime c=0 for y...
243b689861bcfa9dd4fd2ce32d7912aa8ba1c8b9
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_KunalJaiswal-17.py
645
4.25
4
def is_prime(num): if num > 1: for i in range(2, num // 2 + 1): if (num % i) == 0: return False else: return True else: return False def fibonacci(num): num1, num2 = 1, 1 count = 0 if num == 1: print(num1) ...
d5e2382900b729a2e3392882cf95a006a36e57b9
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_IshaSah.py
835
4.34375
4
'''Take input the value of 'n', upto which you will print. -Print the Fibonacci Series upto n while replacing prime numbers, all multiples of 5 by 0. Sample Input : 12 27 Sample Output : 1 1 0 0 0 8 0 21 34 0 0 144 1 1 0 0 0 8 0 21 34 0 0 144 0 377 0 987 0 2584 4181 0 10946 17711 0 46368 0 121393 196418''' import mat...
82a0b63b6b46dbc1b0fb456cf23d1554814c3b04
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_devulapallisai.py
922
4.1875
4
# First take input n # contributed by Sai Prachodhan Devulapalli Thanks for giving me a route # Program to find whether prime or not def primeornot(num): if num<2:return False else: #Just checking from 2,sqrt(n)+1 is enough reduces complexity too for i in range(2,int(pow((num),1/2)+1)): ...
0319816ef3a65374eaa7dd895288b6eff0f42f4a
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_RolloCasanova.py
1,276
4.3125
4
# Function to print given string in the zigzag form in `k` rows def printZigZag(s, k): # Creates an len(s) x k matrix arrays = [[' ' for x in range (len(s))] for y in range (k)] # Indicates if we are going downside the zigzag down = True # Initialize the row and column to zero col, row = 0, 0 ...
5a840100907d0fe49012b75d8707ee142ba80738
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_Candida18.py
703
4.125
4
rows = int(input(" Enter the no. of rows : ")) cols = int(input(" Enter the no. of columns : ")) print("\n") for i in range(1,rows+1): print(" "*(i-1),end=" ") a = i while a<=cols: print(a , end="") b = a % (rows-1) if(b==0): b=(rows-1) a+=(rows-b)*2 print(" "*((rows-b)*2-1),end=" ") print("\n") """ ...
396726314d4a7a5730434f43964dd172e1a451b0
xmumcmp/ratools
/renameTool/urlsort.py
436
3.546875
4
#-*-coding:utf-8-*- import os import codecs import re def func(arg): name,url = arg.split(',') url = re.sub('\n','',url) return url def main(): fname = raw_input('please input the file name: ') with codecs.open(fname,'rb') as f: urllist = map(func,list(set(f.readlines()))) wi...
6ddb300e897007083316ff39af19db4a883b5f42
afletunova/MCCW-Homeworks
/Sem1/Week7/Task_7.py
6,879
3.515625
4
import math def f(x, y): return -y + math.cos(x) y = lambda x: 1 / 2 * (math.exp(-x) + math.sin(x) + math.cos(x)) h = 0.1 N = 10 x_0 = 0 y_0 = 1 derivatives = [] derivatives.append(-f(x_0, y_0) - math.sin(x_0)) derivatives.append(-derivatives[x_0] - math.cos(x_0)) derivatives.append(math.sin(x_0) - derivatives[...
7f58d3d265af0eaf889cf7e9cc158933524280bb
yunhsincynthiachen/SoftwareDesign
/hw6/gravity2.py
10,013
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 8 20:49:27 2014 Gravity Video Game! @author: ychen1, mwelches, mborges """ import pygame from pygame.locals import * import random import math import time class GravityModel: """ Encodes the game state of Gravity: will update the states of the junk and sandra (veloc...
3d7ba334497ba3dfac86b3b4bfbeb929e4d8a436
Leon-Ray/MOOC
/DataSci/matrix_multiply_MR/matrix_multiply.py
1,302
4.03125
4
import MapReduce import sys """ Matrix Multiplication Example in the Simple Python MapReduce Framework """ mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(record): #as recommended in the course, dimensions are hardcoded #(two passes can't be done in th...
cfdc8a85efd911ec5d025a59b9521792c5afe126
lefranco/pnethack
/src/experience.py
979
3.703125
4
#!/usr/bin/env python3 """ File : experience.py Handles experience points and levels (monster and player level) """ import sys # local here since linked to experience table MAX_HERO_LEVEL = 30 EXPERIENCE_TABLE = [ 0, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10000, 20000, 40000, 80000, 160000, 320000, 64000...
c0c783babf61017685ce422abe0d34a6448c08a5
lefranco/pnethack
/src/mycurses.py
2,725
3.5625
4
#!/usr/bin/env python3 """ File : mycurses.py Interface layer to curses, the library handling the screen and the keyboard. """ import typing import curses import os import constants import mylogger def color(front: int, back: int) -> int: """ color """ if front == 0 and back == 0: return curses.c...
d2d56f7fc126004e97d41c53f9b3704d61978473
alexsmartens/algorithms
/stack.py
1,644
4.21875
4
# This stack.py implementation follows idea from CLRS, Chapter 10.2 class Stack: def __init__(self): self.items = [] self.top = 0 self.debug = True def is_empty(self): return self.top == 0 def size(self): return self.top def peek(self): ...
3db82a924147df59bf934f457fcb910da34d8105
icrazy/snake-game-algorithm
/SnakeGameAlgorithm/Hamilton New/cycle.py
9,620
4
4
import random, turtle, math from grid import Grid class HamiltonianCycle: """ A Hamiltonian Cycle Generation algorithm using a Prim MST tree as a maze and traversing it to generate a cycle that passes through every point once - self.generateSpanningTree() -- Makes MST Prim Tree - s...
8916210273411f429ed234227db6709d1702d584
abirbhattacharya82/Integral-Calculator-Using-Automation
/main.py
882
3.75
4
#The Intrgral Calculator with the help of Integral Calculator from tkinter import * from selenium import webdriver from selenium.webdriver.common.by import By def integrate(): s=e1.get() d=webdriver.Chrome("D:/Python/Automation/files/driver_1.exe") d.get("https://www.integral-calculator.com/") ...
347c310d484dfafa8487c0cb8d52f639ecf18b0c
JonathanScialpi/learning-python
/sals_shipping/calc_best_shipping.py3
1,545
3.765625
4
# cost by normal ground shipping def ground_shipping_cost(weight): cost = 0 if weight <= 2: cost = weight * 1.50 elif weight > 2 and weight <= 6: cost = weight * 3 elif weight > 6 and weight <= 10: cost = weight * 4 elif weight > 10: cost = weight * 4.75 return cost + 20 PREMIUM_GROUND_SHIP...
78b2a54064a34e9f68b79ccd14968387c034d9f6
camelNotationsdjkh/Pento-s-Pledge
/src/platforms.py
6,197
3.640625
4
""" Module for managing platforms. """ import pygame import constants from spritesheet_functions import SpriteSheet # These constants define our platform types: # Name of file # X location of sprite # Y location of sprite # Width of sprite # Height of sprite """ Put these constants here inst...
31baecb1e27d32cc745a7994860790d71589ef0e
probsonline/hourOfPython
/pythonApp/files.py
750
3.90625
4
#Open a file fo = open('test.txt', 'w') #get some info print('Name: ', fo.name) print('Is close:', fo.closed) print('Opening mode:', fo.mode) fo.write('I love python\n') fo.write(' I love java') #This will append as file i not yet closed fo.closed fo = open('test.txt', 'w') #again open in write mode fo.write('I al...
ef48ef98c5bec74240a26e035c6110ba9745429d
lakshikha/postiv
/posneg.py
106
3.765625
4
a=raw_input() b=int(a) if b>=0: print("positive") elif b==0: print ("zero") else: print ("negative")
d3b047b5375c6dcd1bff110909be87ad97db9b23
WindChimeRan/leetcode-codewars
/633. Sum of Square Numbers.py
401
3.65625
4
# 1 from math import sqrt class Solution: def judgeSquareSum(self, c: int) -> bool: end = rt = int(sqrt(c)) for i in range(rt + 1): for j in range(end, i - 1, -1): if i**2 + j**2 == c: return True elif i**2 + j**2 < c: ...
0c15a607b2c897e2130a889c941a09988f2802c8
WindChimeRan/leetcode-codewars
/451. Sort Characters By Frequency.py
387
3.65625
4
from collections import Counter class Solution: def frequencySort(self, s: str) -> str: cnt = Counter(s).most_common() res = [] for k, t in cnt: res.append(k*t) return ''.join(res) from collections import Counter class Solution: def frequencySort(self, s: str) -> str...
cd31ee598bfd4026a391305522c1b5a691a8f70b
WindChimeRan/leetcode-codewars
/671. Second Minimum Node In a Binary Tree.py
814
3.859375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def findSecondMinimumValue(self, root: TreeNode) -> int: min1, min2 = float('inf'), float('inf') def add_node(val): ...
1cb2f5ae2a198f7023841d524ed945ff094325cf
jared-vanausdal/project-euler
/Python/PE_Problem15.py
580
3.8125
4
# File: PE_Problem15.py # # Finds the number of paths on a 20x20 grid of numbers import math ''' The number of paths on a grid is the (n choose k) where n is the total number of steps you must take, and k is the number of steps in one direction ''' def FindPaths(x,y): numPaths = math....
78b823c6d6c63086626a791c11542a61639b5ea9
jared-vanausdal/project-euler
/Python/PE_Problem6.py
527
3.921875
4
# File: PE_Problem6.py # # Finds the difference between the sum of n numbers squared, and the sum of # those n numbers squared. I.E. (1+2+...+n)^2 - (1^2 + 2^2 + ... + n^2) def main(): n = 100 values = [] squared_values = [] for i in range(1,n+1): values.append(i) squared_val...
fb772dc8460e66ad1a5aeabf3b9917eb348dc303
aishwarya-b-patil/Python_Sample
/bubble_sort(f).py
305
3.796875
4
def bubble_sort(a): for i in range(len(a)): for j in range(len(a)-i-1): if a[j]>a[j+1]: temp=a[j] a[j]=a[j+1] a[j+1]=temp return a input_list=[89,34,17,13,10,4,0] result_list = bubble_sort(input_list) print(result_list)
74ca6e09855b087a84779156bcb96723938ac84d
rmwenzel/cs_fundamentals
/algorithms/listsort.py
7,939
4.25
4
"""Sorting algorithms for lists.""" from math import ceil from random import randrange class ListSort(list): """Built-in list class augmented with sort algorithms.""" # Quicksort helper methods @staticmethod def choose_median_index(a_list): """Choose index of median of first, last, and mid...
fbd1206fe3f48d67b8542fb45a2b69a902c5ea53
Catboi347/python_homework
/fridayhomework/homework65.py
123
4.03125
4
fibonacci = [0, 1] for num in range(8): num = fibonacci[-2] + fibonacci[-1] fibonacci.append(num) print(fibonacci)
93a2588caddc526f1c6693f9119afccd59b37044
Catboi347/python_homework
/fridayhomework/homework39.py
198
3.875
4
def function(list1): for num in list1: if num % 2 == 0: print ("evennumber = ", num) else: print ("oddnumber = ", num) print (function([1,21,4,45,66,93]))
88b91bd7cac6aa52104090e5e9b194a9b5913a92
Catboi347/python_homework
/exercise14.py
88
3.6875
4
def palindrome(string): return string[::-1] == string print (palindrome("racecar"))
06df1833888c2dca6cfb4d1d4b43e64ce2dbc6a1
Catboi347/python_homework
/fridayhomework/homework92.py
444
3.921875
4
list1 = [] ele = int(input("Type in the amount of elements")) for i in range(0,ele): numbers = input("Enter the amount of things you want in the list") list1.append(numbers) list2 = [] ele2 = int(input("Type in the amount of elements")) for i in range(0,ele): numbers2 = input("Enter the amount of things you...
06402e13f2754f7694b90f94d6a0cfd47205a04d
Catboi347/python_homework
/exercise9.py
149
3.921875
4
def is_anagram(word1, word2): return sorted(word1) == sorted(word2) print (is_anagram("typhoon", "opython")) print (is_anagram("Alice", "Bob"))
a8be30b1e70651dc849bfa512b9d0f36302919e7
Catboi347/python_homework
/fridayhomework/homework57.py
161
3.59375
4
keys = ['Ten', 'Twenty', 'Thirty'] values = [10, 20, 30] updated_dict = {} for x in keys: for y in values: updated_dict[x] = y print (updated_dict)
df997b4a1d6355262ce78657700dbe830cfb46b5
Catboi347/python_homework
/Math_solving/area_of_trapezoid.py
185
3.875
4
b1 = int(input("Input your first base ")) b2 = int(input("Input your second base ")) h = int(input("Input your height ")) A = ((b1 + b2)/2)*h print ("{:.2f}".format(A), "units squared")
640ef55e51e89b278e367fa405ee9b3cbf445793
Catboi347/python_homework
/fridayhomework/homework86.py
209
3.734375
4
list1 = [1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20] even_numbers = list(filter(lambda x: x%2 == 0, list1)) odd_numbers = list(filter(lambda x: x%2 != 0, list1)) print (even_numbers) print (odd_numbers)
a6581d1cc9c928a87c033bd1d22d847721479e0c
Catboi347/python_homework
/fridayhomework/homework69.py
194
3.984375
4
string = input("Type in a string ") digit = 0 letter = 0 for x in string: if x.isdigit(): digit += 1 else: letter += 1 print ("letters", letter) print ("digits", digit)
1b08d68dbb2b101d5f271e12bc87695b6a95f9ef
Catboi347/python_homework
/Mainarea/file_reader1.py
356
3.703125
4
f = open("C:\PythonProjects\data_files\info1.txt", "r") largest_number = 0 while True: the_value = f.readline() if len(the_value) > 0: number = int(the_value) if number > largest_number: largest_number = number else: break #print(f.read()) #print (f.readline()) #print (f...
050c621ab18bc3bb063ad9d14e233c1386f71a00
Catboi347/python_homework
/excersise3.py
278
3.734375
4
def online_count(dictionary): counter = 0 for i in dictionary: x = dictionary[i] if x == "online": counter +=1 return counter statuses = { "Alice": "online", "Bob": "offline", "Eve": "online", } print (online_count(statuses))
58fa55150c3bc3735f3f63be5193eb2433eddd28
Catboi347/python_homework
/fridayhomework/homework78.py
211
4.1875
4
import re string = input("Type in a string ") if re.search("[a-z]", string): print ("This is a string ") elif re.search("[A-Z]", string): print ("This is a string") else: print ("This is an integer")
334c81266e24b8048b8cea5fe404edc1510cdb4c
hmanzanodiaz/git_practice
/classes_2.py
3,022
3.890625
4
# INHERITANCE Above we defined User as our base class. We want to create a new class that inherits from it, so we created the subclass Admin class Bin: pass class RecyclingBin(Bin): pass # EXCEPTIONS # Define your exception up here: class OutOfStock(Exception): pass # Update the class below to raise OutOfS...
ab5c356e0377fe32e6bce8d8084e89dff19e68f6
antiface/fts-book
/code/document.py
2,005
3.828125
4
#!/usr/bin/env python ''' Called like so: >>> import document >>> d = document.Document(open('tests/incorrect_spelling'), 'file://tests/incorrect_spelling') ''' import spell_checker import collections import re # If the document is *huge* don't index it all, just the first part. BYTES_TO_READ=100000 sc = spell_chec...
9bb7603cfd3c9595b0142a4f4d575b1c50d5e5bf
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Bubble_Sort.py
784
4.46875
4
# bubble sort function def bubble_sort(arr): n = len(arr) # Repeat loop N times # equivalent to: for(i = 0; i < n-1; i++) for i in range(0, n-1): # Repeat internal loop for (N-i)th largest element for j in range(0, n-i-1): # if jth value is greater than (j+1) value ...
c3358ef21e7393f7f57fb5238cea8dc63bdf5729
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Selection_Sort.py
423
4.3125
4
# selection sort function def selection_sort(arr): n = len(arr) for i in range(0, n): for j in range(i+1, n): # if the value at i is > value at j -> swap if arr[i] > arr[j]: arr[i], arr[j] = arr[j], arr[i] # input arr arr = [3, 2, 4, 1, 5] print('Before selectio...
5e0bf04f50e383157a0f4d476373353342f3385e
karngyan/Data-Structures-Algorithms
/Tree/BinaryTree/Bottom_View.py
1,305
4.125
4
# Print Nodes in Bottom View of Binary Tree from collections import deque class Node: def __init__(self, data): self.data = data self.left = None self.right = None def bottom_view(root): if root is None: return # make an empty queue for BFS q = deque() # dict to...
0075bbf662a10b00b65f502236a2175a74c6e11a
karngyan/Data-Structures-Algorithms
/DynamicProgramming/WaysToCoverDistance.py
475
3.875
4
"""Given a distance ‘dist, count total number of ways to cover the distance with 1, 2 and 3 steps Input: n = 3 Output: 4 Below are the four ways 1 step + 1 step + 1 step 1 step + 2 step 2 step + 1 step 3 step""" def count_ways(n): count = [0] * (n+1) count[0] = 1 count[1] = 1 count[2] = 2 fo...
cbb8aa8c41dc1059382b1c6a07a3d92641ee840f
karngyan/Data-Structures-Algorithms
/Tree/BinaryTree/Lowest_Common_Ancestor.py
2,428
3.96875
4
""" Program to find LCA of n1 and n2 using one traversal of Binary tree """ # A binary tree node class Node: # Constructor to create a new node def __init__(self, key): self.key = key self.left = None self.right = None # This function returns reference to LCA of two given values n1 ...
9388a768465962c32e15fdf9a1bf6a294e42b504
karngyan/Data-Structures-Algorithms
/Bit_Manipulation/Find_Non_Repeating.py
458
4
4
# Find the two non-repeating elements in an array of repeating elements def find_non_repeating_numbers(arr): xor = arr[0] for i in range(1, len(arr)): xor ^= arr[i] right_set_bit = xor & ~(xor-1) first = 0 second = 0 for i in arr: if i & right_set_bit: first ^= i ...
57a026b0276cac97fc7f5315fc50a1d4ba5f3732
karngyan/Data-Structures-Algorithms
/String_or_Array/Shifted_Array_Search.py
1,150
3.984375
4
"""If the sorted array arr is shifted left by an unknown offset and you don't have a pre-shifted copy of it, how would you modify your method to find a number in the shifted array?""" def binarySearch(arr, num, begin, end): while begin <= end: mid = round((begin+end)/2) if arr[mid] < num: ...
8fd74242f802dd8438d622312f8bfd0f246826cc
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Insertion_Sort.py
567
4.34375
4
def insertion_sort(arr): n = len(arr) for i in range(1, n): x = arr[i] j = i - 1 while j >= 0 and arr[j] > x: # copy value of previous index to index + 1 arr[j + 1] = arr[j] # j = j - 1 j -= 1 # copy the value which was at ith inde...
f7c7ddc29425d13c58734fb60573a45aa332ebdb
karngyan/Data-Structures-Algorithms
/Heaps/MinHeap.py
3,372
4.0625
4
"""A Min heap is a complete binary tree [CBT] (implemented using array) in which each node has a value smaller than its sub-trees""" from math import ceil class MinHeap: def __init__(self, arr=None): self.heap = [] self.heap_size = 0 if arr is not None: self.create_min_heap(ar...
487d70507adea1986e7c35271ced0d4f702f1897
karngyan/Data-Structures-Algorithms
/String_or_Array/Searching/Linear_Search.py
480
4.125
4
# Function for linear search # inputs: array of elements 'arr', key to be searched 'x' # returns: index of first occurrence of x in arr def linear_search(arr, x): # traverse the array for i in range(0, len(arr)): # if element at current index is same as x # return the index value if a...
d4a24ac26947497ebe50f610c3a3ea9ecc121714
quelhasu/pydeco
/pydeco.py
1,291
3.984375
4
""" ~ decorators.py Python decorators are written here, they can be used anywhere in your code. Example of the use of a decorator: @add_method(str) def double_last_letter(self) return self + self[-1] """ from functools import wraps from timeit import default_timer from forbiddenfruit import curse de...
fd351b84ed251e0b6631424e86c2b0963cf30b3e
johnk1729/CSDS344Proj
/RSA.py
3,811
3.96875
4
import math ## gets gcd of two numbers a and b def gcd(a, b): if a == 0: return b return gcd(b % a, a) ## checks if n is prime def isPrime(n): if (n <= 1): return False if (n <= 3): return True if (n%2 == 0 or n%3 == 0): return False sqr = int(math.sqrt(n)) + 1...
4770509557c298d5cbfc73ad196e704055cc65a4
Squadzone/solar_drive
/solar/common.py
1,502
3.6875
4
# -*- coding: utf-8 -*- from datetime import datetime, timedelta import Pysolar as pysol def az_to_str(arcsec): """ Convert azimuth to a pretty printed string seconds -- azimuth in seconds Returns string like ±18d26m32s """ az = int(abs(arcsec)) d, m, s = az // 3600, (az // 60) % 60, az % ...
cfa8d80639a99d40e539616a344f8b079b7e2c9f
YChanHuang/Python-for-every-body-notes
/ch11/ex11.py
267
3.6875
4
import re fh = open('actual.txt') sum = 0 # create a starting point for line in fh: nums = re.findall('[0-9]+', line) if len(nums) < 1 : continue # print(nums) for n in nums : sum = sum + int(n) # change the number into interger print(sum)
1f038f9c7aa265ec80a332450fbf34777c3a6552
YChanHuang/Python-for-every-body-notes
/ch9/ex9.4.py
653
3.546875
4
name = input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" handle = open(name) di = {} for line in handle: if line.startswith('From '): #I forgot the space while the first trial line = line.rstrip() words = line.split() email = list() # it should use list to store the em...
60d4f8bdfa2fd68fefbda48763320a6a590edd84
xulihang/misc
/python/计算机技术课算法作业/2/printList.py
136
3.8125
4
list1=[["life","is"],["nothing","but"],["a"],["game"]] for innerList in list1: for element in innerList: print(element)
12d046444d5b250a9b8e94086c99afa981fb943f
xulihang/misc
/python/计算机技术课算法作业/3/input_radius.py
226
3.71875
4
#coding=utf-8 def getRadius(): try: radius=input("Please input the radius:") radius=float(radius) return radius except: print("please input a num.") return None
882ac44816ce731de1b21811c3c08f3b849e53e5
StevenJimenez18/CodingDojo
/Python/_python/python_fundamentals/helloworld.py
389
4
4
print("Hello World") yourName = "Steven" print("Hello", yourName+"!") print("Hello " + yourName +"!" ) favoriteNumber = 29 print("Hello", str(favoriteNumber) + "!") print("hello " + str(favoriteNumber) +"!") favFoodOne = "pizza" favFoodTwo = "ice cream" print("i love to eat {} and {}." .format(favFoodOne...
4c62ef3396c9f8d9ea7905ad2551627faf541f14
joegalaxian/LPTHW
/ex40/ex40.py
344
3.765625
4
# Exercise 40: Modules, Classes, and Objects # Modules Are Like Dictionaries mystuff_dic = {'apple': 'I AM APPLES!'} print mystuff_dic['apple'] import mystuff mystuff.apple() print mystuff.tangerine mystuff_dic['apple'] # get apple from dict mystuff.apple() # get apple from the module mystuff.tangerine # same thin...
e1a0969a8c4bb9bfc2867f70e0739d1f2bf539ac
joegalaxian/LPTHW
/ex13/ex13.py
470
3.828125
4
# EXERCISE 13: PARAMETERS, UNPACKING, VARIABLES. # Imports "modules" (features) to the script from the Python feature set. from sys import argv # Unkpacking argv ("Argument variable") into STRING variables. script, first, second, third = argv # The first in argv is the name of the *.py file. print "The script is ca...
2a1bb660c1f53e7ae8d5d7f5d1781f52ae93ff04
AluuLL/initial-exper_python
/kaifa_cnv/dateduring.py
488
3.671875
4
#获取两个日期间的所有日期 import datetime def getEveryDay(begin_date,end_date): date_list = [] begin_date = datetime.datetime.strptime(begin_date, "%Y-%m-%d") end_date = datetime.datetime.strptime(end_date,"%Y-%m-%d") while begin_date <= end_date: date_str = begin_date.strftime("%Y-%m-%d") d...
712b0afcbb9021d88e4bc377f18f6320baa6bbac
Shemplo/Study-courses
/Information search/IS - 2. Indexing/varbyte.py
545
3.578125
4
# -*- coding: utf-8 -*- def encode (value): pure = [] while value >= 128: rest = value & 0b01111111 pure.append (rest) value = value >> 7 pure.append (value) pure [0] += 1 << 7 pure.reverse () buffer = [chr (code) for code in pure] return "".join (...
1643160b78a5aefdb07225a4fa6ab56c11bcdcc7
ashwini-8/PythonUsing_OOP_Concept
/dictionariesImplementation.py
1,183
4.28125
4
d ={101:"Ashwini", 103:"Jayashree" , 104:"Rajkumar" ,102:"Abhijit" , 105:"Patil"} #created dict print(d) print(list(d)) #print list of keys print(sorted(d)) #print keys in sorted order print(d[101]) #accessing element using key print(d[10...
8cd285463fa90df622467e4b634e03e3d738b052
VinicciusSantos/CeV-Python
/Mundo1/ex008.py
277
4.1875
4
# Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. m = float(input("Digite uma distância em metros: ")) print(f'{m/1000}Km') print(f'{m/100}hm') print(f'{m/10}dam') print(f'{m*10}dm') print(f'{m*100}cm') print(f'{m*1000}mm')
010c12cc6fc53766a93f72d2262bf11a52c9a171
VinicciusSantos/CeV-Python
/Mundo1/ex025.py
193
4.03125
4
# Crie um programa que leia o nome de uma pessoa e diga se ela tem “SILVA” no nome. nome = str(input("Qual é seu nome completo? ")).upper() print(f'Seu nome tem Silva? {"SILVA" in nome}')
dbf432fb8243028282aaf3dc30d2b1a506a0d670
VinicciusSantos/CeV-Python
/Mundo1/ex017.py
326
4.09375
4
# Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo. Calcule e mostre o comprimento da hipotenusa. from math import sqrt co = float(input('Cateto Oposto: ')) ca = float(input('Cateto adjacente: ')) hip = sqrt(ca**2 + co**2) print(f'A hipotenusa vai medir {hip:.2f}...
674ba225acb3cb441f1dfbd4d32a8713cfc8ba9a
VinicciusSantos/CeV-Python
/Mundo1/ex022.py
504
4.15625
4
# Crie um programa que leia o nome completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas. # – Quantas letras ao todo (sem considerar espaços). # – Quantas letras tem o primeiro nome. nome = str(input('Qual o seu nome? ')).strip() print(f'Seu nome em letras maiúsculas: {nome.upper()}') ...
71cacd0a555a2c74631949f312a9d36c69c21708
fboaventura/hackerrank-30doc
/day01/data_types.py
338
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # """ Declare, read and sum different data types variables """ def main(): i = 4 d = 4.0 s = 'HackerRank ' j = int(input()) e = float(input()) t = str(input()) print(i + j) print(d + e) print(s + t) # Main body if __name__ == '__mai...
e6e3915561067f8ed9f97e3853ffd2efe69bd8aa
konugautham/ChatBot
/chat_bot_class/city_data.py
461
3.5
4
import pandas as pd import numpy as np def city_finder(city_name): df=pd.read_html('https://worldpopulationreview.com/world-cities') df=df[0] statistics= df.iloc[np.where(df['Name']==city_name)] name=statistics['Name'] population= statistics['2020 Population'] Response= str('populati...
6f42056418893fa7c843a80c08fc49e25f7f4a1a
dipeshjoshi/MachineLearning
/python/algoInPython/linkedList/printReverse.py
394
3.84375
4
import singly_linked_list as sll def reverse(inputLinkedList): if(inputLinkedList is not None): start = inputLinkedList reverse(start.next) print start.data if __name__=="__main__": inputList = [9,3,1,4,7,8,2,5] lList = sll.SinglyLinkedList() for item in inputList: l...
9e2bd1ec6ccca2fdec9424a28850bbcea100df7f
dipeshjoshi/MachineLearning
/python/algoInPython/goldman/sumTree.py
756
3.875
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def ifSumTree(root): if root is not None: left = ifSumTree(root.left) right = ifSumTree(root.right) if(((left + right == root.data) or (left==0 and right==0)) and (left...
0631fca87339bd352a146d0e90986bf072f2641b
dipeshjoshi/MachineLearning
/python/algoInPython/string.py
3,143
3.828125
4
s = " Dipesh Joshi " ''' # 1. Substring #s[start_index : end_index] print(s[3:6]) # 2. String concatination (+ operator) n = "Mr." print(n+" "+s) # 3. Repetition (* operator) print(s*2) # 4. membership (in operator) for c in s: print c # 5. Built in string methods # 1. capitalize() print(s.capitaliz...
091053a03866e487a4a04797944870b4ecaeace7
dipeshjoshi/MachineLearning
/python/algoInPython/tree/binary_tree_traversal.py
2,251
3.90625
4
import queue as q from collections import deque stack = [] queue = deque([]) class Node: def __init__(self, data): self.data = data self.left = None self.right = None def preorderRecursive(root): if root is not None: print(root.data) preorderRecursive(root.left) ...
066346fccab63cdf3bdda7a5dec7dfa55abe975c
dipeshjoshi/MachineLearning
/python/algoInPython/goldman/linkedListIntersection.py
1,420
3.765625
4
class Node: def __init__(self, data): self.data = data self.next = None def printLL(head): temp =head while temp is not None: print temp.data temp = temp.next def findLength(head): temp = head length = 0 while temp is not None: length += 1 tem...
2873e469337abb906b91839b9db906f559484e4b
kh1987/rbCAD
/Legacy/physical_geometry/Arc.py
536
3.734375
4
""" An Arc. An edge that is defined as the arc. """ from physical_geometry import Edge class Arc(Edge): """The Arc class.""" def __init__(self, v1, v2, center, radius): """Create a new arc.""" super(Arc, self).__init__(v1, v2) self.set_center(center) self.set_radius(radius) ...
e31f2364212940a6ebf85ada59786bfd73a2b4d1
lm10pulkit/data_science-
/linear_regression.py
1,051
4
4
# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values # Splitting the dataset into the Training set and Test set from sklearn.model_selection import...
9bab62dae0145b71d834b58b1f1c05afd893ce5c
henningth/Cryptopals-Python
/Set1/Challenge6.py
7,253
3.84375
4
""" Cryptopals challenge 6 in set 1. Breaking repeated-key XOR. Challenge website: https://cryptopals.com/sets/1/challenges/6 """ # Standard library imports import base64 import os # Function for computing edit distance (Hamming distance): # how many bits are different in the two input strings. def editDistance(b...
02eefd1e28927eeb13c1f3f5404e45b1d5c59a45
ashutoshfolane/Binary-Search-2
/first_and_last_in_sorted_array.py
1,708
3.828125
4
""" Problem: Find First and Last Position of Element in Sorted Array Leetcode: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ Example: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Solution: Use binary search to find target on left and right side of mid separatel...
6a7405129933f193a424ebb00fb0036ff98a8394
NEK0128/Python
/map.py
95
3.546875
4
#def double (x): # return x * x #print map(double, [2,5,8]) print map(lambda x:x *x,[2,5,8])
ce008e8bdfdc1bb0e45a7f4c7ba7af96cc99fe13
ankurpawar/Python-Matplotlib-learning
/Animation/CircleRadiusAnim.py
929
3.75
4
import numpy as np import matplotlib.pyplot as plt from numpy import pi from matplotlib.lines import Line2D import matplotlib.animation as animation from matplotlib.animation import PillowWriter theta = np.linspace(0, 2 * pi, 500); r = np.ones(500) x = r * np.cos(theta) y = r * np.sin(theta) fig, ax = plt.subplots() ...
b7cd35418b08b88bc034d2574e80776d0f13a4e1
naurlaunim/u
/0809(numpy0).py
3,483
3.546875
4
import numpy as np import random print('# 20.12') def up_tr(a): s = a.shape for i in range(s[0]): for j in range(s[1]): if i > j and a[i, j] != 0: return False if i <= j and a[i, j] == 0: return False return True def down_tr(a):...
57240d3ba1e96af6fb8a26a89c5c5d3e63255292
naurlaunim/u
/0704.py
2,818
3.796875
4
import random import turtle class BinaryTree: def __init__(self): self.data = self.ls = self.rs = None def is_empty(self): return self.data == self.ls == self.rs == None def make_tree(self, data, t1, t2): self.data = data self.ls = t1 self.rs = t2 ...
16ff3b41bfb349e3c40b2ea86ce355ca63621edb
naurlaunim/u
/1003+1703.py
5,169
3.71875
4
class Person: def __init__(self): self.name = None self.byear = None def input(self): self.name = input('surname: ') self.byear = input('year og birth: ') def print(self): print(self.name, self.byear, sep = '\n') # 13.1 ph = open('phonelist.txt', 'w') ...
66220313fbb4f444c6c22006d5941a56bde82607
IamManchanda/python-regex
/phone_test.py
644
3.984375
4
import re def extract_all_phones(input): phone_regex = re.compile(r"\b\d{2}\s\d{4}\s\d{4}\b") return phone_regex.findall(input) # search instead of find all for single input. def is_valid_phone(input): phone_regex = re.compile(r"^\d{2}\s\d{4}\s\d{4}$") match = phone_regex.search(input) return True...
2f5613bf5e12c7e0375463298d7dc84b7cf02694
simonaDemo/python
/fibonacci.py
375
4.03125
4
def fib (x): if x == 0: a = [] elif x == 1: a = [1] elif x == 2: a = [1,1] elif x > 2: a = [1,1] for i in range (1,x-1): a.append(a[i-1] + a[i]) i += 1 return a print (fib(int(input(("How many numbers do you want to know fr...
8fd37fb2ae5ea0c334632ece0481a132fe9eb27f
christopherhooper78/lpthw
/ex19_sd3.py
718
4
4
def number_of_pallets(item_size, number_items): import math print(f"Your item size is {item_size}.") print(f"You have {number_items} items.") print("Pallet capacity is 100.") number_pallets = math.ceil(item_size * number_items / 100) print(f"That means you need {number_pallets} pallets. \n") nu...
a0ae429d5410107e52fa559830a2411203627979
ColtonChill/Portfolio
/Example_Teaching_Assignments/Bingo/Example/src/Card.py
1,410
3.75
4
import sys from NumberSet import NumberSet class Card(): def __init__(self, idnum, size, numberSet): """Card constructor""" self.id = idnum self.size = size numberSet.randomize() self.numberSet = numberSet def getId(self): """Return an integer: the ID number of...
2142cf763e39f41de449d8b0d5c680c6acb8f212
mynameisvinn/pychain
/PyBlockchain/node.py
2,647
3.609375
4
from .block import Block from .baseblock import BaseBlock class Node(BaseBlock): """node class""" def __init__(self, blockchain): self.blockchain_copy = blockchain def update_blockchain(self, new_block): """a node can add a new block to the blockchain, as long the block has a satis...
f15c4b10dc6fa7787ce3ba3aec9164a7253a4a15
Owaisaaa/Python_Basics
/basic.py
709
4.09375
4
############## Program demonstrating some basic code and functions ############### print('AAlaikum') print('What is your name : ') yourName = input() # input() function is used here print('Welcome, ' + yourName + ' Its good to meet you ') print('The length of your name is : ' + str(len(yourName))) # len() function is ...
3db18ca7ea66953d123232e832a7229d1940d2cc
dftty/LeetCode
/PythonSolution/CarPooling.py
424
3.5
4
class Solution: def carPooling(self, trips, capacity: int) -> bool: events = [] for i in range(len(trips)): events.append([trips[1], trips[0]]) events.append([trips[2], -trips[0]]) people = 0 events.sort() for i in range(len(events)): peo...
ec4ccb947f3f86ba4a5be2881db8c198ee8bbb40
luxaflow/ChatRoomMVC
/model/User.py
268
3.53125
4
class User(object): """ Object voor gebruikerrs gegevens Momenteel geen noodzaak kunnen vinden voor meer dan een naam """ def __init__(self, username): self.__username = username def get_username(self): return self.__username
ab1ed1680147d7b09e7478722959ef66fa21410b
charmoniumQ/Homework
/number_theory/tools_extra.py
1,875
3.65625
4
from __future__ import print_function from itertools import tee class memoize_iterator(object): # one class for each original-iterator I source from def __init__(self, it): self.initial = it self.clear() def clear(self): self.initial, self.it = tee(iter(self.initial)) self.c...
2a58530e5039e2e6609e87037a7b1271a5c08e51
SalasC2/python-algos
/algorithms/most_common_element.py
299
4.0625
4
# find the most common element in an arrays def most_common(array): counter = {} for x in range(len(array)): if array[x] in counter: counter[array[x]] += 1 else: counter[array[x]] = 1 return max(counter) print most_common([1, 1, 4, 5, 6, 6, 6,])
d87e3ccfe1dcebc2ba0e3d030b0704c68b52d684
dominiquecuevas/dominiquecuevas
/05-trees-and-graphs/second-largest.py
1,720
4.21875
4
class BinaryTreeNode(object): def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value): self.left = BinaryTreeNode(value) return self.left def insert_right(self, value): self.right = BinaryTreeNode(value...
06e8cc608b4fbc85efb14ff6669285603fcf18ca
dominiquecuevas/dominiquecuevas
/06-dynamic-programming-and-recursion/permutation_retry.py
814
3.734375
4
''' move 1 character at a time to get permutations get slices of string and find permutations of each move the last letter throughout each index ''' def get_permutations(string): if len(string) <= 1: return set([string]) all_chars_except_last = string[:-1] last_char = string[-1] permutations_al...
24e0044dcef9c5ef5d689587a4298c299a479f7c
kxlsx/sudoku-solver
/src/sudoku/requestsJson.py
6,663
3.640625
4
import requests import json def get_data_from_json_site(siteURL, endpoints='', params='', headers=''): """ Fetches json data from URL and converts it to python data structures. Arguments: siteURL {str} Keyword Arguments: endpoints {str} (default: {''}) params {di...