blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
2ad7197fd85f713b16fece5d7253bb4a4bd8b606
JuanSaldana/100-days-of-code-challenges
/day-19/turtle_race.py
1,638
4.125
4
from turtle import Turtle, Screen, colormode from random import randint colormode(255) def set_random_color(turtle: Turtle): r, g, b = randint(0, 255), randint(0, 255), randint(0, 255) turtle.color((r, g, b)) def setup_race(n): turtles = [] screen_size = screen.screensize() step = screen_size[1...
200d02725f7f7564ff49209b6a50e9096f8bbf40
wackywendell/ipycurses
/basicsequence.py
4,318
3.765625
4
import collections import exceptions class BasicSequence(collections.Sequence): """A class that uses an abtract _get(loc) command to implement a __getitem__. Used as a base class, one can write a _get(loc) method, and slices will automatically be supported (returning lists). Full req...
49d4b93c7748e98ded4c8fcfb9a636c2abcb3532
Daria-Zay/skillfactory_rds
/module_0/GitHub_Project0.py
2,894
3.8125
4
#Author Daria Zaytseva #Guess the number # Проект GitHub 0.Быстрый старт # Author Daria Zaytseva # Guess the number # Программа "Угадай число!" import numpy as np import random def game_core_v_by_DZ(number): count = 1 # счетчик попыток begin = 1 # нижняя гр...
1e2404e9c9a27a336a91eafb1a38d7f58eb6e378
RNaveen99/Machine-Learning
/linearRegression.py
2,427
3.640625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split def init(): dataset = pd.read_csv('headbrain.csv') X = dataset['Head Size(cm^3)'].values Y = dataset['Brain Weight(grams)'].values X_train, X_test, Y_train, Y_test = train_test_s...
d2c04420c6cfc0fe30f518d69750e87754b8c912
parvej35/Programming-with-Python
/5_Complementing_a_Strand_of_DNA.py
985
4.03125
4
# http://rosalind.info/problems/revc/ DNA_MOLECULES = ["A", "T", "C", "G"] MOLECULES_REPLACING_DICT = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'} def replace_dna_molecules(dna_sequence): dna_seq_list = [] for i in dna_sequence: dna_seq_list.append(MOLECULES_REPLACING_DICT[i]) return ''.join(dna_seq...
026aead2ba555ccbc5bf998da594bf71899dbf93
Mitjaje/test
/test.py
377
3.953125
4
my_name = "Matej" print(my_name) print("My name is " + my_name) print("My name is %s" % my_name) name = raw_input("Please enter your name: ") print("Howdy, %s" % name) if name == "Mitja": print("Hello Mitja") kakosi = raw_input("Kako si?") print("Vidim da si %s" % kakosi) else: print("Hello %s" % nam...
f819f63a534793fc156955e3f5e1a10990306ce9
jamesdeal89/Chatbot-SortSearchLibrary
/sortSearch.py
3,820
4.21875
4
# sorting and searching functions import random class Sort(): """ a sorting class containing sorting for bubble, merge, heap and quick """ def __init__(self): pass def bubble(self, myList): """ function for bubble search. simply swaps adjacent values if they're ordered wrong """ len...
2f670bc211c79e26693e10e99a95c01a5b5ebd05
anassfresco/data-structure
/closet_node.py
806
3.515625
4
def closest_point(self,target): max=sys.maxsize target2=None actual_node=self.tree while actual_node is not None and actual_node.data!=target: target2, max = self.comparaison(actual_node, target, max,target2) if target>actual_node.data: actual...
377d0b269cdfe22e8895b5dc4e6a471e8d9a270c
kltjrcks/move_test
/1110/1110.py
565
3.515625
4
import sys def split_inputNum(number): if number < 10: f = 0 e = int(number) f = int(number / 10) e = int(number % 10) return f, e def make_newNum(first, end): new = first + end f, e = split_inputNum(new) result = end * 10 + e return result ori_number = int(sys.st...
cd24eca138df2d77db82c131f7a0721b7fa4b800
kltjrcks/move_test
/programmers/pSolution24.py
218
3.625
4
# -*- coding : utf-8 -*- # 정수 제곱근 판별 import math def solution(n): num = math.sqrt(n) if num - int(num) == 0: return math.pow(num + 1, 2) else: return -1 print(solution(121))
d973cc41b571fc8b04c3308227039910688cff3e
kltjrcks/move_test
/programmers/pSolution25.py
362
3.546875
4
# -*- coding : utf-8 -*- # 최대공약수와 최소공배수 def solution(a, b): answer = [] ansMin = 0 ansMax = 0 for i in range(1, a+1): if a % i == 0 and b % i == 0: ansMin = i ansMax = (a // i) * (b // i) * ansMin answer.append(ansMin) answer.append(ansMax) return answer pr...
a320ddc31841ebc6ea08ac43c0a475c6e71ab558
kltjrcks/move_test
/programmers/pSolution2.py
329
3.671875
4
# -*- coding : utf-8 -*- #두 정수 사이의 합 def solution(a, b): answer = 0 count = 0 if a == b: answer = a elif a < b: count = b - a + 1 answer = (a + b) * count // 2 else: count = a - b + 1 answer = (a + b) * count // 2 return answer print(solution(5,3))
e5ad7640bcdfadab08030ce4749b97ddc4a4744c
willyowi/python-intro
/Fissbuzz.py
212
3.65625
4
list_b=list(range(1,101)) for i in range(1,101): if i%3==0 and i%5==0: print("fzzBuzz") elif i%3 ==0: print("buzz") elif i%5 ==0: print("fzzz") else: print("none")
cb0fd70666a65c04f70c2d492df45485252663c3
willtrinh/School
/cs121/Project1/PartA.py
1,751
3.75
4
""" Name: Will Trinh ID: 17986840 Assignment 1 - Text Processing Functions Part A: Word Frequencies April 18, 2018 """ import re, sys, time, os # import system functions, regular expression, time, and misc. operating system modules from collections import Counter # import counter to count word fr...
065150bc68efd85c35963c64afb92bfe6a986120
willtrinh/School
/cs178/hw1/hw1.py
488
3.578125
4
import numpy as np import matplotlib.pyplot as plt iris = np.genfromtxt("data/iris.txt",delimiter=None) # load the text file Y = iris[:,-1] # target value (iris species) is the last column X = iris[:,0:-1] # features are the other columns # Note: indexing with ":" indicates all values (in this case, all rows); # index...
422c99b8822f5846fd6c1cf6eccb65b990f517ef
nikhil-kolangara/ENPM-661---Project-2
/codes/Dijkstra_rigid.py
15,342
4.0625
4
""" ENPM 662 : Planning for Autonomous Robotics Project 2 : Dijkstra Algorithm for path finding and traversing for a rigid robot with Radius of robot and clearance with obstacle Team Members : Sukoon Sarin, Nikhil Kolangra """ import numpy as np import pygame from pygame import gfxdraw import math import time ...
47bea29a40c6b9d417e8909c08bedf0c38cb9043
illoh-py/MonsterGame
/lab4main.py
6,729
3.59375
4
#Mark Boady and Matthew Burlick #Drexel University 2020 #CS 172 import random import time ## TODO: import CustomMonster class here from monster import CustomMonster def driver(): ## TODO: Get first monster's name, health, description, basicAttackDamange, specialAttackDamage, defenseDamage, defenseName he...
8412be3158ced9cda22b82984ba0b2296c3da8a2
jsculsp/python_data_structure
/11/buildhist.py
1,361
4.25
4
# Prints a histogram for a distribution of the letter grades computed # from a collection of numeric grades extracted from a text file. from maphist import Histogram def main(): # Create a Histogram instance for computing the frequencies. gradeHist = Histogram('ABCDF') # Open the text file containing the grades....
4d79e76fceb858235da96274f62274bd8bc9fa7a
jsculsp/python_data_structure
/2/gameoflife.py
1,548
4.25
4
# Program for playing the game of Life. from life import LifeGrid from random import randrange # Define the initial configuration of live cells. INIT_CONFIG = [(randrange(10), randrange(10)) for i in range(50)] # Set the size of the grid. GRID_WIDTH = 10 GRID_HEIGHT = 10 # Indicate the number of generations. NUM_GEN...
7b37bb7acc6c035aaeb649d750983ec9af284bdc
jsculsp/python_data_structure
/8/priorityq.py
1,346
4.1875
4
# Implementation of the unbounded Priority Queue ADT using a Python list # with new items append to the end. class PriorityQueue(object): # Create an empty unbounded priority queue. def __init__(self): self._qList = list() # Return True if the queue is empty. def isEmpty(self): return len(self) == 0 # Re...
a42d02f63a03c287dde78549413d3231468549ba
brucehzhai/Python-JiangHong
/源码/Pythonpa/ch13/squareDone.py
534
3.78125
4
import turtle import time #定义绘制时画笔的颜色 turtle.color("purple") #定义绘制时画笔的线条的宽度 turtle.pensize(5) #定义绘图的速度 turtle.speed(1) #以0,0为起点进行绘制 turtle.goto(0,0) #绘出正方形的四条边 for i in range(4): turtle.forward(100) turtle.right(90) #画笔移动到点(-150,-120)时不绘图 turtle.up() turtle.goto(-150,-120) #再次定义画笔颜色 turtle.co...
9745a3573f7e6b949f9c4ee6bdc291f1e671eb86
brucehzhai/Python-JiangHong
/源码/Pythonpa/ch03/if_seg.py
812
3.578125
4
import math x=-1 y = math.sin(x) + 2 * math.sqrt(x + math.exp(4)) - math.pow(x + 1, 3) if (x<0): y = math.log(-5 * x) - math.fabs(x * x - 8 * x) / (7 * x) + math.e print(y) #或两句单分支语句: if (x>=0): y = math.sin(x) + 2 * math.sqrt(x + math.exp(4)) - math.pow(x + 1, 3) if (x<0): y = math.log(-5 * x) - mat...
8f7d5896ecab00fb03e73bea7a2ef49fbeb13095
brucehzhai/Python-JiangHong
/源码/Pythonpa/ch01/hello1.py
263
3.625
4
import random #导入库模块 #print("Good Luck!") #输出:Good Luck! print("Hello, World") #输出:Hello, World print("你今天的幸运随机数是:", random.choice(range(10))) #输出从0到9之间随机选择的数 input() #等待用户输入
7e2da885ca014026620bfb38664bba21d8a5f2c4
brucehzhai/Python-JiangHong
/源码/Python课后上机实践源代码/ch11-算法与数据结构基础/P11-prg-22-集合SetAB.py
443
3.765625
4
import random A=set() for i in range(10): A.add(random.randint(0,10)) #随机产生一个0~10的整数,添加到A B=set() for i in range(10): B.add(random.randint(0,10)) #随机产生一个0~10的整数,添加到B print("集合的内容、长度、最大值、最小值分别为:") print(A,len(A),max(A),min(A)) print(B,len(B),max(B),min(B)) print("A和B的并集、交集和差集分别为:") print(A|B,A&B,A-B...
9faf065c45733ad7384a94feaf65a5c76afd9495
brucehzhai/Python-JiangHong
/源码/Pythonpa/ch08/my_max1.py
172
3.75
4
def my_max1(a, b): if a > b: print(a, '>', b) elif a == b: print(a, '=', b) else: print(a, '<', b) my_max1(1, 2) x = 11; y = 8 my_max1(x, y) my_max1(1)
a169d85e34677ae59ee323ebeefe50834f4af171
brucehzhai/Python-JiangHong
/源码/Python课后上机实践源代码/ch5-系列数据类型/P5-prg-1-单词统计.py
320
3.75
4
Number = 0 #统计单词个数 word = False #判断是否是单词 strs=input("请输入字符串:") for i in range(len(strs)): ch=strs[i] if (ch == ' '): word = False elif (not word): word = True; Number+=1 #print("字符串为:", strs); print("其中的单词总数有:", Number)
9152e3e2c998b65648bfe1b7e72ff6d6f4df99b6
georgi0u/TheFundamentals
/problems/_books/the_algorithm_design_manual/03_data_structures/03_23/solution.py
4,904
4.25
4
#!/usr/bin/env python2.7 """ A toy module for demonstrating and playing around with some linked list operations. """ import os import sys class LinkedList(object): """ An incomplete LinkedList class implementation for playing around with some algorithms. """ class Node(object): """ ...
71b4560498b49c6abbe38c2c31c5fed073248d10
evasey/smartninja_homework_6
/moodchecker.py
321
3.875
4
mood = input("How are you? ") if mood == "happy": print("Share it with the world! Laugh out loud!") elif mood == "sad": print("You are not alone. It can really get " "hard for you to get out of such conditions. " "But it is not permanent.") else: print("I don't recognize this mood"...
9376497c4e26fbb96d6719c7e6d67ff04529618b
YogeshSingla/cnl
/final/lab_nov_2/bellman_ford.py
3,167
3.75
4
# Computer Networks Lab Assignment # Routing # author: yogesh (kirito) import random as r import math MAX_X = 100 MAX_Y = 100 MIN_X = 0 MIN_Y = 0 NUM_NODES = 8 INF = 999999 def create_node(): x = int(r.random()*(MAX_X-MIN_X) + MIN_X) y = int(r.random()*(MAX_Y-MIN_Y) + MIN_Y) return [x,y] def weights(n1,n2): sq...
f7bcd331bb6d6f09f9aee48a11b19485d1590a41
kevklash/pyTest
/main.py
3,000
4.3125
4
# Python Basics # Tips: ''' Multiline comment ''' # Print type: print(type(variable or value)) def basics(): name = input("Enter your name:\n") print(f'Welcome {name}!') def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggl...
ae1fd2db86e6224453a3834d9ac6674aca0c1338
eduardo-zepeda-j/pruebas-python
/listaEnListaX.py
2,199
3.78125
4
class NodoCabecera(): def __init__(self,posX): self.posX = posX self.next = None self.down = None class NodoLista: def __init__(self,data): self.data = data self.down = None class ListaCabecera: def __init__(self): self.head = None self.down ...
356eab53c45ec5170aeeba0eb6e2c52f8d545c79
daid3/PracticeOfPython
/201801/180130NumPy.py
565
4
4
# !/usr/bin/env python # encoding: utf-8 __author__ = 'Administrator' ###### Sum of vector a and vector b # #### Using Pure Python: # def pythonsum(n): # a=range(n) # b=range(n) # c=[] # # for i in range(len(a)): # a[i]=i**2 # b[i]=i**3 # c.append(a[i]+b[i]) # # return c...
f3ea0baef94bdbab0374f984eecaa1204b7205b5
daid3/PracticeOfPython
/201802/180212Quadratic.py
4,338
3.859375
4
# !/usr/bin/env python # encoding: utf-8 __author__ = 'Administrator' #quadratic.py 二次方程式 #计算二次方程的实数根程序 #此程序在方程没有实数根的情况下报错 import math def main(): print("This program find the real solution to a quadratic\n") a,b,c=eval(input("Please enter the coefficients (a,b,c):")) discRoot=math.sqrt(b*b-4*a*c) root...
c83fe07fcf908618d2c1659fcecd53d7f65fa16e
daid3/PracticeOfPython
/201802/180219CalculateBMI.py
1,808
4.1875
4
#By 000 ####本程序计算BMI(Body Mass Index 身体质量指数) ##Python分支的应用:编写一个根据体重和身高计算并输出 BMI值的程序,要求同时输出国际和国内的BMI指标建议值。 # 分类 | 国际BMI值(kg/m^2) | 国内BMI值(kg/m^2) # 偏瘦 | < 18.5 | <18.5 # 正常 | 18.5~25 | 18.5~24 # 偏胖 | 25~30 | 24~28 # 肥胖 | >=30 | >=28 #emmmmm ...
740cb7bc4bd7ba52c7fc4e93458310faedb75a04
daid3/PracticeOfPython
/201803/180306OOExample.py
2,447
4.125
4
# !/usr/bin/env python # encoding: utf-8 __author__ = 'Administrator' #------------面向对象程序设计的例子 #铅球飞行轨迹计算 #铅球对象的属性:xpos,ypos,xvel,yvel #构建投射体类 Projectile #创建和更新对象的变量 from math import * #Projectile类: class Projectile: def __init__(self,angle,velcity,height): #根据给定的发射角度、初始速度和位置创建一个投射体对象 self.xpos=0.0 ...
49cedb6b77e3d94355eb7d6681c97392ab2a1c6f
daid3/PracticeOfPython
/201802/180223FuncExample.py
7,151
4.21875
4
###########5.3 函数实例分析 #turtle 库是非常适合初学者使用的简单图形绘制模块。 #自Python2.6版本以后,turtle库就已经成为Python的内嵌模块,无需特别安装。 #turtle中的指令,形象而简单,它绘制的坐标轴以屏幕中心点为原点。 # |y # | # | # ----------------小乌龟--------------------> x # (0,0) |(头朝右即x轴正向) # | # ...
7ea4d9c2d3220f68fc85e11d32f36f34168d3049
Gaonuk/IIC2233-Gaonuk
/Actividades/AC04/excavadores.py
1,861
3.65625
4
from threading import Thread, Lock from utils import reloj import random lock_global = Lock() class Excavador(Thread): def __init__(self, nombre, berlin, tunel): super().__init__() self.nombre = nombre self.tunel = tunel self.berlin = berlin def run(self): ...
fc47e348f79fd432cb9c5a59fe0d1e29b2ce937f
Gaonuk/IIC2233-Gaonuk
/Actividades/AC02/bonus.py
1,380
3.65625
4
""" Aquí debes completar las funciones del Bonus ¡OJO¡: Puedes importar lo que quieras aquí, si no lo necesitas """ TECH_KEYS = { 'Piso -1': ['red', 'yellow', 'blue', 'purple', 'blue', 'purple', 'green', 'red', 'orange'], 'Piso -2': ['black', 'pink', 'blue', 'green', 'green', 'orange', 'grey', 'red', 'y...
1b6b0b72c1e291e78c8c0c6a0b108e5263c47205
kbetoacero/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
141
4.03125
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): find = [n if n != search else replace for n in my_list] return find
97dc32127f83a02a119ae527a1d26dfcec337e13
kbetoacero/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
241
3.953125
4
#!/usr/bin/python3 """ Function thar reads a file """ def read_file(filename=""): """ read a text file (UTF-8) and print to stdout """ with open(filename, encoding="UTF-8") as my_file: print(my_file.read(), end="")
86987b9e8776b8bd303cd905e747818ebaad47bc
mr-devansh/WEATHER-ANALYSIS-USING-PANDAS
/WEATHER ANALYSIS PANDAS/main.py
1,107
3.796875
4
# with open("weather_data.csv") as data_file: # data = data_file.readlines() # print(data) # import csv # with open("weather_data.csv") as data_file: # data = csv.reader(data_file) # temp = [] # for row in data: # if row[1] != "temp": # temp.append(int(row[1])) # prin...
f9edad113367caa0cc86374001b36dd227d63a1c
davidhammaker/logs_analysis
/logs_analysis.py
6,449
4.125
4
#!/usr/bin/env python3 """ This code performs an analysis on a database of HTTP request logs on from a news website. The code uses psycopg2 as its PostgreSQL adapter. The code contains three functions, each of which performs a single SQL query. The results of these queries are printed to the console. """ import psycop...
8a4d4fe646f6c71243c99df314f218232026ff40
davidpluseipi/python
/fizz_buzz/fizz_buzz.py
157
3.90625
4
def fizz_buzz(): number = int(input("Input any integer:")) if number % 3 == 0: print("fizz") if number % 5 == 0: print("buzz")
3be188e6e2a12bf6ff319980a0e74d3a28108be6
davidpluseipi/python
/variables_and_keywords/variables_and_keywords.py
597
3.515625
4
# Variables are like boxes or containers you store stuff in. # Variable names are the labels on the boxes. # Valid variable names can contain only letters, numbers, and underscores apple = 5 user_input12 = "Name" output_3 = user_input12 # Avoid Python keyword and function names, like... # # and, as, assert, break, ...
e0d85b34dcb675a2769b24258401913fc57308b7
abdiswork/Data-Science
/career-track/Python for Data Professional/Part1/decision1.py
391
3.890625
4
x = 4 if x % 2 == 0: print("x habis dibagi dua") x = 7 if x % 2 == 0: # jika sisa bagi x dengan 2 sama dengan 0 print("x habis dibagi dua") elif x % 3 == 0: # jika sisa bagi x dengan 3 sama dengan 0 print("x habis dibagi tiga") elif x % 5 == 0: # jika sisa bagi x dengan 5 sama dengan 0 print("x habis dibag...
1f63a67218e6a28289865ac063148453ea9d8dca
wk1984/ccc-gistemp
/code/step3.py
10,398
3.734375
4
#!/usr/bin/env python # $URL$ # $Rev$ # # step3.py # # David Jones, Ravenbrook Limited, 2008-08-06 """ Python code reproducing the STEP3 part of the GISTEMP algorithm. """ import earth # required for radius. import eqarea import giss_data import parameters import series from giss_data import MISSING, valid, invalid ...
023201b3c853a7e6d392df880f2921fd02e48d6b
nefta1937/memoria
/src/funciones.py
9,425
3.5
4
import math import os from io import open '''Función para elegir dato a mandar''' def DatoPWM(xf,yf,xr,yr,xo,yo,c,ConsMo): AlpR = math.degrees(math.atan2((yo-yr),(xo-xr)))*-1 if AlpR >= 0: AlpR = AlpR else: AlpR = 360 + AlpR AlpRP = math.degrees(math.atan2((yf-yr),(xf-xr...
ac0ca45de03da9e85d16cbd00e07595e92ceb8cc
Ethan2957/p02.1
/fizzbuzz.py
867
4.5
4
""" Problem: FizzBuzz is a counting game. Players take turns counting the next number in the sequence 1, 2, 3, 4 ... However, if the number is: * A multiple of 3 -> Say 'Fizz' instead * A multiple of 5 -> Say 'Buzz' instead * A multiple of 3 and 5 -> Say 'FizzBuzz' instead The function f...
68e04e2709304b3ea9f8d16ebc22c009496c198f
fabiiogomes/exerciciospy
/exercicios/010.py
175
3.625
4
#Converter real em dolar real = float(input('Quanto dinheiro você tem? R$')) dolar = real / 3.69 print('Olá, com R${:.2f} você pode comprar US${:.2f}'.format(real, dolar))
d2450b2c7eb3616fb2982ce2407b6e65820c9223
fabiiogomes/exerciciospy
/exercicios/011.py
423
3.90625
4
#área de uma parede e quantidade de tinta sabendo que cada litro pinta uma área de 2m² larg = float(input('Digite a largura da parede: ')) alt = float(input('Digite a altura da parede: ')) área = alt * larg tinta = float(área / 2) print('Sua parede tem a dimensão de {:.2f}x{:.2f} e sua área é de {:.3f}m²'.format(larg,...
7307669144fb61678697580311b3e82de4dc9784
sujoy98/scripts
/macChanger.py
2,495
4.34375
4
import subprocess import optparse # 'optparse' module allows us to get arguments from the user and parse them and use them in the code. # raw_input() -> python 2.7 & input() -> python3 # interface = raw_input("Enter a interface example -> eth0,wlan0 :-") ''' OptionParser is a class which holds all the user input ...
b70c7c3407f3f2cc808b10da3f96761f3803e281
heramareh/test
/src/test3.py
5,158
3.671875
4
#encoding=utf-8 # def get_str_length(s): # num = 0 # for i in s: # num += 1 # return num # # print get_str_length('abcde') # import string # import time # # def isLower(s): # "判断字符是否是小写" # if s in string.ascii_lowercase: # return True # else: # return False # # def ...
83cd7e49661b458a81b825edf27ead0185017735
tlee10/dataStructures
/trie.py
2,212
3.828125
4
class Trie: def __init__(self): self.root = Node("!") def insert(self, word): node = self.root for i in range(len(word)): if node.links[ord(word[i]) - 97] == None: node.links[ord(word[i]) - 97] = Node(word[i]) node = node.links[ord(word[i]) - 97] ...
b3ccaee062de1a1701e4376c17af80b4f8450606
robot-tutorial/robotics_tutorial
/python/loop.py
542
4.15625
4
# range for i in range(10): print(i, end=' ') # 取消换行 for i in range(5, 10): print(i, end=' ') for i in range(5, 10, 2): print(i, end=' ') # loop over a list courses = ['Calculus', 'Linear Algebra', 'Mechanics'] # low-level for i in range(3): print(courses[i]) # advanced for course in courses: pri...
ce376791feee82fa16230b955d04c3386f200f78
robot-tutorial/robotics_tutorial
/python/numpy1.py
133
3.609375
4
import numpy as np a = np.array([[1, 2], [3, 4]]) print(a) print(a[0, 0]) a = np.arange(6).reshape([2,3]) print(a) print(a[:, 1])
a8390cbfbbc88df572beaabde6901bdf01aa9bea
ibrahim-ctrl/AMCC-DESKTOP-Ibrahim
/pertemuan4.py
818
3.703125
4
# dict = {'mangga':'5 kg', 'jeruk':'10 kg', 'mangga2':'rp 10.000', 'jeruk2':'rp 1.000'} # print ("andi beli mangga:",dict['mangga'],",jeruk :",dict['jeruk']) # print ("Harga Mangga:",dict['mangga2']) # print ("Harga Jeruk:",dict['jeruk2']) # def salam(): # print ("Hello") # salam() # def hitung(alas, tinggi): #...
b9fe07b6448a8bdfdc4a45615d303034929488f3
AlexanderHarry/CCI
/main.py
711
3.703125
4
import random chapters = ['VI : Big O', 'VII : Technical Questions', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17'] questions = {'VI : Big O': 12, 'VII : Technical Questions': 4, '1': 9, '2': 8, '3': 6, '4': 12, '5': 8, '6': 10, '7': 10, '8': 14, '...
f302e2bc0fade22feb42e70367983747f740df60
Julian21A/Python-HackerRank-Challenges-Medium
/Word Order.py
213
3.59375
4
import collections; dic = collections.OrderedDict() for i in range(int(input())): txt=input() if txt in dic: dic[txt]+=1 else: dic[txt]=1 print(len(dic)); for k,v in dic.items(): print(v,end=" ")
5172c4d5e19598fb65ee9bf09d439727af3da354
r1xvu0/pyRPG
/commands.py
21,922
3.546875
4
from main import * from items import * from skills import * from mobs import * import random lowkey_lvl = 0 # Basic commands def commands(comm): global lowkey_lvl if in_battle == 0: if comm == "inventory" or comm == "inv": check_inv() elif comm == "skill" or comm == "skills": ...
9546f9d65e8006083561a0871803f5f456294160
WINKgroup/worldpopulation
/worldpopulation.py
465
3.625
4
import pandas as pd import numpy as np df = pd.read_csv('worldpopulation.csv') print("Riga relativa all'Italia:", df.loc[ df['Country Code'] == 'ITA' ]) dfNoNan = df.dropna() dfNoNan = dfNoNan.set_index('Country Code') df2018 = dfNoNan['2018 [YR2018]'] df2018 = df2018.replace('..', np.nan) df2018 = df2018.dropna() d...
13b53e482f5d6781b290c6e7bf9568b9d13350a1
JeisonCuesta/Recursividad
/Torres/TorresP/Main.py
434
4
4
def hanoi (num, inicio='1', temporal='2', fin='3'): if num==1: print('Se mueve el disco de la torre (' + inicio + ') a la torre (' + fin +')') else: hanoi(num-1, temporal,inicio, fin) print('Se mueve el disco de la torre (' + inicio + ') a la torre (' + fin +')') hanoi(num-1,...
ea6f60cb1a949de5a597647c3888084c2a21dd3d
catechnix/greentree
/string.py
175
3.890625
4
word =" banana" count_num=word.count("a") print(count_num) strip_letter=word.strip(" a") print (strip_letter) replace_letter=word.replace("a","t",2) print (replace_letter)
4da9e5bb9096d891064eb88bfa4ccfd5bcf95447
catechnix/greentree
/sorting_two_lists.py
502
4.15625
4
""" compared two sorted arrays and return one that combining the two arrays into one which is also sorted, can't use sort function """ array1=[0,3,2,1,6] array2=[1,2,4,5] print(array2) for i in array1: if i not in array2: array2.append(i) print(array2) array3=[] while array2: minimum = a...
32061facf23b68d0d1b6f7794366186dba758ead
catechnix/greentree
/print_object_attribute.py
442
4.375
4
""" Write a function called print_time that takes a Time object and prints it in the form hour:minute:second. """ class Time(): def __init__(self,hour,minute,second): self.hour=hour self.minute=minute self.second=second present_time=Time(12,5,34) def print_time(time): time_text="The pre...
6c11a5a9b17a16dd5439db691f4bf0cbf4b09e15
ejolie/problem-solving
/LeetCode/src/com/ejolie/learn/topinterviewquestions/strings/_7/Solution.py
767
3.71875
4
''' 7. Reverse Integer ''' class Solution: def __init__(self): self.MAX_INT = 2**31 - 1 self.MIN_INT = -2**31 def reverse(self, x: int) -> int: isMinus = 1 if x < 0: isMinus = -1 x *= -1 num = int(str(x)[::-1]) * isMinus if num <= self.MI...
ce172fa359d34fa471f70cfe4ed7f435cd4837da
ejolie/problem-solving
/LeetCode/src/com/ejolie/problems/medium/lc_735.py
1,039
3.734375
4
from typing import List """ 735. Asteroid Collision """ class Solution: def asteroidCollision(self, asteroids: List[int]) -> List[int]: stack = [] canAppend = True for a in asteroids: while stack and stack[-1] > 0 and a < 0: if stack[-1] < abs(a): ...
c2df939654c810f695a100e530118d36a8f4579b
ejolie/problem-solving
/SWEA/D2/swea1989.py
334
3.6875
4
''' 1989. 초심자의 회문 검사 단어를 입력 받아 회문이면 1을 출력하고, 아니라면 0을 출력하는 프로그램을 작성하라. ''' t = int(input()) for i in range(1, t+1): word = input().strip() word.replace(' ', '') isPalindrome = '1' if word == word[::-1] else '0' print(f'#{i} {isPalindrome}')
74d000bb694899acbb39abd3d3649576f828a20d
ejolie/problem-solving
/SWEA/D3/swea1216.py
1,294
3.703125
4
''' 1216. 회문 주어진 100x100 평면 글자판에서 가로, 세로를 모두 보아 가장 긴 회문의 길이를 구하는 문제이다. 각 칸의 들어가는 글자는 'A', 'B', 'C' 중 하나이다. 가로, 세로 각각에 대해서 직선으로만 판단한다. ''' def find_palindrome(arr, SIZE): for LEN in range(100, 0, -1): # palindrome LEN : 100 - 1 for i in range(SIZE): # row SIZE : 0 - 100 f...
536b4d6ab12aa641257c11106aa6f643898b56ab
EY-cmyk/hw_lection3
/hw_lection3_exercise3.py
133
4.0625
4
name = "Dima" name2 = str(input("Input your name: ")) if name2 == name: print("True") elif name2 != name: print("False")
c3e2dbea9644d12fd9b33eb8e48fc486cf5d4f70
TsundereGamer/AED
/fich8/09_sort_500.py
3,072
4.0625
4
import timeit import random def bubbleSort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp def selectionSort(alist): for fillslot in r...
fef658136e0110c96c6983b8a510ed2b575d7fb3
TsundereGamer/AED
/extra/test.py
3,462
3.984375
4
import random # name = "John Smith" # age = 20 # is_new = True # # print("Patients data") # print("| Name | Age | New Patient |") # print("| " + name + " | " + str(age) + " | " + str(is_new) + " |\n") # name = input("What is your name?") # color = input("What is your favourite color?") # print(name + " ...
e0589e98102ee4403189fcaa815c4d0140b76be8
TsundereGamer/AED
/fich05/ex03_size.py
1,775
3.953125
4
from fich05.ex01_node import Node class LinkedList: def __init__(self): self.head = None self.size = 0 def isEmpty(self): return self.head is None def size(self): return str(self.size) def add(self, item): temp = Node(item) temp.setNext(self.head) ...
5ba550f44422c5f7f589806696076581a8d73e7d
TsundereGamer/AED
/fich07/01.py
450
3.640625
4
def findmin_n(l): min_n = l[0] for i in l: if i < min_n: min_n = i return min_n def findmin_n2(alist): for i in alist: i_is_min = True for j in alist: if j < i: i_is_min = False if i_is_min: return i return min ...
1e046af7edff42b8dba60b283aaf3feafe7f1bad
TsundereGamer/AED
/fich05/ex10_linkedlist_concatenate.py
4,772
3.921875
4
from fich05.ex01_node import Node from copy import deepcopy from fich04.ex01_queue import Queue class LinkedList: def __init__(self): self.head = None def add(self, item): temp = Node(item) temp.setNext(self.head) self.head = temp def remove(self, item): if self....
f2bac036c2767bc78cd1965b92dcdd57a8860393
TsundereGamer/AED
/fich06/ex02_palindromo.py
1,088
3.859375
4
def verificar_alpha(string): new_string = "".join(filter(str.isalpha, string.lower())) return new_string def palindromo(string): if len(string) <= 1: return True else: if string[0] == string[-1]: return palindromo(string[1:-1]) else: return False strin...
c0b2c5611a782fe0e50262cfc6aa4bbe84a44ec2
ravi4all/PythonApril_21
/FileHandling/07-csv_operations.py
417
3.71875
4
# csv - comma separated values import csv # data = [ # ["first name", "last name"], # ["Sachin", "Tendulkar"], # ["Virat", "Kohli"], # ["MS", "Dhoni"] # ] # with open('data.csv','w', newline='') as file: # obj = csv.writer(file) # for item in data: # obj.writerow(item) wi...
382accd38eea0087a552cf95e21e52be46afe666
ravi4all/PythonApril_21
/ExceptionHandling/01-code.py
435
3.953125
4
try: x = int(input("Enter first number : ")) y = int(input("Enter second number : ")) a = x + y b = x - y c = x / y d = x * y except ZeroDivisionError as err: print("Cannot divide by zero") except ValueError: print("Invalid Input...") except BaseException as ex: print("Er...
94656e9223ae1c95bcd8dce62715c10f858c7dd8
ravi4all/PythonApril_21
/functions/10-func.py
278
3.65625
4
# Nested Function def calc(): x = 6 y = 10 def add(): z = x + y print("Sum is",z) def sub(): z = x - y print("Sub is",z) return add, sub operations = calc() # print(operations) operations[0]() operations[1]()
7205fd18efb2d17bb61283a797c095bad42d1b7d
ravi4all/PythonApril_21
/tic_tac_toe/game.py
894
3.71875
4
import random positions = list(range(1,10)) occupied = [] def gameBoard(): print(""" {} | {} | {} ------------ {} | {} | {} ------------ {} | {} | {} """.format(positions[0],positions[1],positions[2], positions[3],positions[4],positions[5], ...
6d663a4485f3a131e4165b28ddfb417b5c87b891
PArun/project_euler
/10.py
292
3.828125
4
''' The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ''' def is_prime(number): def sum_numbers(max_number): n = 0 list = max_number while n<=len(list): x = list(n) if __name__ == '__main__': main()
3d1bc1794905b80c0cd7815b2adda989cf92d77b
hanfeng11/python1
/rr/day05_2.py
243
3.75
4
list=[] s=0 for i in range(101,201): bool=True for j in range(2,i-1): if(i%j==0): bool=False if(bool==True): list.append(i) s+=1 else: continue print(list) print("素数个数为:",s)
f5c8c9621dd6595beb26f00f058d06e1c52dccf1
hanfeng11/python1
/zhuan2_1/day02lianxi.py
2,733
3.609375
4
# import threading # lock=threading.Lock() # import time # list1=[i for i in range(1,101)] # def fun(): # global list1 # while True: # if list1!=[]: # lock.acquire() # one=list1[0] # del list1[0] # lock.release() # time.sleep(0.01) # ...
ae93bfb6248e1917af4dff7a5d2dfebd9500026c
hanfeng11/python1
/rr/day01_rikao2.py
126
3.640625
4
#2. 输入一个数字,求其绝对值。 var1=int(input("请输入一个数字:")) var2=abs(var1) print("绝对值:",var2)
74fa5566c760efecb6db61bc0ac81408742b1184
dreaminkv/gb_basic_python
/test.py
3,221
3.5
4
<<<<<<< HEAD <<<<<<< HEAD class Camera: counter = 0 def __init__(self): print('New cam add') self._is_on = False self.counter += 1 self.__working_time = 10 def turn(self, is_on: str): self.is_on = is_on def sent_data(self): print('Data sent') class Re...
fa3eb3ea8a585370c8f2aaebd508ed4927a93dd6
dreaminkv/gb_basic_python
/TolstovMikhail_dz_11/task_11_7.py
936
4.21875
4
# Реализовать проект «Операции с комплексными числами». Создать класс «Комплексное число». # Реализовать перегрузку методов сложения и умножения комплексных чисел. Проверить работу проекта. # Для этого создать экземпляры класса (комплексные числа), выполнить сложение и умножение созданных # экземпляров. Проверить корре...
378d0df46a63a9c4a54e5e653122d8e83f8132fe
dreaminkv/gb_basic_python
/lesson_1/Tolstov_Mikhail_dz_1/task_1_3.py
722
3.984375
4
# 3. Реализовать склонение слова «процент» для чисел до 20. Например, задаем число 5 — получаем «5 процентов», # задаем число 2 — получаем «2 процента». Вывести все склонения для проверки. percent_value = ['процент', 'процента', 'процентов'] percent_key = int(input('Введите количество процентов от 1 - 20: ')) if perc...
02699aecf41823918425e686cbf2fb2e899c507b
dreaminkv/gb_basic_python
/Tolstov_Mikhail_dz_5/test_compr.py
391
3.6875
4
import sys def num_digit(num): sum_of_digit = 0 for char in str(num): sum_of_digit += int(char) return sum_of_digit list_odd_num = [str(i * 5) + '!' for i in range(0, 50, 2) if sum(map(int, str(i * 5).strip())) % 2 == 0] print(list_odd_num) user_info = ['Basil', 'Ivanov', 27] user_info_nums = ...
8f6253e19d64eb0b4b7630e859f4e3a143fb0833
IBA07/Test_dome_challanges
/find_roots_second_ord_eq.py
751
4.1875
4
''' Implement the function find_roots to find the roots of the quadriatic equation: aX^2+bx+c. The function should return a tuple containing roots in any order. If the equation has only one solution, the function should return that solution as both elements of the tuple. The equation will always have at least one solut...
490d65d6d0a576dfa74be45bf8d7ea652392b37a
Victor7004/stepik-auto-tests-course
/p2.py
109
3.875
4
s = 'My Name is Julia' index = s.find('Name') if index != -1: print(f'Substring found at index {index}')
5dc26c4b2829d56b289b414733ae9a87daac6cc7
Victor7004/stepik-auto-tests-course
/exemple_set2.py
676
3.828125
4
#Операции на множества a = {12, 13, 14, 15} #нахождение длины множества при помощи функции len print(len(a)) #нахождение элемента в множестве print(12 in a, 7 in a) #нахождение пересечений множеств b = {1, 2, 3, 4} c = {3, 4, 5, 6} d = {10,11, 12} print(b & c) print(b & d) #объединение множеств print(b | c) print(c.uni...
b69d7df2b5cedc7c479218dc94f02af9f26f0feb
cybermimile/santtalgi
/Exemple_Instructions.py
1,150
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 12 15:05:55 2020 @author: cybermimile Several examples for using the instructions recording feature (uncomment the part you want to try) """ import atmega8 import time at = atmega8.ATMega8('/dev/ttyUSB0') pin = atmega8.PB0 at.pinMode(pin,atmega8....
6dfc7a408e366f6e6575f100adf8cd6a7db37502
vivekhebbar/DraftLord
/nba/train.py
7,653
3.734375
4
import sqlite3 from datetime import datetime, timedelta import numpy as np from sklearn import utils, linear_model import csv import warnings warnings.filterwarnings("ignore", category=RuntimeWarning) warnings.filterwarnings("ignore", category=DeprecationWarning) # global variables data, labels, model = [], [], None ...
57da5088f363eaf1e9ae5cab5192e7d6db8620d1
PavelPu/PyIOT
/houseClass.py
651
3.5
4
import time class TRelay(object): num = 0 def tmet(self): print("test method %d" % self.num) def __init__(self, n): self.num = n class House(object): def __init__(self): self.startTimeStamp = time.asctime( time.localtime(time.time())) self.roomSet = {"bath", "dini...
91bd2e803e12dae1fb6dad102e24e11db4dfdb03
ZainabFatima507/my
/check_if_+_-_0.py
210
4.1875
4
num = input ( "type a number:") if num >= "0": if num > "0": print ("the number is positive.") else: print("the number is zero.") else: print ("the number is negative.")
524b1d0fa45d90e7a326a37cc1f90cdabc1942e0
CTEC-121-Spring-2020/mod-5-programming-assignment-Rmballenger
/Prob-1/Prob-1.py
2,756
4.1875
4
# Module 4 # Programming Assignment 5 # Prob-1.py # Robert Ballenger # IPO # function definition def convertNumber(numberGiven): # Here a if/elif loop occurs where it checks if the numberGiven is equal to any of the numbers below, and if it does it prints the message. if numberGiven == 1: ...
094e3636f9b8569e11341fc97e9eda326fb1d908
Degamey/-
/tifunc.py
741
3.59375
4
import time #ааааа трындец сложнА def timer(seconds): timenow=time.asctime() timee=[int(timenow[11]+timenow[12]),int(timenow[14]+timenow[15]),int(timenow[17]+timenow[18])] timee[2]+=seconds if timee[2]>59: timee[1]+=1 timee[2]-=60 if timee[1]>59: timee[0]+=1 ...
ec65fc9c46724f2e5568bbe2875e94e2ec89530f
georgenavarro1802/powerball1
/main.py
6,400
3.859375
4
from collections import defaultdict import operator objects_list = [] general_numbers_list = [] general_powerball_ist = [] def get_input(question): return raw_input(question) def get_element(elem, list, index): """ Keep asking the user for an valid element until it is finally selected and valid. ...
c79f9b2fdeb89f7cdbec3978d6b1479a2f667560
s-londono/labs
/python/ds-from-scratch/examples/probability/phacking.py
1,206
3.890625
4
import random from typing import List # A procedure that erroneously rejects the null hypothesis only 5% of the time will, by definition, 5% of the # time erroneously reject the null hypothesis. # If you are are setting out to find "significant" results, you usually can. # P-Hacking is the deceitful trick of: # - Tes...
4a16efa4d48325d9a9c726a16484f0875031d1ed
s-londono/labs
/python/ds-from-scratch/examples/basics/set.py
289
3.9375
4
# Build a set s1 = set() s2 = {1, 2, 3, 4, 5} l1 = range(1, 5) s3 = set(l1) # Set lookup is very fast print(f"Set has 1 {1 in s2}") # Sets can be used to find dictinct elements in a collection l2 = [1, 2, 3, 1, 3, 4, 6, 3, 2, 1, 6, 8] s4 = set(l2) print(f"Distinct in l2: {list(s4)}")
6b71da46af235be2a433649b4c72b91c41c9f929
s-londono/labs
/python/ds-from-scratch/examples/basics/comprehensions.py
450
3.859375
4
# Pythonic way to transform and filter lists even_squares = [x * x for x in range(0, 50) if x % 2 == 0] # Turn lists into dictionaries or sets square_odd_dict = {x: x * x for x in range(20) if x % 2 == 1} square_pair_set = {x for x in range(20) if x % 2 == 0} zeros = [0 for _ in range(25)] # List comprehensions can...