blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
542da4b047a76fd24855bdacfd14749bb9a2b56a
pktippa/hr-python
/strings/whats_your_name.py
261
3.90625
4
def print_full_name(a, b): print("Hello " + a + " " + b + "! You just delved into python.") # Using + operator for concatinating strings. if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)
0ff7d34d4052847acf9a11bf0e2017578ea13e57
pktippa/hr-python
/sets/check_subset.py
267
3.71875
4
for i in range(int(input())): a = int(input()); A = set(input().split()) b = int(input()); B = set(input().split()) # Or we can also use A.issubset(B) function directly if A.intersection(B) == A: print("True") else: print("False")
67d7f68e4f22f559371da94cf0ea0be9e8051132
pktippa/hr-python
/basic-data-types/lists.py
1,208
4.03125
4
list_to_handle=[] input_list=[] def do_insert(given_list): global list_to_handle list_to_handle.insert(int(given_list[1]), int(given_list[2])) def print_list(given_list): global list_to_handle print(list_to_handle) def remove_element(given_list): global list_to_handle list_to_handle.remove(int...
fc8492aca1595ba8df424f489c563b8c932edbde
pktippa/hr-python
/itertools/iterables_and_iterators.py
932
3.875
4
# Importing combinations from itertools from itertools import combinations # trash input not used in the code anywhere trash_int = input() # Taking input string split and get the list input_list = input().split() # Indices count indices = int(input()) # first way # Get the combinations, convert to list combination_lis...
e03cc807d94143ba7377b192d5784cbdb07b1abd
pktippa/hr-python
/math/find_angle_mbc.py
376
4.34375
4
# importing math import math # Reading AB a = int(input()) # Reading BC b = int(input()) # angle MBC is equal to angle BCA # so tan(o) = opp side / adjacent side t = a/b # calculating inverse gives the value in radians. t = math.atan(t) # converting radians into degrees t = math.degrees(t) # Rounding to 0 decimals and ...
bed0fc094ed0b826db808aa4449cbf31686cbd2a
aryakk04/python-training
/functions/dict.py
549
4.53125
5
def char_dict (string): """ Prints the dictionary which has the count of each character occurrence in the passed string argument Args: String: It sould be a string from which character occurrence will be counted. Returns: Returns dictionary having count of each character in ...
73ca8208af36edbc825de7e4579c8eb15ef1fcd6
habahut/GrocerySpy
/Source/ingredientParserBAK.py
12,462
3.75
4
#! /usr/bin/env python from ingredient import Ingredient ## these follow this form: # <num> |unit| {name} (, modifer) # so we split by " ". Then we check each thing for a comma. # if there is a comma, we now know where the modifier is. ## for now we are going to assume everything is of the form above ## i.e. t...
8f4737c5028b5237c809d24ee24fd3280d466d46
SamuelSebastianMartin/folder_tree_ac_eng
/make_google_folders.py
3,087
3.8125
4
#! /usr/bin/env python3 """ This may be a one-off program, depending on changes made to registers. It reads a SOAS Google Docs register (2019-20) into a pandas dataframe and creates folders necessary for all academic English student work. Student work/ | |___ SURNAME Firstname/ | | | ...
149b7cdf5c74d2bc96c2249ad192000659303926
edmartins-br/PythonTraining
/general.py
4,281
4.0625
4
#! /usr/bin/python3 #Fiibonacci a,b = 0, 1 for i in range(0, 10): print(a) a, b = b, a + b # ---------------------------------------------------------------- # FIBONACCI GENERATOR def fib(num): a,b = 0, 1 for i in range(0, num): yield "{}: {}".format(i+1, a) a, b = b, a + b for item ...
2d87b86197a7790b8596ee19e8099661d2a89536
ZinoKader/X-Pilot-AI
/pathfinding/navigator.py
2,045
3.6875
4
import math import helpfunctions class Navigator: def __init__(self, ai, maphandler): self.ai = ai self.pathlist = [] self.maphandler = maphandler def navigation_finished(self, coordinates): targetX = int(coordinates[0]) targetY = int(coordinates[1]) selfX =...
2bc03bbfed056ccd044b253e6e1430c59215d59a
ZinoKader/X-Pilot-AI
/excercises/exc3.py
5,294
3.5625
4
# # This file can be used as a starting point for the bot in exercise 1 # import sys import traceback import math import os import libpyAI as ai from optparse import OptionParser # # Create global variables that persist between ticks. # tickCount = 0 mode = "wait" targetId = -1 def tick(): # # The API won'...
8e18bf9cc041596acb023cd5d68c0933f432f6cd
hitsumabushi845/Cure_Hack
/addSongInfoToDB.py
1,167
3.65625
4
import sqlite3 from createSpotifyConnection import create_spotify_connection def add_songinfo_to_db(): db_filename = 'Spotify_PreCure.db' conn = sqlite3.connect(db_filename) c = conn.cursor() spotify = create_spotify_connection() albumIDs = c.execute('select album_key, name from albums;') s...
9d035da888745f18febd025b110dab7cb6f1f2d7
KarChun0227/PythonQuizz
/Expertrating/Word_sort.py
201
3.984375
4
input_str = input() result = "" word = input_str.split(",") sortedword = sorted(word) for x in sortedword: result = result + "," + x result = result[1:] print(result) # order,hello,would,test
a5bb0c599c2cb8e70b3d60a85932b9fd28b65780
KarChun0227/PythonQuizz
/Exercise/Ex8.py
747
3.953125
4
def winner(P1, P2): if P1 == P2: return 0 elif P1 == "S": if P2 == "R": return 2 else: return 1 elif P1 == "R": if P2 == "S": return 1 else: return 2 elif P1 == "P": if P2 == "S": return 2 ...
7d27fc42523b5ae8e1cb509c38d5538c85d959d5
KarChun0227/PythonQuizz
/Expertrating/exam.py
199
3.890625
4
import string input_str = raw_input() for i in range(1,6): password = input_str[i] if (password)<5: return False if " " in password: return False if "*" or "#" or "+" or "@" in
f4f03e85c8c0d572714451962e539fd4736c18c8
lulzzz/counter-1
/Counter/serv/report_python/reportmg.py
711
3.78125
4
import sqlite3 import re conn = sqlite3.connect('/Users/itlabs/db1.db') cur = conn.cursor() cur.execute(''' DROP TABLE IF EXISTS mega''') cur.execute(''' CREATE TABLE mega (dates TEXT, people TEXT)''') fname = '/tfs/report-MEGA.txt' fh = open(fname) count = 0 for line in fh: if not count % 2: people = ...
bf61860cd0381b0b6eb5563ff529da0b4a07c9bf
PavelErsh/Python-for-pro
/shop.py
896
3.6875
4
from datetime import datetime class Greeter: def __init__(self, name, store): self.name = name self.store = store def _day(self):#tace date return datetime.now().strftime('%A') def _part_of_day(self): current_hour = datetime.now().hour if current_hour < 12:...
766b98ad78790d5cb7436b20afc07ddc1b8fdd0e
Asakura-Hikari/assignment-2-travel-tracker-Asakura-Hikari
/a1_classes.py
4,745
3.65625
4
""" Replace the contents of this module docstring with your own details Name: Chaoyu Sun Date started: 31/july/2020 GitHub URL: https://github.com/JCUS-CP1404/assignment-1-travel-tracker-Asakura-Hikari """ # main() function is to open and save the file. def main(): print("Travel Tracker 1.0 - by Chaoyu Sun") ...
2e0deae0231338db84a2f11cd64994bf82900b33
seanakanbi/SQAT
/SampleTests/Sample/classes/Calculator.py
1,677
4.375
4
import math from decimal import * class Calculator(): """ A special number is any number that is - is between 0 and 100 inclusive and - divisible by two and - divisible by five. @param number @return message (that displays if the number is a special number) """...
af698f93e23c3d8a429b72ecc03bdb272de5d3b5
patrickgaskill/project-euler
/patrick.py
642
3.671875
4
from functools import reduce from operator import mul from math import sqrt def is_prime(n): if n < 2: return False if n == 2: return True if n == 3: return True if n % 2 == 0: return False if n % 3 == 0: return False i = 5 w = 2 while i * i ...
d9de3d0d4860d0ace81217ddf8fa23bd15c47c16
patrickgaskill/project-euler
/7.py
177
3.625
4
from patrick import is_prime N = 10001 primes = [2, 3] i = primes[-1] + 2 while len(primes) < N: if (is_prime(i)): primes.append(i) i += 2 print(primes[-1])
87d068764544cb2670704d56028940a1847bd061
TheUlr1ch/3-
/main3.py
655
3.984375
4
# 1-е задание myList = [1, 2, 3] myNewList = [i * 2 для i в myList] print(myNewList) # 2-е задание myList = [1, 2, 3] myNewList = [i * * 2 для i в myList] print(myNewList) # 3-е задание list = 'Hello world' для i в диапазоне(len(list)): if list[i] == " ": список = список.заменить("w"...
0df98d530f508a752e42a67ad7c6fe0a2608f823
JaiAmoli/Project-97
/project97.py
266
4.21875
4
print("Number Guessing Game") print("guess a number between 1-9") number = int(input("enter your guess: ")) if(number<2): print("your guess was too low") elif(number>2): print("your guess was too high") else: print("CONGRATULATIONS YOU WON!!!")
a71aa0afdb02234d87afe81f5b3b912748e66027
marcusshepp/hackerrank
/python/anagram.py
1,963
3.984375
4
#!/usr/bin/python # -*- coding: ascii -*- """ Your task is to help him find the minimum number of characters of the first string he needs to change to enable him to make it an anagram of the second string. Note: A word x is an anagram of another word y if we can produce y by rearranging the letters of x. Input Fo...
88794e943e08e346af71e6e3e8b398a22c6c4432
marcusshepp/hackerrank
/python/openkattis/ahh.py
177
3.78125
4
jon = raw_input() doc = raw_input() def noh(s): return [a for a in s if a != "h"] jon = noh(jon) doc = noh(doc) if len(jon) >= len(doc): print "go" else: print "no"
956019e0287fed6689e94f291add98e827fc9744
marcusshepp/hackerrank
/python/warmup/chocolate_feast.py
610
3.640625
4
""" Problem Statement: Little Bob loves chocolate, and he goes to a store with $N in his pocket. The price of each chocolate is $C. The store offers a discount: for every M wrappers he gives to the store, he gets one chocolate for free. How many chocolates does Bob get to eat? Input Format: The first line contain...
7b9c3c2cd1a9f753a9f3df2adeb84e846c9eb1b4
mschaldias/programmimg-exercises
/list_merge.py
1,395
4.34375
4
''' Write an immutable function that merges the following inputs into a single list. (Feel free to use the space below or submit a link to your work.) Inputs - Original list of strings - List of strings to be added - List of strings to be removed Return - List shall only contain unique values - Li...
c65d5f051adcb61c0b2b98e304551f4538779177
tethig/oyster_catchers
/oyster_catchers/gaussian_walk.py
1,001
3.65625
4
''' Generalized behavior for random walking, one grid cell at a time. ''' # Import modules import random from mesa import Agent # Agent class class RandomWalker(Agent): ''' Parent class for moving agent. ''' grid = None x = None y = None sigma = 2 def __init__(self, pos, model, sigma...
3df2910d100c84048bee5a5a965580cdea802811
susie9393/spaces
/spaces.py
1,413
3.796875
4
# spaces import numpy as np import random as rn def Spaces(no_rolls): # initialise an array to record number of times each space is landed on freq = np.zeros(14) # s denotes space landed on, 1 <= s <= 14 s = 0 # a counter has been set up to perform a check on total number of ...
6aaf293f5c0eb3ecbeac2a8844eae47189ed22b5
Romannweiler/hu_bp_python_course
/02_introduction/guess_a_number_rm.py
853
3.984375
4
# This is a guess the number game. import random guessesTaken = 0 print('Welcome to my Game') print('I am thinking of a number between 0 and 100!') number = random.randint(0, 100) while guessesTaken < 4: numTries = 3 - guessesTaken numTriesStr = str(numTries) print('you have '+ numTriesStr +' tries') ...
da4f38b16f878727966067fa8da540115169ad66
Nori1117/Recursion-lv.2
/MyLogic.py
1,075
3.890625
4
#Given a number n, write a program to find the sum of the largest prime factors of each of nine consecutive numbers starting from n. #g(n) = f(n) + f(n+1) + f(n+2) + f(n+3) + f(n+4) + f(n+5) + f(n+6) + f(n+7) + f(n+8) #where, g(n) is the sum and f(n) is the largest prime factor of n def find_factors(num): factors = []...
7473ceb49464bcf2268a790243b1dae6c671ec03
zhouxiongaaa/myproject
/my_game/congratulation.py
266
3.71875
4
name = input('你想给谁发祝福:') def cong(name1): a = list(map(lambda x: 'happy birthday to' + (' you' if x % 2 == 0 else ' '+name1+''), range(4))) return a if __name__ == '__main__': print(cong(name)) b = input('如要退出请输入exit:')
bac10c57ecb9bccb3a13cda38a104937d8bcd1b2
Goro-Majima/OpenFoodFacts
/pureBeurre.py
4,468
3.5
4
# -*- coding: utf-8 -*- """Starting program that calls insert and display functions from other file """ from displaydb import * from databaseinit import * from connexion import * from displayfavorite import * #query used to check if filling is needed CHECKIFEMPTY = '''SELECT * FROM Category''' CURSOR.execute(CHECKIFEM...
5c2bfd87eae9ecbf66be718816136f425a11fd24
NandanIITM/Pizzeria_Zearth_Sol
/Nandani_Garg/graph.py
4,709
3.671875
4
from collections import defaultdict import numpy as np # Class to represent a graph class Graph: def __init__(self, vertices): ''' Args: vertices : No of vertices of graph ''' self.V = vertices # No. of vertices self.graph = [] # default list to ...
2385bc762c835072e42a2e7bfdbbd66579f3ee84
amssdias/python-school
/classes.py
2,537
3.78125
4
class Student: id = 1 def __init__(self, name, course): self.name = name self.course = course self.grades = [] self.id = Student.id self.teachers = [] Student.id += 1 def __repr__(self): return f"<Student({self.name}, {self.course})>" def __str_...
00dfb0b8881dcccdd6f8ef059e0149956b6ed29b
ashleybaldock/tilecutter
/old/Script1.py
1,693
3.796875
4
import os class pathObject: """Contains a path as an array of parts with some methods for analysing them""" def __init__(self, pathstring): """Take a raw pathstring, normalise it and split it up into an array of parts""" path = pathstring norm_path = os.path.abspath(pathstring) ...
b30bc8c68c43339e91c03673aa98bd186fdee092
wheatgrinder/donkey
/donkeycar/parts/pitft.py
3,020
3.8125
4
#!/usr/bin/env python3 ''' donkey part to work with adafruitt PiTFT 3.5" LCD display. https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/displaying-images classes display text on display So far I have only been able to find a methond to write to the display using the frame buffe...
3df6b8f9818261092de3b9df2143871c121fc360
leosartaj/thinkstats
/ch1.py
1,463
3.5
4
""" Chapter 1 """ import sys import survey import thinkstats as ts def live_births(table): cou = 0 for rec in table.records: if rec.outcome == 1: cou += 1 return cou def partition_births(table): first = survey.Pregnancies() other = survey.Pregnancies() for rec in table.r...
d47912664ed0a3d113d4d868ff9ecb16ae22e800
akhilharihar/optimus
/optimus/optimus.py
1,548
4
4
class Optimus: """ Arguments - prime - Prime number lower than 2147483647 inverse - The inverse of prime such that (prime * inverse) & 2**31-1 == 1 xor - A large random integer lower than 2147483647""" def __init__(self,prime, inverse, xor): self.prime = int(prime) self.i...
03e2d051ac1d3c734e5d4d2127a53ddf4187d7f9
Asritha-Reddy/2TASK
/positivenumbers.py
354
3.78125
4
#positive numbers list1=[12,-7,5,64,-14] print('List1: ',list1) print("Positive numbers in list1:") for i in list1: if i>=0: print(i, end=", ") print('\n') list2=[12,14,-95,3] print('List2: ',list2) print("Positive numbers in list2:") for j in list2: if j<=0: list2.remove(j) prin...
da9b9a622dbe2abc55064bb484c030c88f2587c8
Chearfly/-
/xiang_mu.py
1,010
3.609375
4
from tkinter import * from tkinter import ttk # from PIL import Image #建立模块对像 root = Tk() #设置窗口标题 root.title("人工智能项目") #设置显示窗口的大小 root.geometry("700x500") #设置窗口的宽度是不可变化的,但是他的长度是可变的 root.resizable(width = "true",height = "True") # l = ttk.Label(root, text="欢迎来到人工智能的项目", bg = "blue", font= ("Arial",15), width=30,\ ...
9f9ca4275f16934ecb0dc4b331dd3ed3cfa150be
alex123012/Bioinf_HW
/fourth_HW/hw_5.py
512
3.515625
4
k = int(input('Enter k number: ')) # wget https://raw.githubusercontent.com/s-a-nersisyan/HSE_bioinformatics_2021/master/seminar4/homework/SARS-CoV-2.fasta with open('SARS-CoV-2.fasta') as f: f.readline().strip() fasta = f.readline().strip() hash_table = {} for i in range(len(fasta) - k): j = i + k h...
511aac38c0edf5a12b6819d91b2bb20246581308
alex123012/Bioinf_HW
/first_HW/first_hw_1.py
1,231
3.71875
4
def quadratic_equation(a, b, c, rnd=4): """Solving quadratic equations""" if a == 0: if b == 0: if c == 0: return 'any numbers' else: return 'No solutions' else: return -c / b elif b == 0: if c <= 0: re...
27bdec3ef8bcff49ef41716fb4b2dd5fe0e39168
isabella0428/Leetcode
/python/695.py
1,383
3.5
4
class Solution: def maxAreaOfIsland(self, grid: 'List[List[int]]') -> 'int': def search(row, col, grid, num): grid[row][col] = 0 up = 0 if row == 0 else grid[row - 1][col] if up: num += search(row - 1, col, grid, 1) down = 0 if row == m - 1 els...
1fa0995dcf2c1f58e42c542e5cdc31c02bad6be1
isabella0428/Leetcode
/python/141.py
1,132
3.953125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution1: def hasCycle...
cc17363e0989be93f817691c1b64e6968091eb8b
isabella0428/Leetcode
/python/81.py
2,919
3.609375
4
class MySolution: pivot = 0 ans = False def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ def findPivot(start, end, nums): if start == end: return mid = (start + end) >> 1 ...
734b98d18f175109c48e16afeec4b64cdea4d0ac
isabella0428/Leetcode
/python/413.py
890
3.671875
4
class Solution1: def numberOfArithmeticSlices(self, A: 'List[int]') -> 'int': # dynamic programming memo = [0 for i in range(len(A))] if len(A) < 3: return 0 sum = 0 for i in range(2, len(A)): if A[i] - A[i - 1] == A[i - 1] - A[i - 2]: ...
dac3c5e2a9f05e6ac34168e145ccb5b25f3d854f
isabella0428/Leetcode
/python/217.py
794
3.515625
4
class Solution1: def containsDuplicate(self, nums) -> bool: if len(nums) < 2: return False min_term = min(nums) for i in range(len(nums)): nums[i] += - min_term max_term = max(nums) stack = [-1 for i in range(max_term + 1)] for item in nums: ...
bc860577a7a9c6466fb1cf604dae49dcb08f89df
isabella0428/Leetcode
/python/86.py
904
3.609375
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def partition(self, head: 'ListNode', x: 'int') -> 'ListNode': num = [] while head: num.append(head.val) head = head.next loc = 0 for i in range(len(num))...
24ab2e2b98b68d9b357a49b1c9816d1ee5cc9ba2
isabella0428/Leetcode
/python/22.py
1,845
3.640625
4
class Solution1: def __init__(self): self.result = [] def isValid(self, s): """ :type s: str :rtype: bool """ bal = 0 # if bal < 0 and bal !=0 at last returns False for i in s: if i == '(': bal += 1 else: ...
f4ce8e0353739753200f9742ff5be3ca3a971651
isabella0428/Leetcode
/python/5.py
1,339
3.546875
4
class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: str """ def expandAroundElement(index, s): left = index - 1 right = index + 1 ans = str(s[index]) while left >= 0 and right < len(s): ...
eae3eb282eb9ea947d758ea1c59a3c4e0b2d0a85
isabella0428/Leetcode
/python/17.py
2,002
3.546875
4
class Solution1: def __init__(self): self.result = [] def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ strs = [] s = [] dict = {2:['a','b','c'], 3:['d','e','f'], 4:['g','h','i'], 5:['j','k','l'], 6:[...
bfc6f9541b8b93b9eee437c24594552e1bc9da45
isabella0428/Leetcode
/python/34.py
1,804
3.6875
4
class Solution: def searchRange(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ def binarySearch(nums, start, end, ans, target): if start > end: return if nums[start] > target or nums[end] ...
eb7bdb086ac0f1932e9b66811db53f1d8957818d
isabella0428/Leetcode
/python/847.py
743
3.515625
4
class Solution: def shortestPathLength(self, graph): # use bits to represent states N = len(graph) dp = [[float('inf') for i in range(N)] for j in range(1 << N)] q = [] for i in range(N): dp[1 << i][i] = 0 q.append([1 << i, i]) while q: ...
c59b550736aeef6603de8b7406839051f495e7b6
isabella0428/Leetcode
/python/35.py
1,106
3.875
4
class Solution1(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ for i in range(len(nums)): if target == nums[i]: return i if target < nums[i]: return i ...
9ebdf9b2d26b2f720896b0281362f4f08318955f
isabella0428/Leetcode
/python/680.py
512
3.6875
4
class Solution: #greedy def validPalindrome(self, s): """ :type s: str :rtype: bool """ def isPali(s, i, j): return all(s[k] == s[j - k + i] for k in range(i, j)) for i in range(len(s)): if s[i] != s[~i]: # ~i = -(i + 1) ...
667e87890af57db213b90fa41a5027e46a404cfe
OliverOC/countryScratchMap
/functionLib.py
6,634
4
4
import json import os import matplotlib.pyplot as plt import pandas as pd from collections import defaultdict def if_no_json_create_new(file_name): """ This function checks whether a JSON file exists under the given file name. If no JSON file exists, a new one is created. :param file_name: Name of th...
d089ecb536c7d01e7387f82dbe93da65da98358c
yogabull/TalkPython
/WKUP/loop.py
925
4.25
4
# This file is for working through code snippets. ''' while True: print('enter your name:') name = input() if name == 'your name': break print('thank you') ''' """ name = '' while name != 'your name': name = input('Enter your name: ') if name == 'your name': print('thank you') """ ...
8837287f4ef533b32c594b35c8b432216cb8c628
yogabull/TalkPython
/ex3_birthday_program/ex3_program_birthday.py
1,221
4.28125
4
"""This is a birthday app exercise.""" import datetime def main(): print_header() bday = get_user_birthday() now = datetime.date.today() td = compute_user_birthday(bday, now) print_birthday_info(td) def print_header(): print('-----------------------------') print(' Birthday App')...
ce930feff941e3e78f9629851ce0c8cc08f8106b
yogabull/TalkPython
/WKUP/fStringNotes.py
694
4.3125
4
#fString exercise from link at bottom table = {'John' : 1234, 'Elle' : 4321, 'Corbin' : 5678} for name, number in table.items(): print(f'{name:10} --> {number:10d}') # John --> 1234 # Elle --> 4321 # Corbin --> 5678 ''' NOTE: the '10' in {name:10} means make the name var...
77ddf7f2e6d19a20ca71862d7507a72ed1cde4bd
rohitgang/MATH471
/rank_matrices.py
1,677
3.75
4
""" (Ranks of random matrices) Generate square (n x n) matrices with random entries (for instance Gaussian or uniform random entries). For each n belonging to {10,20,30,40,50}, run 100 trials and report the statistics of the rank of the matrix generated for each trial (mean, median, min, max). What do you notice? Pleas...
8a07ac0097bdfa92665a85be956b5dfc40b217dc
gregor42/python-for-the-stoopid
/diction.py
733
3.640625
4
#!/usr/local/bin/python # # diction.py - playing with dictionaries # import pri filename = 'templ8.py' # Say hello to the Nice People pri.ntc(filename + " : Start.") pri.bar() D = {'a': 1, 'b': 2, 'c': 3} pri.ntc(D) pri.bar() D['e']=42 pri.ntc(D) pri.bar() #underfined value will break #print D['f'] pri.ntc('f' i...
3a3bf87bc7aeede084d8df8e78331110b8f3e441
zumioo/tweet
/remove.py
1,203
3.671875
4
""" 使うときはコメントアウト外してね import tweepy import calendar import random import time def main(): consumer_key = 'XXXXX' consumer_secret = 'XXXXX' access_token_key = 'XXXXX' access_token_secret = 'XXXXX' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token_key...
f08ec1974b033d5bd56b64b764f23541a811acbc
febin72/LearnPython
/oddoreven.py
149
4.28125
4
''' Find even or odd ''' import math print ('enter the number') x= int(input()) if (x%2==0): print ('the number is even') else: print('odd')
2550c545f6f0f73faef10670b3dde6f2235b21a1
febin72/LearnPython
/strings.py
509
3.9375
4
''' play with strings ''' import string print ('enter a string') a = str(input()) print ('ented one more string') one_more_string = str(input()) print ('entered strings length is ' , len(a) , len(one_more_string)) #print (a[2:6]) #print ('The length of the string entered is' ,len(a+one_more_string)) newstring = a + one...
c7fc3ced3296f7e181ba9714534800b59d20dd53
thevirajshelke/python-programs
/Basics/subtraction.py
586
4.25
4
# without user input # using three variables a = 20 b = 10 c = a - b print "The subtraction of the numbers is", c # using 2 variables a = 20 b = 10 print "The subtraction of the numbers is", a - b # with user input # using three variables a = int(input("Enter first number ")) b = int(input("Enter first number ")) c ...
ef45e2377ab4276345644789a17abdd20da69aca
johnehunt/computationalthinking
/week4/tax_calculator.py
799
4.3125
4
# Program to calculate tax band print('Start') # Set up 'constants' to be used BASIC_RATE_THRESHOLD = 12500 HIGHER_RATE_THRESHOLD = 50000 ADDITIONAL_RATE_THRESHOLD = 150000 # Get user input and a number income_string = input('Please input your income: ') if income_string.isnumeric(): annual_income = int(income_st...
fecc9d49fc1df51d7b793fb052c8defcbc86300e
johnehunt/computationalthinking
/week1/exammarks/main3.py
633
3.9375
4
# Alternative solution using compound conditional statement component_a_mark = int(input('Please enter your mark for Component A: ')) coursework_mark = int(input('Please enter your mark for Component B: ')) # Calculating mark by adding the marks together and dividing by 2 module_mark = (component_a_mark + coursework_...
8d7ca111c403010de98909a1850ae5f7a1d54b2b
johnehunt/computationalthinking
/number_guess_game/number_guess_game_v2.py
1,262
4.34375
4
import random # Print the Welcome Banner print('===========================================') print(' Welcome to the Number Guess Game') print(' ', '-' * 40) print(""" The Computer will ask you to guess a number between 1 and 10. """) print('===========================================') # Initialise the...
0f25b7552ca48fbdc04ee31bd873d899ffae26c6
johnehunt/computationalthinking
/week4/forsample.py
813
4.34375
4
# Loop over a set of values in a range print('Print out values in a range') for i in range(0, 10): print(i, ' ', end='') print() print('Done') print('-' * 25) # Now use values in a range but increment by 2 print('Print out values in a range with an increment of 2') for i in range(0, 10, 2): print(i, ' ', end=...
0e6908ec30831e4ea0218e8af6b0605dae3cef78
johnehunt/computationalthinking
/week4/ranges.py
171
4.1875
4
for i in range(1, 10): print(i, end=', ') print() for i in range(0, 10, 2): print(i, ' ', end='') print() for i in range(10, 1, -2): print(i, ' ', end='')
3a3069f8e96bf2bdcf973dececffb43dc0ca59c4
johnehunt/computationalthinking
/week2/numbers.py
1,867
3.734375
4
x = 1 print(x) print(type(x)) x = 10000000000000000000000000000000000000000000000000000000000000001 print(x) print(type(x)) home = 10 away = 15 print(home + away) print(type(home + away)) print(10 * 4) print(type(10 * 4)) goals_for = 10 goals_against = 7 print(goals_for - goals_against) print(type(goals_for - goals...
2acb0005b760b130fc4c553b8f9595c91b828c0e
tainagdcoleman/sharkid
/helpers.py
2,892
4.125
4
from typing import Tuple, List, Dict, TypeVar, Union import scipy.ndimage import numpy as np import math Num = TypeVar('Num', float, int) Point = Tuple[Num, Num] def angle(point: Point, point0: Point, point1: Point) -> float: """Calculates angles between three points Args: point...
33a375ed2fb0b278b1304dffb4815c4cfdf67982
rose60730422/writingTest
/writingTest.py
696
3.84375
4
def reverseString(t): reverseString = t[::-1] return reverseString def reverseWords(s): s = s.split(" ") for index, word in enumerate(s) : s[index] = reverseString(word) r = ' '.join(s) return r def countingFactor(n): cnt = 0 for i in range(n): if ((i+1) % 3 == 0) ...
0438c1b364eae318c527df99ea6b1959489e0fce
lakshmanboddoju/Automate_the_boring_stuff_with_python
/11/31-hello_txt_read.py
867
3.734375
4
#! python3 import shelve # Read Operation helloFile = open('C:\\Users\\lakshman\\Desktop\\hello.txt') #helloFileContent = helloFile.read() #print(helloFileContent) print(helloFile.readlines()) helloFile.close() # Write Operation helloFile2 = open('C:\\Users\\lakshman\\Desktop\\hello2.txt', 'w') he...
8079ac6be8a7cbfbda9230c0fffeb89170e04f8d
AshWije/Neural-Networks-In-Python
/WithPyTorch/ImageNet_ResNetX_CNN.py
9,451
3.53125
4
################################################################################ # # FILE # # ImageNet_ResNetX_CNN.py # # DESCRIPTION # # Creates a convolutional neural network model in PyTorch designed for # ImageNet modified to 100 classes and downsampled to 3x56x56 sized images # via resizing and croppin...
21e93a9e63969f1a8a0ff398cc8b5b1c94668317
dcronin05/timewaster
/main.py
212
3.859375
4
print("Hello world") class AClass(object): def __init__(self, a, b): self.a = a self.b = b def getter(self): return self.a newObj = AClass(3, "hello") print(newObj.getter())
c1c530035fcd38d5b23e00dd66f914206de5d313
iampaavan/Internet_Data_Python
/urllibdata_start.py
910
3.703125
4
# Send data to a server using urllib # TODO: import the request and parse modules import urllib.request import urllib.parse def main(): # url = 'http://httpbin.org/get' url = 'http://httpbin.org/post' # TODO: create some data to pass to the GET request args = { 'Name': 'Paavan Gopala', 'Is_...
0b8333949d8b4a32573cd24b8c83cedd9585e25e
pancham2016/ScubaAdventure
/bubble.py
1,042
3.921875
4
import pygame from pygame.sprite import Sprite class Bubble(Sprite): """A class that manages bubbles released from the diver.""" def __init__(self, sa_game): """create a bubble object at the diver's current position.""" super().__init__() self.screen = sa_game.screen self.setti...
62d9367a9114d703024070eee7b92f1d4c067f2a
xiaojin9712/data_strcture_review
/two_sum.py
1,005
3.671875
4
A = [-2, 1,2,4,7,11] target = 13 # Time Complexity: O(n^2) # Space Complexity: O(1) def two_sum_brute_force(A, target): for i in range(len(A) - 1): for j in range(i+1, len(A)): if A[i] + A[j] == target: print(A[i], A[j]) return True return False two_sum_brute...
1f2b1c0f66ca6d9b116a1d86c5097cbaa0bd41e7
pvsreenivas/BillingSoftware-SalesTax
/TaxCalc/ReceiptGenerate.py
1,137
3.609375
4
# 01a, 07Apr2021, SreenivasK, Initial code from typing import List, Dict from .TotalCalc import TotalCalc class ReceiptGenerate: def __init__(self): self.product_list: List[str] = [] def receipt_generate(self): """ Returns: None """ print("Ready to bill ...
ba76365aa5bf69e54e4ee4cba9ebb4ef7c6daf97
arehy/Elvenar
/tesztek/radioButton.py
540
3.84375
4
from tkinter import * def sel(): selection = "You selected the option " + str(var.get()) label.config(text = selection) root = Tk() var = StringVar(root, '1') R1 = Radiobutton(root, text="Kristály", variable=var, value='kristaly', command=sel) R1.pack( anchor = W ) R2 = Radiobutton(root, text="Márvány", variab...
792d0ff1f1bf339810b83c2b3f1c6f9aa637ea86
sofiyuh/ProgramAssignments
/dictionarypractice.py
855
3.578125
4
groceries = {"chicken": "$1.59", "beef": "$1.99", "cheese": "$1.00", "milk": "$2.50"} NBA_players = {"Lebron James": 23, "Kevin Durant": 35, "Stephen Curry": 30, "Damian Lillard": 0} PHONE_numbers = {"Mom": 5102131197, "Dad": 5109088833, "Sophia": 5106939622} shoes = {"Jordan 13": 1, "Yeezy": 8, "Foamposite": 10, "A...
d59bd150cb4fcb379cb959b9310cf1204d06b65a
asolisn/Ejercicios-de-la-S9
/class Ordenar.py
440
3.59375
4
class Ordenar def__init__(self,lista): self.lista=lista def recorrerElemento(self): for ele in self.lista: print(ele) def recorrerPosicion(self): for pos,ele in self.lista.items(): print(pos,ele) ...
d160a250d883ed92ce1b9effd217a4d5177b3bfc
FullStackToro/Python_Orden_por_Inserci-n
/main.py
633
3.90625
4
#Los datos en el arreglo son ordenados de menor a mayor. def ordenamientoPorInserccion(num): #Recorre todas las posiciones del arreglo for x in range (len(num)): #No es necesario evaluar con un solo valor if x==0: pass else: #Comparación e intercambio (en caso de que el numero ubicad...
acdd2bf6a695151004880dffae1d509918fb7b59
jpcirqueira/Grafos1_Fofocando
/criagrafo.py
514
3.953125
4
def main(): h = {} numnos = int(input('digite o numero de pessoas:\n')) for i in range(0,numnos): vizinhos = [] nomeno = input('represente a pessoa por um nome ou numero ' + str(i) + ' :') numvizinhos = int(input('digite o numero de conhecidos do ' + str(nomeno) + ' :' )) ...
d4a3251bdf830118e2c04dd9cdff7c74ab1c1e1c
IanMK-1/Password-locker
/password_locker_test.py
2,975
3.703125
4
import unittest from User import User class TestPasswordLocker(unittest.TestCase): def setUp(self) -> None: """Method that define instructions to be ran before each test method""" self.new_locker_account = User("Ian", "Mwangi", "ianmk", "1234567") def test_init(self): """Test to chec...
419e9c5cbb652df0abccd13ca68273bc18327cd9
jadugnap/python-problem-solving
/Task4-predict-telemarketers.py
1,300
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. text.csv columns: sending number (string), receiving number (string), message timestamp (string). call.csv columns: calling number (string), receiving number (string), start timestamp (string), duration in seconds (string) """ impor...
33a9b899adfee643bc01dfb05d9291fbec3d65c0
JiahuanChen/homework2
/simulator_v2.py
10,991
3.5
4
#! /usr/bin/python """ Try to finished all three extra tasks. I used Gaussian distribution for the reason that it is the most common distribute in statistics. """ import sys import math import string import random from optparse import OptionParser #add functions parser = OptionParser() parser.add_opt...
a4b024fe5edf1f5da39078c8d52034ba303a98cc
schirrecker/Math
/Math with Python.py
397
4.15625
4
from fractions import Fraction try: a = Fraction(input("Enter a fraction: ")) b = Fraction(input("Enter another fraction: ")) except ValueError: print ("You entered an invalid number") except ZeroDivisionError: print ("You can't divide by zero") else: print (a+b) def is_factor (a, b): ...
09772c3ab8555b1b1e33b480f7fb02dedc8dfacc
schirrecker/Math
/Censor text.py
278
3.84375
4
def censor(text, word): list = text.split() newlist = [] for w in list: if w == word: newlist.append(len(w)*"*") else: newlist.append(w) return " ".join(newlist) print (censor("Hi there Ismene", "Ismene"))
5ad4cf6a9e1acb0834dcb0d663d83e0db1417a46
schirrecker/Math
/mathematical_functions.py
109
3.546875
4
def equation(a,b,c,d): ''' solves equations of the form ax + b = cx + d''' return (d - b)/(a - c)
b105489d556e2941fa532c828bb47f8f19e4ea8d
hahapang/py_tutor
/Ch_11_TEST/names.py
967
3.9375
4
# Данная прога предназначена для проверки правильности работы функции # get_formatted_name(), расположенной в файле name_function.py (Ex. 1). # Данная функция строит полное имя и фамилию, разделив их пробелами и # преобразуя первый символы слов в заглавные буквы. # Проверка проводится путем импорта функции get_forma...
258b95d7a40c7c62c7b195cc4fffd038e2ba0373
hahapang/py_tutor
/magic_number.py
320
3.703125
4
# Аналогичнофайлу из предыдущего коммита. # Условие answer (17) не равго 42. Так как условие # истино - блок с отступом выполняется! # answer = 17 if answer != 42: #1 print("That is not correct answer.Please tre again!")
6aa4ee170811b133b8d66b3bc6ae6c87812412bf
christislord12/Panda3D-Project-Collection
/panda3dcgshaders/8.py
8,642
3.5
4
""" Like 0.py we restart from scratch and create a basic example with one point light, that only supports diffuse lighting. There is no shader attached to this example. If you do not understand this sample then open the Panda3D manual and try to understand e.g. the Disco-Lights sample. When we talk about lightin...
618105d73f3df6c48f4760c14401e7ef202b66af
christislord12/Panda3D-Project-Collection
/panda3dcgshaders/2.py
2,227
3.5
4
""" The first useful sample. After this tutorial we are able to draw our cubes, which look like cubes. With our knowledge we are not able to color them correctly, but we can do some nice stuff and see the result. If everything is black this time, something must be wrong. """ import sys import direct.direct...
0c07ac63e4e0c8bdb25ff27d3f18419705cc3506
AnkitaPisal1510/list
/listmagic1.py
746
3.625
4
m=[ [8,3,4], [1,5,9], [6,7,2] ] A=15 k=0 while k<len(m): column=0 sum=0 l=len(m[k]) while column<l: sum=sum+m[k][column] column+=1 print(sum,"column") x=sum+sum+sum k+=1 print(x) i=0 while i<len(m): row=0 sum1=0 while row<len(m[i]): sum1+=m[row...
ee51b89083daa92736666f1712448406f4b118c3
AnkitaPisal1510/list
/listdifference.py
149
3.546875
4
#difference # l=[1,2,3,4,5,6] # p=[2,3,1,0,6,7] # i=0 # j=[] # while i<len(p): # if l[i] not in p: # j.append(l[i]) # i+=1 # print(j)
d9ebfa0746c3b2daf9bb4796bc910aaa34842e8a
AnkitaPisal1510/list
/listmagic.py
713
3.5625
4
# #majic square # a=[ # [8,3,8], # [1,5,9], # [6,7,2] # ] # row1=row2=row3=0,0,0 # col1=col2=col3=0,0,0 # dia1=dia2=0,0 # i=0 # b=len(a) # while i<b: # c=len(a[i]) # j=0 # while j<c: # if i==0: # row1=row1+a[i][j] # col1=col+a[j][i] # elif i==1: # ...
e085c19faf6fe9e11e547c31d30f02e8f29a9d4f
superxingzai/bhattacharyya-distance
/bhatta_dist.py
4,095
3.75
4
""" The function bhatta_dist() calculates the Bhattacharyya distance between two classes on a single feature. The distance is positively correlated to the class separation of this feature. Four different methods are provided for calculating the Bhattacharyya coefficient. Created on 4/14/2018 Author: Eric...