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
bd862f5281e03dd6ae25aba9ff37846e1d8b1c90
grapess/python_eleven_2019
/35.py
276
3.6875
4
from math import * num = float( input(" Enter Any Number : ")) result = ceil( num ) print(" Result : " , result ) result = floor( num ) print(" Result : " , result ) result = log10( num ) print(" Result : " , result ) result = log2( num ) print(" Result : " , result )
0deb2f9aa929810edb86a01bce516e39bedf5a24
warleyken42/estrutura-de-dados
/Primeira_Lista/Questao8.py
188
3.8125
4
Valor_Hora = float(input("Quanto voce ganha por hora: ")) Horas_Trabalhada = float(input("Numero de horas trabalhadas no mes: ")) print("Você ganha = R$",(Valor_Hora * Horas_Trabalhada))
03b414198e924dd1369869018fad555cef95bc4c
jose-brenis-lanegra/Brenis.Lanegra.T06
/doble.nro05.py
544
3.828125
4
import os ciudad,clima="","" #input ciudad=(os.sys.argv[1]) clima=(os.sys.argv[2]) #outpout print("##########################") print("#el clima de una ciudad") print("##########################") print("#") print("##########################") print("#ciudad :", ciudad) print("#clima :", clima) print("#...
2c556ce86b249edd39b830f1ed647f87bbf405fd
ACLoong/LeetCode
/src/118-Pascal-Triangle/118._Pascal_Triangle.py
532
3.796875
4
class Solution: def generate(self, numRows): """ Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. Args: numRows(int): the given non-negative integer Returns: the first numRows of Pascal's triangle(List[List[int]]) ...
7c76336b1ef009854fa3616fb1e00513b488bdf5
rlhernandezch/code
/python/basics/typeconv.py
187
3.609375
4
#!/user/bin/python import random import math x=3 #int(x) #long(x) #float(x) #complex(x) #complex(x,y) print(random.random()) list=[1,2,3,4,5,6,7,8,9] random.shuffle(list) print (list)
075ac604b6dbcc38e52a1b0061fb4edc06e74842
Pyk017/Python
/OOPs/Question02.py
1,282
4.21875
4
# 2. Write a class to implement the following: #  Create a class Employee #  #  The Employee class contain properties to store the following # o ID # o Name # o Designation o Department # o Basic Salary # o HRA (House Rent Allowance) # o VA (Vehicle Allowance) # o NetSalary #  The Employee class contain methods t...
c5cabe62f2aceab70d10fbcee668cf4a2adc431e
me6edi/Python_Practice
/B.Code Hunter/30. Python Bangla Tutorial -- For Loop - 02 -- Code Hunter/30. Python Bangla Tutorial -- For Loop - 02 -- Code Hunter.py
221
3.671875
4
#for loop p = [1,2,3,4,5] # 1++2+3+4+5 = 15 s = 0 for i in p: s = s + i print("Sum of elements: ",s) q = ["apple","banana","orange","pine allple"] c = '' for i in q: c = c + i print("concanate of fruits: ",c)
a556e74f8bc7e2ef2960f9bcd277110e28c06b1d
p-render/fizzbuzz
/fizzbuzz_simple.py
386
3.65625
4
def fizz_buzz(i): mapping = { 3: 'Fizz', 5: 'Buzz', } result = "" for key in sorted(mapping.keys()): value = mapping[key] if not i % key: result += value if not result: result = str(i) return result if __name__ == '__main_...
32834792239e73ee76c3cc5f5508f93836c03cfd
claudiordgz/udacity--data-structures-and-algorithms
/notes/trees/depth3.py
354
3.953125
4
def print_tree_postorder(tree): """ Implement a post-order traversal here Args: tree(object): A binary tree input Returns: None """ if tree == None: return print_tree_postorder(tree.left) print_tree_postorder(tree.right) print(tree, end=' ') print("Post-order:", end='...
29a6ba34939a3a25c7338220464d4fad8035e106
sharondsza26/python-Technology
/proceduralParadigm.py
1,096
4.03125
4
# Stage 1 print("Namaste") print("Namaste") print("Namaste") # Stage 2 -while i = 0 while i < 5 : print("Namaste") i = i + 1 # Stage 3 -function def greeting() : i = 0 while i < 5 : print("Namaste") i = i + 1 print("Welcome") greeting() print("Bye") # Stage 4 -parameters print("Welc...
17a4fbdc7532bb19c653af78f9e4ded20eaa05ab
AntonioReyesE/ProyectoMetodosFinal
/MétodosFinal/dist/sourcecode/newton.py
4,076
4.03125
4
# -*- encoding: utf-8 -*- import math #Clase que implementa los métodos necesarios para solucionar por el método de Newton class newton: k = 0 #El orden lista = [] #La lista que guarda los valores iniciales y los generados a partir de ellos intervalo = 0 #La diferencia general entre los valores de x xAnterior = ...
a7f2d27d425038f8e634c67369f4c6cd9e3e8a9d
Rlyslata/DataStauct-And-Algorithm
/数组排序算法/BubbleSort/__init__.py
1,217
3.9375
4
""" 冒泡排序: 算法思想: 未排序的序列,必然存在两个不符合排序规则的相邻元素。 array 长度 为 n 一轮排序过程: 对array[i],将之array[i+1]比较,并交换他们的值,然后i++,直到i = n-1-i(n-i~n-1是已经排好序的,再参与比较无意义) 一轮排序结果: 经过一轮排序后,会将0~n-i-1中的最大值放到后面n-i-1的位置 (从大到小排序以从n-1~0的顺序执行,每轮排序会将未参与排序的序列中的最小值放到前面) """ def bubbleSort(a...
ea10cf4b05d17d57f2b2111161302e5f68199151
seattlegirl/jianzhioffer
/fibonacci.py
403
3.84375
4
# -*- coding:utf-8 -*- class Solution: def Fibonacci(self, n): # write code here result=[0]*(n+1) if n==0: return 0 if n==1: return 1 result[0]=0 result[1]=1 for i in range(2,n+1): result[i]=result[i-1]+result[i-2] r...
ebd02939cd2caaa1f6c3f9dc6bb179d6f3dc9a83
bartoszp1992/kicad-coil-generator
/spiral.py
4,832
3.953125
4
import math import collections from math import pi import KicadModTree as kmt def polar2cartesian(r, theta): x, y = r * math.cos(theta), r * math.sin(theta) return (x, y) def cartesian2polar(x, y): r, theta = math.sqrt(x**2 + y**2), math.atan2(y, x) return (r, theta) def arc_through_3_points(A, B, ...
0f1f498427dff673390ffbd80652075499029751
AoifeFlanagan/Blackjack
/Blackjack.py
8,645
4.125
4
"""Program for a game of Blackjack.""" import random from IPython.display import clear_output class Card: """A class to represent each card in the deck, using two attributes, suit and rank.""" def __init__(self, suit, rank): self.suit = suit self.rank = rank self.value = values[ra...
f4e9a1b5e1a04f64957f33166c93d2b0ead7aa3b
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/288_Unique_Word_Abbreviation.py
956
3.703125
4
c_ ValidWordAbbr o.. ___ - dictionary """ initialize your data structure here. :type dictionary: List[str] """ dictionary = s..(dictionary) abb_dic # dict ___ s __ dictionary: curr = getAbb(s) __ curr __ abb_dic: abb_d...
5d62c2a178b417bb1f0a9196e2b8072f1b0e436a
spacetime314/python3_ios
/extraPackages/matplotlib-3.0.2/examples/subplots_axes_and_figures/colorbar_placement.py
1,766
3.78125
4
""" ================= Placing Colorbars ================= Colorbars indicate the quantitative extent of image data. Placing in a figure is non-trivial because room needs to be made for them. The simplest case is just attaching a colorbar to each axes: """ import matplotlib.pyplot as plt import numpy as np fig, axs ...
40301a240890eb8d414712c3e4da59d1cf891686
Legend0300/Codingandbeyond
/Ahmed's stuff/hello.py
315
3.515625
4
prive_of_house = 1000000 down_payment = (prive_of_house - 200000) goof_credit = () bad_credit = () if goof_credit == True: print("your payment is; ", (prive_of_house - 100000)) elif bad_credit == True: print("Yuor down payment will be:", down_payment) else: print("you dont ahve enough credit")
62cba7b2453bd574aaf7d3097d7f75ae110eaf94
yousstone/python3_learning_note
/reduce_prod.py
161
3.53125
4
#!/usr/bin/python3 from functools import reduce def prod(L): return reduce(lambda x,y : x*y,L) print(prod([1,2,3,4])) print(prod([x for x in range(1,11)]))
f94352f5ff55bd248bac7f0d9cf844085fc85e28
BDunk/ME303_Project_01
/Project_01/bonus.py
3,926
3.859375
4
import random import numpy as np # number of agents n = 20 agents = [] for ii in range(n): # create an agent, who starts with no cash, and as an active trader agents.append({'money': 0}) if ii < n - 1: # assign the first n-1 agents the fruit corresponding to their id # this doesn't bias a...
017e709b0c9b722dfba154276b4bedcf146d7269
ksu-is/Sport-Score-Tracker
/SportScoreTracker.py
1,159
3.9375
4
import sports def main(): print('Introducing the Sport Tracker Application!\n') print('I can provide you with scores from soccer, basketball, football, and baseball that occured today!\n') print('What sport scores would you like to read? (enter a digit)\n') print('1. Soccer\n2. Basketball\n3. Football\...
e6ac8c8d7ec264f8906ca7391e45f1fc92e2be4c
Dessdi/python-simple-projects
/CountWordsInString.py
110
3.5
4
path = input("set file path") with open(path) as file: words = file.read().split() print(len(words))
85688ae2dfeb727702d88055619aed97e9f915d0
pawanpatil636/sorting-algorithms
/quicksort.py
399
3.703125
4
#-----------------------------quick sort--------------------------------- def quick(seq): n=len(seq) if n<=1: return seq else: pivot=seq.pop() greater=[] lower=[] for i in seq: if pivot > i: greater.append(i) else: lower.append(i) ...
06d3f54eb6c422bdf878452866ce7c8a944bd9b6
nick-fang/pynetwork
/pynetwork/python异步_同步非阻塞方式.py
2,001
3.984375
4
"""深入理解python异步编程-非阻塞方式""" import socket import time def nonblocking_way(): """非阻塞的socket连接和传输""" sock = socket.socket() sock.setblocking(False) #将该sock对象的所有方法设置为非阻塞 try: sock.connect(('example.com', 80)) except BlockingIOError: #无论阻塞(比如设置了超时)还是非阻塞模式,只要连接未完成就被强制返回,操作系统低层就会抛出该异常;所以非阻塞模式下几乎肯定...
de187b3c586af46b6899e47371234a47b840f351
LordBao666/MITLecture6.0002_introduction_to_computational_thinking_and_data_science
/practice/14random_walks_and_more_about_data_visualization/random_walk/random_walk.py
5,527
3.53125
4
""" @Author : Lord_Bao @Date : 2021/3/21 """ from entity import * import pylab def walk(drunk, field, num_steps): """ :param drunk: Drunk实例 :param field: Field实例,假设drunk 处在 field中 :param num_steps: 走的步数 :return: 返回初始点到走了num_steps的距离 """ start_loc = field.get_location(drunk) for ...
ddd8abad67d7db2f910740717fd51876c346c677
arpita-lataye14/NESTED_LIST
/calculator.py
588
4.3125
4
print('what operation do you want?') operator=input('either +,-,*,/,//,%,**:') n1=float(input('enter first number:')) n2=float(input('enter second number:')) if operator=='+': print(n1,operator,n2,'=',n1+n2) elif operator=='-': print(n1,operator,n2,'=',n1-n2) elif operator=='*': print(n1,operator,n2,'=',n1*...
00964e6a4d1c65ed83947626cc5622cfd007a316
Rogersunfly/pythoncamp0
/scr/guess the number.py
1,190
3.671875
4
import simplegui import math import random secert_the_number = 100 guess_the_number = 0 def new_game(): if guess < secert_the_number: print "lower!" elif guess > secert_the_number: print "higer!" elif guess == secert_the_number: print " correct,you are a gooooooood booy!" else: ...
a841611dea467b93e1cd8715b67c3dccd6ffaa2f
yanggelinux/algorithm-data-structure
/algorithm/dijkstra_search.py
914
3.625
4
# -*- coding: utf8 -*- nodes = { "a":{"b":0.2,"c":0.3}, "b":{"d":0.2,"f":0.3}, "c":{"d":0.4,"e":0.1}, "d":{"e":0.3}, "e":{"f":0.2}, "f":{} } finish = {} mw = {} def get_min_val(dicts={}): if dicts: val_list = [] re_dicts = {} for k,v in dicts.items(): ...
83e56c8b59af06cd71596b6d962a5b62f2e83639
Kolyan78/P101
/Занятие3/Лабораторные_задания/task1_1/main.py
597
3.828125
4
# def main(): # a = 0 # while True: # sum_ = pow(a + 1, 2) * 2 # #print(f"Сумма квадратов {a} равна {sum_}") # if sum_ > 500: # break # else: # a += 1 # return a def main(): a = 0 list_ = [] while True: if sum(list_) > 500: ...
515e08198f12cba35372ac23af17aef2875fbaed
mws19901118/Leetcode
/Code/Transpose Matrix.py
200
3.546875
4
class Solution: def transpose(self, matrix: List[List[int]]) -> List[List[int]]: return [[matrix[i][j] for i in range(len(matrix))] for j in range(len(matrix[0]))] #Transpose matrix.
b72085fa05aef68e768629b4378886940c2a0fab
rajasree-r/Bactracking-1
/addOperators.py
1,395
3.640625
4
# Time complexity: O(4^N) # Space complexity: O(4^N) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : No class Solution: def addOperators(self, num: str, target: int) : result = [] self.backTrack(num, 0, 0, '', target, result) return result ...
6049df909df7d54a7e58d825f17611a4f396a347
PriscillaRoy/Parking-Lot-Vacancy-Detector
/testscr.py
624
3.609375
4
import os class runFolder: def runfolder(self,folderpath): filenames = os.listdir(folderpath) # get all files' and folders' names in the current directory xml = [] jpg = [] for filename in filenames: # loop through all the files and folders #Listing the separate xml an...
2114d138ca658aa217c2f44b666797b1ffd338e4
IDemiurge/LeetCodePython
/algs/removeDuplicates.py
391
3.53125
4
# https://leetcode.com/problems/longest-substring-without-repeating-characters/ class Solution: def removeDuplicates(self, nums) -> int: for n, val in enumerate(nums): for i, val2 in enumerate(nums[n + 1:]): if val2 == val: nums.pop(i + 1) return nums...
2c1ea5cbcb911796b18dfa853fec0eac517c588e
antalcides/migit
/py/ej3_rkutta4o.py
1,013
3.765625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ Fecha de creación: Thu Oct 22 01:58:05 2015 Creado por: antalcides """ """ A spacecraft is launched at the altitude H = 772 km above the sea level with the speed v 0 = 6700 m/s in the direction shown. The differential equations describing the motion of the spacecraft are ...
d7e320069ddc1871954fc98d2a603770f3cd3158
jjcrab/code-every-day
/day72_subarraySumEqualsK.py
870
3.8125
4
# https://leetcode.com/problems/subarray-sum-equals-k/ ''' Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2 ''' # can't pass # class Soluti...
b06170edc81d96b5b172cb6b345b20371c70aea8
Ma-rk/python-cookbook-3rd
/04_IteratorsAndGenerators/08_SkippingTheFirstPartOfAnIterable.py
508
3.640625
4
from itertools import dropwhile with open('sample.txt') as f: for line in f: print(line, end='') print() print() print() print('========using drop while========') with open('sample.txt') as f: for line in dropwhile(lambda line: line.startswith('pip'), f): print(line, end='') print() print() ...
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...
f9cecdd5440c7a202d3ef2ad4ae8f2640c71fb44
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/83_6.py
2,490
4.40625
4
Python | Frequency of numbers in String Sometimes, while working with Strings, we can have a problem in which we need to check how many of numerics are present in strings. This is a common problem and have application across many domains like day-day programming and data science. Lets discuss certain ways in ...
85276698a74c996bbf7b6bfb3752e7d7d86bfb22
yyf-fan/keyunxing
/勾玉.py
492
3.546875
4
import turtle mp = turtle.Pen() mp.speed(0) #放置图案居中 mp.penup() mp.goto(140,86) mp.pendown() #for循环绘制勾玉 for j in range(3): #双曲线绘制勾 mp.fillcolor("black") mp.begin_fill() mp.dot(100,"black") mp.backward(50) mp.right(90) mp.circle(100,-90) mp.circle(50,150) mp.end_fi...
8d7dc46026cd1e151e740c039a24e4db6d22a05e
mentat-us/PythonExercises
/Chapter_4_Selections/Exercises/Exercise_4_16.py
97
3.546875
4
import random number = random.randint(65, 90) print("Random upper case letter is", chr(number))
95a68978d7e36e1fb8328f699187105b162ca7ba
WongueShin/codeit_ex
/student.py
4,309
3.703125
4
class Student: # 코드를 쓰세요 def __init__(self, name, idnum, major): self.info_manage = InfoManage(name, major, idnum) self.student_info = Info(self.info_manage.gpa, self.info_manage.name, self.info_manage.major, self.info_manage.idnum) self.average_gpa = Ave...
7a9fa0c750f757eeb8463ef117f11f5b0d344004
attapun-an/A2_advanced_data_types
/linked_list_ordered.py
4,478
3.96875
4
from LL_node import * class OrderedList(): def __init__(self): self.head = None # isEmpty def isEmpty(self): return self.head is None """Mr. M: Ca."we know if it's empty, head == None, and if we reach the end, we get None .Loop through it until we hit None, then add it" """ #...
a0ac834985afe3379e319f2db37b73dacec20c5b
jangjichang/Today-I-Learn
/Algorithm/Programmers/베스트앨범/test_bestalbum.py
1,174
3.8125
4
""" """ genres = ["classic", "pop", "classic", "classic", "pop"] # , "hiphop", "hiphop" plays = [500, 600, 150, 800, 2500] # , 1000, 500 returns = [4, 1, 3, 0] def test_simple(): assert solution(genres, plays) == returns def solution(genres, plays): # zipped = zip(genres, plays, range(0, len(genres))) ...
41d8c61f0779271a6ab1965cf261dc86c2ef3c54
iamasik/Python-For-All
/C6/Tuple_to_List_to_string.py
354
3.84375
4
Tuple=tuple(range(1,8)) print(Tuple) #Tuple to list to tuple List=list(Tuple) print(List) List.append(6) Tuple=tuple(List) print(Tuple) Tuple2=tuple(range(1,8)) Str=str(Tuple2) print(Str) print(type(Str)) #Join Tuple T1=(1,2,3,4) T2=(5,6,7,8) T3=T1+T2 print(T3) #Delete tuple del T1 print(T1) ...
17a5f20e63d19f233aae4c2fe2f13c8daa8f517c
bharadwajnunna/average-of-students-using-class
/avg students.py
596
3.765625
4
#Use Classes: #Find the avg marks of each student. class AvgMarks: print("Avg Marks of each student : ") def average(self,i,students): [print("{}\t\t{}\t-->{}".format(j['name'],sum(i)/len(i),sum(i)//len(i))) for j in students if i==j['marks']] students=[{'name': "John",'rollno': 1234,'marks': [...
6f4adfe7bc218464b2f7e11e98b90cb0b9421154
kingsley-ijomah/python-basics
/dot-dsl/dot_dsl.py
1,409
3.59375
4
NODE, EDGE, ATTR = range(3) class Node: def __init__(self, name, attrs): self.name = name self.attrs = attrs def __eq__(self, other): return self.name == other.name and self.attrs == other.attrs class Edge: def __init__(self, src, dst, attrs): self.src = src self...
45cee2698a98e24244ab00c1383514bd5f9b9d42
travisrobinson/coursera-specializations
/data-structures-and-algorithms/algorithmic-toolbox/week-2/lcm.py
214
3.625
4
# Uses python3 import sys def gcd(a, b): while b!= 0: (a,b) = (b,a%b) return a def main(): a,b = map(int,sys.stdin.readline().split()) c = gcd(a, b) d = (a*b)//c print(d) main()
721ff6d2373e9b291533d550215ff196412aee4c
gpf1991/pbase
/day15/exercise/generator.py
827
3.9375
4
# 练习: # 1. 已知有列表: # L = [2, 3, 5, 7] # 1) 写一个生成器函数,让此函数能够动态的提供数据,数据 # 为原列表中数字的平方加1 即 : x**2+1 # 2) 写一个生成器表达式,让此表达式能够动态提供数据,数据 # 同样为原列表中的数字的平方加1 # 3) 生成一个列表,此列表内的数据为原列表L中的数字的平方加1 # 最终生成的数为: 5 10 26 50 L = [2, 3, 5, 7] def mygen(lst): for x in lst: yield x *...
1401f8bc06b7cbdf79142af599304d3fe5902d0e
hoxuanhoangduong/hoxuanhoangduong-labs-c4e22
/Lab3/Homework/ex5.py
277
3.828125
4
from turtle import * def draw_star(x,y,length):#,color): # colormode() # pencolor(color) penup() setx(x) sety(y) pendown() for i in range(5): forward(length) right(144) draw_star(20,250,100) # draw_star(20,250,100,"blue") mainloop()
e9c10f66655e4384996bc4d67053cf415ddc7018
Phong-Hua/Udacity_Show-me-the-Data-Structures
/Problem5.py
4,611
4.71875
5
""" Blockchain A Blockchain is a sequential chain of records, similar to a linked list. Each block contains some information and how it is connected related to the other blocks in the chain. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data. For our blockchain we will...
e7c4fa27fe60bdde5f5015e8d0627cb05d720ab5
kimi9527/chess-yi
/chess/chess_view.py
1,939
3.5
4
# coding=utf-8 import pygame from sys import exit from chess.images import BACKROUND, SELECTED MAX_X = 8 # 0-8 MAX_Y = 9 # 0-9 class ChessView(object): """ 棋盘显示 """ @staticmethod def Pixel2XY(pixel_x, pixel_y): ''' 界面像素到棋局坐标变化 ''' x = (pixel_x - 5) // 40 ...
3fb07e8762f1876e6d6cc2680500145be6d333c1
aa-fahim/leetcode-problems
/Pacific Atlantic Water Flow/main.py
1,552
4.09375
4
''' DFS Approach Time Complexity: O((n * m)^ 2) where n is the number of rows and m is the number of columns in the matrix. Iterate through each position of the grid and perform DFS until we have visited a node that touches the atlantic ocean and a node that touches the pacific ocean. ''' class Solution: ...
ce1d72b36cfd56f5ae1e75bce167417dced8055d
taihuibantian/workspace
/binary_search.py
721
3.8125
4
import sys #二分探索法 # arr : 数値リスト # n : 要素数 # left : 左端要素のindex # right : 右端要素のindex # center : 中央要素のindex # target : 探索値 arr = [11,13,24,26,35,37,46,49,54,68] print(arr) target=input("探索値を入力する:") target=int(target) n = len(arr) left = 0 right = n -1 while left <= right: center = (left + right) // 2 #...
a53c4569ce35be5d1a7556b07f491ac2477f1966
danaimone/Grokking-The-Coding-Interview-Solutions
/Tree Breadth First Search/zigzag_traversal.py
1,260
4.09375
4
from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def traverse(root): result = [] if root is None: return result queue = deque() queue.append(root) left_to_right = True while queue: l...
372f952d9817c4e4e954584deb96a912673e8c5d
Kapilpatidar5001/MPT1
/mid1_1.py
309
3.59375
4
l1=(input("enter list 1 seperated by comma")).split(',') w=input("enter world to remove") o=int(input("enter the occurence to remove")) c=0 r=[] print(type(w)) print(l1) for i in l1: if (i==w): c=c+1 if (c!=o): r.append(i) else: r.append(i) print(r)
84b4313b59cb60649f27d1a01a9237f7bb3cf253
arundhathips/programs_arundhathi
/CO1 pg 11.py
304
4.28125
4
#Find biggest of 3 numbers entered. x = int(input("Enter 1st number: ")) y = int(input("Enter 2nd number: ")) z = int(input("Enter 3rd number: ")) if (x > y) and (x > z): largest = x elif (y > x) and (y > z): largest = y else: largest = z print("The largest number is",largest)
3945694a0bb9cf543a828b7af9d267a11471cf26
sgfm/BrightsideDataChallenge
/main.py
3,179
3.71875
4
import pandas as pd import numpy as np import pickle import math def check_interest(loan, desired_interest): ''' Checks if the loan has the desired interest rate to invest. Returns boolean. ''' return float(loan.int_rate[:-1]) >= desired_interest def format_loan(loan): ''' This takes in a loan...
e42f291e8f902a91b6e44eacb16ee490c52ccb85
messerzen/Pythont_CEV
/aula06_desafio01.py
128
3.8125
4
n1=int(input('Digite um nro:')) n2=int(input('Digite outro nro:')) s=n1+n2 print('A soma entre {} e {} é {}'.format(n1, n2, s))
a10a0606ba1732d757f5814c5e5955aadab4e0cc
kingfi/cs181-s21-homeworks
/hw1/T1_P4.py
4,669
3.5625
4
##################### # CS 181, Spring 2021 # Homework 1, Problem 4 # Start Code ################## import csv import numpy as np import matplotlib.pyplot as plt import math csv_filename = 'data/year-sunspots-republicans.csv' years = [] republican_counts = [] sunspot_counts = [] with open(csv_filename, 'r') as csv_...
7cf57531750623eed76a78f9f8284407a11887a3
Farooqut21/my-work
/assignment from 3 .1 to 3.13/3.10/no vowel.py
136
3.75
4
s=input("enter a string") def noVowel(s): for char in s: if char in 'aeiou': return False return True
b53aa413ac28e2375c5554fee45739ad55daba43
joaqFarias/poo-python
/tienda_y_productos/product_lib.py
684
3.859375
4
class product: def __init__(self, name: str, price: int, category:str) -> None: self.name = name self.price = price self.category = category def update_price(self, percent_change: float, is_increased: bool) -> object: if is_increased == True: self.price = self.price ...
de148db132644417340bd5675fbcc4e9a4225f6a
schwertJake/Barren_Land_Analysis
/barren_land_graph/barren_land.py
1,571
3.5625
4
""" barren_land.py This module is the vertex objects for the graph that will be created from the barren land plots. The vertex contains coordinates and total area. """ class BarrenLand: _coord_map = { "x0": 0, "y0": 1, "x1": 2, "y1": 3 } _plotly_viz_attr = { "type...
f4545a9e1017d08c40c7e0467ca95a92752b84ad
GriTRini/study
/python/1일차/알바비계산.py
737
3.921875
4
#응용문제1 : Part-time calculation Program name = str(input('alba name : ')) hour = int(input('hour: ')) pay = int(input('pay : ')) total = hour * pay print(total) #출력방법 #1. 콤마연산자사용 print(name ,'님의 총 금액은',total, '원 입니다. 수고많으셨습니다.^^') #2. 형식문자(서식문자) 사용 : 정수(%d), 실수(%f), 문자열(%s) print('알바생의 이름은 %s 입니다' % name) print('총금액...
90b6c518ba17e1b79f97899aacc68e2c7c193417
SinCatGit/leetcode
/00204/count_primes.py
727
3.65625
4
class Solution: def countPrimes(self, n: int) -> int: """ [204. Count Primes](https://leetcode.com/problems/count-primes/) Count the number of prime numbers less than a non-negative number, *n*. **Example:** ``` Input: 10 Output: 4 Explanation: Ther...
99b610579e5eafe4c7a218b45cc1412ff2814a83
arnabs542/DataStructures_Algorithms
/bitwise/Min_XOR_value.py
638
3.8125
4
''' Min XOR value Given an integer array A of N integers, find the pair of integers in the array which have minimum XOR value. Report the minimum XOR value. Problem Constraints: 2 <= length of the array <= 100000 0 <= A[i] <= 109 Input 1: A = [0, 2, 5, 7] Input 2: A = [0, 4, 7, 9] Output 1: 2 Output 2: 3 ''' ...
785da3de78d0e5059a632a62eb95d191e190e185
pdturney/modeling-major-transitions
/view_contest.py
4,776
3.515625
4
# # View Contest # # Peter Turney, July 16, 2019 # # Select two seeds from pickles and watch them battle. # import golly as g import model_classes as mclass import model_functions as mfunc import model_parameters as mparam import random as rand import time import pickle import os # # Open a dialog windo...
89bfe9554fc45480038510661013667fbf9bc782
soumya9988/Python_Machine_Learning_Basics
/Python_Basic/4_Lists/list_basics.py
992
4
4
my_shopping_list = ['butter', 'egg', 'milk', 'fish', 'potato'] dessert_list = ('ice cream', 'cookie', 'pineapple') print('I have %d items to buy and they are: ' % (len(my_shopping_list))) for item in my_shopping_list: print(item, end=' ') my_shopping_list.sort() print('After sorting, the list is: ', my_shopping...
feb64b4ddca2623f736c0ed638e0d8b4e87ca877
Grug16/CS112-Spring2012
/Objects2.py
963
4.25
4
#!/usr/bin/env python class Student(object): def __init__(self, name): self.name = name def say(self, message): print self.name +": "+message def say_to(self,other,message): self.say(message+", "+other.name) def printf(self): print self.name bob = Student(...
37628c443287fe3222077c047359a2437f57e91a
damiansp/AI_Learning
/AI_modern_approach/03_SolvingBySearching/missionariesAndCannibals/missionaries_and_cannibals.py
2,187
3.5
4
def get_boat_side(state): return 0 if state[0][2] == 1 else 1 # Test #print(get_boat_side([[0, 0, 0], [3, 3, 1]])) #print(get_boat_side([[3, 3, 1], [0, 0, 0]])) def cross_river(state, n_cannibals, n_missionaries, boat_side): new_state = [state[0][:], state[1][:]] change = [n_cannibals, n_missionaries, 1]...
a2e030d61c355b54573bb9b8f9c59c88a8a50426
Twice22/PythonMachineLearning
/ch10/PolynomialRegression/lr_to_polreg.py
1,919
3.6875
4
# in the previous sections, we assumed a linear relationship between # explanatory and response variables but we can have sth like : # y = w0 + w1x + w2x²x² + ... + wdx^d # we will use PolynomialFeatures transformer class from scikit # to add a quadratic term (d = 2) to a simple reg problem with # one explanatory var...
b0ee47291040fa7a225796bd2d7510a0bafa7583
paulwratt/cloudmesh-pi-burn
/cloudmesh/burn/wifi/ubuntu.py
2,079
3.59375
4
""" Implementation of a function the set the WIFI configuration. This function is primarily developed for a Raspberry PI """ import textwrap from cloudmesh.common.console import Console from cloudmesh.common.sudo import Sudo from cloudmesh.common.util import writefile class Wifi: """ The class is used to gro...
2a2d0440139eee30be0e720ff3b02b31edaaf0c8
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/kindergarten-garden/4243f13b01c94421ac2f8cd5e668440f.py
722
3.671875
4
from collections import defaultdict class Garden: def __init__(self, plants, students=('Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Fred', 'Ginny', 'Harriet', 'Ileana', 'Joseph', 'Kincaid', 'Larry')): self._garden = defaultdict(list) students = tuple(sorted(students)) flower...
c2bde8e8a379ffd502cce4f76079a76aac8b4345
ksvikram/hRankworkouts
/python/RegEx/Applications/SplitthePhoneNumbers.py
274
3.765625
4
import re R = re.compile(r'(\d{1,3})[\-\ ](\d{1,3})[\-\ ](\d{4,10})') for _ in range(input()): line = raw_input() match = R.search(line) if match: print 'CountryCode={},LocalAreaCode={},Number={}'.format(match.group(1), match.group(2), match.group(3))
cc4572c43d3aa694e03255f9f94d1bd43628d532
kwura/python-projects
/Foundations of Programming/Spiral.py
2,808
4.5625
5
# Description: Creates a spiral with a specific dimension and outputs the neighboring numbers of a target number in three lines. def make_spiral(dims): # create 2-D list with zeros a = [] for i in range (dims): b = [] for j in range(dims): b.append(0) a.append(b) reference = dims ** 2 f...
ec2cf5c57b123686804436dc8ef7d6fb0d33069b
slchangtw/Advanced_Programming_in_Python_Jacobs
/assignment_6/vballsim.py
2,952
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # JTSK-350112 # a6_3.py # Shun-Lung Chang # sh.chang@jacobs-university.de from random import random def get_inputs(): # RETURNS prob_a, prob_b, number of games to simulate a = float(input("What is the prob. player A wins a serve (between 0 and 1)? ")) b...
fa413d8d3221fc761c60f4fead461ae9f41c415c
Nextc3/aulas-de-mainart
/Listas/Lista 3/q2.py
1,156
4.15625
4
#Crie três listas, uma lista de cada coisa a seguir: ##• frutas #• docinhos de festa (não se esqueça de brigadeiros!!) #• ingredientes de feijoada #Lembre-se de salvá-las em alguma variável! #a. Agora crie uma lista que contém essas três listas. #Nessa lista de listas (vou chamar de listona): #b. você consegue acessar ...
2c1a05d74485982b8b3ec9e72e788feeb9816b66
KDiggory/pythondfe
/PYTHON/Files/Files.py
1,213
3.828125
4
#help(open) ##opens the help info for the inbuilt method open openedfile = open("README.md") print(openedfile) ## prints metadata - (open file IO type of data). Not the contents of the file! #help(openedfile) ## will then open help for the new variable you've made - can see there is a read function in there. ...
8c5dca2178ab6ec77ff9c863eed8eeccc099e65b
kibazohb/Leetcode-Grind
/Medium/braceExpansion/solution_02.py
1,386
3.75
4
from collections import defaultdict class Solution: def expand(self, S: str) -> List[str]: """ "{a,b}c{d,e}f" Questions to ask: Will sequence of characters be in order? can we have more than one interfering character? can we have interfering characters at the beginning of the...
2ff11413f9c77b387250dce359d712fbc426f1a3
stephensb/devcon19python
/ListComprehension.py
150
3.828125
4
numbsq = [] for num in range(8): numbsq.append(num**2) print(numbsq) #list comprehension numbsq = [num**2 for num in range(8)] print(numbsq)
c841c9b1ad3401e995f9b8cd0662299deee35ebb
JetimLee/DI_Bootcamp
/pythonlearning/week1/listMethods2.py
532
4
4
basket = [1, 2, 3, 4, 5] new_basket = ['a', 'b', 'c', 'd'] print(basket.index(2)) print(new_basket.index('a')) # this will tell you the index of the item passed inside print(new_basket.index('c', 0, 3)) # here you say which thing you want the index of and the indices you're searching through print('z' in new_basket)...
81f5cc170d86fd440a8c49d3cea319e5d254117a
enra64/iot-ledmatrix
/host/helpers/TextScroller.py
3,025
4.03125
4
from Canvas import Canvas from CustomScript import CustomScript from helpers.Color import Color class TextScroller: """ This class is designed to help with scrolling text over the canvas. Following functions are expected to be forwarded: * :meth:`update` to update the text position * :meth:`draw` to d...
54cee7e266bf311bed11f13a4b2c0d708b8c80e6
kenekc18/MiniProjects_
/GuessingGame.py
473
4.09375
4
import random targetNumber = random.randrange(1,10) print(targetNumber) while True: guessedNumber = int(input("Enter a number between 1 and 10:")) if guessedNumber == targetNumber: print("Congratulations you guessed the right number") elif guessedNumber < targetNumber: print("The number is ...
744808ae5dbb38d9c6b11ab6fac9cba4c3cad781
shalom-pwc/challenges
/Pytho Challenges/02.calculate-remainder.py
121
3.890625
4
# Calculate Remainder # ---------------------------------- def remainder(num): return num % 2 print(remainder(5)) # 1
90a2d82ac44bcedd78470cf744dfefb7ec4c25e0
Aadi2001/HackerRank30DaysChallenge
/Day 2-Operators/Operators.py
2,029
4.28125
4
""" Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Round the result to the nearest integer. Example mealcost = 100 tippercent = 2...
cafc9dda499d07b8103ff3922c623270038f9715
nate-d-olson/CBBG_Rosalind_Bioinf
/ba1i_KC.py
1,141
3.609375
4
#!/usr/bin/python # File created on Nov 05, 2015 __author__ = "Kenneth Cheng" __credits__ = ["Kenneth Cheng"] __version__ = "0.0.1-dev" __maintainer__ = "Kenneth Cheng" __email__ = "" """ Definition: Problem Description: Find the most frequent words with mismatches in a string. Given: Strings Text along wit...
c33de1d20031e544564d61ab744e00737135eaaf
ovwane/leetcode-1
/src/HammingDistance.py
684
3.859375
4
''' LeetCode: Hamming Distance description: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Input: x = 1, y = 4 Output: 2 Example: Explanation: 1 (0 0 0 1) 4 (0...
6a3416ef730e94c2df91c349b10efca2fb3495e9
nisarggurjar/PythonRevisionSession
/String.py
534
3.984375
4
X = 'hello to ALL' Y = str("Welcome to Python's Class") Z = 'Good Afternoon' print(X[1]) print(X[-3]) a = X[-3] print(a) print(Y +' ' + X + ' ' + Z) print(X*5) # Slicing print(Y[0:7]) print(Y[8:10]) print(Y[11:]) print(Y[:7]) print(X[::2]) print(X[::-1]) print(list(X)) print(X.split()) print(X.split('o')...
b90577fd5cb2966a94e50950b1281ad639875a61
mjindal585/snapbuzz
/codes/edgeenhance.py
1,286
3.515625
4
# import image module from PIL import Image from PIL import ImageFilter from PIL import ImageDraw, ImageFont import math import time import tkinter from tkinter import filedialog import os root=tkinter.Tk() root.withdraw() def edgeenhance(): print(":: Welcome To Edge Enhancement ::") time.sleep(0.5) p...
1b769f895322ba26a21c8e3ec260ccacf8118d1d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2405/60641/303877.py
3,064
3.625
4
class BinaryTree: def __init__(self, value): self.father = None self.left_node = None self.right_node = None self.value = value def set_father(self, x): self.father = x def set_son(self, x): if self.left_node is None: self.left_node = x e...
a350a064edbc2e5fe912d76b49bf62c89e387624
ResmyBaby/pythonPlayground
/oop/Enumarate.py
332
3.75
4
__author__ = 'asee2278' list = [2,2.2,0," " ] count = 0 for item in list : print "index "+ str(count) +" has element ", print item count+=1 for index,item in enumerate(list): if index >2 : break; print( index , item) lst = [2==2,2==3,4%2==0] print all(list) print complex(1,2) er = complex('2+2j'...
375e539c5b4eb744be0044ae7ebc4de9f78c4663
tonycao/CodeSnippets
/python/homework/Archive/A2/A2Answer_sean.py
5,029
3.765625
4
## Assignment 2 - Analyzing water ## Author: Sean Curtis ## Collaborators: None ## Time spent (hours): N/A ## In this assignment, we're going to visualize and analyze data to answer ## meaningful questions. Some of the framework you need is in place, you ## have to fill in the gaps. import numpy as...
1ce03a3f7aab8af12c5188038d8b4d79595d7d8f
GraysonO/O-Connell_Grayson_CISC233
/Linked List.py
1,211
3.75
4
class LinkedStack: class Node: slots = '_element', '_next' def init (self, element, next): self.element = element self.next = next def init (self): self.head = None self.size = 0 def len (self): return self.size def is_empty(self): ...
925ae08a59d1c71d5e0b630d103fbdf3a57a174a
tmu-nlp/NLPtutorial2020
/seiichi/tutorial00/tutorial00.py
1,045
4.1875
4
# tutorial00 # ファイルの中の単語の頻度を数えるプログラムを作成 import sys, os from itertools import chain from collections import Counter def count(path: str): """ Args: path, str Return: word_cnt, dict """ if type(path) != str: raise TypeError cnt = 0 word_cnt = {} with open(path, "r") as f: ...
e4b96d9ba800d8220855d881ac398615d12f1c75
Jorgeteixeira00/CURSO-EM-V-DEO---EXERCICIOS
/Ex47.py
165
3.828125
4
#Exercício Python 047: Crie um programa que mostre na tela todos os números pares que estão no intervalo entre 1 e 50 for x in range(0,51,2): print(x,end=' ')
c22f8c4ee468d8810349e71eca8bd884c5685a99
Ethan-O/Computational-Physics
/Assignment 5/Animation test.py
2,040
3.6875
4
# Planetary motion with the Euler-Cromer method # based on Giordano and Nakanishi, "Computational Physics" # Yongli Gao, 2/11/2006 # # Add a plot for the Earth as the Vpython zooming has failed. # Yongli Gao, 2/15/2017 from vpython import * # possible values x=1, y=0, v_x=0, v_y=2pi, dt=0.002, beta=2 print ("two pl...
722925a74c58f3e2697ee41d58211f3f3a16f5d7
sky-dream/LeetCodeProblemsStudy
/[0505][Medium][The_Maze_II]/The_Maze_II_2.py
2,020
3.8125
4
# -*- coding: utf-8 -*- # leetcode time cost : time exceeded # leetcode memory cost : time exceeded # Solution 2, DFS class Solution: def shortestDistance(self, maze: List[List[int]], start: List[int], destination: List[int]) -> int: m,n = len(maze),len(maze[0]) Distances = [[float('inf')]*n...
b553996a64ceb9b88886a71df6329384baa1badb
fontfish/Wolf-and-Poems
/Tools/fibonacci.py
341
3.796875
4
# From my Fibonacci bash script, converted into Python. smlFib = input('First number:') bigFib = input('Second number:') fibRep = input('Number of repeats:') times = 1 repeat = int(fibRep) + 1 while times <= repeat: newFib = int(smlFib) + int(bigFib) smlFib = bigFib bigFib = newFib times = times + 1 ...
fde27fc6f4f64d6d5170931b0d79dee13cb3eca9
AkiraMisawa/sicp_in_python
/chap2/c2_03_width_height.py
507
3.625
4
import utility def make_rectangle(width, height): return utility.cons(width, height) def width_rectangle(r): return utility.car(r) def length_rectangle(r): return utility.cdr(r) def perimeter_rectangle(r): return 2 * (width_rectangle(r) + length_rectangle(r)) def area_rectangle(r): return ...
8a78226d7d581fbe760e5a038af498e67133a38a
Czy2GitHub/Python
/python_exec/tuple/tuple.py
605
3.90625
4
# -*- coding:utf-8 -*- # 元组的基本知识 # 元组中的元素不可变 # 元组的三种创建 tuple1 = ("c语言", "Java", "python", "c++") tuple2 = ("高级语言", ("Python", "Java"), "中级语言", "汇编语言",) tuple3 = "计算机组成原理", "计算机网络", "数据结构" # 如果元组只有一个元素,则元组定义时需要添加一个"," tuple4 = ("Python_exec",) # 定义了一个字符串 tuple5 = ("Python_exec") # 可以使用type()来测试变量类型 p...
7c1dc5ab4625adfd8fc344d5ffd6065208f65ffc
peterkisfaludi/Leetcode
/142_linked-list-cycle-ii.py
667
3.578125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def detectCycle(self, head: ListNode) -> ListNode: s=head f=head if head is None: return None while True: f=f.nex...