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
c3f87ab648316a201d3b964a4e3ed4421426c82d
gaurav0529/Python_Questions
/Loops and Conditional Statements/Ques6_loop&cond.py
305
3.6875
4
print("Question 6") print("How much No. do you want to enterd") l=int(input()) ls=[] print("Enter No :-") for n in range(l): ls.append(int(input())) print(ls) c=0 d=0 for n in range(l): if ls[n]%2==0: c+=1 else: d+=1 print("No. of Even No. :-",c) print("No. of Odd No. :-",d)
c16f5b9ef8f20d1072a4205d0679c20c854c4320
gaurav0529/Python_Questions
/ProgramsList/Ques8_list.py
194
3.96875
4
#question 8 li=[] print("enter no of elements") l=int(input()) for n in range(l): li.append(input()) print(li) if len(li)==0: print("list is empty") else: print("list is not empty")
1c309ef7708b97b708070e9b6729749325abfb75
gaurav0529/Python_Questions
/ProgramsList/Ques6_list.py
218
3.671875
4
lt=[(2,5),(1,2),(4,4),(2,3),(2,1)] print(lt) def last(n): return n[-1] def sort(tp): return sorted(tp, key=last) print(sort(lt)) ''' l=[] for n in range(4): #tp=ls[n].sort() l=l.append(t) print(l) '''
9fdf622cff18edc526164fae5d2fff5c54c549fa
gaurav0529/Python_Questions
/Loops and Conditional Statements/Ques13_loop&cond.py
198
3.671875
4
print("Question 13") print("Enter 4 digit Numbers seprated by Comma") n=input() a=n.split(",") print(a) l=len(a) print("Length",l) for n in range(l): d=int(a[n]) if d%5==0: print(d)
968c654009cbbdb673b8e9fd5b66ee0f8aa67edf
gaurav0529/Python_Questions
/Loops and Conditional Statements/Ques24_loop&cond.py
223
3.984375
4
# Question 24 st="" for r in range(7): for c in range(7): if ((c==1)or((r==0 or r==3)and(c>1 and c<5))or((r==1 or r==2)and c==5)): st+="*" else: st+=" " st+="\n" print(st)
6f634858aa83468c281e844b1069029ea6f952cb
rezami/Robotics
/projects/controls/examples/pi_controller/pi_controller.py
2,807
3.921875
4
################################################################################## # Your goal is to follow the comments and complete the the tasks asked of you. # # Good luck designing your proportional integral controller! ################################################################################## class PI_C...
052572c6897362cac7d2c19f51709bb55315c9d8
shuai000/Localization-HMM
/hmm.py
21,125
3.546875
4
""" 1. Hidden Markov Based Module 2. Ref: Lawrence tutorial on HMM & selected application in speech recognition 3. Author: Shuai Sun 05/09/2018 ----------------------------------------------------------------------------- Parameter needs to be specified once a HMM model instance is initialized """ import numpy as np...
f11eaee874e32e69c9865406fb1a450a90279a0d
Minfante377/go_linux
/scripts/get_users.py
346
3.578125
4
import sqlite3 from sys import argv db = sqlite3.connect(argv[1]) cursor = db.cursor() cursor.execute("SELECT name FROM sqlite_master WHERE type='table';") table = cursor.fetchone()[0] cursor.execute("SELECT user_id FROM {};".format(table)) res = cursor.fetchall() ids = [] for r in res: ids.append(r[0]) print(" "....
ada2c584e691e45157120dc592ecca1a0b6fe05c
Oficina-TIC-BGA/OTICFinder
/OTICFinder/address_cleaner.py
11,667
3.703125
4
# all functions for address cleaning import re def regex_cleaner(string): """ string: direccion tipo:string return: direccion filtrada """ string = str(string) # pattern 1-3: Colocar espacio entre los numero y letras, numeros y signos (#-,) for typ, regex in zip(['finditer', 'finditer', 'f...
a24aa252474e083953804c92fd5baa8b86bf353d
entomologyx/work-with-wordlists
/flallcofcharswl.py
792
3.671875
4
# this script is used to create a wordlist of all the combinations of a charset of a specific length. import itertools from itertools import product charset = ['a', 'b', 'c','e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', ...
b4f6a6e4e3f9767b5bac6c3c61dcd4fa2f2ac09c
nishanthr017/Programs
/datetime.py
145
3.8125
4
import datetime now2 = datetime.datetime.now() print ("Current date and time using str method of datetime object:") add1=str(now2) print (add1)
8c988bf453d8f1c5bb69272e69e254df77c1b874
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx2.py
2,924
4.5625
5
# WPCC # basicEx2.py # Let's take a look at some different types of data that Python # knows about: print(10) print(3.14) print("Python is awesome!") print(True) # There are 4 fundamental types of data in Python: # integers, floating point numbers, strings, and booleans # You can create more types of data, but we'll...
9312b66e4affd28406293cfca61b6d5ed8a25088
shreeji0312/learning-python
/python-Bootcamp/assignment4/funcAssign2.py
212
3.515625
4
#Shreeji Patel #105151171 def subtract(a, b): c = a[:] for i in range(len(b)): if b[i] in c : c.remove(b[i]) print(c) ''' a = [1,2,3,4,5,6,7,8,9,10] b = [2,5,6,7] subtract(a,b) '''
46004672cd99417c2bc0027e364ecb4441f1c8f9
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx6.py
1,907
4.84375
5
# WPCC # basicEx6.py # So far we've made our own variables that store # data that we have defined. Let's look at how we can # ask the user to enter in data that we can manipulate # in our program # We will use the `input` function to ask the user to enter # some data user_input = input("Please enter a number: ") # ...
6c4c8561cb46045307cf14a1481f97b3e63c1af8
shreeji0312/learning-python
/python-Bootcamp/assignment5/assignment5notes/2dlistEx1.py
2,000
4.71875
5
# WPCC # 2dlistEx1.py # We're going to look at what a 2D list is. # A 2D list is a list that contains other lists. # For example: marks = [ [90, 85, 88], [68, 73, 79] ] # The list `marks` contains 2 other lists, each containing # integers. We would say that this list is of size 2x3: # two lists, each containing 3 ele...
1e5e58296ff0d65ef46f056d8f3ea3b3302c416f
shreeji0312/learning-python
/python-Bootcamp/assignment3/listAssign3.py
245
3.59375
4
#Shreeji Patel #105151171 import random bdays = [] while True: date = random.randint(1,365) if date in bdays: print('Birthdays generated before duplicate: %d' %len(bdays)) break else: bdays.append(date)
291d09272a542e9b24fab373d154466f9d1b0c30
shreeji0312/learning-python
/python-Bootcamp/assignment4/assignment4notes/functionEx2.py
1,611
4.84375
5
# WPCC # functionEx2.py # When we call some Python standard functions, it gives us back # a value that we can assign to a variable and use later in our programs. # For example: import random randomNumber = random.randint(0, 10) # This function will return the value it generates so we can assign its # value to `rand...
2cbb1bc7114f2a0e562f76d2c5016d10c5b6784f
shreeji0312/learning-python
/python-Bootcamp/assignment1/basicAssign2.py
329
4
4
#Shreeji Patel #105151171 percent = int(input('Please enter your percentage:')) if percent>=80: print('Your grade is A') elif 80>percent>=70: print('Your grade is B') elif 70>percent>=60: print('Your grade is C') elif 60>percent>=50: print('Your grade is D') elif 50>percent: print('You...
017c91a80351315e84c648efd4bb6d3135897d35
agoshula1/SynchProblems
/src/dpsemaphore.py
1,570
3.6875
4
''' Based on a the first solution to Dining Philosophers problem given in the "Little Book of Semaphores" by Allen B. Downey. As in the book, this solution uses semaphores as the main concurrency mechanism. ''' import threading import random import time class SyncCtrl(): def __init__(self): self.forks =...
c8623b83f455d15534d0fac2d1628955977d5236
SucharitaMullapudi/python-leetcode-sol
/hard/First Missing Positive.py
319
3.578125
4
class Solution(object): def firstMissingPositive(self, nums): """ :type nums: List[int] :rtype: int """ for num in range(1,len(nums)+2): if num not in nums: if num <=0: pass else: return num
3bdc532c69c13b12c8db0f4314d51c31c4d5a9fa
SucharitaMullapudi/python-leetcode-sol
/easy/Third Maximum Number.py
408
3.78125
4
class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ nums = list(set(nums)) if len(nums)==0: return 0 elif len(nums)==1 or len(nums)==2: return max(nums) else: nums.pop(nums.ind...
cb2b065294514e92dc994075f379a83ffa2ecbc0
fantasylsc/LeetCode
/Approach/Classification/Shortest_path_in_graph.py
2,819
4.03125
4
''' find shortest path from start_node to end_node in a graph, and return the path in list ''' import unittest from collections import deque def construct_path(reversed_path, end_node): path = [] current = end_node while current: path.append(current) current = re...
450dc0fceb56574620a15053a0ee505898cad0a1
fantasylsc/LeetCode
/Algorithm/Python/300/0300_Longest_Increasing_Subsequence.py
1,699
3.8125
4
''' Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may be more than one LIS combination, it is only necessary f...
5defe774dfdb6ee74ec9c409c36d25a8cf05ca88
fantasylsc/LeetCode
/Algorithm/Python/25/0012_Integer_to_Roman.py
2,439
3.890625
4
''' Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one's added togeth...
fdac3378a11804a6a46719f98b9c7eb4949cbd7a
fantasylsc/LeetCode
/Algorithm/Python/1175/1170_Compare_String_by_Frequency_of_Smallest_Character.py
4,961
3.6875
4
''' Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smallest character in s. For example, if s = "dcce" then f(s) = 2 because the smallest character is "c" and its frequency is 2. Now, given string arrays queries and words, return an integer array answer, where each a...
cff4bb07655d01e59c013ce8b4093967b7194779
fantasylsc/LeetCode
/Algorithm/Python/150/0145_Binary_Tree_Postorder_Traversal.py
2,764
4
4
''' Given a binary tree, return the postorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [3,2,1] Follow up: Recursive solution is trivial, could you do it iteratively? ''' # Definition for a binary tree node. # class TreeNode: # def ...
20656a0b0704de6339feab22f2a2a4d539cda92f
fantasylsc/LeetCode
/Algorithm/Python/75/0056_Merge_Intervals.py
977
4.15625
4
''' Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] ...
a6955c5169259671ea14f206d5aa62166400c0ce
fantasylsc/LeetCode
/Approach/Classification/searchRange_BST.py
1,096
4.0625
4
''' Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Print all the keys of tree in range k1 to k2. Print all the keys in increasing order. Example: Input: k1 = 10, k2 = 22, root = Node(20) Output: 12, 20, 22 20 / \ ...
1474a3216737c428ec04eab0c74a70acf1ebeb20
fantasylsc/LeetCode
/Algorithm/Python/25/0016_3Sum_Closest.py
2,498
4.03125
4
''' Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is c...
a2b885219ae947349be88818f314ef1152034fe4
fantasylsc/LeetCode
/Approach/Classification/Counting_Sort.py
1,147
3.921875
4
''' Counting Sort Worst case performance: O(n + k) Best case performance: Ω(n + k) Average performance: Θ(n + k) Worst case space complexity: O(k) ''' ''' idea: count the number of nums for each num, then append each num with n count to result ''' import unittest from typing import List class ...
a312e0acb76d0747602ccf4c39d799a3c814c30c
fantasylsc/LeetCode
/Algorithm/Python/1025/1007_Minimum_Domino_Rotations_For_Equal_Row.py
2,473
4.1875
4
''' In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A...
829b4a5b4b6c2a6e274e216b36bddb716440fcf8
fantasylsc/LeetCode
/Algorithm/Python/125/0110_Balanced_Binary_Tree.py
3,353
4.21875
4
''' Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the left and right subtrees of every node differ in height by no more than 1. Example 1: Given the following tree [3,9,20,null,null,15,7]: 3 /...
66520ef3e74a3348651ed8ab5153791d6eace6e8
fantasylsc/LeetCode
/Approach/Classification/Heap_Sort.py
2,228
3.625
4
''' Heap Sort Worst case performance: O(nlogn) Best case performance: Ω(nlogn) Average performance: Θ(nlogn) Worst case space complexity: O(1) Heap 4 / \ 10 3 / \ 5 1 Note: Root is at index 0 in array. Left child of i-th node is at (2*i + 1)th index. Right child of...
be6dcdfbf31e868c37a3493f23d57da9859ca5d3
fantasylsc/LeetCode
/Approach/Interview/Min_Amplitude.py
2,218
3.9375
4
''' Question 1: Given an Array A, find the minimum amplitude you can get after changing up to 3 elements. Amplitude is the range of the array (basically difference between largest and smallest element). Example 1: Input: [-1, 3, -1, 8, 5, 4] Output: 2 Explanation: we can change -1, -1, 8 to 3, 4 or 5 Exa...
6140034d631c34e6bf00741fa4647fd5785cb70c
fantasylsc/LeetCode
/Algorithm/Python/125/0115_Distinct_Subsequences.py
1,807
3.84375
4
''' Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" ...
776f5224c9de9c1797e9447545fb782f06c8c042
fantasylsc/LeetCode
/Algorithm/Python/400/0377_Combination_Sum_IV.py
1,362
4.0625
4
''' Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, 1, 1) (2, 2) (3, 1) Note t...
a18260a2c70db8afa8c17a910f0ea09a4d1802b1
fantasylsc/LeetCode
/Algorithm/Python/100/0079_Word_Search.py
2,907
4.15625
4
''' Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E']...
8f3f5394b435a3b706388f72f98d14ac42e5ed10
fantasylsc/LeetCode
/Algorithm/Python/75/0065_Valid_Number.py
2,383
4.125
4
''' Validate if a given string can be interpreted as a decimal number. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true " -90e3 " => true " 1e" => false "e3" => false " 6e-1" => true " 99e2.5 " => false "53.5e93" => true " --6 " => false "-+3" => false "95a54...
a7ca8d4b44ebc5f2c4ced55c649fca809610430c
pratham12345/python-practice
/Qr.py
178
3.578125
4
starts_with = lambda x: True if x.startswith('P') else False print(starts_with('Python')) starts_with = lambda x: True if x.startswith('P') else False print(starts_with('Java'))
72f88afe3e30ced6174f0ad71987be8b38b7f409
balshetzer/AdventOfCode
/2019/16a.py
650
3.515625
4
#!/usr/bin/env python3 import fileinput from itertools import repeat, cycle, islice import operator base_pattern = [0, 1, 0, -1] def repeat_elements(it, i): for elem in it: yield from repeat(elem, i) def pattern(index): gen = cycle(repeat_elements(base_pattern, index+1)) next(gen) yield from gen def ne...
c11d7f672fa973501bfd21cc96c4eb02c6da37c6
balshetzer/AdventOfCode
/2020/1b.py
337
3.53125
4
#!/usr/bin/env python3 import fileinput nums = [int(line.strip()) for line in fileinput.input()] def f(sum, nums): while nums: num = nums.pop() other = sum - num if other in nums: return num * other while nums: num = nums.pop() others = f(2020-num, nums.copy()) if others: print(num * o...
6acfa5996a5340579c44377bc36deb477fec2caf
balshetzer/AdventOfCode
/2019/3a.py
656
3.515625
4
#!/usr/bin/env python3 import fileinput import operator import itertools dirs = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)} def wire(steps): add = lambda a,b: tuple(map(operator.add, a, b)) result = [(0,0)] for step in steps.split(','): for dir in itertools.repeat(dirs[step[0]], int(st...
195df0c3e09088c5935da184c546fba0d25d78f9
balshetzer/AdventOfCode
/2022/04b.py
410
3.65625
4
#!/usr/bin/env python3 from parse import compile from sys import argv, stdin f = open(argv[1]) if len(argv) == 2 else stdin pattern = compile('{:d}-{:d},{:d}-{:d}') def parse(line): return pattern.parse(line).fixed def overlaps(a, b, c, d): return a <= c <= b or c <= a <= d def process(line): return o...
0e623b3b493e76f3613d7a4cebc409a161df27e1
balshetzer/AdventOfCode
/2019/2b.py
408
3.53125
4
#!/usr/bin/env python3 import fileinput import intcode program = list(map(int, next(fileinput.input()).strip().split(','))) def run(noun, verb): program[1] = noun program[2] = verb m = intcode.Interpreter(program) m.run() return m.mem[0] def search(): for noun in range(100): for verb in range(100): ...
e0a96f11f4ff31b1ef3aeb9001583f854a54e418
jiyuan312986471/LeetCode
/python/5-Longest Palindromic Substring.py
733
3.8125
4
class Solution: def palindrome(self, s, i): leng = len(s) # odd l, r = i, i while l >= 0 and r < leng and s[l] == s[r]: l -= 1 r += 1 palin = s[l + 1:r] # even l, r = i, i + 1 while l >= 0 and r < leng and s[l] == s[r]: ...
3865141f1482d85ade34b8804f8b75b6a3e6491d
sorghumking/aoc2019
/day3.py
1,883
3.65625
4
from inputs import parse_day3 # Works, but is incredibly inefficient, making a list of every # coordinate visited by both wires. On the upside this made part 2 # very easy, as the index+1 of each coordinate is also the number of # steps it took to get there. def part1(wire1, wire2): w1coords = [] x = 0 y =...
50afd70a0e9a46759907287cc887c1ae236dd8f9
chunmusic/Data-Science-Training-Camp-I
/Course I/Ex3/Exercise 3.2.py
563
3.625
4
# Exercise 3.2 #1 import pandas as pd df = pd.io.parsers.read_csv("homes.csv") print("Number of House for each no. of bathroom:") print(df["Baths"].value_counts()) #2 print("Number of house for each area:") area = pd.qcut(df["Acres"], q=10, precision=0) print(area.value_counts()) #3 print("Number of bathroom ...
c5a37892933b500517b7de891baf1015a8dc35b0
chunmusic/Data-Science-Training-Camp-I
/Course I/Ex5/Exercise 5.6.py
983
3.546875
4
# Exercise 5.6 (Extra) from geopy.geocoders import Nominatim geolocator = Nominatim(user_agent="chun") # Finding the location name of the coordinate from geopy.extra.rate_limiter import RateLimiter geocode = RateLimiter(geolocator.reverse, min_delay_seconds=0.5) import pandas as pd location_data = pd.read_csv("loc...
ad66f5c67364e3b3a5355857e7f9ad3d4cf9293b
woochan-hwang/Algorithms-DS-Practice
/Linked Lists/loopdetect.py
1,577
3.921875
4
# Write a code to detect the beginning of a loop in a singly linked list # Standard Python implementation of Node object class Node: def __init__(self, x): self.val = x self.next = None class Solution: def __init__(self, dummy = 0): self.dummy_head = Node(dummy) # Loop back from...
539b9959302ced2be3ce892c67ff559dddb41ffb
dimizisis/high-performance-computing
/MPI/mpi4py/shell_sort/shell_sort_parallel.py
3,866
3.65625
4
import numpy as np from mpi4py import MPI TAG = 200 ROOT = 0 N = 10 LOWER = 0 UPPER = N*2 def merge(x, n1, y, n2): ''' Function: merge -------------------- Merges two arrays with different length x: pointer of the first array n1: size of array x y: pointer of the second array n2: s...
f95936c56c6abda10b2ea4623d385ee0e886ac5d
xboard/AoC
/2020/Day_15/rambunctious_recitation.py
2,651
3.84375
4
#!/usr/bin/env python3 """ Solves day 15 tasks of AoC 2020. https://adventofcode.com/2020/day/15 """ import argparse from typing import Sequence, List from collections import defaultdict SEQUENCE = [14, 3, 1, 0, 9, 5] def task(sequence: List[int], ith: int) -> int: """ Solve task 1 or 2. Parameters ...
04f58a515d7ba348617d103f78be58474ce785a1
Arnaud-D/analemma
/conversions.py
730
4.0625
4
from math import pi rad_per_deg = pi / 180 # number of radians per degrees deg_per_rad = 180 / pi # number of degrees per radians minutes_per_hour = 60 # number of minutes per hour seconds_per_hour = 3600 # number of seconds per hour seconds_per_minute = 60 # number of seconds per minutes seconds_per_day = 86400...
8d87280555ec0673c2d7868ff172931acd813a0a
IgorKalinovskii/HW4
/t1.py
1,230
3.921875
4
def lala (lines = 3, la_per_line= 3, end = 0): """Пишем функцию, которая генерирует песню la-la-la. Функция принимает 3 аргумента: 1-е число – сколько строк будет в песне. По умолчанию 3 2-е число – сколько «la» будет в строке («la» в строке объединяются дефисом). По умолчанию 3 3-е число – если 0, то в конце песни...
7a11016614d1882df94b1c632cc5ec1b30aa22d0
ssalgadoe/emergencyAlertGenerator
/dbtest.py
925
4.03125
4
import psycopg2 import sys import pprint print("hello world") #Define our connection string conn_string = "host='localhost' dbname='alerts' user='alert_user' password='ingle@123'" # print the connection string we will use to connect print ("Connecting to database\n ->%s" % (conn_string)) # get a connection, if a c...
94ae2cd31bc8e3b475c1c0e9e7c4b26156533fae
sasiashwin/accenture
/rightmost sum.py
189
3.59375
4
def find(arr): n = 0 s = 0 for i in range(len(arr)-1,-1,-1): if(arr[i]>n): s+=arr[i] n = arr[i] return s arr = [33,7,21,14] print(find(arr))
c27c18eaac67b6f05d524dfe2e6bab2219a944b2
rishi7292/Flight-Accident-Analysis
/Fatal injuries vs Flight Phases.py
2,108
3.640625
4
#Description: This program provides the frequency of fatalities caused during different phases of flight. #It focuses on how the phases affect the criticality and fatal injuries. The plot shows different states of phases with corresponding fatal injury counts #importing Packages import numpy as np import matplo...
fb370dc8d183b2a99a6800a333fa54a51c59f135
nshearer/doccol
/src/doccol/engine/utils/Cache.py
989
3.90625
4
class Cache(object): '''Basic in-memory caching implementation''' def __init__(self, max_size, close_cb=None): self.__max_size = max_size self.__close_cb = close_cb self.__entries = dict() self.__entry_order = list() def add(self, key, value): # Clean out cache ...
955c1c68bdd8c6c869585f98009b603eb3938d28
amirhosseinghdv/python-class
/Ex4_Amirhossein Ghadiri.py
1,617
4.1875
4
"""#Ex12 num1=int(input("addad avval?")) num2=int(input("addad dovvom?")) if num1 >= num2: print(num2) print(num1) else: print(num1) print(num2) """ """#13: num=int(input("please enter a number lower than 20: ")) if num >= 20: print("Too high") else: print("Thank you") """ ...
9de377caeb1b77b0e350e0c5c1e553e3f265372f
amirhosseinghdv/python-class
/Ex3_Amirhossein GHadiri jadid.py
665
3.5
4
rouz=int(input("rouze miladi ro vared konid.")) mah=int(input("mahe miladi ro vared konid.")) sal=int(input("sale miladi ro vared konid.")) if sal%4 !=0 : print("kabise nist.") kabise=False elif sal%4 ==0 and sal%400 ==0 : print("kabise ast.") kabise=True elif sal%4 ==0 and sal%100 ==0 : p...
466fe5625913577f62f17a34a63f2f27d0cfbdf0
mahimamalik/stack-route
/Algorithm/muller_method.py
1,015
4.03125
4
import math as Math def func(x): return (x**3 - 32*x + 8) def muller_method(x0,x1,x2,allow_error): iteration = 0 while(1): h0 = x1 - x0 h1 = x2 - x1 del0 = (func(x1) - func(x0))/h0 del1 = (func(x2) - func(x1))/h1 a = (del1 - del0)/(h0 + h1) b = a*h1 + del1 c = func(x2) if(b < 0): x3 = x2 ...
ecd250268b50968afda1f4634302b94527a87068
yassinerahhaui/python3_course
/course/condition.py
202
4.09375
4
# if else elif stetment x = 10 y = 20 if x < y: print("x less than y") elif x > y: print("x greater than y") else: print("x equal y") print("less than") if x < y else print("greater than")
ffca4e4f939111245146c6d2648b8f674d93fef5
carlospisani10/webscraping_pymongo.io
/mission_to_mars.py
3,504
3.53125
4
# https://splinter.readthedocs.io/en/latest/drivers/chrome.html from splinter import Browser from bs4 import BeautifulSoup import pymongo import requests import os import pandas as pd mars = {} def scrape(): ### NASA Mars News browser = Browser('chrome', headless=False) url = 'https://mars.nasa.gov/news/...
b27db69ddb32b5b5b52d6d6ccf9b1435eac3949d
singachea/ProjectEuler
/python/Problem047.py
1,077
3.5
4
# The first two consecutive numbers to have two distinct prime factors are: # # 14 = 2 x 7 # 15 = 3 x 5 # # The first three consecutive numbers to have three distinct prime factors are: # # 644 = 2**2 x 7 x 23 # 645 = 3 x 5 x 43 # 646 = 2 x 17 x 19. # # Find the first four consecutive integers to have four distinct pri...
07d431c2473e33a00b597bc6412af322f116abab
AnumaThakuri/pythonassignment
/assignment4/question 1.py
310
4.28125
4
#average marks of five inputted marks: marks1=int(input("enter the marks 1:")) marks2=int(input("enter the marks 2:")) marks3=int(input("enter the marks 3:")) marks4=int(input("enter the marks 4:")) marks5=int(input("enter the marks 5:")) sum=marks1+marks2+marks3+marks4+marks5 avg=sum/5 print("average=",avg)
8497b2c33f8cb02bac7ad7f35c4cc7e9591de163
AnumaThakuri/pythonassignment
/Assignment3/question 11(B).py
69
3.671875
4
for length in range(1,8,2): print(' '*(length-1)+"O "*(8-length))
eeb99ecb937015ff83f16e6c592a8bdab7a25852
AnumaThakuri/pythonassignment
/Assignment3/question 5.py
88
4
4
num=int(input("Enter any number")) for i in range(1,13): print(num ,'x',i,'=',num*i)
dbab42072443f60b56534fe47400d76c0b94bb2a
AnumaThakuri/pythonassignment
/python theory class/class item.py
1,239
3.78125
4
class item: def __init__(self,name,price,quantity): self.name=name self.price=price self.quantity=quantity def purchase(self,quantity): self.quantity=self.quantity-quantity print("number of item to be purchased :",quantity) print("quantity after a purchased ...
d31d93b209af4b77ca648275bc4761eea3596026
AnumaThakuri/pythonassignment
/assignment 5/question 6.py
183
4.09375
4
#create a set of 5 element. insert a new element in the set and delete an existing element from the set: set1={2,4,5,3} print (set1) set1.add(8) print(set1) set1.remove(4) print(set1)
86ed441f6d4ab832a0087ed1b6b5adac3085ebcf
AnumaThakuri/pythonassignment
/Python test1/question 1.py
264
4.34375
4
#convert tempersture clesius to farenhuet and vice versa farenheit=float(input("Enter the temperature : ")) celsius=(farenheit-32)*5/9 print(farenheit ," Farenheit is",celsius,"Celsius") farenheit=(celsius*9/5)+32 print(celsius," Celsius is",farenheit,"Farenheit")
d838698cf42c28b6072f07fcbfcf9a0b5f05cba5
AnumaThakuri/pythonassignment
/assignment 5/question 10.py
150
3.875
4
# given a python list of numbers. two every item of a list into its square: num=[1,2,3,4] squ_numbers=[number**2 for number in num] print(squ_numbers)
aea0a95ada9f6ad8535861694147484e0ab30570
AnumaThakuri/pythonassignment
/assignment 5/question 3.py
171
4.09375
4
# write an expression that changes the first item in a tuple.(4,5,6) should become (1,5,6) in the process: T=(4,5,6) print(T) temp=list(T) temp[0]=1 T=tuple(temp) print(T)
0dcdf78da1adfcbc13cf3b28367621854c260b8c
AnnaLenaMeiners/Python-CI-Test
/corgi.py
1,183
3.75
4
import pygame from pygame.sprite import Sprite class Corgi(Sprite): """ A class to represent the corgi ... Methods ------- update() - updates the corgi's position blitme() - draws corgi on new position """ def __init__(self, settings, screen): super().__init__() se...
b798aac447c584d7fb6aac5f315137f08f1813a6
Verroe/Ejiba_Verro_python
/HW1_11.py
2,169
3.765625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 15 16:45:02 2016 @author: verroejiba """ ''' A sentence splitter is a program capable of splitting a text into sentences. The standard set of heuristics for sentence splitting includes (but isn't limited to) the following rules: Sentence boundaries occur at one of "." (...
f252974c8bc6b068c774d6e08315298e324c5afa
Verroe/Ejiba_Verro_python
/HW1_10.py
1,795
4.0625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 15 16:39:59 2016 @author: verroejiba """ #Number 10 ''' In a game of Lingo, there is a hidden word, five characters long. The object of the game is to find this word by guessing, and in return receive two kinds of clues: 1) the characters that are fully correct, with r...
86e61caf24690468f575656912c4d36a38f3d3f6
Verroe/Ejiba_Verro_python
/HW2. 5.py
1,375
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 21 02:04:40 2016 @author: verroejiba """ #Number 5 ''' In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£...
b8baded51f6f12a80c2fdddaf485ad405bbb8bef
Verroe/Ejiba_Verro_python
/HW2.1.py
1,107
3.96875
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 21 01:34:23 2016 @author: verroejiba """ import math #Number 1 ''' The 12th term is the first term to contain three digits. Write a function that calculates the th term of the Fibonacci sequence. What is the index of the first term in the Fibonacci sequence to contain 1...
e747eaedae35a76084011c40fc775471887bfb45
blindgemaster/kacs_go_max
/score_sorter/Score_Sorter.py
1,098
3.609375
4
import os def clear(): os.system('cls') def student_number_sortout(): list1 = [] numbers = 1 list2 = [] while not numbers == 0: try: numbers = int(input('Enter numbers: ')) if numbers > 520 or numbers < 0: raise ValueError list1.append(...
f40f0bca22a2d69c81445fdc5135b51eaefa73ec
sreenath-kada/Python
/merge_sort.py
857
4.0625
4
def merge_sort(list): if len(list) <= 1: return list middle = len(list) // 2 left_list = list[:middle] right_list = list[middle:] left_list = merge_sort(left_list) right_list = merge_sort(right_list) return_list = merge_lists(left_list, right_list) return return_list...
06c09eccef54d933b1340ddbded6d468c2570ec2
basestart/python-start
/basic/func.py
247
3.625
4
# python function 返回的是tuple def mabs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: return -x def nop () : pass print mabs(-1) print mabs('3')
53637f992f04f33963fee2475442e9acaa35290c
st-wolf/JuneML
/optimize.py
1,243
3.640625
4
# Тут лежит куча алгоритмов минимизации # from scipy.optimize import minimize from numpy.linalg import norm # Осваиваю Google Code Style for Python def gradien_descent(f, grad, x0, xtol = 1e-5, maxiter = 100): """ Метод градиентного спуска Args: f: Функция одного аргумента типа ndarray grad: Градиент функц...
b0b2f4517a5a492e779f1fbe430c0ebb389702bb
hakanozbek64/Pythonkodlama-1-
/Kodlama Egzersizleri/Döngüler/Atm_Makinesi.py
740
3.65625
4
print("""********************* ATM Makinesine Hoşgeldiniz. işlemler; 1.bakiye sorgulama 2.Para yatırma 3.Para Çekme Programdan cıkmak için 'q'ya basınız.. ************************* """) bakiye=1000 while True : işlem=input("işlemi seçiniz:") if(işlem=="q"): print("yine bekleriz...") br...
f69d84eac423ad171e9c345ca73f884e204b64ec
hakanozbek64/Pythonkodlama-1-
/Kodlama Egzersizleri/Döngüler/Faktoriyel_Bulma.py
398
4
4
print("""*********************** Faktoriyel Bulma Programı cıkmak için 'q'ya basınız..! ************************ """) while True: sayı=input("Sayı:") if(sayı=="q"): print("Program Sonlandırılıyor..") break else: sayı=int(sayı) faktoriyel=1 for i in range(2,sayı+1): ...
e343ff42820c7d794248635ec646eb8d4b184181
lxiong515/Module13
/GuessGame/topic1.py
2,385
4.15625
4
""" Program: number_guess.py Author: Luke Xiong Date: 07/18/2020 This program will have a set of buttons for users to select a number guess """ import tkinter as tk from random import randrange from tkinter import messagebox window = tk.Tk() window.title("Guessing Game") label_intro = tk.Label(window, text = "Guess...
c39d007f52faa7a1f8c974c9e91991656973a125
Jokestir/codePractise
/python/tmseffort.py
516
3.59375
4
# 1. open browser. (has to firefox 8) 2. open website. 3. authenticate if it asks. 4. read a field. #5. wrtie to file. 6. close # selenium documentation = http://selenium-python.readthedocs.io/locating-elements.html from selenium import webdriver firefox = webdriver.Firefox() # step 1 end firefox.get('https://ex...
b25d31e6a9f70a95f53253acd335c6268517bbc0
Jokestir/codePractise
/python/notes/automateBoringStuff/code/while_addition.py
111
3.75
4
sum = 0 integer = 1 while integer <= 100: sum = sum + integer integer = integer + 1 print(str(sum))
e27edf6529da5b92f34ea71412d960ad43584709
nsonnad/project-euler
/002.py
542
3.96875
4
# Each new term in the Fibonacci sequence is generated by adding # the previous two terms. By starting with 1 and 2, the first 10 # terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values # do not exceed four million, find the sum of the even-valued...
7ce87b1307b114abf2cc37d1443d6cf33809e3f4
HariM4274/Hello-world-
/positive integers in a range.py
248
3.9375
4
# positive integers in a list list1 = [] n = int(input("Enter limit ")) for i in range ( 0 , n ) : x = int( input()) list1.append(x) print (x) for num in list1: if num >= 0: print(num, end = " ")
903b2f67f86003120976115bf215a57cf4215853
repoCS/Algorithmen_UE
/ue_hanoi_algorithm_comparison/hanoi_speedcomparison.py
2,349
3.703125
4
#!/usr/bin/env python3 import sys from datetime import datetime import subprocess def RecursiveHanoi(n, fr, to): un = 6 - fr - to if n == 1: print("Moving disk from tower {} to tower {}.".format(fr, to)) else: RecursiveHanoi(n - 1, fr, un) RecursiveHanoi(1, fr, to) Recursiv...
6d7e146a295ac309d62d224d84b6e9b217b256e7
justalittlenoob/AN24
/tests/leetcode/2sum/2sum.py
626
3.546875
4
def twoSum(nums, target): i = 0 j = len(nums) - 1 k =0 dic = [] tup =() for k in range(1,len(nums)+1): tup = (k,nums[k-1]) dic.append(tup) dic.sort(lambda x,y:cmp(x[1],y[1])) print 'dic:', dic while i < j: ...
23e768fd6b7156989b4bd0ee852e10cfa9f9020d
justalittlenoob/AN24
/tests/leetcode/ZigZag.py
679
3.59375
4
def convert(s, nRows): if nRows == 1: return s step = nRows * 2 - 2 # first row ret = s[::step] print 'first lin:', ret for i in range(1, nRows - 1): for j in range(i, len(s), step): print 'j',j print 's[j]', s[j] print 'befor+,r...
cfe82a9893f4f6d374e37f23b72a84f321f71e7b
fredericklussier/ObservablePy
/observablePy/ObservableProperty.py
1,763
3.703125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Decorator to set observable to a property. It override the python property decorator to specified the setter and deleter behaviour, so it can diffuse to observer any change. warning: If the property does not have a setter or deleter function no change wi...
0de3bde6577d30f1409a42129ee4ef4105d980d0
Nihuan000/python_script
/math/learn.py
1,424
3.515625
4
# -*- coding: utf-8 -*- """ * Created by PyCharm Community Edition. * User: nihuan * Date: 18-4-3 * Time: 下午4:55 """ __author__ = 'nihuan' import numpy import matplotlib.pyplot as plot # 定义存储数组 x 和目标数组 y x, y = [], [] for sample in open(r'demo/data.txt', 'r'): # 调用python中的split方法并将逗号作为参数传入 _x, _y = sample.sp...
d57a83027186af6b4784985804955c7a7b7620c8
michaelfisher/python
/ex21.py
416
3.921875
4
def add(a, b): print "ADDING %d + %d" % (a, b) return a+ b def subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return a - b def multiply(a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b def divide(a, b): print "DIVIDING %d / %d" % (a, b) return a / b print "Let's do some math with functions!" ...
abb5a24b1918db874fd218d43a14727ec18dacee
cyan33/leetcode
/067-add-binary/add-binary.py
548
3.84375
4
# -*- coding:utf-8 -*- # # Given two binary strings, return their sum (also a binary string). # # # # For example, # a = "11" # b = "1" # Return "100". class Solution(object): def helper(self, a, b): if not b: return str(bin(a))[2:] else: return self.helper(a ^ b, (a ...
a970f1be719d68082548cf222aeff5beaea5da64
cyan33/leetcode
/677-map-sum-pairs/map-sum-pairs.py
1,235
4.15625
4
# -*- coding:utf-8 -*- # # Implement a MapSum class with insert, and sum methods. # # # # For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new ...
1a40c7226338a984d68d455c06bf26b621d2847b
cyan33/leetcode
/485-max-consecutive-ones/max-consecutive-ones.py
1,213
3.71875
4
# -*- coding:utf-8 -*- # Given a binary array, find the maximum number of consecutive 1s in this array. # # Example 1: # # Input: [1,1,0,1,1,1] # Output: 3 # Explanation: The first two digits or the last three digits are consecutive 1s. # The maximum number of consecutive 1s is 3. # # # # Note: # # The inp...
1e5195c318b0dbc25e4ce985b61e15b82a5d6c00
patricks1/mergers
/mergers2/staudt_utils.py
2,314
3.71875
4
import numpy as np def lookup(lookupval,lookuparray,resultarray,threshold): #defining a lookup function that assumes lookuparray is sorted in ascending #order #**threshold is the maximum difference between the lookupval and the value #found in the lookup aray in order for the function to return a...
826136903b038e489d631ef965eebb96b26202d3
aedades/Halloween-Math
/game.py
2,242
3.78125
4
import random import operator import pygame def generate_nums(difficulty): ops = ['+', '-', '*'] num1 = random.randint(0, difficulty) num2 = random.randint(1, difficulty) op = random.choice(ops) nums = [num1, op, num2] return nums def get_question_text(nums): return f"{nums[0]} {nums[1]}...
33f03475677465b7dbb392eaba5fd3905f71949c
KangsanKim07/OpenSource_2020
/ownmodel_back/face_swap/convex_hull.py
859
3.75
4
#! /usr/bin/env python """ A convex hull is a tight fitting boundary around points We will we use a convex hull to find the boundary of a face given its points (obtained from openCV) This can be made more efficient by doing multiple hulls in one iteration Keeping simple for clarity """ import numpy as np import cv2 d...
e54004078678ccf0338dafd3ad6cb6e15c101a56
marcos-bah/study-graphs
/grafo.py
1,442
3.609375
4
from heap import * class Grafo: def __init__(self, vertices): self.vertices = vertices self.grafo = [[0] * self.vertices for i in range(self.vertices)] def adiciona_aresta(self, u, v, peso): self.grafo[u-1][v-1] = peso self.grafo[v-1][u-1] = peso def mostra_matriz(self): ...