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
525bea426bd338a87b1c0b2a76c833fd2eedae49
CHENHERNGSHYUE/pythonTest
/class.py
566
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 5 15:33:44 2019 @author: chenmth """ class Calculator: #class名稱第一個字母要大寫 Name = 'kenny' def add_function(a,b): return a+b def minus_function(a,b): return a-b def times_function(a,b): return a*b def divide_function(a,b): ...
9a0d3d86d0390f77a0533b36d751799489a582e3
CHENHERNGSHYUE/pythonTest
/pandas/a.py
450
3.734375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 15 20:18:54 2019 @author: chenmth """ #list = ['3','4','a','-1','b'] # #try: # total = 0 # for i in list: # # if type int(i) is int: # total = total + int(i) # else: # pass # print(total) #except: # ValueError list = ['3', ...
982bf085f43b2e0d3c48701b3df06e8edb66cd76
CHENHERNGSHYUE/pythonTest
/copy_id.py
767
3.53125
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 7 14:46:21 2019 @author: chenmth """ import copy a = [1,2,3] b = a print(id(a)) #id表示秀出該物件存放記憶體的位置 print(id(b)) print(id(a)==id(b)) b[0]=111 print(a) #因為空間共用, 所以互相影響 c = copy.copy(a) #copy a 的東西, 但存放記憶體空間位置不同 print(c) print(id(a)==id(c)) c[0] = 1 print(a) #c是copy a來的 ...
d11526d684d51e31950e0220c01d977fde90a8f6
CHENHERNGSHYUE/pythonTest
/pandas/pandas_07_merge04_index.py
542
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 12 12:05:55 2019 @author: chenmth """ import pandas as pd import numpy as np A = pd.DataFrame({'A':[0,1,2], 'B':[3,4,5], 'C':[0,1,2]}, index=['X','Y','Z']) B = pd.DataFrame({'C':[0,1,2], 'M':['A','A','...
5a8526d077625013a78de556b1c3f86f6f628860
CHENHERNGSHYUE/pythonTest
/numpy/numpy_01.py
404
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 10 15:20:54 2019 @author: chenmth """ import numpy as np array = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]]) print(array) #秀出矩陣形式 array不能有逗號且必須是矩形 print(array.ndim) #2 多少維度 print(array.size) #12 (4*3) 多少個元素 print(array.shape) #(4,3) (x,y)->(矩陣數、行、row, 矩陣內部元素、列、colum...
beebefcc521dfb5aafbb12b0d67d9a6516c831d5
natahlieb/adventofcode2017
/Day2/day2.2.py
540
3.625
4
import sys def findDivisor(row): max = 0 min = sys.maxsize for k in range(0, len(row), 1): for j in range(k+1, len(row), 1): print(' comparing k {} j {}'.format(row[k], row[j])) if(int(row[k]) > int(row[j])): if (int(row[k]) % int(row[j]) == 0): return int(row[k]) / int(row[j]) el...
7b10d33efe740095c60a6d108f704c85d413eefd
natahlieb/adventofcode2017
/Day13/day13.0.py
1,645
3.53125
4
import sys def calculateScannerLocation(cycleNubmer, depth): currentLocation = 0 count = 0 direction = "down" depth = depth - 1 while(count != cycleNubmer): if (direction == "down"): if currentLocation+1 <= depth: currentLocation += 1 else: direction = "up" currentLocation -= 1 elif di...
1b344f93dd4970ffba799d08516651b0958a7ba2
joshwinebrener/clock-math
/clockmath.py
3,148
3.53125
4
""" Created to compute all the meaningful mathematical arrangements of a sequence of integers. Specifically, this script is made to find the percentage of such meaningful arrangements in 12- and 24-hour time formats. E.g. 6:51 : 6 - 5 = 1 """ import sys class Mode: twelve_hour = 0 twentyfour_hour = 1 d...
750870bd2e4bdfc1ca690ec6a09cf37245f0ad59
Binary-Developers/Dark-Algorithms
/Count_Inversions/countInversion.py
249
3.78125
4
n=int(input('Enter number of elements\n')) a=[] print('Enter n elements\n') count = 0 for i in range (0,n): a.append(int(input())) for i in range(0,n): for j in range(0,i): if a[j]>a[i]: count+=1 print(count)
344023505df184a5c5dca70610b0f77c116b3158
antonioanerao/python-codecademy
/aula2.py
459
3.578125
4
def applicant_selector(gpa, ps_score, ec_count): if (gpa >= 3.0) and (ps_score >= 90) and (ec_count >= 3): return "This applicant should be accepted." elif (gpa >= 3.0) and (ps_score >= 90) and (ec_count < 3): return "This applicant should be given an in-person interview." else: return "This applicant...
3a0fdd4a1bcc83eb0501f91cdc0da8abebfd8172
Gabriel-Teles/Mercado
/Mercado.py
799
3.5625
4
#coding: utf-8 from Estoque import estoque class mercado: def mercado(self): esto = estoque() while True: print("\n= = = = Bem-vindo(a) ao EconomizaTec= = = =\n") print("Digite a opção desejada\n") print("1. Cadastrar um Produto") print("2...
00dc2338120ff076d7e0f1e7a16e1affbec35fb7
Pallavirampal/python_games_programs
/exercise 6.py
2,562
3.765625
4
import random comp=['Rock','Paper','Sicssor'] # print(comp_choice) user_score=0 comp_score=0 i=1 while i<=6: comp_choice = random.choice(comp) print('*** ROUND',i,'***') user_choice = input('Press (r) for rock (p) for paper and (s) for scissor:') if user_choice == 'r': if comp_choice == 'Rock':...
f0b9981c887e5a642a1479a2ae52da120b79d3dc
MarlenXique/lab-10-more-loops
/hanoi.py
872
4
4
def move(f,t): #from,to.A value passed to a function (or method) when calling the function. print("move from {} to {}".format(f,t)) #.format is amethod because of the dot. ots a strong, class of data. move("A","C") def moveVia(f,v,t): #from,via,to. move(f,v) #function call to move(): move from step1 to step 2 (...
79b5d599291b8b0ec5532134e2f382177e935d3b
Chih-YunW/Full_Name
/name.py
174
4.15625
4
def full_name(f: str, l:str): full_name = f + ' ' + l return full_name f = input("What is the first name: ") l = input("What is the second name: ") print(full_name(f,l))
c4167ce0440026258141ff33fb5c0ba2404938fa
Artarin/study-python-Erick-Metis
/operation_with_files/exceptions/words_counter.py
488
3.96875
4
"""this program search and counting quontity of simple word in text.file""" pre_path = "books_for_analysis//" books = ["Életbölcseség.txt", "Chambers's.txt", "Crash Beam by John Barrett.txt" ] for book in books: print (book +':') with open (pre_path+book, 'r', encoding='utf-8...
71a2fe42585b7a6a2fece70674628c1b529f3371
pltuan/Python_examples
/list.py
545
4.125
4
db = [1,3,3.4,5.678,34,78.0009] print("The List in Python") print(db[0]) db[0] = db[0] + db[1] print(db[0]) print("Add in the list") db.append(111) print(db) print("Remove in the list") db.remove(3) print(db) print("Sort in the list") db.sort() print(db) db.reverse() print(db) print("Len in the list") print(len(db)) pr...
97745f9a33b8e5653d050d3a5c875c57bc4e5780
WangMingJue/StudyPython
/Test/Python 100 example/Python 练习实例6.py
1,134
4.25
4
# 题目:斐波那契数列。 # # 程序分析:斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……。 # # 在数学上,费波那契数列是以递归的方法来定义: # F0 = 0 (n=0) # F1 = 1 (n=1) # Fn = F[n-1]+ F[n-2](n=>2) # 普通方法 def method_1(index): a, b = 1, 1 for i in range(index - 1): a, b = b, a + b return a # 使用递归 def method...
e87c204af85487af4753814f850156fd414b36b8
WangMingJue/StudyPython
/Test/Python 100 example/Python 练习实例8.py
260
3.796875
4
# 题目:输出 9*9 乘法口诀表。 # # 程序分析:分行与列考虑,共9行9列,i控制行,j控制列。 for i in range(1, 10): result = "" for j in range(1, i + 1): result += "{}*{}={} ".format(i, j, i * j) print(result)
16ea342f088dabb6af5c4f932144b9904e417cd3
ueoSamy/Python
/lesson4/easy.py
1,552
4.09375
4
# Все задачи текущего блока решите с помощью генераторов списков! # Задание-1: # Дан список, заполненный произвольными целыми числами. # Получить новый список, элементы которого будут # квадратами элементов исходного списка # [1, 2, 4, 0] --> [1, 4, 16, 0] list_a = [1, 2, 4, 0] list_b = [elem ** 2 for elem in list_a]...
678e8e9b2995324a8c7fd091d1a9b2cc7dde8171
KIMZI0N/bioinfo-lecture-2021-07
/src/016_1.py
811
3.59375
4
#! /usr/bin/env python file_name = "read_sample.txt" ''' #1 with open(file_name, 'r') as handle: for line in handle: print(line) #line에 이미 \n가 들어있음. #print()도 디폴트end가 \n이므로 enter가 두번씩 쳐짐. #print(line, end' ')하면 end를 띄어쓰기로 바꿀 수 있음. #2 #print(line.strip()) #line의 \n를 없앨 수 있음. #3 handle = open(file_name,'r') for line in...
f5c58e281c315b60b44426eff8ccb551624691a1
KIMZI0N/bioinfo-lecture-2021-07
/src/028.py
738
3.75
4
#! /usr/bin/env python seq = "ATGTTATAG" ''' #1 if문 list=[] for i in range(len(seq)): if seq[i] == 'A': list.append('T') elif seq[i] == 'T': list.append('A') elif seq[i] == 'G': list.append('C') elif seq[i] == 'C': list.append('G') l = ''.join(list) print(l) ''' #2 강사님 co...
a36002de7981c81dc1f4170809a47c37b2cca0d5
pnads/advent-of-code-2020
/day_06.py
3,730
4.0625
4
"""--- Day 6: Custom Customs --- As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers. The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone i...
049494c7eb2cd4b110164def15827503b616ef2e
sprotg/2020_3h
/algoritmer_og_datastrukturer/heap.py
968
3.5625
4
from random import randint class Heap(): def __init__(self): self.a = [randint(1,100) for i in range(10)] self.heap_size = len(self.a) def left(self, i): return 2*i + 1 def right(self, i): return 2*i + 2 def parent(self, i): return (i-1)//2 def max_heap...
f7179afa985135e89d3f83e772db20440c361106
sprotg/2020_3h
/algoritmer_og_datastrukturer/sorting.py
848
3.9375
4
from random import randint import time import matplotlib.pyplot as plt antal = [] tid = [] def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n-1): # range(n) also work but outer loop will repeat one time more than needed. # Last i elements are already in ...
e3cdc173691a2ccdcdda891e41258f4fcc970b4c
sprotg/2020_3h
/databaser/database_start.py
2,168
3.703125
4
import sqlite3 #Her oprettes en forbindelse til databasefilen #Hvis filen ikke findes, vil sqlite oprette en ny tom database. con = sqlite3.connect('start.db') print('Database åbnet') try: con.execute("""CREATE TABLE personer ( id INTEGER PRIMARY KEY AUTOINCREMENT, navn STRING, alder INTEGER)""") ...
74bda556d528a9346da3bdd6ca7ac4e6bcac6654
adaoraa/PythonAssignment1
/Reverse_Word_Order.py
444
4.4375
4
# Write a program (using functions!) that asks the user for a long string containing multiple words. # Print back to the user the same string, except with the words in backwards order. user_strings = input('input a string of words: ') # prompts user to input string user_set = user_strings.split() # converts stri...
7b35393252d51e721ffddde3007105546240e5df
adaoraa/PythonAssignment1
/List_Overlap.py
1,360
4.3125
4
import random # Take two lists, say for example these two:... # and write a program that returns a list that # contains only the elements that are common between # the lists (without duplicates). Make sure your program # works on two lists of different sizes. a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, ...
8b396545767f1cd2d9cd925bd6006542116cbc4c
Mercy435/python--zero-to-mastery
/Advanced Python Object Oriented Programming.py
8,816
4.34375
4
# OOP # 1. class BigObject: # creating your class pass obj1 = BigObject() # instantiate means creating object obj2 = BigObject() # instantiate obj3 = BigObject() # instantiate print(type(obj1)) # 2. gaming company class PlayerCharacter: # make it singular membership = True # class object attribute (t...
1cd49270025286ef2a143bde60119ff410c4fb63
Mercy435/python--zero-to-mastery
/Testing_in_python/testing_exercise.py
988
3.71875
4
import unittest import random_game_testing class TestGame(unittest.TestCase): # 1 def test_input(self): answer = 5 guess = 5 result = random_game_testing.run_guess(answer, guess) self.assertTrue(result) def test_inputw(self): answer = 15 guess = 5 ...
ed46bde96311d2f53554158365edc3c8280f4a34
kgupta1542/interviewQs
/Daily-Coding-Problem/dcp004.py
669
3.78125
4
#Refer to Daily Coding Problem #3 def findMissingInt(x):#find lower and upper, checks if in x, declares as missing, finds smallest missing missing = 0 temp = -1 for i in range(len(x)): if x[i] >= 1: lower = x[i] - 1 upper = x[i] + 1 if upper in x or lower in x:#Fulfills last three reqs temp = u...
c8174a43df4b0e5dab7d954db25f41a3c604094a
Liangmiaomiao123/yiyuan
/demo02.py
500
3.78125
4
#缩进indent a=int(input('请输入数字:')) if a>0: print('a大于零') else: print('a小于零') #字符串 i="i'm fine" print(i) #查看字符编码 print(ord('a')) print(ord('A')) #字符串 name=input('请输入您的名字:') age=input('请输入您的年龄:') print('我叫%s,今年%d岁'%(name,int(age))) #创建列表 classmates=['zhang1','zhang2','zhang3','zhang4','zhang5'] print(classm...
97ab0921063f3db55af7f5dbcbea99cf5409489a
HuXuzhe/algorithm008-class02
/Week_09/541.反转字符串-ii.py
840
3.515625
4
''' @Descripttion: @version: 3.X @Author: hu_xz @Date: 2020-06-23 15:03:24 @LastEditors: hu_xz @LastEditTime: 2020-06-23 15:33:23 ''' # # @lc app=leetcode.cn id=541 lang=python # # [541] 反转字符串 II # # @lc code=start class Solution(object): def reverseStr(self, s, k): """ :type s: str :type ...
2d7c7a182da252c7ace81b792290ddc36b3b6447
HuXuzhe/algorithm008-class02
/Week_03/236.二叉树的最近公共祖先.py
985
3.546875
4
''' @Descripttion: @version: 3.X @Author: hu_xz @Date: 2020-05-06 14:27:39 @LastEditors: hu_xz @LastEditTime: 2020-05-08 11:52:57 ''' # # @lc app=leetcode.cn id=236 lang=python # # [236] 二叉树的最近公共祖先 # # @lc code=start # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # ...
7036212232a843fe184358c1b41e5e9cb096d31d
andrew5205/MIT6-006
/ch2/binary_search_tree.py
1,377
4.21875
4
class Node: # define node init def __init__(self, data): self.left = None self.right = None self.data = data # insert into tree def insert(self, data): # if provide data exist if self.data: # 1 check to left child # compa...
6141ec333d44e99c0c1968f7a21a9d6d83f56c3d
aliazani/python-exercise
/fun.py
306
3.6875
4
from random import randint answer = 209 guess = randint(1, 2000) print(guess) mini = 1 maxi = 2000 count = 0 while guess != answer: guess = randint(mini, maxi) if guess > answer: maxi = guess elif guess < answer: mini = guess count += 1 print(guess) print(count)
eed8a14cb453e976317a8e2ecbce711e627ebe83
aliazani/python-exercise
/review.py
388
3.71875
4
class Celsius: def __get__(self, instance, owner): return 5 * (instance.fahrenheit - 32) / 9 def __set__(self, instance, value): instance.fahrenheit = 32 + 9 * value / 5 class Temperature: celsius = Celsius() def __init__(self, initial_f): self.fahrenheit = initial_f t = ...
05588ff773753216a4345b4a3fd7ad903f7aec3f
aliazani/python-exercise
/getter&setter.py
359
3.90625
4
class Circle: def __init__(self, diameter): self.diameter = diameter @property def radius(self): return self.diameter / 2 @radius.setter def radius(self, radius): self.diameter = radius * 2 small_one = Circle(10) small_one.radius = 20 print(small_one.diameter) print(small...
aea31ea7e2069290e0fc0931d00e0d57018cca75
aliazani/python-exercise
/class_number_string.py
1,343
4.03125
4
class NumberString: def __init__(self, value): self.value = str(value) def __str__(self): return f"{self.value}" def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __add__(self, other): if '.' in self.value: ...
6d3c2605deadcf5d437323ee455866506b42dabd
khaiduong/lpy
/Learn_Project/6th_day/6.3.py
688
3.875
4
""" Write a python script which write to file 64out.txt, each line contains line index, month, date of month (Feb 28days). E.g:: 1, January, 31 2, February, 28 """ import calendar from sys import argv def write_days_monthname_to_file(year=2016, filename=None): try: std_int = int(year)#raw_input(std_int)) e...
f8e3c787070297a6a7554baaf61eef82fb9c0f67
Picik-picik/Python
/Chapter 03. 프로그램 사용자로부터의 입력 그리고 코드의 반복/03-2 입력받은 내용을 숫자로 바꾸려면.py
3,596
3.515625
4
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> # 03-2 입력받은 내용을 숫자로 바꾸려면 >>> >>> # 프로그램 사용자로부터 '문자열'이 아닌 '수'를 입력받으려면 어떻게 해야 할까? >>> # 파이썬은 수를 입력받는 함수를 제공하지 않는다. 대신에 문자열의 내용을 수로 바꿀 때 >>> # 사용할 수 있...
bfee9aead792afa056a6254d96037a18856d594c
mariamingallonMM/AI-ML-W3-LinearRegression
/p37/ridge_regression.py
7,425
3.921875
4
""" This code implements a linear regression per week 3 assignment of the machine learning module part of Columbia University Micromaster programme in AI. Written using Python 3.7 """ # builtin modules import os #import psutil import requests import sys import math # 3rd party modules import pandas as pd import nu...
53151036235900e092ebba543a029f333ef8228f
monilezama/inteligencia_artificial
/lezamaMonicaT3.py
5,708
3.609375
4
# Este archivo contiene un programa con varias funciones incompletas, que el # usuario tiene que terminar. # Las configuraciones del tablero son una lista de listas # pe meta = [[1,2,3],[8,0,4],[7,6,5]] donde 0 es el blanco # Ab es una lista de tuple de la forma (node,padre,f(n),g(n)) # g(n) es la longitud d...
d459bade9a96ebe9963e0d240e2724506b9f7665
TitoSilver/codigoFacultad
/diccionario/practica.py
6,558
3.671875
4
from algo1 import * from mydictionary import * from myarray import * from linkedlist import * #=========================================# #ejercicio 4 def igualString(text1,text2): #función que verifica si dos strings son iguales #creamos un dic con los elementos del text2 if len(text1)==len(text2): ...
8eb212398880ce375cf3541eac5fcd73c1ab95fe
Srbigotes33y/Programacion
/Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_5.py
1,767
4.125
4
# Programa que solicita 3 números,los muestra en pantalla de mayor a menor en lineas distintas. # En caso de haber numeros iguales, se pintan en la misma linea. # Solicitud de datos n1=int(input("Ingrese tres números.\nNúmero #1: ")) n2=int(input("Número #2: ")) n3=int(input("Número #3: ")) # En caso de que no se pr...
b3f93af0e701d69fe601fa45a19863f742fa0e49
Srbigotes33y/Programacion
/Python/Traductor binario/main.py
3,260
4.0625
4
# Traductor que convierte decimales y caracteres a binario y visceversa. # Importación de la libreria de conversores from conversor_binario import * # Solicitud de datos decimal a binario def solicitud_decimal_binario(): bandera = True while bandera: decimal = input("\nIngrese el número decimal (X p...
25b2d05140a1397680d93d95c6a305f6c39f5602
Srbigotes33y/Programacion
/Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_4.py
1,043
4.15625
4
# Programa que pide 3 números y los muestra en pantalla de menor a mayor # Solicitud de datos n1=int(input("Ingrese tres números.\nNúmero #1: ")) n2=int(input("Número #2: ")) n3=int(input("Número #3: ")) # Determinacion y exposición de los resultados if n1>n2 and n2>n3: print("\nEl orden de los números es:\n",n3...
7d3db72a696aaa2ce106381c13f94b983447ae41
Srbigotes33y/Programacion
/Python/Aprendizaje/Ciclo For/Taller for/Ejercicio_1.py
1,210
3.984375
4
# Programa que lee los lados de n triangulos e informa el tipo de triángulo y la cantidad de tringulos de cada tipo veces=int(input("¿Cuántos triángulos va a ingresar?\nTriángulos: ")) equilatero=0 isoceles=0 escaleno=0 print("Ingrese el valor de cada lado del triángulo: ") for i in range(1,veces+1): lado1=int(i...
94ec7029af42fab2fc4ab0082f21a99505977bd0
Srbigotes33y/Programacion
/Testing y Debugging/POO/3_atrubitos_metodos2.py
750
3.703125
4
# Se define la clase Auto class Auto: rojo = False # Método __init__ o constructor, instancia el objeto al momento de ser llamada la clase. def __init__(self, puertas=None, color=None): self.puertas = puertas self.color = color if puertas != None and color != None: print...
3380b8cb3334eb26b54958785764f0220bf0e9a6
Srbigotes33y/Programacion
/Python/Aprendizaje/Ciclo For/Taller for/Ejercicio_5.py
615
4.09375
4
# Progrma que calcula el factorial de un número factorial=1 numero=int(input("Ingrese el número a calcular el factorial: ")) if numero<0: print("El número no puede ser negativo") elif numero>50000: print("El número es demasiado grande") else: for i in range(1,numero+1): factorial=factorial*numero ...
e6e5d947ff4072402a040cdb5efb6f19e32b3ad8
Srbigotes33y/Programacion
/Python/Aprendizaje/Pruebas/Critografia.py
624
3.671875
4
#Critografia E=3, A=4, O=0, B=8 #Sapo=54p0 ; ALEJO= 413J0 palabra=input("Ingrese una palabra o frase: ").upper() i=0 nueva="" while(i<len(palabra)): if(palabra[i]=="a"): nueva=nueva+"4" elif (palabra[i]=="e"): nueva=nueva+"3" elif (palabra[i]=="l"): nueva=nueva+"1" elif (palabra[...
f423d11aa0d16c8959e8899f15e1761a4fe6a16a
zhtiansweet/DataStructure
/StackByQueue.py
1,428
3.6875
4
__author__ = 'tianzhang' # Implement a stack with two queues import Queue class stack: def __init__(self): self.queue1 = Queue.Queue() self.queue2 = Queue.Queue() def push(self, x): if self.queue1.empty(): self.queue2.put(x, False) else: self.queue1.pu...
7f04fcd227b6abbc473ac21f48241b9d0e88296f
jarulsamy/boxSim
/src/sim.py
11,428
3.796875
4
#!/usr/bin/env python3 """ Simple simulator for the shortest-path-to-target problem. +------------------------------------------------------------------------------+ | | | □ ------------------------------------- ...
aabdf3585e0921c82e2753eabc623be348f63000
aleksbel/python-project-lvl1
/brain_games/games/prime.py
486
3.9375
4
from random import randrange GAME_TOPIC = 'Answer "yes" if given number is prime. Otherwise answer "no".' def is_prime(n): d = 3 while d * d <= n and n % d != 0: d += 2 return d * d > n def new_round(): # Odd numbers only x = randrange(1, 1000, 2) # Correct answer if is_prime(x...
c92ac1ecaf837ff1e754475007b37ff58e30ab28
shilpageo/pythonproject
/functions/factorial.py
356
3.921875
4
#method1 def fact(): num=int(input("enter number")) fact=1 for i in range(1,num+1): fact*=i print(fact) fact() #method2 def fact(n1): fact=1 for i in range(1,n1+1): fact*=i print(fact) fact(5) #method3 def fact(num1): fact=1 for i in range(1,num1+1): fact*=i...
25732642d700e35e08b653d3cb7dbab3adb4fc6e
shilpageo/pythonproject
/functions/demo1.py
343
3.953125
4
#def functionname(arg1,arg2): #fn statemnt #fncall() #fn without arg and no return type #fn with arg and no return type #fn with arg and return type #1st method(without arg and no return type) #............. def add(): num1=int(input("enter a number1")) num2=int(input("enter a number2")) sum=num1+nu...
962aaa4964ae4989cce63115c3ccf6397161a36e
shilpageo/pythonproject
/collections/demo6.py
96
3.59375
4
#insert 1 to 100 elements into a list lst=[] for i in range(101): lst.append(i) print(lst)
e32224443d385bc3aa0b5caa0291a1537e44ff3f
shilpageo/pythonproject
/collections/word count.py
214
3.671875
4
#split line of data can be split into word by word line="hai hello hai hello" words=line.split(" ") dict={} count=0 for i in words: if i not in dict: dict[i]=1 elif i in dict: dict[i]+=1 print(dict)
fa492076ecbfed6856da7e20a3bf7a06464dbdb3
shilpageo/pythonproject
/functional programming/lambda fn.py
844
4.0625
4
#lambda keyword is used #ad=lambda num1,num2:num1+num2 #print(ad(10,20)) #function #--------- #def sub(num1,num2): # return num1-num2 #lambda function #---------------- #sub=lambda num1,num2:num1-num2 #print(sub(20,13)) #mul=lambda num1,num2:num1*num2 #print(mul(10,20)) #div=lambda num1,num2:num1/num2 #prin...
10145e2e0f1a58ea60288828d7c09f87399ca253
ngocthuan94/Python-Thuan-2
/myFirstPython/first.py
118
3.828125
4
print('hello from a file') print( 'My name is Thuan. Have a nice day!') x= 20 while x > 3: print (x) x -= 3
e9aa4621abbe5b8b60fa7bc02b3a54ba2f42531a
sharmar0790/python-samples
/misc/findUpperLowerCaseLetter.py
241
4.25
4
#find the number of upper and lower case characters str = "Hello World!!" l = 0 u=0 for i in str: if i.islower(): l+=1 elif i.isupper(): u+=1 else: print("ignore") print("Lower = %d, upper = %d" %(l,u))
94f1c45ba972a5e598b11d8db7068135ccdcc79b
sharmar0790/python-samples
/graphing/barGraphPlotting.py
654
3.546875
4
import matplotlib.pyplot as p import csv,numpy as np list_hurricanes = list() list_year = list() with open("../data/Hurricanes.csv", mode="r") as h: reader = csv.DictReader(h) for row in reader: print(row) list_hurricanes.append(row.get("Hurricanes")) list_year.append(row.get("Year")) ...
4b6bf4b0865f101b5545c7cb1033c5738c33dc3b
sharmar0790/python-samples
/misc/factors.py
267
4.28125
4
nbr = int(input("Enter the number to find the factors : ")) for i in range(1, nbr+ 1 ): if (nbr % i == 0): if i % 2 == 0: print("Factor is :", i , " and it is : Even") else: print("Factor is :", i , " and it is : Odd")
916ae65531ca61db7f61c5c0b30f8f7c0f5ca99c
MorphisHe/NumericalAnalysis
/linear_algebra/linear_system/gauss_elimination.py
1,776
3.640625
4
''' Author: Jiang He SBU ID: 111103814 ''' import time import numpy as np ''' A is a matrix (square) B is a col vector ''' def forward_elimination(A, b): ''' N = len(A) for j in range(N-1): for i in range(j+1, N): mij = A[i][j] / A[j][j] for k in range(j, N): ...
4de948a13a9c7415536a74070b4f4792108e7e40
createwv/exploring_python
/language/variables/functions_main.py
107
3.53125
4
def add_numbers(first_num, second_num): sum = first_num + second_num return sum print(add_numbers(1,2))
560998d4f73fc42ba65c869a1ba50160f59600dc
Vinicius-Tessaro/Python
/solar_yesol.py
1,454
3.609375
4
con_t = float (input ('Digite o valor do consumo total(em KWh): ')) qnt_f = int (input ('Digite a quantidade de fases do motor: ')) con_r = float if qnt_f == 1: con_r = con_t-30 elif qnt_f == 2: con_r = con_t-50 else: con_r = con_t-100 con_rd = float (con_r/30) hrs_sp = float (input ('digite Horas sol p...
6772ec2535d0416e96d0d0a82cdc3359ba8c1341
603627156/python
/day-01/03-练习-求最大值.py
458
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : # @Author : tangbo # @Site : # @File : # @Software: #求这个list的最大的两个值 list = [1,2,3,2,12,3,1,3,21,2,2,3,4111,22,3333,444,111,4,5,777,65555,45,33,45,5000] #方法一、 list.sort() print(list[-2:]) #方法二、 max = 0 max1 = 0 #max_list = [] for i in list: if max<...
4cbdbc1b64a1500d6c1f02ee3f665a0721f6f6e8
jblazzy/Weather
/Weather.py
2,346
4.03125
4
""" -- Weather.py -- Josh Blaz -- Denison University -- 2019 -- blaz_j1@denison.edu """ import requests import datetime import calendar def UnixConverter(timestamp): """ Converts Unix Timestamps to readable time. See https://timestamp.online/article/how-to-convert-timestamp-to-datetime-in-python for Unix-t...
8ca83b341856182afc219534f0f80040a639eb7a
mareis/inf1-2021
/Thonny/oppgaver3_1.py
338
3.921875
4
tall1 = float(input("Skriv in et tall: ")) talle = float(input("Skriv in et tall til: ")) if tall1 > tall2: print(f'{tall1} er større enn {tall2}.') #print(tall1, "er større enn", tall2) elif tall2 > tall1: print(f'{tall2} er større enn {tall1}.') elif tall1 == tall2: print(f'{tall1} er lik {tall...
0fffed88c100ea269eb0c1da41846323a0003698
mareis/inf1-2021
/Thonny/input_og_sqrt.py
156
3.734375
4
from math import sqrt n = input("Skriv iunn det du ønsker å ta kvadratroten till: ") n = int(n) kvadratrot = sqrt(n) print("kvadratroten er", kvadratrot)
a182d55b5efe26137379a07556a8a04e001878fc
MehmetCanBOZ/AI_minimaxalgoritm_tictoctoe_game
/tictactoe.py
3,532
3.890625
4
""" Tic Tac Toe Player """ import math X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Returns player who has the next ...
5f364e19483cf86257903c17167941a190da1bd8
traders-see/pytohn1
/program/if for .py
1,819
3.625
4
# if的意思(如果)的意思, 他的输出必须是布尔值, ''' if 条件A满足布尔值 elif 条件B满足布尔值 elif 条件C满足布尔值 else 以上所有条件都不满足的时候执行 ''' # symbol = 'btcusd' # if symbol.endswith('usd'): # a条件 # print(symbol, '美元计价') # elif symbol.endswith('btc'): # b条件 # print(symbol, '比特币计价') # elif symbol.endswith('eth'): # c条件 # print(symbol, '以太坊计价')...
3f4868748b96cde0ad69c6724fbc780f11489d27
CapsLockAF/python--tqa-hw-tasks
/p1/task4-pythoncore-CapsLockAF/src/squares_sum.py
155
3.578125
4
def squares_sum(n): # Type your code count = 1 res = 0 while count <= n: res += count**2 count += 1 return res
b9bff2a8e344dabb03de95bfd95e9f2ac59f1cc5
WillLuong97/MultiThreading-Module
/openWeatherAPI.py
4,137
3.75
4
''' OpenWeatherMap API, https://openweathermap.org/api by city name --> api.openweathermap.org/data/2.5/weather?q={city name},{country code} JSON parameters https://openweathermap.org/current#current_JSON weather.description Weather condition within the group main.temp Temperature. Unit Default: Kelvin, Metric...
66c870b15db3040c1030deb637c4e5b8998897ff
bukovskiy/Coursera-Data-Structures-and-Algorithms-Specialization
/algorithmic_toolbox/week2/fibonacci.py
400
3.921875
4
# Uses python3 def fibNonRecursive(n): counter = 1 array=[0,1] while counter < n: number = array[counter]+array[counter-1] # print(number) counter = counter+1 array.append(number) return array[-1] def main(): c = {0:0,1:1,2:1} n = int(input()) p...
8fc1a31146fa1377e33283d271c58144c5492a41
Muha-tsokotukha/PyGame
/TSIS-6/11.py
170
3.765625
4
def perf(a): summ = 1 x = 2 while x <= a: if a % x == 0: summ += x x += 1 return summ/2 == a x = int(input()) print(perf(x))
9f4e38cd4a6a1e6f2ec380f64571e72634ddb1a2
Muha-tsokotukha/PyGame
/week3-4/classing2.py
410
3.671875
4
class transport(): def __init__( self, brand, model ): self.brand = brand self.model = model def brnd(self): print(self.brand) class cars(transport): def __init__(self, brand,model,price): super().__init__(brand,model) self.price = price def prs(self): ...
2ab5b0f7a4a6071ab828ed713a990ed4b0e8c51f
Muha-tsokotukha/PyGame
/week10_Tsis7/2_3.py
803
3.6875
4
import pygame pygame.init() screen = pygame.display.set_mode((480,360)) x = 50 y = 100 done = False step = 5 while not done: for events in pygame.event.get(): if events.type == pygame.QUIT: done = True press = pygame.key.get_pressed() if press[pygame.K_UP]: y -=...
8ea6c2251009090a4b37666cc05741637705ae66
madinamantay/webdev2019
/week10/Informatics/3/for/K.py
76
3.53125
4
a = int(input()) s=0 for i in range(a): s += int(input()) print(s)
3cb4b68000a36fb919a7766351baf05f84c1a6a3
sumi89/Numpy_based_CNN
/cnn_numpy_utils.py
2,708
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 16 18:09:03 2017 @author: Anthony """ import cnn_numpy as layer def cnn_relu_forward(x, w, b, cnn_param): """ A convenience layer that performs a convolution followed by a ReLU. Inputs: - x: Input to the convolutional layer - w, b, conv_param: We...
3ec1466ffce05f83b108a81a83c5aeef1f999a05
ethan-douglass/SHSPythonWork
/Chapter 2/Exersises/(2-10) Adding_Comments.py
296
3.671875
4
# Adds a Name to a quote famous_person = "Albert Einstein" message = f'{famous_person} once said,"A person who never made a mistake never tried anything new."' print(message) #Asks Eric if he wants to learn python message = "\nHello Eric, would you like to learn some Python today?" print(message)
9b4ca5602cbf2ce9bb25e5d5ce8faa29d7d3e7c2
wiktoriamroczko/pp1
/04-Subroutines/z31.py
107
3.859375
4
def reverse(tab): return tab[::-1] tab = [2, 5, 4, 1, 8, 7, 4, 0, 9] print (tab) print (reverse(tab))
3b50eb1cf1d948aeff1a9e9b41cde7f7efaa8b90
wiktoriamroczko/pp1
/06-ClassesAndObjects/z7.8.9.py
683
3.703125
4
class University(): # konstruktor obiektu (metoda __init__) def __init__(self): # cechy obiektu (pola) self.name = 'UEK' self.fullname = 'Uniwersytet Ekonomiczny w Karkowie' # zachowania obiektu (metody) def print_name(self): print(self.name) def set_name...
02b28b1caa84961387b5bbdce17aa7dd531afb48
wiktoriamroczko/pp1
/10-SoftwareTesting/programs/zadanie6pkt.py
1,008
3.765625
4
class Macierz(): def __init__(self,m,n): self.m = m self.n = n def stworzMacierz(self): self.macierz = [[0 for a in range(self.m)]for b in range(self.n)] return self.macierz def rand(self): import random for i in self.macierz: for j ...
a0f15910ea6d931d057bc6e61e57b84c28f15622
wiktoriamroczko/pp1
/07-ObjectOrientedProgramming/z14.py
814
3.984375
4
class Phone(): def __init__(self, phone_number, brand, operating_system): self.phone_number = phone_number self.brand = brand self.operating_system = operating_system self.is_on = False def turn_on(self): self.is_on = True def turn_off(self): ...
88cd3bb80fcae3d0b2630154be9887310cbe9ea9
wiktoriamroczko/pp1
/02-ControlStructures/zadanie49.py
471
3.921875
4
print ('| PN | WT | SR | CZ | PT | SB | ND |') nrDniaTygodnia =3 print ('| '*nrDniaTygodnia, end='') for i in range(1, 31): if i < 10: print ('|', i, end=' ') elif i >=10: print ('|', i, end=' ') if i == 7-nrDniaTygodnia: print ('|') if i == 14-nrDniaTygodnia: print ...
4a374436c0bf4099eb09579a49d15befe5b27c50
wiktoriamroczko/pp1
/07-ObjectOrientedProgramming/z16.py
710
3.75
4
class Student(): def __init__(self, name, surname, album): self.name = name self.surname = surname self.album = album def __str__(self): return f'{self.name} {self.surname} {self.album}' def __eq__(self,other): return self.album == other.album ...
fd8b41ce2736ce7e7818be2855f5b4bd01b64db1
wiktoriamroczko/pp1
/02-ControlStructures/1.py
357
3.78125
4
x = int(input('wprowadź liczbę: ')) if x % 2 == 0 and x >= 0: print (f'{x} jest liczbą parzystą i dodatnią') elif x % 2 == 0 and x < 0: print (f'{x} jest liczbą parzystą i ujemną') elif x % 2 != 0 and x >= 0: print (f'{x} jest liczbą nieparzystą i dodatnią') else : print (f'{x} jest liczbą niepa...
628b0675e9e0ce68c1b7f212ac66fc26c1f6b1e8
wiktoriamroczko/pp1
/01-TypesAndVariables/BMI.py
287
3.9375
4
height = int(input("Podaj wzrost w cm:")) x = height/100 weight = int(input(("Podaj wagę w kg:"))) bmi = weight/x**2 print (f"wskaźnik BMI: {bmi}") if bmi >= 18.5 and bmi <= 24.99: print ("waga prawidłowa") elif bmi< 18.5: print ("niedowaga") else: print ("nadwaga")
fa2a9583c449a012a6ed19295f87e00d94b79bc1
wiktoriamroczko/pp1
/02-ControlStructures/zadanie39.py
92
3.546875
4
a = 0 b = 1 c = 0 for i in range(51): print(a, end=' ') c = a+b a = b b = c
4f5fa5eb22637e05980a2e6c97f7f19e691540ac
Svengeelhoed/nogmaals
/duizelig/duizelig5.py
228
3.609375
4
banaan = input("vindt u ook bananen lekker?") poging = 1 print(poging) while banaan != "quit": banaan = input("vindt u ook bananen lekker?") poging = poging + 1 print(poging) if banaan == "quit": quit()
8c18d8b92868feb42bc1570ee7d5dd5f9fc3d757
RomyNRug/pythonProject2
/Week 4/Week 4.py
1,186
3.9375
4
import turtle def draw_multicolor_square(animal, size): for color in ["red", "purple", "hotpink", "blue"]: animal.color(color) animal.forward(size) animal.left(90) def draw_rectangle(animal, width, height): for _ in range(2): animal.forward(width) animal.left(90) ...
cbc542bd2d87fe3291b7b58cfac7ad584ca0037c
RomyNRug/pythonProject2
/Week 5/Exercises5.4.6.py
987
3.84375
4
#1 def count_letters(text): letter_counts = {} for letter in text.lower(): if letter.isalpha(): if letter not in letter_counts: letter_counts[letter] = 1 else: letter_counts[letter] += 1 return letter_counts def print_letter_counts(letter_cou...
a2f83dfcfdc486d479192c74fffe1b9ca6c7b82c
scmartin/python_utilities
/GAOptimizer/population.py
8,594
3.5625
4
# ToDo: # - redesign evolution algorithm to create a new population # without replacing any of the old population. Then, take # top 50% of parent and child populations # - add threading for creating child population # - add convergence criteria # import numpy as np from abc import ABC, abstractmethod import xml.et...
3b084397643d6a5276f75f7b4abe42e7b487ccd3
trup922/ExtractCompetitorKeywords
/venv/Include/FindKeywords.py
4,289
3.5625
4
import requests from bs4 import BeautifulSoup from urllib.parse import urljoin import re import heapq import difflib #helper function for removing all occurences of an item from a list, will come in hand when we will filter out certain words from a string def remove_values_from_list(the_list, val): return [value fo...
e4abf277d6f7e139a1a8c52d0101707400a92396
Marcbaer/02.01.Deploying_Forecasting_Model_using_AzureML_SDK
/Train_LSTM.py
735
3.515625
4
import matplotlib.pyplot as plt from LSTM_LV import Lotka_Volterra #Define model and training parameters n_features=2 n_steps=12 hidden_lstm=6 Dense_output=2 epochs=250 #Lotka Volterra data parameters shift=1 sequence_length=12 sample_size=2000 #Build, train and evaluate the model LV=Lotka_Volterra(shift,seq...
8d1ae76c20631b26a86436a0a4a02a0fdb73699a
nedchewnabrJCU/Sandbox
/Finished Practicals/prac_02/randoms.py
917
4.09375
4
import random print(random.randint(5, 20)) # line 1 print(random.randrange(3, 10, 2)) # line 2 print(random.uniform(2.5, 5.5)) # line 3 # What did you see on line 1? # The number seen was "5". # What was the smallest number you could have seen, what was the largest? # Smallest number is "5", largest numbe...
0fec5b9ccde19b79c8751870433d1c3fad64c483
gauravthadani/ml-learning
/python/demo_dtc.py
800
3.953125
4
#Introduction - Learn Python for Data Science #1 #youtube link = https://www.youtube.com/watch?v=T5pRlIbr6gg&t=3s from sklearn import tree import graphviz #[height, weight, shoe size] X = [[181, 80, 44], [177, 70, 43], [160, 60, 38], [154, 54, 37], [166, 65, 40], [190, 90, 47], [175, 64, 39], [177, 70, 40], [15...
18bd45cd6fa90bd71e719888237f80fc44908984
leonh/pyelements
/examples/a7_generators.py
801
3.875
4
from examples.a1_code_blocks import line # generators use yield something def integers(): for i in range(1, 9): yield i integers() print(line(), integers()) # Generator objects execute when next() is called print(line(), next(integers())) chain = integers() print(line(), list(chain)) def squared(seq)...
b0c33c8848844a6a025ee5c145f1ef1373ba3c30
x223/cs11-student-work-Aileen-Lopez
/practice_makes_perferct.py
160
4.125
4
number = input("give me a number") def is_even(input): if x % 2 == 8: print True else: print False #can't get it to say true or false
ece16e9a25e880eaa3381b787b12cecf86625886
x223/cs11-student-work-Aileen-Lopez
/March21DoNow.py
462
4.46875
4
import random random.randint(0, 8) random.randint(0, 8) print(random.randint(0, 3)) print(random.randint(0, 3)) print(random.randint(0, 3)) # What Randint does is it accepts two numbers, a lowest and a highest number. # The values of 0 and 3 gives us the number 0, 3, and 0. # I Changed the numbers to (0,8) and the res...