blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
95c003e92550f4a6b9cfe630938d3da2b380ad23
lrascius/Project-Euler
/problem17.py
1,843
3.625
4
#Project Euler #Problem 17: Number letter counts #Description: If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be u...
1832c036c378e858bd4b055b1635d55771ac1a54
lrascius/Project-Euler
/problem20.py
478
3.953125
4
#Project Euler #Problem 15: Lattice Paths #Description: n! means n x (n - 1) x ... x 3 x 2 x 1 # For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800, # and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. # Find the sum of the digits in the number 100! import math # for x...
cba59967bdc1e47bc149fbe9ee401e7440af1175
oleg15-cloud/python_qa_oop
/src/square.py
278
3.546875
4
from src.figure import Figure class Square(Figure): def __init__(self, a): self.a = a self.name = "Square" @property def perimeter(self): return round(self.a * 4, 2) @property def area(self): return round(self.a ** 2, 2)
ee361112dc44ec98641281ca38cec39dd98022d9
kdharlley/kdharlley.github.io
/CS_1110/A4_file_tree_manipulation_100/positions_test.py
3,519
3.8125
4
# positions_test.py # Lillian Lee (LJL2) # Apr 11, 2018 """Some demonstrations of the use of class Positions and related functions from positions.py. Also tests whether students can use networkx to draw org charts. STUDENTS: try running this file on the command line, i.e., python positions_test....
40ec8f4af3235e2d8287ad6e6ed9ddc6865dbddb
ushift-d/get_excel_data
/getExcelData.py
1,081
3.65625
4
import pandas as pd #variables for source file, worksheets, and empty array for dataframes spreadsheet_file = pd.ExcelFile('[filepath + filename]') worksheets = spreadsheet_file.sheet_names appended_data = [] for sheet_name in worksheets: #column header name month = 'August' #read all worksheets in source f...
fd9646ea3d2ffed1a8871781bb1e7b17f1a4f13f
stymsingh/Snake-Game
/tutorials- pygame/12 - Adding Text to the Screen.py
2,232
3.546875
4
import pygame import time pygame.init() white = (255,255,255) black = (0,0,0) red = (255,0,0) display_width = 800 display_height = 600 gameDisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption('Snakky!!!!') gameExit = False lead_x = display_width/2 lead_y = display_height/...
873769adac645ce00b3c6a5cd7a68dbfbef4e7af
andersonritzmann/Exerc-cios-resolvidos
/algoritmo_illinois.py
506
4.0625
4
def funcao(x): return float(2*x*x*x - 4*x*x + 3*x) x0 = float(input("Digite a aproximação para x0: ")) x1 = float(input("Digite a aproximação para x1: ")) iteracoes = 100 i = 2 f0 = funcao(x0) f1 = funcao(x1) TOL = 0.001 convergiu = False while i<=iteracoes: x = (f1*x0 - 0.5*f0*x1)/(f1-0.5*f0) if abs(x-x1)<...
5e82a38e3e455224439c515158439d74634caba0
dbzhao/ranked_choice_voting
/rcv_utilities.py
2,906
3.859375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Utility functions to run ranked choice vote election Created on Mon Nov 18 13:02:06 2019 @author: daniel.zhao """ import logging import pandas as pd import sys def tally_votes(votes, candidates): """Tally first-choice votes and readd any candidates w/ 0 first ...
95647397cd0ce069b8b4c29db50c22b89a6bac2a
ShazidHasanRiam/100DaysOfPython
/Day-05/Day-05-02-Average_Height.py
560
3.953125
4
#Day-05 of 100 Days of Coding #November 23, 2020 #Shazid Hasan Riam student_heights = input("Input a list of student heights: ").split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) # print(student_heights) total_height = 0 for height in student_heights: t...
2f3f2387f9b54561e55f14a660a1e1bf4246547a
ShazidHasanRiam/100DaysOfPython
/Day-05/Day-05-05-Adding_Even_Numbers.py
158
3.640625
4
#Day-05 of 100 Days of Coding #November 23, 2020 #Shazid Hasan Riam total = 0 for number in range(2, 101, 2): print(number) total += number print(total)
41fe8640569bac30ab62990468d0f906ddb26b11
dwindy/learn_tensorflow
/play_mnist.py
1,072
3.5
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) print("Training data size:", mnist.train.num_examples) x = tf.placeholder(tf.float32, [None, 784]) y_ = tf.placeholder(tf.float32, [None, 10]) W = tf.Variable(tf.zeros([78...
e71028bc1437474dfc0a67ab0f595c9ff2831a6b
anthonyportalatin/BasicPython
/StringSample.py
489
4.21875
4
#String sample string = "Bath and body" print (len(string)) print (string.upper()) print (string.lower()) number = 10 print ("This is a number "+str(number)+" in string.") print ("I want to go to "+string.upper()+" right now.") #This introduces input method name = input("What is your name? ") person = input("Who ...
22e82a2c4cb7fbc43f214368289d08a0b1406dac
Gokulmishra/ComputerVision
/OpenCV/Varying_Brightness.py
1,215
3.6875
4
# Varying Brightness of Images using Add and Subtract Operations # Import Computer Vision package - cv2 import cv2 # Import Numerical Python package - numpy as np import numpy as np # Read the image using imread built-in function image = cv2.imread('image_2.jpg') # Display original image using imshow bui...
30df04187a330c04012bbef5e29bfd63883d7bf9
jumbokh/appliedNum_learn
/python/sandbox/inverse_detail.py
2,292
3.671875
4
__author__ = 'Florian Cassayre' from copy import copy, deepcopy from pmat import * def inverse(toInverse): size = len(toInverse) matrix = [[0 for j in range(size * 2)] for i in range(size)] # Matrix n x 2n for i in range(size): # We copy the matrix to reverse for j in range(size): ...
71b3aab3e65ad7dfde247bb54767289dee06ba57
jumbokh/appliedNum_learn
/python/sandbox/pmat.py
365
3.53125
4
def pmat(matrix): size = len(matrix[0]) #print(size) print() for a in matrix: for i in range(size): #print("%+d"%round(a[i],2),end="") number = round(a[i],2) print('{0: .2f}'.format(number, '-' if number else ' '),' ',end='') if i < size-1 : ...
8deab9b32348c785b952033e9c60146bb9a7e545
uzulim/shqod
/shqod/io.py
5,940
3.609375
4
"""Read and write data.""" from typing import Union, Optional, Tuple, List, Iterable from .dtypes import Trajec, LexTrajec import json import numpy as np import pandas as pd LoadedTrajec = Union[Iterable[Trajec], Iterable[LexTrajec]] def read_trajec_csv(filename: str, return_length: bool = Fals...
22ceeeb0a696258a73b639a518a82f68f08d6a26
ShumaoHou/MyOJ
/leetcode/0728.py
1,104
3.9375
4
""" 自除数 是指可以被它包含的每一位数除尽的数。 例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0。 还有,自除数不允许包含 0 。 给定上边界和下边界数字,输出一个列表,列表的元素是边界(含边界)内所有的自除数。 示例 1: 输入: 上边界left = 1, 下边界right = 22 输出: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22] 注意: 每个输入参数的边界满足 1 <= left <= right <= 10000。 """ class Solution(object): def selfDividin...
36b423d3a5430e840c0ce0e7a12fc5010b52f39e
ShumaoHou/MyOJ
/Advanced_algorithm/oj_classwork2/1.py
2,790
3.765625
4
''' 书本分发 描述 You are given N number of books. Every ith book has Pi number of pages. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permutation one of the M students will be allocated the maximum number of pages. Out of all these permutations, the task is to ...
c01b2236f8c2cd11817af8077f4e0a4109ec2259
ShumaoHou/MyOJ
/mi_oj/11.py
1,189
3.734375
4
''' 构建短字符串 描述 给定任意一个较短的子串,和另一个较长的字符串, 判断短的字符串是否能够由长字符串中的字符组合出来,且长串中的每个字符只能用一次。 输入 一行数据包括一个较短的字符串和一个较长的字符串, 用一个空格分隔,如: ab aab bb abc aa cccc uak areuok 输出 如果短的字符串可以由长字符串中的字符组合出来, 返回字符串 “true”,否则返回字符串 "false",注意返回字符串类型而不是布尔型。 输入样例 a b aa ab aa aab uak areuok 输出样例 false false true true ''' """ @param string line 为单行测试数据 @...
43d0d3b7506c41917f256077745a02b9fe41fc9f
ShumaoHou/MyOJ
/Advanced_algorithm/oj_homework3/3.py
1,611
3.84375
4
""" 实现Shell排序,对给定的无序数组, 按照给定的间隔变化(间隔大小即同组数字index的差), 打印排序结果,注意不一定是最终排序结果! 输入: 第一行表示测试用例个数,后面为测试用例, 每一个用例有两行,第一行为给定数组,第二行为指定间隔,每一个间隔用空格隔开。 输出: 每一行为一个用例对应的指定排序结果。 输入样例 1 49 38 65 97 76 13 27 49 55 4 5 3 输出样例 13 4 49 38 27 49 55 65 97 76 """ def ShellInsetSort(array, len_array, dk): # 直接插入排序 for i in range(dk, len_...
3cea36a6e4c7d3de3f6f5f08d51b4c2fc7bc783d
ShumaoHou/MyOJ
/leetcode/0070.py
429
3.78125
4
''' 爬楼梯 递归算法 ''' from functools import lru_cache class Solution: @lru_cache(10 ** 8) def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 1: return 1 elif n == 2: return 2 return self.climbStairs(n - 1) + self.climbSta...
b3ec5962d08fbdb3fcc895b145bd3eb905dbc488
ShumaoHou/MyOJ
/leetcode/0905.py
1,032
3.640625
4
""" 给定一个非负整数数组 A,返回一个由 A 的所有偶数元素组成的数组,后面跟 A 的所有奇数元素。 你可以返回满足此条件的任何数组作为答案。 示例: 输入:[3,1,2,4] 输出:[2,4,3,1] 输出 [4,2,3,1],[2,4,1,3] 和 [4,2,1,3] 也会被接受。 提示: 1 <= A.length <= 5000 0 <= A[i] <= 5000 3 1 2 4 """ class Solution(object): def sortArrayByParity(self, A): """ :type A: List[int] :rtype:...
38609e1ee9e021da8e805498f4afaff6fd220bb1
ShumaoHou/MyOJ
/Advanced_algorithm/oj_classwork1/3_1.py
931
3.65625
4
''' 1 8 8 3 2 9 7 1 5 4 17 ''' def mergeSort(arrA): num = 0 if len(arrA) > 1: arrB = arrA[0: int(len(arrA) / 2)] arrC = arrA[int(len(arrA) / 2): len(arrA)] num += mergeSort(arrB) num += mergeSort(arrC) num += merge(arrB, arrC, arrA) return num def merge(B, C, A): ...
6df74a7b58d9f860c5892b65596339ad13e745f8
ShumaoHou/MyOJ
/leetcode/0590.py
1,009
4.03125
4
""" 给定一个 N 叉树,返回其节点值的后序遍历。 """ """ # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def postorder_stack(self, root): """ :type root: Node :rtype: List[int] 非递归-栈 ...
0779c872107e156e25e6770374b51a3b21464960
ShumaoHou/MyOJ
/leetcode/0067.py
710
3.609375
4
class Solution: def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ sumStr = str(int(a) + int(b)) sumList = [int(sumStr[i]) for i in range(len(sumStr))] for i in range(0, len(sumList) - 1): k = len(sumList) - i - 1 ...
b0c561695e852aead6a06549c5a84090c5e2842b
ShumaoHou/MyOJ
/leetcode/0965.py
1,004
4.0625
4
""" 如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树。 只有给定的树是单值二叉树时,才返回 true;否则返回 false。 示例 1: 输入:[1,1,1,1,1,null,1] 输出:true 示例 2: 输入:[2,2,2,5,2] 输出:false 提示: 给定树的节点数范围是 [1, 100]。 每个节点的值都是整数,范围为 [0, 99] 。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # se...
d1b7064f37ed47b0d4594b7d0679516d446e5291
ShumaoHou/MyOJ
/mi_oj/102.py
956
3.828125
4
''' 解救我 mi 标签:栈 给定一个只包含小写字母的字符串,现在我 mi 被众友商品牌的字符串围困在其中, 需要我们将字符串中的 mi 全部移除然后输出,保证最后输出的字符串中没有 "mi"。 输入:一行数据包含一个字符串,长度 <= 100000,字符串仅包含小写字母。 输出:处理后的字符串 输入样例 huaweimivivo chuizimmmiioppo samsungmimiapple 输出样例 huaweivivo chuizimoppo samsungapple ''' """ @param string line 为单行测试数据 @return string 处理后的结果 """ def solution(line...
a6be2cbc5efd687ccdfeef70865bbe2da4ca7fcb
ShumaoHou/MyOJ
/mi_oj/14.py
765
3.671875
4
''' 在一个有序的经过旋转的数组里查找一个数 假设一个有序的数组,经过未知次数的旋转(例如0 1 2 4 5 6 7 被旋转成 4 5 6 7 0 1 2), 从中查找一个目标值,如果存在,返回其下标,不存在,返回-1。注:假设数组无重复数字 输入一个有序经过旋转的数组和要查找的目标数字,数组中各数字用“逗号”分隔,数组和目标数字用“空格”分隔 输出一个整数,表示该目标数字的下标(不存在返回-1) 输入样例 4,5,6,7,0,1,2 6 输出样例 2 ''' def solution(line): a, b = line.strip().split() a = a.split(",") for i in ...
ae9f7f04f7530548d51112f8e6e975ffe961d8f3
ShumaoHou/MyOJ
/Advanced_algorithm/oj_homework1/p7.py
2,155
3.59375
4
''' 先升后降 描述: 从一列数中筛除尽可能少的数使得从左往右看,这些数是从小到大再从大到小的。 输入: 输入时一个数组,数值通过空格隔开。 输出: 输出筛选之后的数组,用空格隔开。如果有多种解雇哦,则一行一种结果。 输入样例 1 2 4 7 11 10 9 15 3 5 8 6 输出样例 1 2 4 7 11 10 9 8 6 ''' def fun_LIS(arr): arrLen = len(arr) count = [1] * arrLen # 以第i元素结尾的LIS长度 id = [0] * arrLen # 记录第i元素在LIS第i-1元素的位置 for i in range(arr...
9f0b4506b5c1b2ac22a66635b446751f018b64fd
ShumaoHou/MyOJ
/Advanced_algorithm/oj_classwork4/2.py
1,976
3.6875
4
""" 帮帮Mike 描述 Mike is a lawyer with the gift of photographic memory. He is so good with it that he can tell you all the numbers on a sheet of paper by having a look at it without any mistake. Mike is also brilliant with subsets so he thought of giving a challenge based on his skill and knowledge to Rachael. Mike kno...
95cac04656f5aeec37c54f281bed98d67e6c2319
MaheshSirsat/Python
/hacker rank/Minion Game.py
424
3.546875
4
#Question---> https://www.hackerrank.com/challenges/the-minion-game/problem #Solution: def minion_game(string): l=len(string) c,v=0,0 for ss in range(l): if string[ss] in "AEIOU": v=v+(l-ss) else: c=c+(l-ss) #print(c,v) if c>v: print("Stu...
88c561ad2ed8c17f3cda09468db188fb266908e2
peterdobbs77/daily-coding
/py/stripe_FindMissingPosInteger/findMissingPosInteger.py
1,582
3.859375
4
# Given an array of integers, find the first missing positive integer # in linear time and constant space. In other words, find the lowest # positive integer that does not exist in the array. The array can # contain duplicates and negative numbers as well. # For example, the input [3, 4, -1, 1] should give 2. # ...
db9c9f4df6be399f305601b09963e870e7fc80fd
ishaan1996/Movie-Success-Predictor
/code/Neural-Network/valueSetter.py
1,998
3.671875
4
#!usr/bin/python def is_number(s): try: float(s) return True except ValueError: return False def delete_element_in_list(list_element): while True : try : list_element.remove('\n') except ValueError : break def find_element_in_list(element,list_element): try: ...
01cab55e106fa2fb889b7d136e06a8faf66a8e9f
ishaan1996/Movie-Success-Predictor
/code/Neural-Network/genreRating.py
2,225
4.25
4
# The aim of this module is to assign a rating to # each of the 'genres' in the dataset. # The idea here is to create a dictionary with # the name of the genres as keys and the average revenue # generated by the movies in that genre as values assigned to these keys. import creatingDictionary dataset=creatingDictionary...
e9b5e54b056ea6027dca47d1dbddfa1fc32040a8
ishaan1996/Movie-Success-Predictor
/code/Neural-Network/inp.py
278
3.734375
4
import csv '''with open('Final.csv', 'rb') as f: reader = csv.reader(f) your_list = map(tuple, reader) print your_list ''' my_file=open("Final.csv", "rb") for line in my_file: l = [i.strip() for i in line.split(',')] p = l[0].split(' ') print p[0]
2a5da4d58a659d32525cad3cbafe355311066eed
shianchin/mini_projects
/stock_commision_fee_cal/stock.py
6,242
3.890625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #---------------------------------------------------------------------- # Project : Stock commision fee calculator # # File name : stock.py # # Author : Cheang Shian Chin # # Date created : 20 Nov 2015 # # Purpose : Calculate stoc...
0d53945c95ac374688869ea2db9e772b6171b65d
pennhanlee/google_scholar_scrapapi
/lib/node_serpapi.py
2,413
3.75
4
class Node: ''' A node object is used to keep track of the publication information. It also has a dictionary to maintain a record of the bibliographic couples and its weight of connection Attributes ------------ title : str year : int abstract : str cite_id ...
aaab2fdf0f5450502d98516c24092c0a8d581971
pierre-crucifix/real-spanish
/tweepyManager.py
4,117
3.734375
4
""" Script #1 Retrieve all the latest tweets of the chosen usernames (see screen_name_list) Need to create a file called twitter_credentials.py in the same folder. This file will store the keys to log in to the twitter app """ import tweepy import pandas as pd import simplejson as json import datetime impo...
f557d69ed3053776863f5a1bc92ee70bd38c1a6c
niroshavpn/Algorithmic-Warmup
/Greatest Common Divisor/Assignment-1/Calculate_GCD.py
219
3.96875
4
#Euclids Algoritham def calculate_GCD(n,m): if m==0: return n else: return (calculate_GCD(m,n%m)) n=int(input("Enter First Number")) m=int(input("Enter Second Number")) print(calculate_GCD(n,m))
784807e8d7e41b43409c1d8e15a015eba3e8d508
kevinflores99/curso_intermedio_python
/Andres/natural_nums_sqr.py
341
3.953125
4
def main(): squared_nums = [ x**2 for x in range(1,101) if x%3 != 0] print(squared_nums) print("======================================================") # List of nums multiples of 4,6,9 multiples = [ x for x in range(1,10000) if x%4==0 and x%6==0 and x%9==0] print(multiples) if __name__ == "...
cc7e4e6cbcce541e4c35270187b19b8b2633e6e3
VikaYallina/graphics-design
/main.py
5,933
3.765625
4
# Graphics & design class assignment 1 # # Task: given a picture figure out where the red balls(spherical shape) are and mark them # Input: a non-trivial picture (jpg, png??) # Output: a new picture where all of the red balls are marked and possibly numbered(how?) # Possible solution: # 1. Find out the spectrum o...
dea57ec2e2f8c01c0bc5b8e64b3820b4b1916acb
mchooooo/AlgorithmPython
/PythonAlgorithmInterview/study_0311.py
1,405
3.78125
4
import collections import functools import re import sys from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: # leetcode.com/problems/add-two-numbers def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:...
aa78d90be00890fb6069ba55dca009cd53ba3e23
sajimgomez/Competitive-programing
/MergeTwoSortedLists.py
1,310
3.921875
4
class ListNode : def __init__(self, x) : self.val = x self.next = None class Solution : def mergeTwoLists(self, l1, l2) : if l1 == None and l2 == None : return None if l1 == None and l2 != None : return l2 if l2 == None and ...
e7de4a2bc04e8e146ac9b16ab9609d827597a48b
sajimgomez/Competitive-programing
/SearchInsertPosition.py
290
3.9375
4
class Solution : def searchInsert(self, nums, target) : if target not in nums : nums.append(target) nums.sort() return nums.index(target) return nums.index(target) s = Solution() s1 = s.searchInsert([1,3,5,6], 2) print(s1)
92609867011336eef1fbfa49b3340b5de6b08615
sajimgomez/Competitive-programing
/ClimbingStairsv1.py
273
3.609375
4
class Solution : def climbStairs(self, n) : if n == 1 : return 1 elif n == 2 : return 2 else : return self.climbStairs(n - 1) + self.climbStairs(n - 2) s = Solution() s1 = s.climbStairs(5) print(s1)
87abd74fdf22eb826fe711606dc7bd47f5d5b278
netfj/Project_Stu01
/venv/Stu22.py
660
3.671875
4
# -*- coding: UTF-8 -*- """ deque模块是python标准库collections中的一项, 它提供了两端都可以操作的序列,这意味着, 在序列的前后你都可以执行添加或删除操作。 """ from collections import deque queue = deque(["Eric", "John", "Michael"]) print(queue) queue.append("Terry") # Terry arrives queue.append("Graham") # Graham arrives print(queue) queue.popleft...
ffa009d1c009b22e689d02a8e76227c9d09e0831
boris-ns/NineMensMorris
/Ai.py
11,275
3.8125
4
from Heuristics import Heuristics class Ai: """ Class for handling computers inputs. Minimax algorithm + Alpha Beta pruning. Attributes: mark (char): players mark num_of_figures (int): number of figures _game_instance (Game): game object _opponent_mark (char): opponents ma...
38b8c2fdc3509a48ce2a8fc84aa1625058696ef5
iamliguangming/CIS519
/HW1/cis519_hw1_solution.ipynb.py
12,582
3.8125
4
#!/usr/bin/env python # coding: utf-8 # # CIS 419/519 Homework 1 # # Name: Yupeng Li # # Pennkey: yupengli # # PennID: 37169291 # In[ ]: import random import numpy as np import pandas as pd from sklearn import tree # from sklearn.model_selection import train_test_split from sklearn.impute import SimpleImputer r...
b948a48faa59dcfe7bdeaed8caea712d0c496dc3
Ashwin-Dara/DSA
/linked_list_insert_tail.py
333
4.0625
4
class Node: def __init__(self, value): self.value = value self.next = None head = Node(1) b = Node(2) c = Node(3)\ d = Node(4) tail = d e = Node(5) def append_linked_list(node): # want e to come after the tail global tail tail.next = node node.next = None tail = node print...
fd4062a5a4442296c38a6f9c3daff307dc60c13e
Ashwin-Dara/DSA
/q.py
346
3.53125
4
class Queue: def __init__(self): self.q_list = [] def add(self, item): self.q_list.append(item) def remove(self): if len(self.q_list) > 0: return self.q_list.pop(0) def get_item(self, index): if (index >= 0) and (index <= len(self.q_list) - 1): ...
6c678473a6d58183f2e6e3252a5763811b7eefb7
Dom88Finch/python-programs
/apps_2.py
913
3.625
4
from Quiz import Quiz quiz_questions = [" What is batmans' secret identity?\n(a) clark kent \n(b) lex luthor \n(c)bruce wayne \n\n", " Who is green arrows' nememsis?\n(a)black canary \n(b) deathstroke \n(c) barry allen \n\n", " What island whas oliver queen trapped on for 5 years?\n(a)lianyu \n(b)nort...
f3d51f25b9577ffb1be98e2d8fb5b7de6cee0cbb
ArturoOrtiz1/arturo-ortiz-project8
/aoheat.py
597
3.953125
4
#This program takes the average temperature and gives back the total number of #cooling and heating degree days #By Arturo Ortiz, arturo.ortiz1@marist.edu def main(): temp= input("Enter the average tempurature per day separated by spaces: ") temp=temp.split(" ") cooling=0 heating=0 for i...
12d2f6129c00b16e2e3af31e71eafde88a271f35
iandriver/Bioinformatics
/mendel.py
437
3.515625
4
from math import factorial as fac def mend_prob(gen, num): prog = 2**gen # number of progeny in that generation result = 0 for x in range(num, prog+1): #sum the cumulative probability of exactly num or greater individuals occuring result += ((fac(prog)/(fac(x)*fac(prog-x)))*.25**x*.75**(prog-x)) ...
789b51f7d3ff896c92c280b43f167af57e5650b0
kmuni08/The-Peanuts-Programming-Language
/ParseResult.py
828
3.53125
4
# Instead of returning a Node in each function, we'll return # ParseResult, it'll check if there are any errors class ParseResult: def __init__(self): self.error = None self.node = None self.advance_count = 0 # Only for continuing on: def register_advancement(self): self.ad...
b3a6e9e3c1e044c7f34741ded34071fb6601cc31
ChrisLi716/pythondemo
/demo/fluent_python/listcomps.py
372
4.0625
4
# 列表推导(list comprehension) def listcomp(): symbols = '$¢£¥€¤' codes = [ord(symbol) for symbol in symbols if ord(symbol) > 127] print(codes) codes = list(filter(lambda c: c > 127, map(ord, symbols))) print(codes) for x in symbols: if ord(x) > 127: print(x, ord(x)) if __nam...
d2376b5777cde3391c5caa5d5152b5819d3aab88
ChrisLi716/pythondemo
/demo/basic/file_delete.py
1,373
3.859375
4
# coding=utf-8 import os currentPath = os.getcwd() print("currentPath", currentPath, sep=":") newDirPath = currentPath + os.sep + "tmp" + os.sep def create_dir_if_not_exist(): if not os.path.exists(newDirPath): os.mkdir(newDirPath) else: print(newDirPath, "has existed!") def write2file(fi...
11d8bba930bf3f6844c77ea92e29365553fe14a0
ChrisLi716/pythondemo
/demo/fluent_python/list_list.py
99
3.609375
4
list_temp = [['_'] * 3 for i in range(3)] print(list_temp) list_temp[1][2] = "X" print(list_temp)
020f756f199a933c0a73d2ae263f586fb2e55ae1
ChrisLi716/pythondemo
/demo/basic/operator1.py
203
3.765625
4
# 算术运算符 x = 10 y = 3 print(x + y) print(x - y) print(x * y) print(x / y) print(x % y) print(x ** y) print(x // y) # and or not # 身份运算符 is | is not # 成员运算符 in | not in
82db267aeda6e762765d7dcd0ad7daa80a50491e
jordac/pytest
/hangman.py
6,265
4.0625
4
import string def getAvailableLetters(lettersGuessed): ''' lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters that represents what letters have not yet been guessed. ''' # FILL IN YOUR CODE HERE... abc = list(string.ascii_lowercase) f...
bb471a551ad0d1e599bc9f7d8af9a903d56e5e22
connorbuck/NFL-WebScraper
/game_results_class.py
4,281
3.5625
4
import requests from bs4 import BeautifulSoup # Only for games that do not end in a tie class GameResult(): def __init__(self, winning_team, losing_team, date, winning_score, losing_score): self.winning_team = winning_team self.losing_team = losing_team self.date = date self.winning_score = winning_score s...
bc6a6f2a1547fcae84d1860c20776918517e82f1
ddyson1/projectEuler
/problem009.py
189
3.984375
4
def pythagorean_triplet(): for a in range(1,1000): for b in range(1,1000): c = 1000-a-b if (a**2+b**2) == c**2: return a*b*c solution = pythagorean_triplet() print(solution)
479e714f12fb49b3e410d29e5ea9b811f3e990c5
Master-of-moyu/sh_and_md
/python/array.py
462
3.546875
4
import matplotlib.pyplot as plt import numpy as np a = [1, 2] print(a) for x in a: print(x) a.append(3) print(a) b = np.arange(0, 1, 0.1) print("np.arange: ") print(b) c = np.linspace(1, 10, num= 5, endpoint = True) print("np.linspace: ") print(c) arr = [] l = len(arr) print(l) arr.append(100) l = len(arr) prin...
cb78f9b74010ed11d316efb20320497ca3bab438
roberthsu2003/python
/TQC/PYD804.py
671
3.9375
4
''' 1. 題目說明: 請開啟PYD804.py檔案,依下列題意進行作答,將字串轉換成大寫及首字大寫,使輸出值符合題意要求。作答完成請另存新檔為PYA804.py再進行評分。 2. 設計說明: 請撰寫一程式,讓使用者輸入一字串,分別將該字串轉換成全部大寫以及每個字的第一個字母大寫。 3. 輸入輸出: 輸入說明 一個字串 輸出說明 全部大寫 每個字的第一個字母大寫 輸入輸出範例 範例輸入 learning python is funny 範例輸出 LEARNING PYTHON IS FUNNY Learning Python Is Funny ''' st = input() str1 = st.upper() prin...
de7582b50bd8937753f5a314984daa3ee8d82047
roberthsu2003/python
/TQC/PYD308.py
1,211
3.828125
4
''' 1. 題目說明: 請開啟PYD308.py檔案,依下列題意進行作答,將輸入值之每位數全部加總,使輸出值符合題意要求。作答完成請另存新檔為PYA308.py再進行評分。 2. 設計說明: 請使用迴圈敘述撰寫一程式,要求使用者輸入一個數字,此數字代表後面測試資料的數量。每一筆測試資料是一個正整數(由使用者輸入),將此正整數的每位數全部加總起來。 3. 輸入輸出: 輸入說明 先輸入一個正整數代表後面測試資料的數量 依測試資料的數量,再輸入正整數的測試資料 輸出說明 將測試資料的每位數全部加總 輸入輸出範例 輸入與輸出會交雜如下,輸出的部份以粗體字表示 1 1 98765 Sum of all digits of 98765...
5ee85da4b5e7a952da24e2526c43b70f8170dc10
roberthsu2003/python
/python內建的資料結構/initial2.py
922
3.59375
4
#!usr/bin/python3.8 ''' #============================================================================ # Name : initial2.py #建立一個2*3的二維陣列並初始化,用來儲存2個學生各三科成績,再以2層巢狀迴圈將所有成績顯示出來。 #============================================================ 第1位學生第1科成績:85 第1位學生第2科成績:82 第1位學生第3科成績:90 #===============================...
f2b66705e8b7ca51fe48cd38463f36deaaaef39a
roberthsu2003/python
/TQC/PYD908.py
431
3.671875
4
f_name = input() n = int(input()) word_dict = dict() with open(f_name, 'r') as file: for line in file: word = line.strip('\n').split(' ') for x in word: if x in word_dict: word_dict[x] += 1 else: word_dict[x] = 1 word_list = word_dict.items()...
5b2fa2b85764d96b24adc2b3875690b124daebe0
roberthsu2003/python
/重複執行/loop1.py
364
3.515625
4
#!usr/bin/python3 """ 2 - 10所有偶數的總和 第 1.0 次迴圈的i = 2 總和為 2 第 2.0 次迴圈的i = 4 總和為 6 第 3.0 次迴圈的i = 6 總和為 12 第 4.0 次迴圈的i = 8 總和為 20 第 5.0 次迴圈的i = 10 總和為 30 """ sum = 0 i = 2 while(i <= 10): sum += i print("第",i/2,"次迴圈的i =",i,"總和為", sum); i += 2
d380f0d91a1472f7f3dfaf540519ece7c3ef7b5c
roberthsu2003/python
/條件分析/complex.py
259
4.09375
4
#!usr/bin/python3 ''' 請使用者輸入一個任意數,程式會顯示此數的平方值及立方值 ''' num = float(input('請輸入任意數:')) result = num ** 2 print('此數的平方是:',result) result = num ** 3 print('此數的立方是:',result)
aa5cfdf2de713c2eb5e9b2ed22082a2cfbffc08e
roberthsu2003/python
/重複執行/continue.py
708
3.515625
4
#!usr/bin/python3 ''' #continue.py #請設計一個程式,讓使用者輸入數值,只有加總正偶數值,不加總正奇數值,如果輸入負數,結束程式。 顯示:======================================== 請輸入第1個數值:456 請輸入第2個數值:455 請輸入第3個數值:123 請輸入第4個數值:-1 所有輸入的正偶數的加總是:xxxxxxx ============================================= ''' num = 0 sum = 0 while(True): num += 1 inputNum = int(input(...
c886d3e72390332673083ae208ac9059d57ab47d
roberthsu2003/python
/TQC/PYD102.py
860
3.84375
4
''' 請撰寫一程式,輸入四個分別含有小數1到4位的浮點數,然後將這四個浮點數以欄寬為7、欄與欄間隔一個空白字元、每列印兩個的方式,先列印向右靠齊,再列印向左靠齊,左右皆以直線 |(Vertical bar)作為邊界。 提示:輸出浮點數到小數點後第二位。 3. 輸入輸出: 輸入說明 四個浮點數 輸出說明 格式化輸出 輸入輸出範例 範例輸入 23.12 395.3 100.4617 564.329 範例輸出 | 23.12 395.30| | 100.46 564.33| |23.12 395.30 | |100.46 564.33 | ''' # TODO num1 = eval(input()) num2 =...
25ad674ae4f0a1021fe7f06be8e9c644f0f00295
MatheusPereiraBarros/Atividade-01-Python
/3.py
510
3.703125
4
pesoQueijo = 0.05 pesoPresunto = 0.05 pesoHamburger = 0.1 quantQueijo = 0 quantPresunto = 0 quantHamburger = 0 def calcularCompra(quantSand): quantQueijo = quantSand*pesoQueijo*2 quantPresunto = quantSand*pesoPresunto quantHamburger = quantSand*pesoHamburger print("%d kg de queijo, %d kg de presunto, %...
930b562fe54e589a7262a133e7e8fc92633643cd
RobertSuto/Atelierul_Google
/hangman.py
1,373
3.875
4
from random_word import list_of_random_word import random word = random.choice(list_of_random_word) word_list = [] lista_deja_incercate = [] unique_letter = set(word) for item in word: if item != word[0] and item != word[-1]: word_list.append('_') else: word_list.append(item.lower()) ...
70e7c8aa2014fd4aaf4f4c162bdcb720364fd9ee
GenghisKhan-PythonCoder/MyPythonStudies
/Embedded_Functions/zip.py
234
4.03125
4
names = ["Kerim","Tarık","Ezgi","Kemal","İlkay","Şükran","Merve"] surnames = ["Yılmaz","Öztürk","Dağdeviren","Atatürk","Dikmen","Kaya","Polat"] print(list(zip(names,surnames))) for i,j in zip(names,surnames): print(i,j)
c58d941e102d2ef4b9a27506e2672f7a1eeecb80
GenghisKhan-PythonCoder/MyPythonStudies
/Sqlite_DataBase/song/song.py
1,923
3.921875
4
import sqlite3 class Song(): def __init__(self, name , artist , album , production , time): self.name = name self.artist = artist self.album = album self.production = production self.time = time def __str__(self): return f"Şarkı ismi:{self.name}\nSanatçı:{self.a...
d1a62d01b1f5c38b5678063638d67c395bdac0fe
oleg31947/python-selenium-automation
/algorithm/my_1.py
1,141
3.921875
4
# print("Hi. What's your name?") # name = input() # #print('Glad to meet you ', name, 'What\'s your age ?', sep='') # print(f'Glad to meet you {name}. What\'s your age?.') # age = int(input()) # age2 = age+1 # age3 = 0 # # if age == 1: # age3 = 'год' # elif 1 < age < 5: # age3 = 'года' # else: # age3 = 'лет...
8cbd9d246fe288abad81a9e8691e24198b43deb6
Ghostom998/CythonTemplateC-
/rectangleapp/CalcRect.py
507
3.8125
4
# ignore the import error below in your IDE as it should run fine in python from rect import PyRectangle # Then implement! def main(): x0, x1, y0, y1 = 1, 3, 4, 7 # Create rectangle object rectangle = PyRectangle(x0, y0, x1, y1) # Run methods width, height = rectangle.get_size() area = rectangl...
7db84e9032b05361afb1e23851e9f90c695a9792
NathCcode/Hangman-1.0
/Hangman.py
3,312
4.0625
4
#Hangman 1.0 #by Nathan #how to play #--------------------------------------------------------------------------------- #imput 1 letter at a time #if you think you got the word put the whole word e.g #'-''e''l'l''-' #hello #you win! #----------------------------------------------------------------------...
6b7ed5bc493857336d6691d0ffce496c1d50ec93
r2kode/se-udemy
/pytut/basicsyntax/methods.py
552
3.90625
4
def sum_num(a, b): """ Returns sum of two numbers :param a: numeric :param b: numeric :return: numeric """ return a + b def is_metro(city): l = ['sfo', 'nyc', 'la'] if city in l: return True else: return False def optional_params(a, b, c=3): """ Usage...
9c97684771c7e87485b4ae2086fa30b7cd4895c0
r2kode/se-udemy
/pytut/basicsyntax/buildinfunction.py
425
3.609375
4
def largest_num(*args): """ *args - allows to pass multiple arguments :param args: :return: """ return max(args) def smallest_num(*args): return min(args) def abs_function(a): return abs(a) print(largest_num(2, 3, 10, -1, 100)) print(smallest_num(2, 3, 10, -1, 100)) print(abs(-20))...
2e65b7fcb45b2a0a66c9e3c72250cd4738d2b867
b166erbot/sql-khanacademy
/sql-9.py
3,224
3.828125
4
import sqlite3 from os.path import exists def bancoDeDados(*args: tuple): """ Função que comita os comandos sql. """ connection = sqlite3.connect('teste9.db') cursor = connection.cursor() cursor.execute(*args) retorno = cursor.fetchall() connection.commit() connection.close() r...
8c649a25161434adbec375e83821ea1662ad0d24
b166erbot/sql-khanacademy
/sql-5.py
1,000
3.90625
4
import sqlite3 from os.path import exists def bancoDeDados(*args: tuple): """ Função que comita os comandos sql. """ connection = sqlite3.connect('teste5.db') cursor = connection.cursor() cursor.execute(*args) retorno = cursor.fetchall() connection.commit() connection.close() r...
cecd4877efdd159d103f28231eccb3759ee9c9c0
jahan19011noor/Python_EssT
/Operators/comparison.py
435
4.0625
4
''' Created on Oct 21, 2016 @author: Noor Jahan Mukammel Program: comparison ''' a, b, c, d = 2, 3, 4, 2 if a!=b: print("a = {} is not equal to b = {}".format(a,b)) if a<b: print("a = {} is smaller than b = {}".format(a, b)) if c>b: print("c = {} is larger than b = {}".format(c, b)) ...
1059d78fed85a722ceb0016f456611376118a921
jahan19011noor/Python_EssT
/Sets_Frozensets/Set_Operations/_copy.py
576
4.3125
4
''' Created on Oct 24, 2016 @author: Noor Jahan Mukammel Program: set_method: copy() * copy() - Creates a shallow copy, which is returned. ''' more_cities = {"Winterthur","Schaffhausen","St. Gallen"} cities_backup = more_cities.copy() more_cities.clear() print(cities_backup) more_cities = {"Winterth...
702003ecf249ff21cb49508c285e5b60c1f177dd
jahan19011noor/Python_EssT
/Functions/returnValues.py
306
3.625
4
''' Created on Jan 7, 2017 @author: Jahan ''' def no_return(x,y): c = x + y res = no_return(4,5) print(res) def empty_return(x,y): c = x + y return res = empty_return(4,5) print(res) def return_sum(x,y): c = x + y return c res = return_sum(4,5) print(res)
64972afb6604af5bed7f615d905c7b80a9714fba
jahan19011noor/Python_EssT
/Operators/bitwise.py
810
4.03125
4
''' Created on Oct 21, 2016 @author: Noor Jahan Mukammel Program: bitwise * Pyhton's built-in function bin() can be used to obtain binary representation of integer number. ''' a = 60 # 60 = 0011 1100 b = 13 # 13 = 0000 1101 print ('a =',a,':',bin(a),'b =',b,':',bin(b)) c = a & b ...
09a676bbc55c18f8a5a6d0b8f107b9d4eb179e07
DomingoRoman/transcriptor_fonologico
/transcriptor_completo.py
8,905
3.53125
4
# Este FOR servirá para ver dónde está el acento gráfico # en la palabra. # por el momento no se usa #for b in lista_palabras: # print("8. ",b) # comienza la separación silábica por la estructura for i in lista_sec_cv: print(i) n_v = i.count("v") print(n_v, "sílabas") if n_v == 1: if i ==...
494e85dbdaab1e4158e296425a146afea8f07773
salmansss/nettech_india_repository
/Control_flow.py
3,298
4.28125
4
#@ IF STATEMENT # The IF statement is similar to that of other languages. The if statement contains a logical # expression using which the data is compared and a decision is made based on the result # of the comparison. # syntax # # if expression: # statement(s) # If the boolean expression evaluat...
79cdce0ad9b090a2cb52efaa10819249e967f0c1
beshad/python-lessons
/simple/mathquiz.py
494
3.59375
4
from random import randint from time import time print('Enjoy a math quiz, and respond with nothing to stop.') while True: m1 = randint(2, 11) m2 = randint(2, 11) product = m1 * m2 start_time = time() response = input('What is %d * %d ' % (m1, m2)) if not response.strip(): break an...
e7d3f2f01c3892753631d9c99cd61b1fc6629da7
zack4114/PythonNotepad
/NotepadPy.py
1,226
3.8125
4
from tkinter import * from tkinter import filedialog filename = None def newFile(): global filename filename = "Untitled" text.delete(0.0, END) def saveFile(): global filename filename = "Untitled" t = text.get(0.0,END) f = open(filename,"w") f.write(t) f.close() def saveAs(): f = filedialog.asksaveasfil...
77ee4431abb057fd8446a606750106d7d4800d20
Esseh/Misc
/Parallel Processing/Parallel Processing/exam2_notes.py
13,622
3.5
4
Chapter 2 Parallel Hardware Cache coherence This refers to a problem with sharing data between multiple processing units. Suppose both are executing in parallel at the same time storing a value in their own cache with x = 1 Thread1 x = 2 Thread2 y = x What is the final value of x? How does thr...
56b752d15e43bd6eb93622e688dc686fa3299612
Esseh/Misc
/Parallel Processing/Parallel Processing/ParallelProcessingMockExam.py
6,863
3.84375
4
1. Write the Names of Three Different Approaches to Pipelining. Describe the difference... 1. Scalar Pipeline: Traditional approach, goes in stages. 2. Parallel Pipeline: Scalar Pipeline forks after some stages, additional paths for instructions to go down. 3. Diversified Pipeline: Scalar Pipeline forks into special...
86878b9e566062cef111c34ce8aa16f1ec173406
gouskova/compsegcode
/code/rawcounts.py
691
4.3125
4
#!/usr/bin/env python3 ''' returns a simple count of the number of times a given segment occurs in a file. file has to contain one word per line, with spaces between segments. like this: p a t a n a ts u e k w a etc. Usage: $python3 rawcounts.py /home/you/filename.txt 'a' will print "4" for the input given abo...
230fbfe2959db523a3583b70aef2020552e8525d
Portia-Lin/caesar-code
/Caesar/caesar_decrypt.py
691
3.6875
4
alph = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' '] print("Start!\nРозмір алфавіту: ", len(alph)) result = "" step = int(input('Введіть крок зсуву: ')) while step >= len(alph): print("Завеликий крок зсуву, повторіть") ste...
3276df81078ac6b687271471a4bbebc0006480d7
mxtm/cmps-200-fall-2018
/asst5/pwd_check.py
990
3.640625
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 """ Check whether a given password is a "good" password, meeting these criteria: 1) at least 8 characters long 2) contains at least one digit 0-9 3) contains at least one uppercase letter 4) contains at least one lower case letter 5) contains at least ...
f458489a25ae1d392752025ddf69892835f81d81
mxtm/cmps-200-fall-2018
/exam3/power.py
800
3.953125
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 from polynom import Polynom def power1(p, d): # A fun iterative version of raising a polynomial to a power. result = p # We use d - 2 instead of d - 1 because we are initializing our result to p already for i in range(d - 2): # Multiply result va...
b9b1af3fa62d0c80249d00b9d4e2c264c6a65f70
mxtm/cmps-200-fall-2018
/asst8/merge_sort.py
750
3.75
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 def merge(l, r): mergedList = [] while len(l) != 0 and len(r) != 0: if l[0] < r[0]: mergedList.append(l.pop(0)) elif r[0] < l[0]: mergedList.append(r.pop(0)) else: mergedList.append(l.pop(0)) ...
a6a83c028c45385de72a003688f010f787965c49
mxtm/cmps-200-fall-2018
/asst6/trees.py
846
3.78125
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 # Recursive tree import turtle def tree(n, length=100, width=20): if length == 100: turtle.forward(length) turtle.width(width * (1/2)) turtle.left(60) turtle.forward(length * (2/3)) if n > 1: tree(n - 1, length / 2, width * (1 / 3)) ...
1d6e4682add6a41842ebb8090dd5822155c9dd0d
mxtm/cmps-200-fall-2018
/final/disk.py
980
3.953125
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 import math class Disk: def __init__(self, radius, x=0.0, y=0.0): self.__radius = float(radius) self.__x = float(x) self.__y = float(y) def radius(self): return self.__radius def x(self): return self.__x def y(self...
4694729a7c4fd31f342dd6f58421e5907084725e
mxtm/cmps-200-fall-2018
/asst3/sum_primes.py
408
4.03125
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 def is_prime(n): for i in range(2, n): if n % i == 0: return False return True sum_of_primes = 0 while True: given_number = int(input('Pick a positive integer: ')) if given_number == 0: print('The sum of your entered primes i...
0f23a5f748a13fd19262e17f4d7a45f29a8d7c7c
mxtm/cmps-200-fall-2018
/asst8/insertion_sort.py
628
3.75
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 def insertion_sort(right_hand): assert len(right_hand) > 0 left_hand = [right_hand[0]] right_hand.pop(0) while len(right_hand) != 0: for j in range(len(left_hand)): if right_hand[0] <= left_hand[j]: left_hand.insert(j, ...