blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
49724e5a686ffcd88418664b31706c68b6c9dd7e
murilosleite/PycharmProjects
/pythonExercicios/ex014.py
151
3.953125
4
C = float(input('Informe a temperatura em Celsius: ')) F = (C * 1.8) + 32 print('A temperatura de {} Celsius corresponde a {} Fahrenheit'.format(C, F))
e7da25b52b080d4d713abd70cbdc7ed949c78b79
johndunne2019/pands-project
/Histogram.py
1,744
4
4
# 2019-04-15 # John Dunne # To create a histogram of the data using matplotlib.pyplot # Script adapted from example analysis read here: https://machinelearningmastery.com/machine-learning-in-python-step-by-step/ print("The Histogram will appear on your screen momentarily") # printed sentence to the screen as the hist...
8ab4e53801e0c8f4715db3ce98448e300f16e77c
danilodelucio/Exercicios_Curso_em_Video
/ex005.py
166
3.75
4
n1 = int(input("Digite um valor: ")) #ns = n1 + 1 #na = n1 - 1 print("O valor digitado é {}. Seu sucessor é {} e seu antecessor é {}.".format(n1, (n1+1), (n1-1)))
85384f3c881e425d6c30b537b6869908d89bbc57
feilaoda/ChatUp
/tools/watermark.py
4,773
3.796875
4
# -*- coding: utf-8 -*- import Image, ImageDraw, ImageFont, uuid import os import ImageEnhance POSITION = ('LEFTTOP','RIGHTTOP','CENTER','LEFTBOTTOM','RIGHTBOTTOM', 'CENTERTOP', 'CENTERBOTTOM') PADDING = 5 MARKIMAGE = 'water.png' def reduce_opacity(im, opacity): """Returns an image with reduced opac...
a7bab224d7677334bf8a39ae48e54420461c7b3d
Alphonso84/Python_Scripts
/greeting.py
154
4.03125
4
name = input("What is your name? ") status = input("Hello {}, how are you today? ".format(name)) print("Good to hear you're {} today".format(status))
abc6b64022789015fc57bba40994d07fb85b5e10
wangxiaolinlin/1803
/高级1803/03day/隔壁老王.py
2,078
3.734375
4
#创建人类 class Person(): def __init__(self,name): self.name = name self.gun = None self.hp = 100 def zhuangzidan(self,danjia,bullet): danjia.addBullet(bullet) def zhuangdanjia(self,gun,danjia): gun.addDanJia(danjia) def takeGun(self,gun):#老王拿枪 self.gun = gun def openGun(self,diren):#老王开枪 #拿到一发子弹 if di...
e551b22bceaa8e624e324787eda228e1edd9aacd
chenjiexu1010/spider
/flaskr/test.py
183
3.671875
4
# -*- coding:utf-8 -*- # !/usr/bin/Python3 import sqlite3 conn = sqlite3.connect('sqlite_db') cur = conn.cursor() cur.execute('SELECT TOP 100 * FROM entries;') print(cur.fetchall())
399f01e057a52f5fd5c40b6392a320fc28dea596
gxmls/Python_Basic
/20210401-star_angle.py
921
3.8125
4
''' 读入一个整数N,N是奇数,输出由星号字符组成的等边三角形,要求:‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬ 第1行1个星号,第2行3个星号,第3行5个星号,依次类推,最后一行共N的星号。‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬ 如:输入3 输出: * *** ''' N=eval(input()) for i in range(1,N+1,2): # range(s...
37ffa5a8d25dbf9a1becb91e4e239dc4973da0e5
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_1/Katajam/a.py
453
3.53125
4
def getNum(x): return list(map(int, list(str(x)))) def solution(ori, x, num, used): if x in used: return 'INSOMNIA' for i in getNum(x): num.add(i) if num == SLEEP: return x used.add(x) x += ori return solution(ori, x, num, used) SLEEP = set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) n = int(input()) for i in range(n)...
464d449205e1a64a0da285210ed5bf6bec7650b4
Ana-MariaDovgan/Instructiunea-IF
/problema12.py
616
3.828125
4
“Mă iubeşte un pic, mult, cu pasiune, la nebunie, de loc, un pic,…”. Rupând petalele unei margarete cu x petale, el (ea) mă iubeşte …. Exemplu: Date de intrare: x=10 Date de ieşire: … de loc. a=int(input("dati numarul de petale ale unei flori: ")) if (a % 5 == 0): print("Nu ma iubeste de loc") elif (a % ...
fa6c7937270de32d2d1c129e4d6258e328aeb513
thanhlankool1/Python-pymi-9-12
/get_repository.py
1,038
3.53125
4
''' 1 - Viết 1 script để liệt kê tất cả các GitHub repository của 1 user: Ví dụ với user ``pymivn``, sử dụng dữ liệu ở JSON format tại https://api.github.com/users/pymivn/repos Câu lệnh của chương trình có dạng:: python3 githubrepos.py username Gợi ý: Sử dụng các thư viện: - requests - sys or argparse ''' im...
52404a48f32a33d61766205a8362319f6f300ca9
kumaravinash7009/Python
/function1.py
130
3.765625
4
def maths(a,b): c=a+b d=a-b e=a*b f=a/b return c,d,e,f add,sub,multi,div=maths(9,3) print(add,multi,div) print(maths(2,3))
4f69779184c3347f84e6ecb4d26554b67c911576
mkatynski/greenphire_assessment
/Assessment.py
8,367
4.125
4
#!/usr/bin/env python # ## ###Marcus Katynski ###May 6, 2017 from random import randint from collections import Counter #We need the random library for tiebreaking as per point 6, and #the Counter module from the collections library for organizing #the duplicates from among the chosen numbers. class employee: #Thi...
cbe7339258f36081b433d10426661d61e598d259
dylanhudson/notes
/tab_reader.py
408
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import csv #import pandas as pd if len(sys.argv) != 2: print("Missing input file.") print('Use: %s <filename>' % sys.argv[0]) sys.exit(1) filename = sys.argv[1] with open('filename', newline='') as data: data_reader = csv.reader(data, delimit...
7cbfbaf301f5ed23bce0dadaec272cad000f86b8
Slash-81/project
/Cacl/calc.py
232
3.828125
4
actions = ["+", "-", "*", "/"] arg1 = input("Enter the first number>>") arg2 = input("Enter the second number>>") action = input("Enter the action>>") arg1 = int(arg1) arg2 = int(arg2) if action not in actions: print("Error")
9a09236d4c241698c5bd272a7d3f4334c4bff419
cabbagecabbagecabbage/CCC-2021
/Junior/J1.py
113
3.546875
4
b = int(input()) p = 5*b - 400 print(p) if p > 100: print(-1) elif p == 100: print(0) else: print(1)
1312fd96736a251119fd1cec6f98e2c9940e0563
Moatasem-Elsayed/Python-Scripts-
/SimpleServer_TCP.py
575
3.515625
4
import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) ip=socket.gethostbyname(socket.gethostname()) print("your ip is : "+ip) print("=============================") s.bind((ip,5000)) s.listen(5) while True : client,address=s.accept() rodata=client.recv(1024) print(f"{address} is se...
5a2376e04a2809d3c059e6a0151ca0c0d71ae83e
sujala/pythonPlayground
/algorithm/search/binary_search_iter.py
659
3.84375
4
""" Binary search """ import random lst = [random.randint(0,10000) for i in range(10000)] lst = [1,3,4,5,4,3,2,7,8,6,34,32,12,76,78,34,32,87] lst = sorted(lst) def binary_search_itr(e,l): start = 0 end = len(l)-1 while end >= start: middle = (start + end) // 2 candidate = l[middle] ...
389a89b468d711acbed6d0057cbaacd3bc8f5ce0
Oussema3/holbertonschool-higher_level_programming
/0x0B-python-input_output/9-student.py
397
3.71875
4
#!/usr/bin/python3 """ class Student """ class Student(): """ Rpresenting a student with: first name , last name and age """ def __init__(self, first_name, last_name, age): """ class init """ self.age = age self.first_name = first_name self.last_name = last_name ...
bff669b4899efc067b62b51610b6c88b496a4375
jongiles/python_data_apy
/session_09_working_files/inclass_exercises/inclass_9.5.py
341
3.921875
4
# 9.5: Convert another function to lambda. The following # function takes a dict key and returns the value. Convert to # a lambda for use in the sorted() function. d = {'a': 10, 'b': 2, 'c': 5} def byvalue(arg): return d[arg] skeys = sorted(d, key=byvalue) print(skeys) # ['b', 'c', 'a'] (in order of v...
352f665e1648cd4be7e740d7fbc08b200a177d81
leetcode-notes/CSE20-Projects
/Assignment_2/MagicNum.py
564
3.984375
4
#we definitely know that 30 is the starting number, so lets start with 30 def loop(n): counter = 0 i = 30 while(counter < n): if(len(checkPrimes(i)) >= 3): print(i) counter+=1 i+=1 def checkPrimes(n): x=2 primes = [] finalprimes = [] while(x <= n): ...
5a901bfa6d2b59c2be1afee0fec151bdc631b294
tsungic/w19a
/app.py
877
4.09375
4
from addition import add from subtraction import subtract from multiplication import multiply from division import divide def add(x,y): return x + y def subtract(x,y): return x - y def multiply(x,y): return x * y def divide(x,y): return x / y #take input from user print ("Welcome to simple calcu...
ecf905486281fd034f0fe45144f261c74a06a1e1
warmslicedbread/mini-projects
/isogram/isogram.py
411
3.96875
4
def is_isogram(string): if len(string) == 0: return True letters = [] count = len(string) string = string.lower().strip(' ') while count > 1: letter = string[-1] string = string[:-1] print(string) print(letter) if letter in string: return F...
c5f3d59ecd773af3452ef69ee8cfc95511c75ab4
FrozenLemonTee/Leetcode
/twoSum/twoSum.py
2,063
3.828125
4
""" 两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/two-sum 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ from typing import...
8a1b35b06d32a93ebb1a6b89a2d6c687e2ff247c
AlelksandrGeneralov/ThinkPythonHomework
/nested_sum_v00.py
403
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 4 20:27:35 2019 @author: aleksandr """ l = [[1, 2, 3], [4, 5, 6], [7, 8, 9], 10] def nested_sum(l): total = 0 for i in l: if isinstance(i, list): #check if i is list total = total + nested_sum(i) ...
edff7d694d4949f6fb66b3d973e2246d552f7324
RomainSabathe/kaggle_expedia2015
/Code/data_cleaning.py
3,678
3.6875
4
import pandas as pd import warnings def generic_clean_date_time(df, column_name, suffix, include_hours=False): """ Clean a column called "column_name" from df which must be of type pandas.tslib.Timestamp. New columns are added with a "suffix" for disam- buiation. df: the df we want to modify. c...
00a8440a55354d545cf6e3ac3e381d6500936391
MrHamdulay/csc3-capstone
/examples/data/Assignment_6/dplaxe001/question1.py
387
4.21875
4
'''Program to print out names Axel du Plessis 20-04-2014''' names = [] namelengths =[0] print("Enter strings (end with DONE):") name = input("") while name not in "doneDoneDONE": names.append(str(name)) namelengths.append(len(name)) name = input("") form = "{0:>"+str(max(namelengths))+"}" prin...
7a19394770222b8530ea6846db7fedf9793da8a7
sinkzephyr/pyslib
/move_to.py
1,317
3.90625
4
''' 删除多余子目录的脚本 如 python move_to.py '/Users/zaker_6/百度云同步盘/得到订阅/LR 实战/2017-10' lr 第一个参数为要遍历的目录,第二个参数为多余子目录 ''' import sys import os import re import shutil import dir if __name__ == '__main__': path = None sub_path = None if len(sys.argv) > 1: path = sys.argv[1] sub_path = sys.argv[2] print('2n...
fd337f20f81a0a88d904c9e6975cd2b9d1074b3d
zhouwh1989/learn_python
/031-property的原理.py
1,637
4.1875
4
### 描述符 ### 将某种特殊类型的类的实例指派给另一个类的属性 ### __get__(self, instance, owner) 访问属性,返回属性的值 ### __set__(self, instance, value) 属性分配中调用,不返回值 ### __delete__(self, instance) 控制删除操作,不返回任何内容 class Mydesc: def __get__(self, instance, owner): print("get: ", self, instance, owner) def __set__(self, insta...
27edecc3d5aa45c1735f5d48a845484815d0b223
ConorSheehan1/ctci
/conor/Python/string_and_arrays/1_3_remove_duplicates.py
797
3.984375
4
# strings are immutable in python so this doesn't really work without a separate buffer # can do something like this, but order isn't preserved, and string is casted to set def rem_dup(some_string): return "".join(set(some_string)) # can do something like this (cast string to list, which is mutable) # can't use f...
fa65ab989ce29e9bf398fdb2294d495c3d28794a
eye-of-dev/gb-py-client-server-applications
/lesson01/task02.py
712
3.890625
4
""" 2. Каждое из слов «class», «function», «method» записать в байтовом типе без преобразования в последовательность кодов (не используя методы encode и decode) и определить тип, содержимое и длину соответствующих переменных. """ WORDS_B = [b'class', b'function', b'method'] for value in WORDS_B: print(va...
ab3dbe0a489be295f9430637e2ebb6788589c763
adityaranjan/KattisSolutions
/speedlimit.py
611
3.671875
4
TimeList = [] flag = True while flag == True: cases = int(input()) if cases == -1: flag = False else: Distance = 0 for i in range(cases): if i == 0: mph, time = map(int, input().split(" ")) TimeList.append(time) ...
03cb423fb3b10ded2a962655b458dfd672d99d02
AlbanCrepel/USMB-BachelorDIM-Lectures-Algorithms
/assignments/Session3/S3_imgproc_tools.py
1,616
3.859375
4
import cv2 import numpy as np img_gray = cv2.imread("cat.jpg",0) img_bgr = cv2.imread("cat.jpg",1) #display the matrix shapes print("Gray levels image shape = "+ str(img_gray.shape)) print("BGR image shape = "+ str(img_bgr.shape)) #display the loaded images cv2.imshow("Gray levels image", img_gray) cv2.imshow("BGR ...
9193296ae83f70ed6225f82f42c3e9e070beec03
gfYaya/yayaPython
/fluent python/chapter 2 An Array of Sequences/Arrays.py
839
3.84375
4
# coding = utf-8 # Example 2-20. Creating, saving, and loading a large array of floats # It shows creating, saving, and loading an array of 10 million floating-point random numbers. from array import array from random import random # array(typecode [, initializer]) -> array , the typecode is C type floats = array(...
5e191c8c3e83b1667744ddabaad5978cb98ad776
paulrefalo/Python-2---4
/python1/caser.py
1,089
4.21875
4
#!/usr/local/bin/python3 """Obj 13 - More Python Functions - caser.py This script allows a user to input a string and have the string modified in typical ways...upper case, lower case, etc. """ import sys if __name__ == "__main__": switch = { # set up switch to give proper str outp...
fe4376d3cb0b2202ed0d465026d60511d2ffdf68
FWRobins/PCPP
/CandyStoreLab_deepCopy.py
1,946
4.1875
4
""" The task Your task is to write a code that will prepare a proposal of reduced prices for the candies whose total weight exceeds 300 units of weight (we don’t care whether those are kilograms or pounds) Your input is a list of dictionaries; each dictionary represents one type of candy. Each type of candy contains a ...
1c156008b5a56866789f04537587be28c4d4a935
codefire53/DDP1
/uas2017/andri_syifa.py
899
3.53125
4
from tkinter import * class Voting: def __init__(self): self.window=Tk() self.window.title('E-Vote') self.window.geometry('270x100') self.VotesOfAndri=IntVar() self.VotesOfAndri.set(0) self.VotesOfSyifa=IntVar() self.VotesOfSyifa.set(0) self.label_andri=Label(self.window,font="Arial 18",textvariable=se...
d233c7d5b8e9180dbd877877caeed5bc69adae3c
brandonyuong/tic_tac_toe_ai
/game_utils.py
4,313
3.796875
4
import random def makeMove(board, letter, key): # Create move on board board[key - 1] = letter def isMoveOpen(board, key): # Return true if the passed key is free on the passed board. return board[key - 1] == ' ' def isWinner(board, playerLetter): # Given a player’s letter, check if player has...
8e45f1d566c8be5360b46cd217165b84146d6e74
angelika22/instructiunea_if
/pr 13.py
573
3.703125
4
#La un concurs se dau ca premii primilor 100 de concurenţi, tricouri de culoare albă, roşie, albastră şi neagră, în această secvenţă. Ionel este pe locul x. Ce culoare va avea tricoul pe care-l va primi? a=100 x=int(input("pe ce loc sta Ionel ")) if x<=100: if (x>0) and (x<=40): print("Ionel a primit ...
39d7b5196571f857b064141f698bda322f104056
duyot/python_begining
/ListData.py
797
3.96875
4
vowels = ["a", "e", "i", "o", "u", "u"] vowels.remove("u") vowels.pop(1) vowels.extend(["k", "j"]) vowels.insert(0, "add through insert") dup_vowel = vowels.copy() print(dup_vowel) print(vowels) word = input("Please provide the word to check vowel: ") found = [] for character in word: if character in vowels: ...
3ddc61c4f2e0b737b1b68c6afd381cb05ac1b9eb
takupaku/pythonCrashCourseCptrFour
/4-1.pizzas.py
318
3.921875
4
pizzas=["chicken pizza","beef pizza","mutton pizza"] for pizza in pizzas: print(pizza) print("\n") for pizza in pizzas: print("i like "+pizza) print("\n") print("my favourite type of pizza is chicken pizza") print("i can cook both chicken and beef pizza") print("I really love pizza!")
7aac6e0ab9b23ea058d77423adba71b6e0186e60
MaisenRv/EjerciciosCiclo1
/eje77_numpy.py
399
3.59375
4
import numpy as np a = np.array(list(range(1,5))) # Crea un arreglo lineal print(type(a)) # Imprime "<class ’numpy.ndarray’>" print(a) print(a.shape) # Imprime "(4,)" es de tamaño 4, de 1 dimensi ́on print(a[0], a[1], a[2]) a[0] = -4 print(a) b = np.array([[1,2,3,5,6],[4,5,6,7,8]]) # Crea un arreglo 2-dimensional pri...
1957711865e1570ed423c327f288ce8a12d2fe50
jacquelinefedyk/team3
/examples_unittest/area_square.py
284
4.21875
4
def area_squa(l): """Calculates the area of a square with given side length l. :Input: Side length of the square l (float, >=0) :Returns: Area of the square A (float).""" if l < 0: raise ValueError("The side length must be >= 0.") A = l**2 return A
e36d87da352dd69e09f58abc54785a7ad00dd2ab
skysamer/first_python
/코딩예제/lambda01.py
438
3.953125
4
power=lambda x:x*x under_3=lambda x:x<3 list_input_a=[1, 2, 3, 4, 5] output_a=map(power, list_input_a) print("# map() 함수의 실행결과") print("map(power, list_input_a):", output_a) print("map(power, list_input_a):", list(output_a)) print() output_b=filter(under_3, list_input_a) print("# filter() 함수의 실행결과") print("filter(un...
28560ba68f67b915cb6a433f5cdb39f3ee35366e
batcha333/python-programs
/tasks/remove null.py
169
3.734375
4
str1=['Emma','Jon',' ','Kelly',None,'eric',' '] s=[] for i in str1: if(i==' ')or(i==None): continue else: s.append(i) print(s)
f8c84cefe02cfbd76434035ab30a209b0830f39f
karanjakhar/python-programs
/prac4py.py
1,326
4.25
4
print("7. Program to demonstrate the use of Various string function") print("capitalize()") strr='akshay Jawla' i=strr.capitalize() print(i) print("count()") strr='akshay' strrr='a' i=strr.count(strrr) print(i) print("endswith()") strr='akshay' strrr='y' i=strr.endswith(strrr) print(i) print("start...
2d65db9814b3a7d6270766fcb0edae6f7beb95fa
thomaszag/TicTacToe
/TicTacToe.py
5,475
3.84375
4
# Prints board def printGame(board): print(board[0],"|",board[1],"|",board[2]) print("-","-","-","-","-") print(board[3],"|",board[4],"|",board[5]) print("-","-","-","-","-") print(board[6],"|",board[7],"|",board[8]) # Gets random player and symbol def random(): import random # to get a random player b...
deca6defd1b3b3eab534fe581aa8d36d1d0e730d
houkensjtu/misc
/fib.py
399
3.53125
4
global x x = 0 def fib(n): global x x += 1 if n==1: return 1 elif n==2: return 1 else: return fib(n-1) + fib(n-2) data = {1:1,2:1} def fib_eff(n,data): global x x += 1 if n in data: return data[n] else: data[n] = fib_eff(n-1,data)+fib_eff(n-2,data) return...
2f697b98552b3b001b219bcac8c95a1b00c13c3c
claraj/ProgrammingLogic1150Examples
/8_strings/join_strings.py
150
3.6875
4
subjects = ['English', 'Math', 'Information Technology', 'Geography'] all_subjects = ', '.join(subjects) print('Your subjects are: ', all_subjects)
853718b581bb0cca316b21e602813eae6a0b9016
testcg/python
/code_all/day17/demo03.py
550
4.03125
4
""" zip """ list_name = ["郭世鑫", "万忠刚", "赵文杰"] list_age = [22, 26] # for 变量 in zip(可迭代对象1,可迭代对象2) for item in zip(list_name, list_age): print(item) # 应用:矩阵转置 map = [ [2, 0, 0, 2], [4, 2, 0, 2], [2, 4, 2, 4], [0, 4, 0, 4] ] # new_map = [] # for item in zip(map[0],map[1],map[2],map[3]): # new...
a2492434a782835316fd9384d10ad0ef3e56d9c0
tahuh/SynbioBioModule
/count_num_seqs.py
737
3.59375
4
#!/usr/bin/python """ count_num_seqs.py Count the number of sequences in fasta/fastq file Author : Thomas Sunghoon Heo """ import argparse import sys parser = argparse.ArgumentParser() parser.add_argument("--infile", type=str, required= True, help="infile") parser.add_argument("--type", type=str,default="fasta", help...
f067474914eeef8c4d441f18e702824c5cbd4f25
SimmaLimma/Web_app_analysis
/PLData.py
7,539
4.21875
4
import pandas as pd import numpy as np class PLData: """ Class that handles data read from Premier league data (or other football data on the same format). The format that the read csv file needs to have it on the form |index|home_team|away_team|home_goals|result|season|, which is stor...
dcb9475a00c1f4bdc0e6988595e3cde2bb816390
tanmaya191/Mini_Project_OOP_Python_99005739
/6_OOP_Python_Solutions/set 1/quadrant.py
773
4.3125
4
""" finding quadrant of a point""" def find_quadrant(x_val, y_val): """quadrant check""" if x_val == 0 and y_val == 0: print("Point is on the origin") elif x_val == 0: print("Point is on Y axis") elif y_val == 0: print("Point is on X axis") elif x_val > 0 and y_v...
968a5c0c6217daaeee37f04a52178a0ae069ddc2
Bonicc/Machine-Learning
/NeuralNetwork/SinglePerceptron.py
2,736
3.75
4
import numpy as np class SinglePerceptron(): # Perceptron which has a weight vector and bias scalar # This model is trained with backpropagation def __init__(self): self.weight = None self.bias = None return def train(self, trainX, trainY, learning_rate = 0.01, loss_function = ...
a865240933e3d951f033b2d627327fe443feade4
zhasun/AIProject
/project3/BayesianNet/question5_solver.py
1,584
3.5
4
class Question5_Solver: def __init__(self, cpt2): self.cpt2 = cpt2; return; ##################################### # ADD YOUR CODE HERE # _________ # | v # Given z -> y -> x # Pr(x|z,y) = self.cpt2.conditional_prob(x, z, y); # # A word begins w...
77ba19df1bad9197f658bfb3554f7324820c946f
rajkrishnan8/peg-solitaire
/python/solitaire.py
736
3.640625
4
class Board: def __init__(self, dim, cutout_dim): self.board = Board.board(dim, cutout_dim) def board(dim, cutout_dim): b = [] for j in range(1, dim+1): row = [] for i in range(1, dim+1): if j <= cutout_dim or j > (dim - cutout_dim): if i <= cutout_dim or i > (dim - cutout_dim): row.append...
e8d2bfba3a1e9914547b7bf502381a52c758998b
cwong168/py4e
/chapter_9/ch_9_ex_3.py
596
3.921875
4
''' Write a program to read through a mail log, build a histogram using a dictionary to count how many messages have come from each email address, and print the dictionary. ''' file = input('Enter file name: ') fo = open(file) word_list = dict() for line in fo: arr = line.split() for item in arr: if ...
5a39d9c5e8828076bafe4ffeeef506b04a440cfb
Reazul137/Complete-Python
/Conditional Logic/08.py
201
3.859375
4
year = input("Type a year value : ") year = int (year) if year % 400 == 0: print("yes") elif year % 100 == 0: print("No") elif year % 4 == 0: print("Yes") else: print("No")
519a3a03b15d0337cde9fef7ea938b099d63db24
atgoud/technical-interviews
/practice_questions/hackerrank/data_structures/trees/height_of_binary_tree.py
473
3.859375
4
""" @author: David Lei @since: 6/11/2017 https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree/problem The height of a single node is 0, the height of a binary tree is the number of edges from the root to it's furthest leaf. Given the root return the height of the tree. Passed :) """ def height(root):...
d21b6d9d5fa588773fee6aca7c09adc3bfc32f4c
git-athul/Python-HARDWAY
/ex07.py
177
3.640625
4
#ex07 More printing print('.' * 12) print("You", end=' ') print("should", end=' ') print("see", end=' ') print("!") #"end= " changes the ending of printing print('.' * 12)
d3366afadcd3e31ec8442c4145cd81fb99cc8ebb
burevestnik-png/tint-ognp
/data-science-module/task_1/services/printer.py
395
3.671875
4
class Printer: separator = "<========================>" @classmethod def print_dict(cls, dictionary, message=""): cls.print_separator() print(message) print("{") for key, value in dictionary.items(): print(" {0}: {1}".format(key, value)) print("}") ...
4e70c35d1ae42e2ed14590c7ab31ad2126922a2d
superartyom/Python_Homeworks
/Day_6_Homework_checked.py
4,916
4.21875
4
"""FUNCTIONS""" # 1. We'll say that an element in an array is "alone" if there are values before and after it, and those values are # different from it. Return a version of the given array where every instance of the given value which is alone is # replaced by whichever value to its left or right is larger. import ran...
fc1ec6534e1a227b6519ac7385ed3fd7e91f4edc
saidaHF/InitiationToPython
/exercises/algebra1.py
1,655
4.5625
5
#!/usr/bin/env python # solution by cpascual@cells.es """ Exercise: algebra1 ------------------- Use numpy arrays for performing algebraic manipulations of matrices and vectors 1. create the following 3x3 square matrix: M = np.array([[1,2,0], [0,2,0], [0,0,3]]) ...
ede9f43f07a0c6a363932eb74251d2a941fb260d
vidhlakh/LeetcodeProjects
/May Leetcode Challenge/16_Odd_Even_List.py
1,368
3.9375
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def oddEvenList(self, head: ListNode) -> ListNode: # Corner case if (head == None): return None # Initialize first node...
124ed04cedf043b7a00d09a2577d4edbae4728f7
mushahiroyuki/beginning-python
/Chapter05/0503potter.py
302
4.09375
4
name = input('May I have your name? ') if name.endswith('Potter'): if name.startswith('Mr.'): print('Hello, Mr. Potter!') elif name.startswith('Mrs.'): print('Hello, Mrs. Potter!') else: print('Hello, Potter!') else: print('Hello, stranger.') # 知らない人
718fe6b84a9a6d0008c027a11ce2d029db77e974
amirdharaja/sarah
/repeat N times.py
134
3.515625
4
try: no_of_times=int(input()) string="Hello" for i in range(no_of_times): print(string) except: print("Give valid input")
2c94c961a7ddee1363f5312e550dd309f3ca0732
MachunMC/python_learning
/python_review/05_什么是列表.py
662
3.921875
4
# -*- coding: utf-8 -*- # @Project : python_learning # @File : 05_什么是列表.py # @Author : Machun Michael # @Time : 2021/3/14 14:23 # @Software: PyCharm # 列表类似数组 # 是由一系列按特定顺序排列的元素组成 # 列表由 "[]"括起来,并用逗号分隔 students = ["Tom", "Lucy", "Lily", "Jack"] print(students) # 可以使用列表索引来访问列表元素,列表索引从0开始 print("The first student ...
09565805b7232ac678bf2910c3e733cee3e67adf
Hryb-Yaroslav/Laba-1
/Task1.py
260
4.125
4
a = int(input("Enter the first number: ")) b = int(input("Enter the second number: ")) d = input("Enter an action: + , - , * , / ") if d == "+": print(a + b) elif d == "-": print(a - b) elif d == "*": print(a * b) elif d == "/": print(a / b)
5c3bf3b7c1a70fde284596572ee9333c24c20ef1
kou1127h/atcoder
/ABC/ver2/106/B.py
441
3.578125
4
def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] N = int(input()) ans = []...
e4c08fb85b9d805fad72f1124145fa666f41127b
eoalbert/pythonPatterns
/bridge.py
967
4.1875
4
from __future__ import annotations from abc import ABC, abstractmethod class Model: def __init__(self, color): self.color = color def display_car(self): pass class Ford(Model): def __init__(self, color): super().__init__(color) def display_car(self): print(f"This Fo...
a620f9be0c2a897c13ecc25208ea3a6f18fa1e3c
thiago-amaral/the-meditating-ninja
/menu.py
5,123
3.703125
4
import pygame from utils import render_font, Screen from constants import MEDIUM_FONT, SCREEN_NAMES, MENU_CONSTANTS from string import ascii_lowercase class Button(): ''' Defines a button which can be either active or inactive. Visuals vary depending on which state the button is in. ''' def __ini...
28f8bd2090dabc04bfffe23d2ff723f17045bdcb
mauriciozago/CursoPython3
/Exercicios/Desafio12.py
138
3.59375
4
preco = float(input("Insira o preço do produto: ")) print('O novo preço do produto, com 5% de desconto, é {:0.2f}'.format(preco*0.95))
4d848120b9d289d205df26861cd2547de3888345
youjia4321/python_patterns
/adapter/adapter-pattern01.py
1,100
3.84375
4
''' #1 所谓适配器模式是指是一种接口适配技术,它可通过某个类来使用另一个接口与之不兼容的类,运用此模式,两个类的接口都无需改动。 #2 适配器模式(Adapter Pattern): 将一个类的接口转换成为客户希望的另外一个接口.Adapter Pattern使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 应用场景:系统数据和行为都正确,但接口不符合时,目的是使控制范围之外的一个原有对象与某个接口匹配, 适配器模式主要应用于希望复用一些现存的类,但接口又与复用环境不一致的情况 ''' class Target(object): def request(self): ...
98020a216534ae75f76685b7d49e2fa1e64f52ec
devathul/prepCode
/DP/longestIncreasingSubsequence.py
3,157
3.9375
4
""" longestIncreasingSubsequence Given a sequence of n number A1,A2,...,An; determine a subsequence (not necessarily contiguous) of maximum length in which the values in the subsequence from a strictly increasing sequence. Approach 1: Using Recursion Here we create a tree, where every node at level one represents the ...
c95d113b4a432c952b188a1542ba9719f44b3dc8
rajeshvermadav/XI_2020
/controlstatements/loop_for.py
106
3.59375
4
# For loop a=0 s=0 for a in range(1,11): s += a print(a) print("Sum of Series %s " %s)
ea40c4d21a9056ebc2f4f30dc02c74aba2c1824a
Chris940915/subbaksu_algorithm
/week2/2-3.py
714
3.609375
4
# https://leetcode.com/explore/learn/card/fun-with-arrays/526/deleting-items-from-an-array/3248/ ''' Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input ar...
f16febb4741e6c9e3d59f3e7cad1fb97e46559c4
satooltama/PycharmProjects
/week2.1/pracSlide57.py
152
4.03125
4
from pracLibrary import namesplit name = input("Please Enter your full name : ") print("Your Thai-Nichi student Email is {}".format(namesplit(name)))
68114fec2263fcc5c4843606b7ab4b082a5630f2
Divya192/divyathoughts
/Read.py
214
3.734375
4
file = open('text file') #print(file.read(1)) #print(file.readline()) #sam=file.readline() #while sam!="": #print(sam) #sam = file.readline() for sam in file.readline(): print(sam) file.close()
5a154d04be86c136b3fb67e562b4732e39f3c5be
madfalc0n/my_coding_labs
/algorithm/programmers/temp/code_box_2.py
618
3.515625
4
""" 제곱수 임의로 더한거 1, 3, 4, 9, 10, 12, 13, 27, 28,,, """ def solution(n): start_index = 3 start_squared = 2 tmp_list = [0,1,3] while start_index < n: if n == 1: return 1 elif n == 2: return 3 else: sum_list = [val+tmp_list[-1] for val in tmp_list[...
bc4fcdccda09ff60c13f6327bc808d0f697d3bdb
stephenrods-21/python-test
/scraper.py
510
3.875
4
from twitter_scraper import Profile def get_account_name_from_url(twitter_url): account_name = twitter_url.replace('https://twitter.com/', '') return account_name if __name__ == '__main__': url = input('Enter the twitter profile url\n') account_name = get_account_name_from_url(url) try: ...
e1f22ce1e949a226b41262a3feb7ddfe59bf215e
worklifesg/Deep-Learning-Specialization
/Introduction to Deep Learning & Neural Networks with Keras/Module3/Classification_with_Keras.py
2,096
3.59375
4
##Lab3_Classification_with_Keras # Sequential model with Dense layer # ReLU activation function, Adam - optimizer and loss - MSE # After saving model we can import it without losing computation memory and time #from keras.models import load_model #pretrained_model = load_model('classification_model.h5') import numpy...
c4940e2a7aeaff9611e5b5322166fe2431628734
JokerTongTong/Matplotlib_learn
/第二章-定制颜色和样式/2.5定制盒状图每一部分的颜色.py
541
3.546875
4
# 2.5定制盒状图每一部分的颜色 import random import matplotlib.pyplot as plt ''' 高斯分布 gauss(num1,num2) num1:平均值 num2:标准差 ''' # 0 是平均值 1 是标准差 values = [random.gauss(0,1) for i in range(100)] # print(values) b = plt.boxplot(values) colorList = ['r','b','g','y'] i = 0 for name,line_list in b.items(): # print(name) # print(l...
28c40900494b10b462a8dcfeba23360fe9762b83
DownToSky/ProjectEuler
/Euler122.py
1,508
3.921875
4
#By DownToSky #Euler Problem 122 from time import time def least_exponen(pow,least_steps,l=[1]): """ We know that binary exponentiation provides us with a very good upper bound on the number of steps. max_h prompts this function to not search for levels lower than the value of the max_h """ if pow<1: raise Va...
e8a425370d4f8d3e88240b56640047bc7471aef5
alexander857/FP_Laboratorio_06_-00355519-
/10gradosFCK.py
1,399
4.09375
4
print("Convertor de °F a °C, °C a °F, Kelvin a °C, °C a Kelvin, Kelvin a °F y °F a Kelvin") def FC(): f = float(input("Ingrese los grados Fahrenheit que desea convertir: ")) c = ((f-32)/1.8) print("Equivale a ",c,"°C") def CF(): c = float(input("Ingrese los grados Celsius que desea convertir: ")) f = ((c*1.8)...
fddb4b73ccef04b5a59c2820d5a748864eec2206
zhangbo111/0102-0917
/就业/day06/03-单例模式.py
1,265
3.671875
4
class Singleton(object): def __new__(cls): ''' cls:接收的是MyClass类 ''' # print(cls) if not hasattr(cls, "_instance"): # 第一次创建实例的时候 # 创建cls(MyClass)类的对象 进行返回 # 将创建的实例赋值给cls(MyClass)的属性_instance cls._instance = object.__new__(cls) ...
a6741c2f5dcc6051d20e16e6ceca297af6543938
measles/test_python
/lib/file_io.py
2,704
3.671875
4
import sys import logging '''This module contains functions to perform IO operations for the test script. Functions: data_input(file_name) results_output(unique_words, match_re) output_to_file(data, file_name) ''' def data_input(file_name): '''This function read input file and store its content as a ...
8cb7397313a8d1cc8b55d9a003d0e696fd2b171f
eclipse-ib/Software-University-Fundamentals_Module
/08-Mid_Exam/More exams/Mid_exam_November_2020/02.Crafting.py
1,462
3.9375
4
strings = input().split("|") while True: commands = input().split() command = commands[0] if command == "Done": print(f"You crafted {''.join(strings)}!") break elif command == "Move": direction = commands[1] move_index = int(commands[2]) if direction == "Left":...
bd7acdb5bd5ddbcd7778e0c2b9d9a8cc85f384bb
mubaskid/new
/TwoTwo/Ten.py
103
3.65625
4
def change_string(str1): return str1[-1:] + str1[1:-1] + str1[:1] print(change_string('coding'))
6be6ca6748ae2a84e18d27f0f51cf530a6c0a3c0
sa616473/ML_Bootcamp
/data_analytics/Intro_NUM.py
5,108
4.40625
4
import numpy as np # lesson 1 #-------------------------------------------------------------------------------- ''' my_list = [1,2,3] print np.array(my_list) my_mat = [[1,2,3], [4,5,6], [7,8,9]] print my_mat print np.array(my_mat) #np.array() converts the list into a matrix print np.arange(0,10) ...
296e90af65ec743bd29dde0c45b570057f296b5d
GabrielHaddad/SistemasDistribuidos
/Entrega 1/Testes/test_nro_clientes.py
1,222
3.640625
4
#!/usr/bin/python3 # O objetivo desse teste a verificaar a quantidade de salas que o servidor consegue criar/administrar sem cair # iremos estabelecer 2 conexões tcp com o servidor e aguardar por um valor respondido porta # caso o servidor não retorne um número ou não consigamos estabelecer uma conexão houve uma falha...
c273e51022f81faef46fc8061e491bae801667f3
jaquemff/exercicio-aprendizagem-python
/ExercicioEmprestimoBancario.py
790
4
4
#Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. #O programa vai perguntar o valor da casa, o salário do comprador e em quantos anos ele vai pagar. #Calcule o valor da prestação mensal, sabendo que ela não pode exceder 30% do salário ou então o empréstimo será negado from time import ...
40e35386e6f4af616dc39d83dc93870cb22e50cc
Najarin321/Python-codes
/Python-codes/Mundo 1 e mundo2/exercicio45curso.py
1,228
3.921875
4
import random from time import sleep print(""" Crie um programa que faça o computador jogar jokenpo com você""") def jokenpo(): minha_escolha = input("""Digite uma opção: - Papel - Pedra - Tesoura\n""").upper() possibilidades = ['PAPEL','TESOURA','PEDRA'] escolha_maquina = random.cho...
48b0c39846f72a36399f228ea4e0c54c4a78e618
ariomer/Python-Basics
/Exercise_120.py
468
3.9375
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 17 15:20:35 2020 @author: ts-omer.ari """ # ============================================================================= # Python Basic: Exercise-120 with Solution # Write a Python program to format a specified string to limit the number of characters to 6. ...
020aecb13c8f16367f1ce6d37d453884ae1c17f2
carlinpeton/callycodespython
/Random.py
2,879
4.15625
4
import random # CHALLENGES # 052 # num = random.randint(1, 100) # print(num) # 053 # fruit = random.choice(["apple", "pear", "orange", "grapes", "watermelon"]) # print(fruit) # 054 # coin = random.choice(["heads", "tails"]) # guess = input("Heads or tails (heads/tails) : ") # # if guess == coin: # print("You...
4fdf71495ffe7cd45f19ccc2f78697d703f06da1
Mamata720/Function
/speed.py
152
3.625
4
def num(speed): if speed<70: print("ok") elif speed >70: print("points:2") else: print("license suspended") num(50)
ee8d726df3a2431d4a8912a4f65adf1f5fef7d69
ahmedsaalah/Hotels
/room.py
555
3.546875
4
from hotel import Hotel class Room (): ''' This class consists of main attributes of the rooms ''' def __init__(self, nonrefundable, mealtype,room_category, room_description, code,nightly_prices,room_type): """ constructor """ self.nonrefundable = nonrefu...
0858fc4f6057d2edb083cc388e008a3e0d3caf4f
lauralaurenti/ADM-HW5
/func_3.py
2,592
3.96875
4
import networkx as nx # This is our version of Dijkstra's algorithm def func_3(graph, node, dest): ret=(0) if graph.has_node(node)==False or graph.has_node(dest)==False: ret=('Not possible') #we check if both nodes actually exist return ret if nx.has_path(graph,node,d...
07037bc013ed81a8321a1c62f072cf35ab54e6c2
mikkey21/testPython
/main.py
775
3.984375
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def Fibonacci(n): # Check if input is 0 then it will # print incorrect input if n < 0: print("Incorrec...
beb099a5e4ba1d8e0d5dba12a010151583f77536
xKolodziej/02
/06/Zad16.py
99
3.578125
4
nums = [12,6,4,9,3] def star(n): for i in nums: print(f"{i}: ") star(1)
83749db7f04c5a50231a5fc01aa4b1a727b6dd39
KajalGada/project-euler
/5-smallest-multiple/5_SmallestMultiple.py
1,633
3.6875
4
print "Project Euler > Problem 5: Smallest Multiple" # --------------------------------------------------------------- # TO DO # --------------------------------------------------------------- # Prime Number generate base list based on num starting with # -------------------------------------------------------...