blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
9c5ca3f0af3e22d8ed74c58d8bcf0ef5dee9ade6
venkatadri123/Python_Programs
/Codesignal_programs/1add.py
120
3.71875
4
#. Write a function that returns the sum of two numbers. def add(param1, param2): c = param1+param2 return(c)
d3604b7b41e62c1cca3c162d7cbbb5810449f075
venkatadri123/Python_Programs
/100_Basic_Programs/program_41.py
392
3.96875
4
# 41. With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the # first half values in one line and the last half values in one line. def halfval(): fl=[] sl=[] tup=(1,2,3,4,5,6,7,8,9,10) l=len(tup)/2 for i in range(1,int((l)+1)): fl.append(i) for j in range(int(l+1),int(l...
01158919c0c3b66a38f8094fe99d22d9d3f53bed
venkatadri123/Python_Programs
/100_Basic_Programs/program_35.py
322
4.15625
4
# 35. Define a function which can generate a dictionary where the keys are numbers between 1 and 20 # (both included) and the values are square of keys. The function should just print the keys only. def sqrkeys(): d=dict() for i in range(1,21): d[i]=i**2 for k in d: print(k) sqrkeys...
b73338136080e4dda8026e64309e34b67926b464
venkatadri123/Python_Programs
/core_python_programs/prog21.py
120
4.0625
4
# Read the elements from the tuple and display them using for loop. mytpl=(13,20,30,40,50) for i in mytpl: print(i)
22599e6316b2e1eeade05e5d1fca3dac7916fe15
venkatadri123/Python_Programs
/100_Basic_Programs/program_76.py
241
3.90625
4
# 76.Please write a program to output a random number, which is divisible by # 5 and 7, between 0 and 200 inclusive using random module and list comprehension. import random print(random.choice([i for i in range(201) if i%5==0 and i%7==0]))
8ed9e0ff208ad57a5c44d0461bc7f9d4f5ce907a
venkatadri123/Python_Programs
/100_Basic_Programs/program_85.py
157
3.875
4
# 85. Please write a program to print the list after removing even numbers in [5,6,77,45,22,12,24]. li=[5,6,77,45,22,12,24] print([x for x in li if x%2!=0])
34eaa7eb343803aed8077aa0082256046230dcfb
venkatadri123/Python_Programs
/100_Basic_Programs/program_91.py
256
3.75
4
# 91. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], # write a program to make a list whose elements are intersection of the above given lists. l1=set([1,3,6,78,35,55]) l2=set([12,24,35,24,88,120,155]) l1 &= l2 li = list(l1) print(li)
bc5117081a9d25c3662a71716194f57b5a46771e
venkatadri123/Python_Programs
/core_python_programs/prog2.py
190
3.921875
4
# To display result of add,sub,mul,div. a=float(input('enter value:')) b=float(input('enter value:')) c=a+b print('sum=',c) c=a-b print('sub=',c) c=a*b print('mul=',c) c=a/b print('div=',c)
b1adffe626fa1a1585012689ec2b1c01925c181c
venkatadri123/Python_Programs
/core_python_programs/prog78.py
334
4.15625
4
# Write a python program to accept values from keyboard and display its transpose. from numpy import* r,c=[int(i) for i in input('enter rows,columns:').split()] arr=zeros((r,c),dtype=int) print('enter the matrix:') for i in range(r): arr[i]=[int(x) for x in input().split()] m=matrix(arr) print('transpose:') print(m...
3625b577e1d82afc31436473149cc7ff1e3ce96c
venkatadri123/Python_Programs
/100_Basic_Programs/program_39.py
318
4.1875
4
# 39. Define a function which can generate a list where the values are square of numbers # between 1 and 20 (both included). Then the function needs to print all values # except the first 5 elements in the list. def sqrlis(): l=[] for i in range(1,20): l.append(i**2) return l[5:] print(sqrlis())
fa7b092a720e7ce46b2007341f4e70de60f8e6ca
venkatadri123/Python_Programs
/100_Basic_Programs/program_69.py
375
4.15625
4
# 69. Please write assert statements to verify that every number in the list [2,4,6,8] is even. l=[2,4,6,8] for i in l: assert i%2==0 # Assertions are simply boolean expressions that checks if the conditions return true or not. # If it is true, the program does nothing and move to the next line of code. # However...
7a26e4bc77d34fd19cf4350c78f4764492d32064
venkatadri123/Python_Programs
/core_python_programs/prog83.py
250
4.25
4
# Retrive only the first letter of each word in a list. words=['hyder','secunder','pune','goa','vellore','jammu'] lst=[] for ch in words: lst.append(ch[0]) print(lst) # To convert into List Comprehension. lst=[ch[0] for ch in words] print(lst)
710af7c61665471765e13c9e73316fb5a16580c5
OrkMartin/Labs-need-work
/lab1/lab2.py
161
3.5
4
x=input() l=list(x) i2=1 mx=max(l) for i in l: if(int(i)!=int(mx)): if (int(i)>int(i2)): mx2=int(i) else: mx2=int(i2) i2=int(i) print(mx2) print()
dc1edd50a486386b3ab7464bef328be9b2a4e67e
imzhangliang/LearningToys
/python/decorator/4.arguDecorator.py
512
3.734375
4
# 参考:https://www.thecodeship.com/patterns/guide-to-python-function-decorators/ # 带参数的修饰器 def tags(tag_name): def tags_decorator(func): def func_wrapper(name): return "<{0}>{1}</{0}>".format(tag_name, func(name)) return func_wrapper return tags_decorator @tags("p") def get_text(name...
82e13a62f99e125e104dc8e2d2dc13f4741e6c44
Teaching-projects/SOE-ProgAlap1-HF-2020-Fmiri08
/008/main.py
312
3.90625
4
x=0.0 y=0.0 ir=input() while ir!="stop": if ir=="forward": y=y+float(input()) if ir=="backward": y=y-float(input()) if ir=="right": x=x+float(input()) if ir=="left": x=x-float(input()) ir=input() print(round(x,2)) print(round(y,2)) origo=((x**2)+(y**2))**(1/2) print(round(origo,2))
14e530c84fedbaaa64eeae87f24fa46549b9a7da
toggame/Python_learn
/第四章/num_to_rmb.py
5,224
3.78125
4
han_list = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] # 数值转换文本列表 unit_list = ['拾', '佰', '仟'] # 数值单位列表 # 把一个浮点数分解成整数部分和小数部分字符串 # num是需要被分解的浮点数(float) # 返回分解出来的整数部分和小数部分(str) # 第一数组元素是整数部分,第二个数组元素是小数部分 def divide(num): # 将一个浮点数强制类型转换为int类型,即可得到它的整数部分 integer_num = int(num) # 浮点减去整数部分,得到小数部分,小数部分乘以...
e8f50c141e2c193134af053d04e88d63ae175a8d
toggame/Python_learn
/第二章/compare_operator_test.py
908
3.625
4
import time print("5是否大于4:", 5 > 4) # True print('3的4次方是否大于或等于90:', 3 ** 4 >= 90) # False print('20是否大于或等于20.0:', 20 >= 20.0) # True print('5和5.0是否相等:', 5 == 5.0) # True print('5.2%4.1与1.1是否相等:', 5.2 % 4.1 == 1.1) # False 浮点精度将会影响值的对比 print('1和True是否相等:', 1 == True) # True 可以用数值1和True/0和False做对比,但是不建议,使用条件或bool...
a25f6d70039117398ad94e101c189100393d748e
toggame/Python_learn
/第二章/bit_operator_test.py
842
3.9375
4
print(5 & 9) # 1 0b0101 & 0b1001 = 0b0001,Python默认4字节 print(bin(5 & 9)) print(5 | 9) # 13 0b0101 | 0b1001 = 0b1101 print(bin(5 | 9)) a = -5 print(a & 0xff) # 251 print(bin(a)) print(~a) # 4 负数的补码规则:反码(原码除符号位取反)加1 print(bin(~a)) # 0b100 print(~-a) # -6 5→0b0101 取反0b1010 -1→0b1001 原码0b1110 5→0b00000101 取反0b111...
34da97ea1abde74ef4f13ffe4216a23742ea14c9
Simsaris/COM404
/1-basics/week-3-repetition/1-while-loop/5-sum-100/bot.py
179
3.96875
4
print("calculate the sum of the first 100 numbers") count = 1 total = 0 while count <= 100: total+=count #total=total+count# count+=1 print("the total is " + str(total))
bf69b97a50aae1366ad4884ad8fa364320c29458
Simsaris/COM404
/1-basics/week-3-repetition/1-while-loop/3-ascii/bot.py
263
4.0625
4
print("how many bars shoud be charged") ChargeNeeded = int(input()) ChargedBars = 0 while (ChargedBars < ChargeNeeded): ChargedBars+=1 print("charging: " + " █ " * ChargedBars) if (ChargedBars == ChargeNeeded): print("battery is fully charged")
665de3ee810564d1001f10b23e7108f856a4a8eb
sacktock/network_summative
/client.py
10,168
3.609375
4
import socket import sys import json # Client functions def GET_BOARDS(): # construct json message message = '{"request" : "GET_BOARDS"}' while True: # make server request response = server_request(message) if response: # parse json response ...
eb19e8d85ac5e4bf75f173c1984483d440eca8bf
ITLTVPo/SimplePython
/SimplePython/Test-Bai25.py
3,065
3.625
4
def DocSoThanhChu(): a = ["một","hai","ba","bốn","năm","sáu","bảy","tám","chín"] b = ["mốt","hai","ba","tư","lăm","sáu","bảy","tám","chín"] SoAm=False number = int(input("Nhập số bạn muốn chuyển đổi: ")) if (number <0): number = 0-number SoAm =True if (number==0): print("...
770a5461e82cc2e3fda4b42a7224f8badfd20c13
ITLTVPo/SimplePython
/SimplePython/SoNgayTrongThang.py
706
3.6875
4
print("Đếm số ngày trong tháng") def KiemTraNamNhuan(month, NamNhuan): if month in (1,3,5,7,8,10,12): return 31 elif month in (4,6,9,11): return 30 elif NamNhuan==True: return 29 elif NamNhuan==False: return 28 try: while (True): print("-"*30) month ...
a4c2e16bfc899de39d68175be19dba4b33d395ce
ITLTVPo/SimplePython
/SimplePython/VeChuN.py
605
3.8125
4
print("Chương trình vẽ chữ N bằng dấu * với độ cao h") while True: h = int(input("Nhập độ cao h: ")) for i in range(h): for j in range(h): if j==0 or j==i or j==h-1: print("*",end="") else: print(" ",end="") print("",end="\n") print("-"...
3022a1b5402c126eac6d93f065472c21efc23a3a
dhrunlauwers/advent_2020
/day01.py
905
3.78125
4
from typing import List def parse(inputs: List[int]) -> int: """ Checks to find two elements that add up to 2020, and the returns their product. """ deltas = {2020 - i for i in inputs} for i in inputs: if i in deltas: return i * (2020-i) def parse2(inputs: List[int]): ...
516507efc6764f24f12843468fce2919690d2c09
IshitaG-2002IGK/streamlit-jina
/app.py
1,224
3.578125
4
""" pclass = 1|2|3 gender = 'male'=1,'female'=0 age = 1-60 sibsp = 1|0 parch = 1|0 fare = 0-100 embarked = 1|0 """ import business import streamlit as st pclass_list = [1,2,3] gender_list = ['male','female'] gender = 1 pclass = st.selectbox( 'Passenger Class', pclass_list) gender_str = st.selectbox( ...
daea1cb549638923f92a0939fc06687b96e74ef9
Vineeth-Agarwal/FileSortingByNumericField-Northwest
/Sort_By_Numeric_Field.py
1,262
3.921875
4
##### Step0: Open input and output files and create empty lists. input=open("InputFile.txt","r") output=open("OutputFile.txt","w") tupples_array = [] sorted_array = [] ##### Step1: Read each line traditionally(as a String) for line in input: ##### Step2: Break each field in the line separated by comma, into i...
b1c41d7bfbc80bdd15642bcb0f02291c7867779e
ProgrammingForDiscreteMath/20170830-bodhayan
/code.py
700
4.15625
4
# 1 # Replace if-else with try-except in the the example below: def element_of_list(L,i): """ Return the 4th element of ``L`` if it exists, ``None`` otherwise. """ try: return L[i] except IndexError: return None # 2 # Modify to use try-except to return the sum of all numbers in L, ...
d442a0ed9a4a4c5d9a6b94b69ea39bb8ead21a3c
andrSHoi/biosim_G07_sebastian_andreas
/src/biosim/island_class.py
6,174
4.25
4
# -*- coding: utf-8 -*- __author__ = "Sebastian Kihle & Andreas Hoeimyr" __email__ = "sebaskih@nmbu.no & andrehoi@nmbu.no" from .geography import Mountain, Savannah, Jungle, Desert, Ocean, \ OutOfBounds import numpy as np import re class Map: """ The Map class takes a multiline string as input and creat...
350b8d465f906a49e22669171c8eb47fa533383c
zxch3n/Leetcode
/53/main.py
565
3.6875
4
# -*- coding: utf-8 -*- """ @author: Rem @contack: remch183@outlook.com @time: 2017/03/14/ 20:58 """ __author__ = "Rem" class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ max_ans = nums[0] t = nums[0] for i in r...
edc611b56aacab9f4b6602b233ce9f3e759bce16
ahdabalhassani/udacity_project2
/starter_code.py
4,817
3.84375
4
import random moves = ['rock', 'paper', 'scissors'] class Player: def __init__(self): self.score = 0 def move(self): return 'rock' def learn(self, their_move): pass def beats(one, two): return ((one == 'rock' and two == 'scissors') or (one == 'scissors' and two ...
650217c072d3380afd569106d224da0527f4799c
khc-data/advent-of-code-2020
/2020/max/day2/solve.py
1,711
3.921875
4
from collections import namedtuple import re PasswordPolicy = namedtuple('PasswordPolicy', 'lower upper char') PasswordWithPolicy = namedtuple('PasswordWithPolicy', 'password password_policy') def read(): passwords_with_policies = [] with open('input') as input: for line in input: (lower...
6de74047e9f7509207bea000f4dd00268077f239
khc-data/advent-of-code-2020
/2020/max/day12/ferry.py
1,394
3.9375
4
class Ferry: def __init__(self): self.dir = 'E' self.x = 0 self.y = 0 def manhattan(self): return abs(self.x) + abs(self.y) def handle_instruction(self, instruction): self.handle_action(instruction[0], instruction[1]) def handle_action(self, action,...
030214bcbe1123ef751976731feacbd614eca0b2
planetblix/learnpythonthehardway
/ex17a.py
1,230
3.9375
4
#!/bin/python #http://blog.amir.rachum.com/blog/2013/10/10/python-importing/ #using os.path as an example import os import os.path from os.path import exists from os.path import exists, dirname from os.path import * from os.path import exists as here from .os import exists os.path = __import__("os.path") reload(foo) ...
b6834d2bf0af216c26a7a2b92880ab566685caea
planetblix/learnpythonthehardway
/ex16.py
1,436
4.40625
4
#/bin/python from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Open the file..." #rw doesn't mean read and write, it just means read! #You could open the file twice...
606294b3e5cf05889729aab4670e9c04c208b98b
wardm5/Data-Structures-and-Algorithms
/Python/Data_Structures/LinkedList/LinkedList.py
1,699
3.875
4
from Data_Structures.Node.Node import * class LinkedList(): # initalize with no value def __init__(self): self.head = None self.count = 0 # initalize with first value def __init__(self, value): self.head = Node(value) self.count = 1 def add(self, value): if...
37808545149f98fdff61b285857b2e63a42fad97
matthewgplace/Projects
/ex5p19MP.py
4,498
3.859375
4
""" Author: Matthew Place Date: December 6, 2017 (Although actually coded sometime in September, I think) Exercise 5.19 part a through part e i. I never got around to e ii. This program simulates light going through a transmission diffraction grating, going through a converging lens, and then hitting a screen. I...
caa1c6539841f07e7acaf8dfc0e5d9d17a972ff7
matthewgplace/Projects
/ex7p1mp.py
1,887
4.0625
4
""" Author: Matthew Place Date: November 7, 2017 Exercise 7.1 This program is designed to calculate the coefficients in the discrete Fourier transforms of a few functions and make a plot of these values """ from __future__ import division from numpy import zeros from cmath import exp, pi, sin from pylab i...
bd225d8181acc7cecb070f5c91a778475d5117d9
ninjafrostpn/PythonProjects
/Writer.py
1,319
3.59375
4
__author__ = 'Charlie' from random import randint as rand text = "" while True: textin = input("Input text for imitation (or @ when done)\n>> ") if textin != "@": text += textin text += " " else: break words = text.split(" ") links = dict() tuples = dict() sanity = int(input("Input...
eb60fc70191ca84f28abc5349263bfbc0702a556
ninjafrostpn/PythonProjects
/BehaviouralEcology/Shoal/CouzinShoal3D.py
10,920
3.6875
4
# Based on Couzin et al. (2002), but as a 2D simulation import pygame from pygame.locals import * import numpy as np from time import sleep debug = False # If True, shows zones of detection and allows their alteration with mouse position # Interface initialisation pygame.init() w = 200 screen = pygame.display.set_mo...
89a4cab84879c77e5ded99c23667abc5daf6154b
ninjafrostpn/PythonProjects
/Neural-Nets/Neural-Net-Tutorial.py
1,578
4
4
# Based on https://iamtrask.github.io/2015/07/12/basic-python-network/ import numpy as np # sigmoid function def sigmoid(x, deriv=False): if deriv: # The derivative of the sigmoid function, for calculating direction/intensity of errors # Here, x is the output of the sigmoid function of the origin...
32b18218321e2250d8f2dbddea7995fabf35d2f9
datnt55/ktpm2013
/Triangle.py
1,109
4.03125
4
def check(a,b,c): if (a < 0) | (b < 0) | (c < 0): print 'Error' else: print 'OK' x = float(raw_input("Please enter an integer: ")) y = float(raw_input("Please enter an integer: ")) z = float(raw_input("Please enter an integer: ")) e = pow(10,-9) while (x < 0)|(y<0)|(z<0): print 'Please enter...
95248b64e89e979c7298ea02ad28f462e602daaa
shanmugapriya98/shanmu
/alphabet_or_not.py
94
3.734375
4
ch = input() if(ch.isalpha() == True) print("Alphabet") else: print("Not an alphabet")
e948cb19f7b3d4c898271cfd956ce3db8a43ba39
shanmugapriya98/shanmu
/hcf_of_two_numbers.py
117
3.84375
4
num1 = int(input()) num2 = int(input()) while(num2 != 0): rem = num1 % num2 num1 = num2 num2 = rem print(num1)
a29a2a9d86f2bb27637275ebe3df713444b0d4d2
rayraysheng/python-challenge
/PyPoll/main.py
4,008
4.03125
4
import os import csv # I've set up a raw data folder and a results folder # The raw data folder will hold the input .csv files # The program will create a summary with each input file # The summary .txt files will be written to the results folder # Work on each file in the input_files folder for filename in os.listdi...
ad04b7264ba1c3cf3486d792afc3c0b1931b5479
geewynn/python_restaurant_simulator
/Menu.py
1,012
3.546875
4
import csv from MenuItem import MenuItem class Menu(object): MENU_ITEM_TYPES = ["Drink", "Appetizer", "Entree", "Dessert"] def __init__(self, filename): self.__menuItemDictionary = {} for t in self.MENU_ITEM_TYPES: self.__menuItemDictionary[t] = [] with open(filename) as f...
978f9bb97e638066dd2540b6c439c5ffdf880efc
yunusaltuntas/MachineLearning
/K Nearest Neighbors/knn.py
2,672
3.671875
4
# K-Nearest Neighbors (K-NN) # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('airbnb_warsaw.csv',sep=';') X = dataset.iloc[:, [7, 9]].values y = dataset.iloc[:, 4].values def PrepareForPrediction(X, y): global X_train,...
b44a6b18c2fb9239c4d2be5ea07bc287b004f1b2
Sher-V/cups
/main.py
3,010
3.578125
4
# время мытья - 10 мин # время тусовки - 5 мин # периодичность захода - 5 мин # количество людей 5-9 # время работы 180 минут # количество чашек в сервизе 40 # Нарисовать график времени работы от количества моющихся чашек, количество чистых чашек, количество грязных чашек import matplotlib.pyplot as plt import random ...
9522b6a465c1644ff8399a838eb3a7fb3b9cbcec
seriouspig/homework_week_01_day_01
/precourse_recap.py
566
4.15625
4
print("Guess the number I'm thinking from 1 to 10, What do you think it is?") guessing = True number_list = [1,2,3,4,5,6,7,8,9,10] import random selected_number = random.choice(number_list) while guessing == True: answer = int(input('Pick a number from 1 to 10: ')) if answer == selected_number: prin...
276f4099bdc847b7c5a92ae909838f063d513a8f
rickhaffey/supply-chain-python
/demand.py
641
3.546875
4
from validation import Validate class Demand: """ Captures all demand-related values. Parameters ---------- quantity : int The amount of demand, in units time_unit : {{'Y', 'M', 'W', 'D'}}, default 'Y' A time unit specifier, representing the period of time over which the `quan...
0fa21bbbb6afa66cd3efe096350b53d2f44670fb
ValS-Itescia/Webtarget
/Liste.py
1,422
3.59375
4
import Read_Write import os # Creation de ma liste et l'affiche liste = ["test@test.fr","test@test.fr","test@orange.fr","test@free.fr"] print(liste) # fonction qui supprime les doublons de ma liste def delete_duplicate(liste): liste = list(set(liste)) return liste # Affichage de ma liste sans dou...
29800604f0b000f1ed4906d51875ab95370a3885
CMPundhir/PandasTutorial
/Ex5.py
448
3.5625
4
import pandas as pd import matplotlib.pyplot as plt # changing index #create a dictionary webDic = {'Day': [1, 2, 3, 4, 5, 6], 'Visitors': [1000, 2000, 200, 400, 10000, 300], 'Bounce_Rate': [20, 20, 23, 15, 10, 43]} #create dataframe df = pd.DataFrame(webDic) print(df) #changing index df2 = df.set_index('Day') print...
a25e94e6f477c54dc1763353db8ffed044016a5e
szhelyabovskiy/tenki
/direction.py
2,683
3.5625
4
import smbus import time import math import RPi.GPIO as GPIO from time import sleep GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT, initial=GPIO.LOW) #This module receives and converts data from the HMC5883L magnetic sensor that reads off the #direction of the weather vane. #Principle of op...
0bcfdb2184da61297f36591fc3f05da63e573ecb
raghukrishnamoorthy/python-tricks
/cleaner python/underscores_and_dunders.py
846
3.734375
4
# Single _variable means it is private class Testy: def __init__(self): self.foo = 11 self._bar = 12 # Single variable_ can be used if name is a reserved keyword def make_object(item, class_): pass # Double __variable causes name mangling class Test: def __init__(self): self.foo ...
5dfdc7a42d5ee842c648979694a4852c791da6cd
dheaangelina/UG9_A_71210693
/1_A_71210693.py
128
3.640625
4
d = int(input("Masukkan diameter : ")) Keliling = 3.14*d print("Keliling lingkaran adalah : ", str(round((Keliling),2)))
961b6639cb292351bff3d4ded8c366ab0d860ed8
IshaqNiloy/Any-or-All
/main (1).py
980
4.25
4
def is_palindromic_integer(my_list): #Checking if all the integers are positive or not and initializing the variable is_all_positive = all(item >= 0 for item in my_list) #Initializing the variable is_palindrome = False if is_all_positive == True: for item in my_list: #Converting...
5729f4ab552107394ea3066e69e5b23a19b61d4d
Andrey-Dubas/inclusion_analysis
/inclusion_analysis/graph.py
8,605
4.15625
4
class Graph(object): """This class describes directed graph vertices represented by plain numbers directed edges are start with vertex which is index of __vertices vertex the edge goes to is a value within list so, __vertices is "list < list <int> >" vertex is __vertices[*vertex_from*] = list o...
bbd8f07902ff5a1ddc8ca56c3903b096c1a63624
CoderMaik/PokerZen
/src/gamemodes/setups/AmericanSetup.py
1,705
3.671875
4
""" File contains objects used in the dem: Card, deck and player to add modularity access to the attributes is not restricted, they are all public """ class Card(object): def __init__(self, val, suit): self.val = val self.suit = suit def __repr__(self): # This could be done with patte...
da6ad33803ebefe4086699cab7216ab2f16fb677
Ang-Li615/leetcode
/mergeSortedArray.py
843
3.6875
4
class Solution: def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ if m == 0 and n == 0: return None ...
14c52991b7a7a5891a7d2e0d5d2af3512d977c33
Ang-Li615/leetcode
/Number0fSegmentsInAString.py
605
3.65625
4
class Solution: def countSegments(self, s): """ :type s: str :rtype: int """ if len(s) == 0: return 0 while True: if len(s.strip(' ')) < len(s): s = s.strip(' ') continue if len(s.strip(',')) < len(s...
c9b0181161248354a1b1640e84e312bb9a76f9e9
Ang-Li615/leetcode
/validParenthese.py
424
3.65625
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ while True: s1 = s.replace('[]', '') s2 = s1.replace('{}', '') s3 = s2.replace('()', '') if s3 == s: return False else: ...
a252dc283a07445f1250dd55dc4018e4e0c94321
Ang-Li615/leetcode
/letterCasePermutation.py
422
3.578125
4
class Solution: def letterCasePermutation(self, S): L = [''] for char in S: LL = [] if char.isalpha(): for s in L: LL.append(s + char.lower()) LL.append(s + char.upper()) L = LL else: ...
c494273bb1e1bbf5889a81b2eeab8f27e3182a3d
Ang-Li615/leetcode
/convertBST2GT.py
1,530
3.71875
4
# # Definition for a binary tree node. # # class TreeNode: # # def __init__(self, x): # # self.val = x # # self.left = None # # self.right = None # # class Solution: # def convertBST(self, root): # if root == None: # return root # # self.L = [root] # s...
84014b5e5aeb46694ced4cd3b4b95c0e31257433
Ang-Li615/leetcode
/binaryTreeTilt.py
2,076
3.78125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def findTilt(self, root): if root == None: return 0 self.diff = 0 self.subtreeSum(ro...
46be376db7886d6ef3d8bde07178182fb09b4878
Ang-Li615/leetcode
/constructRectangle.py
792
3.90625
4
from math import sqrt class Solution: def constructRectangle(self, area): n = int(sqrt(area)) for i in range(n,area): if area % i == 0: return [i, area//i] # # # # # # # if self.is_prime(area): # return [area,1] # # ...
78ef89950a7376242b9d4897dbd092a6cdfc66b4
Ang-Li615/leetcode
/canPlaceFlowers.py
1,167
3.625
4
class Solution: def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ l = len(flowerbed) if l == 0: return n <= l if l == 1: if flowerbed[0] == 1: return n <= 0 ...
05079f16b25dcad0a9dc4f8bce823972c0c62ae3
dan-klasson/tic-tac-toe
/views.py
1,157
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class GameView: def intro(self): return '\nTic Tac Toe\n' def newlines(self, amount=1): return '\n' * amount def number_of_players(self): return 'Enter number of players (1-2): ' def number_of_players_error(self): ret...
de3f02e8416760c40ab208ff7ee372313040fcd1
bishal-ghosh900/Python-Practice
/Practice 1/main30.py
992
4.1875
4
# Sieve of Eratosthenes import math; n = int(input()) def findPrimes(n): arr = [1 for i in range(n+1)] arr[0] = 0 arr[1] = 0 for i in range(2, int(math.sqrt(n)) + 1, 1): if arr[i] == 1: j = 2 while j * i <= n: arr[j*i] = 0 j += 1 for i...
2b72be0a06d4a19932b256628b2b2f8b6703cb25
bishal-ghosh900/Python-Practice
/Practice 1/main3.py
262
3.625
4
#String name = "My name is Bishal Ghosh" print(name[0]) # M print(name[-2]) # h print(name[0:5])# My na print(name[1:]) # y name is Bishal Ghosh print(name[:len(name) - 1]) # My name is Bishal Ghos print(name[:]) # My name is Bishal Ghosh print(name[1:-1]) # y name is Bishal Ghos
eaadca4eda12fc7af10c3a6f70437a760c14358f
bishal-ghosh900/Python-Practice
/Practice 1/main9.py
595
4.6875
5
# Logical operator true = True false = False if true and true: print("It is true") # and -> && else: print("It is false") # and -> && # Output --> It is true if true or false: print("It is true") # and -> || else: print("It is false") # and -> || # Output --> It is true if true and not true: ...
460ea4d25a2f8d69e8e009b70cdec588b8ca7b20
bishal-ghosh900/Python-Practice
/Practice 1/main42.py
782
4.28125
4
# set nums = [1, 2, 3, 4, 5] num_set1 = set(nums) print(num_set1) num_set2 = {4, 5, 6, 7, 8} # in set there is not any indexing , so we can't use expression like num_set1[0]. # # Basically set is used to do mathematics set operations #union print(num_set1 | num_set2) # {1, 2, 3, 4, 5, 6, 7, 8} # intersection pr...
8a72ba35bf514fd7ff13479017fa3615eb4766cc
bishal-ghosh900/Python-Practice
/Practice 1/main39.py
301
3.96875
4
# queue from collections import deque list1 = deque([1, 2, 3, 4, 5]); list1.appendleft(10) print(list1) # deque([10, 1, 2, 3, 4, 5]) list1.popleft() print(list1) # deque([1, 2, 3, 4, 5]) list1.append(6) print(list1) # deque([1, 2, 3, 4, 5, 6]) list1.pop() print(list1) # deque([1, 2, 3, 4, 5])
789e675cb561a9c730b86b944a0a80d6c423f475
bishal-ghosh900/Python-Practice
/Practice 1/main50.py
804
4.75
5
# private members # In python there we can prefix any data member with __ (dunder sign) , then it will be private. In reality it don't get private, if we declare any data member with __ , that data member actually get a differet name from python , which is like => _classname__fieldname. So in the below implementation...
ff52754b77c4caeac1d1bcb6d4def097b2f6d0c8
bishal-ghosh900/Python-Practice
/Practice 1/main53.py
416
4.09375
4
# closure # A closure is a function that remembers its outer variables and can access them def multiplier(x): def multiply(y): return x * y return multiply m = multiplier(10)(2) print(m) # 20 # defected way of closure print # def doThis(): # arr = [] # for x in range(1, 4): # arr....
c2c1d70b70f5829bc69f221aaff4f1a79a682ddf
MStevenTowns/Python-1
/Statistics.py
2,060
3.625
4
##M. Steven Towns ##4/29/204 ##Assignment 14 import math def minimum(aList): guess=aList[0] for num in aList: if num<guess: guess=num return guess def maximum(aList): guess=aList[0] for num in aList: if num>guess: guess=num return guess ...
a533862c6545a575a7d932aa33b99aacb4f6bf0b
MStevenTowns/Python-1
/TurtleWalk.py
2,145
3.9375
4
#M. Steven Towns #Assignment 5 #1/20/2014 import turtle, random anne=turtle.Turtle() anne.speed(0) anne.up() anne.setpos(-325,-275) anne.down() anne.forward(650) anne.left(90) anne.forward(275*2) anne.left(90) anne.forward(650) anne.left(90) anne.forward(275*2) anne.up() anne.setpos(5000,5000) fre...
f2b42f7fdbd15e8c9d5343bbd3ff7aca8a8d4099
MStevenTowns/Python-1
/SecretMessage.py
1,508
3.96875
4
# M. Steven Towns #Assignment 8 #2/4/2014 encoder=True while encoder: msg=raw_input('What do you want to encode?: ') shift=int(raw_input('what do you want to shift it by?: '))%26 secret_msg="" for i in range(len(msg)): letter=msg[i] if letter.isalpha(): if letter...
a9bcd41772d6493b67724fc42a519cadd748020d
MStevenTowns/Python-1
/File Fun.py
1,085
3.78125
4
##M. Steven Towns ##Assignment 13 File Fun ##4/1/14 myList=[] name=(raw_input('What is the name of unsorted input file? (Enter for default): ')).strip() if (name==""): name="InputSort" if not name.endswith(".txt"): name+=".txt" f=file(name) for line in f: myList+=[line.strip()] myList.sort() ...
0cad154951e8b14a01edb5a9a2ba9d7bb81e469e
MStevenTowns/Python-1
/List.py
318
4.03125
4
x=[5,23,5,2,32,53] print len(x) print x[1:2:3] #[start:stop:step] step is to get every x values x[3]=234 #can change value in list, not str #listception to call value in the list in list multidimensional array call x[][] print x.sort() #wont work x.sort() #do not use x=x.sort() it kills list print x
53e8b7c26985bf98e7ed93563f0a0e866b353f01
kenshimota/Learning-Python
/learning Class/class_people.py
415
3.890625
4
class People(): name = "" # obtiene el nombre de la persona def getName(self): return self.name # funcion que agrega el nombre de la persona def setName(self, str = ""): if str != "": self.name = str # fabrica el input para obtene el nombre def inputName(self): name_tmp = input("Ingrese su nombre: ...
4c7f6e74dad352ec6d2627ee502384a7dd361c8f
kenshimota/Learning-Python
/Learning Basic/if_elif_else.py
167
4.09375
4
num1 = 8 num2 = 6 if num1 < num2: print("num1 es menor que num2...\n") elif num1 == num2: print("Son identicos....\n") else: print("num1 es mayor que num2...\n")
1c321283b31a0d7822c27bc3042dce99f1891527
Keerthana8897/Bridgelabz
/Algorithms/monthlypayment.py
181
3.703125
4
import math def monthlypay(P,Y,R): n=12*Y r=R/(12*100) k=P*r h=1-(1+r)**(-n) pay=float(k)/float(h) print pay P=input() Y=input() R=input() monthlypay(P,Y,R)
30b829b57ba2d58fc07c15c00aa7edeba79b1a4f
Keerthana8897/Bridgelabz
/Algorithms/mergesort.py
525
3.734375
4
def merge_sort(a): l = len(a) if l == 1: return a a1 = merge_sort(a[:l//2]) a2 = merge_sort(a[l//2:]) a_sort = [] idx1, idx2 = 0, 0 while idx1 < len(a1) and idx2 < len(a2): if a1[idx1] >= a2[idx2]: a_sort.append(a2[idx2]) idx2 += 1 else: ...
df9db9f0378177ce3dc0daadc266f5b3eb5730a5
vivek-x-jha/TIL
/leet_code/algorithm_problems/twosum.py
361
3.671875
4
def twoSum(nums, target): complements = {} for i, num in enumerate(nums): comp = target - num if comp not in complements: complements[num] = i else: assert target == nums[complements[comp]] + nums[i] return [complements[comp], i] nums = [2, 7, 11, 15...
85207e81ace52bfdcb2be5813bb5d42a5f7842f0
mootils/mootils
/mootils/visualization/__init__.py
974
3.65625
4
from matplotlib import pyplot as plt class Plot: def __init__(self, title: str = '', subtitle: str = '', font: str = 'serif', fontsize: int = 16, default_color: str = '#236FA4', **kwargs): """ :p...
1a21136bd05b232ac4e636e3ddf71e5ec5f44738
ClaudiaSofia222/homework2
/02 - String/04 - Sherlock and Valid String.py
779
3.859375
4
#!/bin/python import sys def isValid(s): ele = {} for e in "abcdefghijklmnopqrstuvwxyz": times = s.count(e) if times > 0: if times in ele: ele[times].append(e) else: ele[times] = [e] if len(ele) == 2: keys ...
0fb3bf481431a680512dbcb404e1409059705123
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional8.py
369
3.9375
4
user = str(input("Please introduce your name: ")) age_user = int(input("Please introduce your age: ")) if age_user <0: print("Invalid age please try again") elif age_user <4: print("Your entrance is free") elif age_user <=18: print("Your entrance will be $5") elif age_user >18: print("Your entrance will be $1...
7181067911603e216f432c9cacfbd7294170499a
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional2.py
134
3.796875
4
edad = int(input("Please introduce your age: ")) if edad < 18: print("No eres mayor de edad") else: print("Eres mayor de edad")
e7f99a79fe4d6eea70f633d16a0343dc7fe704f1
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional7.py
415
3.84375
4
inaceptable = 0.0 aceptable = 0.4 dinero = 2400 score = float(input("Please insert the score of the user: ")) if score == 0.0: print("Insuficient, Your bonus would be : " + str(dinero*0.0)) elif score == 0.4: print("Aceptable, Your bonus would be: " + str(dinero*0.4)) elif score >= 0.6: print("Wonderful, Y...
756259025fb02d1c167a17d85e9069ca9dd2cb8c
avkour13/Avinash_C0804437_Assignment3
/Student.py
1,044
3.734375
4
import unittest import logging class Student(unittest.TestCase): logger = logging.getLogger() logger.setLevel(logging.DEBUG) def total_marks(self, subject1, subject2, subject3): try: assert subject1 > 0 assert subject2 > 0 assert subject3 > 0 self....
281ba6307be6d9dc6ae528eda2f25e7e95d2fd7e
PaulWang1905/tint
/stage1/expression.py
116
3.953125
4
length = 5 breadth = 2 area = length * breadth print('Area is',area) print('Perimeter is' , 2*(length + breadth))
ce80bd1bbe2f8034a45c68e4c3ddb9ca2248d5ed
PaulWang1905/tint
/stage2/assignment11.py
233
3.53125
4
import re name = input('Enter File Name:') handle = open(name) total = 0 for line in handle: x = line y = re.findall('[0-9]+',x) for number in y: number = int(number) total += number print(total)
c35759cf6ddf382cd6ec14e90bd013707af13fd6
learninfo/pythonAnswers
/Task 5 - boolean.py
236
4.375
4
import turtle sides = int(input("number of sides")) while (sides < 3) or (sides > 8) or (sides == 7): sides = input("number of sides") for count in range(1, sides+1): turtle.forward(100) turtle.right(360/sides)
81849f77995e755e9e592c926feb7cee8535cc32
NicholasMaisel/Algorithms
/Stack.py
1,093
4.0625
4
from LinkedList import Node from LinkedList import LinkedList class Stack(LinkedList): #this inherits the Node class def __init__(self): self.top = None #The isEmpty function is used to make sure, before the linkedlist is edited #that the edit will cause no errors. def isEmpty(self): i...
b394361baed2d048d3c658525763171df3ae95e0
NicholasMaisel/Algorithms
/knapsack.py
1,959
3.78125
4
def read(): items = {} capacities =[] for line in open('spice.txt','r'): line = line.rstrip().split(';') line = [x.strip() for x in line] if 'spice name' in line[0]: items[line[0].split('=')[1].strip()] = [float(line[1].split('=')[1].strip()), ...
b76a2b62821a3c9b3e1394fab64b78f8abe6e711
sauravgupta2800/Bikeshare-Project-Python
/bikeshare_2.py
10,192
4.3125
4
import time import pandas as pd import numpy as np CITY="'washington'" CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTH_LIST = ['january', 'february', 'march', 'april', 'may', 'june','all'] DOW_LIST = ['sunday','monday','tue...
227dbfbd5ae0bea2281533033a010b996c27fef7
martintvarog/python
/domecek.py
361
3.5
4
from turtle import forward, left, right, penup, pendown, exitonclick from math import sqrt for _ in range (4): forward (100) left (90) left (45) for _ in range (2): forward (100 * sqrt(2)) left (135) forward (100) left (135) right (135) for _ in range (2): left (45) forward ((100 * ...
d99396e79e06fe7ef172ff5f1613e43d32a27a75
alexandnpu/pythonLearning
/test_corountine.py
1,263
3.515625
4
import time def coroutine(func): def start(*args, **kwargs): cr = func(*args, **kwargs) next(cr) return cr return start def follow(thefile, target): thefile.seek(0, 2) while True: line = thefile.readline() if not line: time.sleep(0.1) ...
7cfc168f42e036a36e9886891ff683d5f1d2d9c8
rajdeep2804/OpenCV
/canny_edge_detection_in_opencv.py
720
3.65625
4
#the canny edge detection is an edge detection operator that uses a multi-stage algorithm to detect #a wide range of edges in images. it was developed by john f canny in 1986 #the canny edge detection algorithm is composed of 5 steps: # 1.) noise reduction # 2.) gradient calculation # 3.) non-maximum suppression ...
a7bef5820765e1ab474de3769ed461300ba9385a
ameliacgraham/udemy_courses
/python_for_data_structures/linked_list_cycle_check.py
971
3.96875
4
class Node(object): def __init__(self, data, next=None): self.data = data self.next = next def is_cycle(self): """Checks if a singly linked list contains a cycle given a head node. >>> a = Node("a") >>> b = Node("b") >>> c = Node("c") >>> a.next = b ...