blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f8ac1f1d75abcedfe6367f2bf8d052b67e97f2ea
patricksile/code_folder
/code_wars/6kyu_is_prime.py
1,114
4.125
4
# Problem: Is Prime (6kyu) """ Is Prime Define a function isPrime/is_prime() that takes one integer argument and returns true/True or false/False depending on if the integer is a prime. Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself....
a81b6529ed46df55e28ac03d634480f087869ffb
YahyaEfeOz/ornekler
/basit_hesap_makinesi.py
779
3.8125
4
def toplama(x,y): return x+y def çıkartma(x,y): return x-y def bölme(x,y): return x/y def çarpma(x,y): return x*y print("↓Yapılacak işlemi seçiniz↓") print("1.Toplama") print("2.Çıkartma") print("3.Bölme") print("4.Çarpma") secim = (int(input("Seçim Yapınız (1/2/3/4):"))) if secim>4 or secim<1: pr...
fea09737a39d812b8521efc647f330e9cb717146
p13lgst/ProjectEuler
/problem-0020.py
466
4.0625
4
""" Problem 20 - Factorial digit sum n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 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! """ from math import factorial def get_sum_of_digits(n): ...
37eba012130fb26d2551bcbe9f98b361b47d5e2b
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_155/1223.py
591
3.53125
4
import sys def d(*args): sys.stderr.write(', '.join(map(str, args)) + "\n") def printf(*args): print(''.join(map(str, args))) def int_input(): return list(map(int, input().split(' '))) def solve(n, s): nb = s[0] toadd = 0 for i in range(1, n+1): if nb < i: toadd += (i-nb)...
7daf6b3300328b32d3500a40ea56a704c1a2b591
quicktypeI/pythonCS
/while loop Elliot.py
911
3.796875
4
def aqquireName(f_name, n_name): name_sys = f_name + ', or ' + n_name return name_sys.title() while True: print("\nLets get to know each other. Please tell me your name and a Nickname ") f_name = input("Name:") n_name = input("Nickname:") name_sys = aqquireName(f_name, n_name) pr...
3179b0ea0a37a15cd9bf3c291f947b231ee21528
svavaosk/Hello_Python
/while loops/verk_3_3.py
485
4.0625
4
num = int(input("Input an int: ")) #gefið er að alltaf byjra í einum #fyrsta sem við gerum er að búa til counter breytu counter = 0 odd_number = 1 while counter < num: print(odd_number) odd_number += 2 counter += 1 # ^það sama og að segja counter = counter + 1 #það má koma hvað sem er inn í while...
a3276a4f94ae55fcc22b95350f171b02ccaa3cac
ruchikamehra/cyber
/Assignment3/cyber3python9.py
240
3.703125
4
def primeno(a): x=0 for i in range(0,a): c=0 for j in range(1,a): if i%j==0: c=c+1 if c==2: x=x+1 return x n=int(input("enter the number")) print(primeno(n))
5b9ebc89a12b9854994f926ad237d3fba6b91222
kunjabijukchhe/python
/kunja2.py
793
4.0625
4
'''char_name="kunja" age="19" print("my name is "+char_name+",") print( age +" years old") print("i like my name "+char_name+"") print("and i am really "+age+" years old")''' '''a="kunja" b=18 print("I'm name is",a+". And your age is ",b) print("I'm name is %r" %"kunja") print("I'm name is %s" %"kunja") ...
e28d6e48ec293a8575829d3bc0b4c3f4b39b5c2d
stellapark401/python-oop
/self_study/test0524.py
746
3.640625
4
a = [1, 2, 3] b = a print(id(a)) print(id(b)) print(a is b) a[1] = 3 print(a) print(b) c = list() print(id(c)) c = a print(id(c)) c[1] = 2 print(a) print(c) d, e = 1, 2 print('d: %d, e: %d' % (d, e)) d, e = e, d print('d: %d, e: %d' % (d, e)) id_num = input('주민번호를 입력하세요(######-#######): ') id_num = id_num.split('-') if...
cf02dee89de4705291f1e10781c0a053ba22edf8
MaratAG/HackerRankPy
/HR_PY_Sets_2.py
705
3.578125
4
# HackerRank Sets 2 No Idea! def problem_solution(moodies, happy, unhappy): # Task function my_mood = 0 for mood in moodies: if mood in happy: my_mood += 1 elif mood in unhappy: my_mood -= 1 return my_mood def main(): # Initialization m = 0 n = 0...
c7c9709eb07065b307fe04de6ee546c57c46d2e1
joningehe/ITGK_Oving
/Oving_2/Sammenligning_av_strenger.py
791
3.75
4
def oppgaveA(): a = str.lower(input('Skriv inn matvare')) b = str.lower(input('Skriv inn en annen matvare')) if a == b: print('Matvarene er like') else: print('Matvarene er ikke like') #str.lower() returnerer lower-case bokstaver def oppgaveB(): a = str.lower(input('Skriv ...
0ee9492b47d98f3d5f42bcc2a0a099d630643beb
ClaudioReevas/DevFBatch1GDL
/facebooktest/facebooktest.py
1,544
3.578125
4
# Facebook Graph API Example in Python # by James Thornton, http://jamesthornton.com # Facebook API Docs # https://developers.facebook.com/docs/graph-api/using-graph-api#reading # Get Your Facebook Access Token Here... # https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me # Before runn...
474734dabdc46c9b7f8c8ea7c8a130018ae3460a
ZilRahman/PythonCourse
/A3/assing2.py
6,844
4.15625
4
# Assingment 3; part 1; Refining assingment 2 into functions. # This program runs an adventure text-based game. # The setting of this game is isnide a house where the objective is to unlock # the door to the inner house. The Objective is achieved through setting the golden lock # in the kitchen to the 'left' positi...
cf15dde7f26cd1e7d132552a19c7b186d93e76a8
TomSteve1102/HelloWorld
/xml_data_parser/dataVisualization.py
5,604
3.9375
4
""" Introduction of this program in dataVisualization.py This program is to visualize the data gathered in previous process. Two figures will be generated: wordNumberDistribution.png describes the distribution of vocabulary size in this xml input file; postNumberTrend.png describes the trend of post number of questions...
e60608d6a25ccb575ef2c321d9d7c558df208f4b
Jason-Woo/leetcode_problemset
/jz_problemset/jz67/code.py
393
3.609375
4
# -*- coding:utf-8 -*- class Solution: def cutRope(self, number): # write code here if number <= 3: return number - 1 dp = [-1 for _ in range(number + 1)] for i in range(5): dp[i] = i for i in range(5, number + 1): for j in range(1, i): ...
eca1f7da68ee57c4deb27de2bc41b73ae37a99a4
alongigi/K-MeansClustering
/PreProcessing.py
1,372
4.0625
4
""" Filling the missing values (NA) with mean. df - Data Frame """ def fillMissingValuesWithMean(df): df_without_missing_values = df.fillna(df.mean()) return df_without_missing_values """ Returns the mean of specific feature df - Data Frame feature_name - The mean of the feature """ def get_featur...
32f815297ee1e8d9729f484481119555b5e51b98
BIAOXYZ/variousCodes
/_CodeTopics/LeetCode/601-800/000796/000796_handmovedoghead.py3
421
3.625
4
class Solution: def rotateString(self, s: str, goal: str) -> bool: # 手动狗头题 return any(s[i:] + s[:i] == goal for i in range(len(s))) """ https://leetcode-cn.com/submissions/detail/295977804/ 执行用时: 40 ms , 在所有 Python3 提交中击败了 29.86% 的用户 内存消耗: 15 MB , 在所有 Python3 提交中击败了 43.29% 的用户 通过测试用例: 47 ...
17e2f43a5ce4309e0ce1d4498be7701eabbfe1f8
wishheart303/nfu40341102
/linear_algebra_Part01.py
1,776
3.78125
4
# -*- coding: iso-8859-15 -*- from __future__ import division # want 3 / 2 == 1.5 import re, math, random # regexes, math functions, random numbers import matplotlib.pyplot as plt # pyplot from collections import defaultdict, Counter from functools import partial # # functions for working with vectors # 2017/03/23 ...
c95e625a7beab763512544804789c465aa67b301
c3c1l1a/Python-advance-tracks
/koans/about_integer_operations.py
1,146
3.9375
4
from runner.koan import * from koan_labs.integer_operations import * class AboutIntegerOperations(Koan): def test_integer_addition(self): """ This activity question will help you understand how looping and integer operations work. ACTIVITY ======== Open koan_labs/integer_operations.py. Inside the integer_...
74538c8e95fac77a26f98ffb686257cb248b2410
openshift/openshift-tools
/openshift_tools/inventory_clients/utils.py
899
3.59375
4
#!/usr/bin/env python # vim: expandtab:tabstop=4:shiftwidth=4 ''' The purpose of this module is to contain small utility functions. ''' import re def normalize_dnsname(name, padding=10): ''' The purpose of this function is to return a dns name with zero padding, so that it sorts properly (as a human woul...
8ca12d8c2a12848ab33180ed236f55248cc8da3c
jggrimesdc-zz/MachineLearningExercises
/02_Statistical_Methods_for_Machine_Learning/06/06_chi_squared_cdf.py
299
3.59375
4
# plot the chi-squared cdf from matplotlib import pyplot from numpy import arange from scipy.stats import chi2 # define the distribution parameters sample_space = arange(0, 50, 0.01) dof = 20 # calculate the cdf cdf = chi2.cdf(sample_space, dof) # plot pyplot.plot(sample_space, cdf) pyplot.show()
5282edc67e38085fb06976cbd9a1c55238b63b56
RishabhGoswami/Algo.py
/Vertical ttraversal .py
959
3.703125
4
class Node: def __init__(self,data): self.left=None self.right=None self.nextRight=None self.data=data def vertical(root): l=[] l.append(root) m={} hd={} hd[root]=0 m[0]=[root.data] while(len(l)>0): a=l.pop(0) if(a.left): l...
a922d43b240aacf087b0438b4af68d045e286491
tarhashi/pynlp100
/chapter8/stop_words.py
182
3.84375
4
# -*- coding:utf-8 -*- def read_stopwords(): return [line.strip() for line in open('English.txt').readlines()] def is_stopword(word, stop_words): return word in stop_words
10e1b42a3f57538b96b28f18b51381d8202bd888
GHP-Software-2021/DailyProblems
/Day3/problem1.py
577
4.40625
4
''' You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of sto...
9c3e66a3bdcd6a0f3500601ecb01f3117322de2f
pioui/adventofcode2020
/adventofcodeDay11Part1.py
1,415
3.609375
4
seatLayout =[list(line.strip()) for line in open("/home/piyi/Documents/adventofcode2020/input.txt", 'r')] print(seatLayout) numberofRows = len(seatLayout) numberofCols = len(seatLayout[0]) def occupied(x, y, seats): if ((x > numberofRows-1) or (y> numberofCols-1) or( x<0) or (y <0)): return 0 elif seats[x][...
b567a023ee57e41f63b65175f9570eccfd67dc32
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/5f63fe02b0ae493b8b65e259b11ba8ef.py
502
3.5
4
class Bob: def hey(self, s): if s.endswith("?") and s.isupper(): return 'Woah, chill out!' if s.endswith("?"): return 'Sure.' if s.isupper(): return 'Woah, chill out!' if s.isl...
4f6b13ba535f0b58f5f7be95087430d7fa0cb774
Fatalcaleb/TheOtherSideofTheWorld
/TheOtherSideofTheWorld/TheOtherSideofTheWorld.py
807
3.921875
4
from folium import Map print("Would you like to know the antipode of a place? (y/n)") antipode_start = input() if antipode_start == "y": print("What is the latitude of the destination? ") latitude = input() print("What is the longitude of the destination? ") longitude = input() antipode_latitude = latitude...
edd55f2fae54e60158d17ca1ac1a8a4dda7b3568
FaisalWant/PythonCheatSheet
/backtoPython1.py
5,967
4.03125
4
#backtoPython1.py # In this programm we will be going through # python language on a fast track basis #type(1) -> <class 'int'> #type("hello") -> <class 'str'> #type(None) -> <class 'NoneType'> #bool is a subtype of int , where True==1 and False=0 # s= 'Arthur' # s[2]=='t' # s[-1]=='r' # s[:2]==...
1c8a5afd41849c5b508aa795f3fa33b6ee9189cf
uyennguyen87/python
/pattern/strategy/StrategyPattern.py
1,061
3.578125
4
''' Created on Jan 28, 2016 @author: ncuyen ''' # strategy pattern interface class FindMinima: def algorithm(self, line): assert 0, 'not implemented yet' class LeastSquares(FindMinima): def algorithm(self, line): return [1.1, 2.2] class NewtonsMethod(FindMinima): def algorithm(self, line)...
b2005619a6fbb696df7e3662290ea628df5cf9b5
cormoran/CompetitiveProgramming
/src/contest/atcoder/abc/abc014/A/main.comp.py
86
3.546875
4
a=int(raw_input()) b=int(raw_input()) cnt=0 while(a%b): a+=1 cnt+=1 print cnt
fa1e78064172675d5bcc999135cb8de0ff68259c
cherry1203-cloud/autotest
/test/aric/bubble_sort.py
765
3.640625
4
#冒泡排序 #将一组无需的数列变成一组有序的数列 #完成多趟比较 list_a=[7,3,6,9,5,2] list_len=len(list_a) for i in range(0,list_len-1): for i in range(0,list_len-1): if list_a[i]>list_a[i+1]: temp=list_a[i] list_a[i]=list_a[i+1] list_a[i+1]=temp # j=j+1 print (list_a) #完成一趟比较 # list_a=[7,3,6,9,5,2...
6d26ab95957530ce04b2348114cd16b0909232a1
Matheus-Morais/URI
/Iniciante/URI 1071.py
237
3.6875
4
numero1 = int(input()) numero2 = int(input()) maior = max(numero1, numero2) menor = min(numero1, numero2) + 1 resultado = 0 while menor < maior: if menor % 2 != 0: resultado = resultado + menor menor += 1 print(resultado)
371fa4feca1cf06699d02f65f5ea72745cb8c94c
rajeevdodda/Python-Practice
/FluentPython/Chapter 10/Example5.py
260
3.8125
4
# Example 10-5. Inspecting the attributes of the slice class s = slice print(s) print(dir(s)) # print(help(s.indices)) string = "ABCDE" s = slice(None, 10, 2) print(s, s.indices(5), string[s]) s = slice(-3, None, None) print(s, s.indices(5), string[s])
e329ee0bc6e507773ff00bb839da1c1ba8133e28
marielitonmb/Curso-Python3
/Desafios/desafio-96.py
414
4.1875
4
# Aula 20 - Desafio 96: Funçao que calcula area # Fazer um programa c/ uma funçao chamada area(). # Ela recebe as dimensoes de um terreno retangular (largura e comprimento) e mostra a area do terreno. def area(larg, comp): a = larg * comp print(f'A largura {larg}m e o comprimento {comp}m formam uma area de {a}...
ebcce7e06d63bc7f835d5939e3b35f6b8acdf675
mpwesthuizen/eng57_oop
/dog_class.py
394
3.5625
4
from animal_class import * class Dog(Animal): def __init__(self, age=0): super().__init__(self, "Irish setter", True, "red", "Clifford") self.age = age def bark(self): return 'woof woof woof!' def eat(self, food): if "toxic" in food: return 'nom nom nom ... ...
1b886eed7ff66b2261aa3664e1ade8673bcec3bd
16030IT028/Daily_coding_challenge
/SmartInterviews/SmartInterviews - Basic/020_Sum_of_Two_Matrices.py
1,111
3.953125
4
# https://www.hackerrank.com/contests/smart-interviews-basic/challenges/si-basic-sum-of-two-matrices/problem """ Given two matrices A and B of size N x M. Print sum(A+B) of matrices(A, B). Note: Try solving it by declaring only a single matrix. Input Format First line of input contains N, M - size of the matrices. I...
4291cf47510d5fd4b896d17aedba94eb3b6583e5
alvesdealmeida/Projeto_Python_TSC_UFF
/AD1Q4.py
3,564
4.25
4
# AD1 - Questo 4 # Aluno: Sebastio Alves - So Fidelis # Subprogramas def repetir(texto, n): for _ in range(n): # Uma forma mais "pythonica" de imprimir N repeties do mesmo texto print(texto * n, end="") print(texto, end="") def espacos(n): repetir(" ", n) def hashtags(n): ...
6be22878178eb428cdb71df5a241da0de36ac16e
tommylim000/Learn-to-program-with-Python-guide
/03 - Interactive applications, buttons and input fields/local_vs_global-example.py
2,849
4.6875
5
# Local vs. Global Variables # Example # For this example, there are five versions of the same # program. Three of them work and two of them don't. The # goal of the program is to move an object along a number # line using a move method, keep track of its location # with the variable loc, and calculat...
184b9e7ff9748c321e8d068cd7db32bb16d74e26
ricardo-rolo/ccomp
/FUNDAMENTOS/Py/Conjuntos/randomcomum2.py
738
3.6875
4
# -*- coding: utf-8 -*- '''Preencher duas listas com 10 valores entre 1 e 50 aleatorios imprimir os valores que existem nas duas listas''' from random import * def preencher(): a=[] b=[] for i in range(10): x=randint(1,50) y=randint(1,50) a.append(x) b.append(y) print('Li...
b330ba0f3790f79251466055eedd962f2e7cb5f9
Babarix/poker
/brain.py
558
3.515625
4
#!/usr/bin/python # -*- coding: UTF_8 -*- import random class allIn(): """This is temporarily something which will make a player randomly leave a table.""" def __init__(self, wantToJoinAGame=True, wantToLeaveTheTable=False): self.wantToJoin = wantToJoinAGame self.wantToLeave = wantToLeaveTheT...
1570be69db03e96c1e68a312fe51f5c46f58ea9a
eunice-pereira/DC-python-fundamentals
/python102/list_1.py
554
4.25
4
# ex. 1 shopping_list = [ ['Corn','Potatoes','Tomatoes'], ['milk','eggs','cheese','yogurt'], ['frozen pizza','popsicle'] ] food = ["veggies", "dairy", "desert"] # for i in food: # print(i) # ex. 2 # Using the code from the previous exercise, # have each grouping have a title with the number in th...
534b8d504104b328c2b2f6618839ac1e71dd85be
Tapsanchai/basic_pythom
/python_basic6_dictionary.py
2,196
3.96875
4
# Dictionary | key -> value (Object Datatype) d_dic = {'id': 1, 'name': 'parew', 'grade': 3.5} print("d_dic = ", d_dic, "->", type(d_dic)) print("name = ", d_dic['name'], "\n") # add / update (ถ้ามีอยู่แล้วให้แก้ไข ไม่มีให้เพิ่มใหม่เข้าไป) new_value = {'school': 'KCC', 'city': 'yasothon'} d_dic.update({'room': '305'})...
25b8f45d1dfbff2aa0ba4ceef5e13ef38236f7eb
UnbanTwin/RPG
/RPG.py
1,332
3.703125
4
#Text Based RPG #11/08/2014 #Adrian Yong import sys import os import random import pickle import tkinter #TODO #Make start on game #Make Intro work #Naming System for saves and loads #Make a GUI so it is easily playable and aesthetically pleasing #RNG #Used for clearing Console def clear(): os.system('c...
74ec7577a15beed8601bdb0421dc22ee10acf713
njlopes/03-Quiz
/Quiz - questão de tempo.py
166
3.8125
4
print(" Qual seu time do coração?") resposta = input() if resposta == "Flamengo": print (" :) " *100) else: print(" vergonha da pôfision, " * 100)
e2b49d23784a27bb16540c7b7665694dbc0f406b
greenca/checkio
/most-wanted-letter.py
1,671
4.1875
4
# You are given a text, which contains different english letters and # punctuation symbols. You should find the most frequent letter in the # text. The letter returned must be in lower case. # While checking for the most wanted letter, casing does not matter, so # for the purpose of your search, "A" == "a". Make sure y...
075d512e741673b0cfc5436240ab67b416e1be22
EricGao2015/leetcode-using-python
/middle/PathSumII.py
1,605
3.859375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def pathSum0(self, root, sum): if root: stack = [[root, [root.val], root.val]] result = [] while stack: current, val_list, sum_val = stack.p...
0c13933c1c98520b03648fb399afe276631918d4
FelixBucket/Toontown-Movie-Maker
/funnyfarm/toonbase/FFTime.py
268
3.578125
4
from datetime import datetime date = datetime.today() month = date.month day = date.day isHalloween = False isWinter = False if month == 10 and day >= 20 and day <= 31: isHalloween = True if month == 12 and day >= 7 and day <= 31: isWinter = True
7b2a8a09daa6427b48b4bff31e982656ebb48cba
AnaGVF/Programas-Procesamiento-Imagenes-OpenCV
/Ejercicios - RepasoExamen/Ejercicio3.py
671
3.640625
4
# 3. Construye una matriz de 10x8 con números aleatorios entre 1 y 50 y # guarda en un arreglo el número y la posición de los valores que se encuentran arriba de 30. # Nombre: Ana Graciela Vassallo Fedotkin # Expediente: 278775 # Fecha: 9 de Marzo 2021. import cv2 from matplotlib import pyplot as plt import numpy...
2428329b32fd1ca78c1babc9aee1d6fe6abea8e4
praneesh12/Data-Structures-Algorithms
/DataStructures/LinkedList/.ipynb_checkpoints/reverseLL-checkpoint.py
919
4.28125
4
class Node: def __init__(self, data=None): self.data = data self.next = None class linkedList: def __init__(self): self.head = Node() def append(self, data): new_node = Node(data) cur = self.head while cur.next: cur = cur.next cur.ne...
0326d41a245fc46c9555429119ae8b6d4c360f11
taowangtu/scrapingDemo
/email_smtp_126.py
661
3.609375
4
''' 126的smtp服务器为host:smtp.126.com port: 25 用户名为xxx@126.com . 注意默认126邮箱没有开启smtp功能,需要登录126网页邮箱在设置中POP3/SMTP/IMAP 设置中开启 ''' import smtplib from email.mime.text import MIMEText mail_host="smtp.126.com" mail_user=input("请输入smtp帐号:") mail_pass=input("请输入密码:") text=input("请输入邮件内容:") msg=MIMEText(text) msg['From']=input(...
04b93fc0b094b5f13678cc9bf093de86a3b5131b
jamiejamiebobamie/CS-1.3-Core-Data-Structures
/project/CallRoutingProject_scenario3.py
3,475
4.09375
4
""" SCENARIO #3 This program builds a Trie from the routes in the routeList files at ./project/data/routeLists. For each digit of a route, a node is added to the the tree. The ancestors of a node are the digits that come before it in the route. For example, the route "+1234" appears in the tree as: ...
f3d5ad3bfd2ae03f412701e849cb8aee108f83e5
choroba/perlweeklychallenge-club
/challenge-198/sgreen/python/ch-1.py
615
3.84375
4
#!/usr/bin/env python3 import sys def main(n): gap = 0 # The maximum gap count = 0 # Number of occurrences # Sort the list n = sorted(n) # Iterate through the list for i in range(len(n)-1): diff = n[i+1] - n[i] if diff > gap: # We have a new maximum, reset ...
e87e4266ac1cfe11453b7c0f925ff6f90ab7ab47
bfan4/MyLeetcode
/117PopulatingNextRightPointersinEachNodeII.py
784
3.859375
4
""" # Definition for a Node. class Node: def __init__(self, val, left, right, next): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, root): if root == None: return if not root.left and not root.right : root.next = ...
411f5fdccde371280fd44c5990b95d59f843eb84
ppnielsen/python-learning
/complete/day021.py
1,237
4.28125
4
''' Day 21 Cup of Code tutorial Learning numpy ''' import numpy as np print(np.__version__) def one_d_arr(): ''' Converting a list of number to 1-d array ''' ls = [1, 1.25, 500, 0.5, 11, -45] print('Starting list:', ls) # Future use in algorithyms one_d = np.array(ls, dtype = int) pri...
0e0ed2271c15f026a6eb45b0d00ffe2f387eefb1
abdulwahidm/Bootcamp-Orang-Siber-X-Progate
/Python-Study/Chapter-02/07-while-lopp.py
813
4.0625
4
# Kita juga dapat menggunakan loop while untuk mengulang code. # Dengan loop while, code akan diulangi sampai kondisi tertentu, # seperti jika x <= 100 mengevaluasi False. # Sintaksis untuk loop while adalah sebagai berikut: # while <conditional expression>: # Code pada loop while akan terus berulang selama kondisi ...
9c96b8f2c242a728bd102e30a0895a702293df52
mikelmh025/CSE210
/hw2/while.py
30,940
3.59375
4
# Follow these blog posts. Build AST and plug in the ARITH language. # https://ruslanspivak.com/lsbasi-part7/ # https://rosettacode.org/wiki/Arithmetic_evaluation#Python import operator class AstNode(object): def __init__(self, opr, left, right): self.opr = opr self.l = left self.r = righ...
afcf611f2842aae953e8dff0a3cc027350391d38
xiaoxiaosasa/example
/2019-6-18/ord使用.py
164
3.640625
4
# ord函数接收一个字符串参数,返回对应的ASCII数值 print(ord('A')) #chr函数接收一个整形参数,返回对应的ASCII字符 print(chr(65))
a114a9cee174038a80e73963177774cf72db2ddf
mrgodrain/shenyu-s-house
/039pool.py
421
4.03125
4
class Turtle: def __init__(self,x): self.num = x class Fish: def __init__(self, x): self.num = x class Pool: def __init__(self, x, y): self.turtle = Turtle(x)#组合:类的实例化放到一个新类里面 self.fish = Fish(y) def print_num(self): print('水池里一共%d只乌龟,%d只鱼'%(self.turtle.num, se...
9e6ae3d690c3842e867f290324b1eb0b67062c08
trstephen/udacity-machine-learning
/datasets_questions/explore_enron_data.py
2,092
3.53125
4
#!/usr/bin/python """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features associated with that pers...
c83fe30e4d5854c372123d786a1639a9c71a1b69
hzhang123/ITest2
/itest2/core/resources.py
2,830
3.75
4
# -*- coding: utf-8 -*- import json import os class Resources(object): """ Resource management methods. Get a resource file path from a given resources directory by filename. example: schema_files = Resources("../resources/schema",".json") """ def __init__(self, base_path=".", ext=""...
8c990c3ed8d5cb7863306b4b1584f312bfd6d23b
Saturn-V/Tweet-Generator
/class_1/first_order_markov_model.py
3,166
3.515625
4
import sys import random # Takes: Clean List of words | Returns: Updated Histogram class Histogram(dict): def __init__(self, source_text_list=None): super(Histogram, self).__init__() self.types = 0 self.tokens = 0 if source_text_list: self.update(source_text_list) ...
5a166693e1944c58cd312baeca35b0f7df38cac2
xiyiwang/leetcode-challenge-solutions
/2021-02/2021-02-24-scoreOfParentheses.py
1,185
3.75
4
# LeetCode Challenge: Score of Parentheses (2021-02-24) # Given a balanced parentheses string S, compute the # score of the string based on the following rule: # * () has score 1 # * AB has score A + B, where A and B are balanced # parentheses strings. # * (A) has score 2 * A, where A is a balanced par...
78f2238d163fa243002c393c5c07d1aed02092cf
ashkhi/Python
/Week3/assignments.py
2,760
3.546875
4
''' for i in 'we are in question one': if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u': continue print(i, end="") print("\n--------------------") str = "Hello Python!\n" print(str * 10) print("--------------------\n") x = int(input()) i = 0 while x % 10 ** i != x: i = i + 1 print(i) p...
a51a452a7fccb2d4d980b98fed862e8a207b29cf
hachemhfaiedh/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
175
3.625
4
#!/usr/bin/python3 """inout/output""" def read_file(filename=""): """read n print file""" with open("{}".format(filename)) as f: print(f.read(), end="")
64e322fa135ef75cf0484cdcc8dd8cf372dbaba8
kevinelong/PM_2015_SUMMER
/wk04/reina-tamagotchi.py
5,381
3.65625
4
import random import sys import time import asciiart def activity(fn): """ Decorator for any methods that represent an activity of daily living for an animal Deals with any needs including death and sleepiness """ def deal_with_needs(animal, *args, **kwargs): return_val = fn(animal,...
57d3c10c6cc74a809fdebdcd9848ab953524e4e2
memoryleakyu/CS101
/MIT_6001/factorial.py
150
4
4
def factorial(n): if (n == 1): return 1 elif (n==0): return 1 else: return n * factorial(n-1) print(factorial(3))
c5e3548bcedd81f4981eec1692b72dad6a8dfc54
limapedro2002/PEOO_Python
/Lista_02/Marilia gabriela/questao1.py
862
3.65625
4
#valor inicial lista = [] print("QUESTIONÁRIO SOBRE UM ASSASSINATO") #código principal a = str(input("Telefonou para a vítima? (Sim ou Não): ")).lower() if 's' in a: lista.append(a) b = str(input("Esteve no local do crime? (Sim ou Não): ")).lower() if 's' in b: lista.append(b) c = str(input("Mora perto da vít...
8eb65fd511c32e16374e02e30007441674797de7
dancb10/ppscu.com
/exercies/SingleNumber.py
562
3.546875
4
from collections import Counter def single_number(nums): counts = Counter(nums) for key in counts: if counts[key] == 1: print(key) def single_number2(nums): counts = Counter(nums) list = dict((filter(lambda elem: elem[1] != 2, counts.items()))) print(list.keys()) def single...
20a2f81bdbf6561c250e424a47a575b2bf65c170
SparrowDivision/aoc2020
/day03/day3.py
786
3.59375
4
def readFile(input_name): return [l.strip() for l in open(input_name, "r").readlines()] def part1(d): x, y, tree_count = 0, 0, 0 while x + 1 < len(d): x += 1 y += 3 check_point = d[x][y % len(d[x])] if check_point == "#": tree_count += 1 return tree_count def part2(d): ...
21178de860827018b2812e175331174afe555295
MichaelShoemaker/AdventOfCode2017
/Day1/Day1-Part2.py
537
3.5
4
def make_data(file): data = open(file, 'r').read() nums = [int(i) for i in data if i != '\n'] offset = int(len(nums)/2) total = 0 for n, d in enumerate(nums): if n + offset > len(nums) - 1: if d == nums[(n+offset) % (len(nums))] and n != ((n+offset) % (len(nums)-1)): ...
a1da11a99a3a2526207b572c9aa6f91f7d63453c
eric496/leetcode.py
/graph/997.find_the_town_judge.py
1,908
3.890625
4
""" In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies properties 1 and 2. You are...
c33f631baaf7d1aea8ac6d561377b143af59fef5
elianamsf/suicide-data-science
/tratamento_coding.py
734
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 27 15:14:48 2019 @author: Eliana-DEV """ import pandas as pd def encoding(file_name_imp): # Lê o csv: sep = '' base=pd.read_csv(file_name_imp, encoding = 'latin1', sep =',', engine = 'python', delimiter=',', skiprows=1) file_name_exp = s...
b86f7134072183a10696fa8afe7be8ef3920e541
OsasAzamegbe/Algorithmic-Toolbox-by-University-of-California-San-Diego
/week1_programming_challenges/week2_algorithmic_warmup/3_greatest_common_divisor/gcd.py
220
3.734375
4
# Uses python3 import sys def gcd(a, b): while b != 0: a, b = b, a % b return a # if __name__ == "__main__": # input = sys.stdin.read() a, b = map(int, input().split()) print(gcd(a, b))
4c53ba06a90bca7e4fbd1a53ad4943bc8755b8ab
vyahello/upgrade-python-kata
/kata/08/digitalize.py
716
4.4375
4
""" Your task is to convert number to reversed array of digits. 51037 -> [7, 3, 0, 1, 5] ----------------------------------- For doctests run following command: python -m xdoctest -v digitalize.py or python3 -m xdoctest -v digitalize.py For manual testing run: python digitalize.py """ from typing import List def ...
2e6f715900c6065f95de7252073753d14d48cbca
gabriellaec/desoft-analise-exercicios
/backup/user_372/ch152_2020_04_13_20_20_19_635035.py
286
3.515625
4
def verifica_preco(dic1,dic2,nome): dic1={} dic2={} nome=str(input('Qual o título do livro que você deseja consultar o preço? ')) while nome in dic1.keys(): cor=dic1['nome'] if cor in dic2.keys(): preco=dic2[preco] return preco
bc95c0d5b8f8c0eae9f816f143b27537e42389e9
people-robots/SafeNavigationHumanExperiments
/test.py
5,483
3.546875
4
#!/usr/bin/python3 from Polygon import Polygon import numpy as np from Human import Human import Geometry import math # test of polygon definition and line detection polygon_1_list = np.array([[2,10],[12,10],[12,4]]) polygon_2_list = np.array([[2,5],[7,5],[7,4],[9,4],[9,3],[2,3]]) line_1 = np.array([[10,0],[10,10]])...
09248247eab4fa160a9d97b254eb3364880afb09
akulahemasanthoshidaughterofmurty/python
/Kth Smallest Number.py
172
3.78125
4
n=input() number=int(input()) str1=n.split(",") for i in range(len(str1)): str1[i]=int(str1[i]) #str1=sorted(str1,reverse=True) str1=sorted(str1) print(str1[number-1])
4dccec1fc1cdbf60b4a9c43e99c83393257a3d60
ITlearning/ROKA_Python
/2021_03/03_22/CH06/014_Except02.py
336
3.578125
4
# 여러 가지 예외가 발생할 수 있는 코드 list_number = [52,273,32,72,100] try: number_input = int(input("정수 입력 > ")) print("{}번째 요소: {}".format(number_input, list_number[number_input])) except Exception as exception: print("type(exception):", type(exception)) print("exception:", exception)
c8c3af92e4572a954c3e99fdac40431824f98165
Kailashcj/tpython
/hackerrank/geeks/rotate_word.py
375
3.90625
4
#!/bin/python3 def rotate_words(words, num): rota = '' for c in words: newnum = ord(c.lower()) + num if newnum <= ord('z'): rota += chr(newnum) else: rota += chr(ord('a') + newnum - ord('z') - 1) return rota if __name__=='__main__': words = input() ...
1f1426d2db003283ef653c1de7f57609a4f75700
everlasting-neverness/async-python
/5_asyncio_async_await.py
861
3.828125
4
import asyncio # python 3.4 syntax @asyncio.coroutine def print_nums(): num = 1 while True: print(num) num += 1 yield from asyncio.sleep(0.1) # python 3.5 syntax async def print_time(): count = 1 while True: if count % 3 == 0: print('{} seconds have passed'...
7e1e3a1965310a4acb5e471bc1db34c091e225e9
crystal-mullins/fsw-200
/week2/mathGame/oddEven.py
497
4.1875
4
num = int(input("Enter a number: ")) if (num % 2) == 0: print("{0} is Even".format(num)) else: print("{0} is Odd".format(num)) if (num % 4) == 0: print("{0} is a multiple of 4".format(num)) else: print("{0} is not a multiple of 4".format(num)) num1 = int(input("Enter a number: ")) check = int(input("Ent...
9dfe486a0f9ad000f5bf3e2fa4ad34a32f3b64b6
code-drops/coding-ninjas
/Basics of data science and machine learning/4. Strings , List and 2D list/9. highest occuring character.py
440
4.125
4
'''Given a string, S, find and return the highest occurring character present in the given string. If there are 2 characters in the input string with same frequency, return the character which comes first. Note : Assume all the characters in the given string are lowercase.''' s = input() d = {} for i in s: ...
207b10e50f014ad21deaeee83beef3cc8a9367a3
chrishuan9/oreilly
/python/python1homework/inputter.py
1,703
4.25
4
__author__ = 'chris' """ Lab 9, Objective 1: This project tests your ability to use file objects. 1.Create a new Python source file named inputter.py. 2.Write a program that uses a while loop to accept input from the user (if the user presses Enter, exit the program). 3.Save the input to a file, then print it. 4.Upon ...
32a00cd2b710d28317f67e50d0fdb1aa3d8ec572
ShounakNR/DeepLearningECE579
/DL-HW1-KNN-classifier/hw1-q1.py
1,224
3.953125
4
import numpy as np X= np.array([[0,1,0],[0,1,1],[1,2,1],[1,2,0],[1,2,2],[2,2,2],[1,2,-1],[2,2,3],[-1,-1,-1],[0,-1,-2],[0,-1,1],[-1,-2,1]]) # make X as an array of 12x3 dimension with the training data. first 4 entries are A, next 4 are of B and the last 4 are of C. Y = np.array([[1],[1],[1],[1],[2],[2],[2],[2],[3],[3],...
c1184fd038fbf3be513c7e5a28dda7a5990f21b7
Srinjana/CC_practice
/MISC/ACCENTURE/caesarcipher.py
1,070
4.0625
4
# Vaibhav protected his confidential information by encrypting it using a cipher. This Cipher shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. # In the case of a rotation by 3, w, x, y and z would map to z, a, b and c. # Ori...
6314882cbe9e11ff2b8d10b9edaef02c09c73fab
aurimrv/src
/aula-12/doctest/ex2-distancia_euclidiana.py
1,541
4.4375
4
#Ex2: Podemos usar vetores para representar pontos num espaço de dimensões N # quaisquer. Por exemplo, o vetor [1, 2] pode representar o ponto x=1 e y=2 # num espaço plano, ou [1,2,3] o ponto x=1, y=2 e z=3 num espaço tridimensional. # # Sejam A e B dois vetores com N elementos cada, representando ponto...
c6c677cc2a292818a0118ded653ad2c59a4b48c6
avanicolex/pythonpractice
/firstprogram.py
1,680
3.921875
4
#This is a comment #print writes to console print('kajfkldj') ## name the variable, set it with = myName = "ava" up = 2 low = 2.4 isTrue = True ## if condition ## = means "set this to" ## == means "if these two are equal" or "is equal to" ## one tab to do what you want to do if the condition evaluates true if myName =...
fa2cb2987a4d832a24c243e1afda343d7683cfc3
AllenAnZifeng/leetcode
/Leetcode/6. ZigZag Conversion.py
3,234
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @author: Allen(Zifeng) An @course: @contact: anz8@mcmaster.ca @file: 6. ZigZag Conversion.py @time: 2020/1/22 20:45 ''' from functools import reduce # class Solution: # def convert(self, s: str, numRows: int) -> str: # res= ['']*numRows # index, m...
2c7f94b92051b02fe90af6cca2d69167db28b2e4
wo-ist-markt/markt-server
/osm_time/__init__.py
641
3.59375
4
def get_minutes_from_midnight(value): """ Return number of minutes from a hh:mm """ hours, minutes = value.split(':') return int(hours)*60 + int(minutes) def clean_value(value): """ Attempt to clean a value (value being an opening hours string) """ value = value.lower().strip() ...
c6f3cbae94a7fe01e426bb8da95144049f5effd3
sidharthmg/rpsgame
/rps.py
1,162
4.28125
4
import random print("Winning rules of the game are as follows\n" "Rock vs paper->paper wins\n" "Rock vs scissor->rock wins\n" "paper vs scissor->scissor wins\n") def comp_ch(num): if num==1: return "rock" elif num==2: return "paper" elif num==3: ...
4913e1e8990ca1521d917adb86242d8087731a04
Neha-kumari200/python-Project2
/sumdict.py
238
4.125
4
#Python program to sum of all items in a dictionary def findSum(dict): sum = 0 for i in dict.values(): sum = sum+i return sum dict = {'a': 100, 'b': 200, 'c': 300} print("Sum of all items in dictionary:",findSum(dict))
0ed5d500aa8b890d0255bb85fdf5d0962b101969
SakuraGo/leetcodepython3
/P3/Solu5139.py
701
3.59375
4
# 5139. 第 N 个泰波那契数 显示英文描述 # # 用户通过次数 0 # # 用户尝试次数 0 # # 通过次数 0 # # 提交次数 0 # # 题目难度 Easy # # 泰波那契序列 Tn 定义如下: # # # # T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 # # # # 给你整数 n,请返回第 n 个泰波那契数 Tn 的值。 # 输入:n = 4 # 输出:4 # 解释: # T_3 = 0 + 1 + 1 = 2 # T_4 = 1 + 1 + 2 = 4 class Solution: def tribonacci...
5e05fba18ec65ea9f45e7c465aeb44486a22f473
rakeshgunduka/Python-Workshop
/Day2/mut_immut_func.py
2,067
4.46875
4
''' If you pass a mutable object into a method, the method gets a reference to that same object and you can mutate it to your heart's delight, but if you rebind the reference in the method, the outer scope will know nothing about it, and after you're done, the outer reference will still point at the original objec...
49ac99e50e8178d4879b801dfdb55e61aeebffb3
Jane-Zhai/LeetCode
/easy_hash_290_wordPattern.py
1,109
3.5625
4
class Solution: def wordPattern(self, pattern, str): """ 给定一种 pattern(模式) 和一个字符串 str ,判断 str 是否遵循相同的模式。 """ dic1 = dict() dic2 = dict() string = str.split() for i,p in enumerate(pattern): # if p not in dic: # dic[p]=string[i] ...
5361daed1f71345a5059a2d857a2b59bdb27d475
GusRigor/Sistema-e-Sinais
/Atividade 3/aula3.py
1,594
3.796875
4
#exemplo de aplicacao de integracao numerica Runge Kutta import math import matplotlib.pyplot R = int(input('Resistência (ohms): ')) L = float(input('Indutância (Henrys): ')) C = float(input('Capacitância (Farads): ')) X = 10.0 Y = 0.0 Z = 0.1 h = 0.001 T = 0 rk11 = 0 rk12 = 0 rk13 = 0 rk14 = 0 rk21 = 0 rk22 = ...
592f7ea2d3933af30c354ff6fb338d2f9f094319
LauraBrogan/pands-project-2019
/Iris.py
723
4.4375
4
#Initial Python Code to Just get the first ten lines of the data set returned to screen. #To start I import pandas as pd import pandas as pd #Identify data as pandas reading the csv file. data = pd.read_csv ("https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/d546eaee765268bf2f487608c537c05e22e4b221/i...
c90c4ba206ae8f738a6b4e434082b9e5301d1d1e
KPH3802/Python_Ramen
/PyRamen.py
1,563
3.703125
4
import csv # Build an empty list to hold menu items menu = [] # Open and read through each line of csv, appending row to menu list with open ("Resources/menu_data.csv") as csvfile: reader = csv.reader(csvfile, delimiter = ',') header = next(reader) for i in reader: menu.append(i) # Build an empty...
bef33f7afd6ee46ef3b222e3d1ec428d41bcfc8f
yz5308/Python_Leetcode
/Algorithm-Easy/28_Implement_strStr().py
844
4
4
class Solution: def strStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype: int """ for i in range(len(haystack) - len(needle) + 1): if haystack[i:i + len(needle)] == needle: return i return -1 if __name__...
025a478b6e3cb871cf278954d57b79c70003f6f8
arnabs542/Leetcode-18
/743. Network Delay Time.py
1,766
3.59375
4
class Solution: def networkDelayTime(self, times: List[List[int]], N: int, K: int) -> int: dist_dic = {} for u, v, w in times: if u not in dist_dic: dist_dic[u] = {} dist_dic[u][v] = min(w, dist_dic[u].get(v, float('inf'))) dist = {n:...
4083aaa4253f748582732427733b04542615b340
mk-dir/classifiles
/tuple.py
998
3.53125
4
# names=(1,2,3,4,["a",[1,2]]) # # print(names[4][0]) # # user={"first_name":"Alex", # "last_name":"Chamwada", # "show":"Daring Abroad", # "employees":["Mouse","Mickey","Rongai","Tao"], # "schools":{"Nursery":"chekechea", # "Primary":"mahali", # "secondary":"Chavakali"}} #...