blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
0af4c124a22325c8964134ab91d216e61f81656c
sylwiadulian/my-first-blog
/test/my script.py
166
3.859375
4
def hi(name): print('Hi ' + name + '!') girls = ['Sylwia', 'Sandra', 'Karolina', 'Monika', 'You'] for name in girls: hi(name) print('Next girl')
108b569a829d3cc31a9b65ce7a0aa6fbf462eb9a
raulmercadox/curso_python
/problem1.py
136
3.875
4
s = "azcbobobegghakl" count = 0 for letter in s: if letter in 'aeiou': count += 1 print("Number of vowels in word:", count)
8b5bea460c3b444a49f9ee533c5cec0206773b09
raulmercadox/curso_python
/payingdebtbisectionsearch.py
1,049
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 6 21:56:09 2019 @author: ezmerra """ balance = 320000 annualInterestRate = 0.2 # expected result: Lowest Payment: 310 def calculateNewBalance(actualBalance, payment, monthlyInterestRate): pendingPayment = actualBalance - payment interest = monthlyInterestRate * ...
58a5e58076a244abdfd8145e52bace35425e272b
raulmercadox/curso_python
/payingdebtoneyear.py
1,009
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 6 21:05:56 2019 @author: ezmerra """ """ Monthly interest rate = (Annual interest rate) / 12.0 Monthly unpaid balance = (Previous balance) - (Minimum fixed monthly payment) Updated balance each month = (Monthly unpaid balance) + (Monthly in...
71dc2e255abafa51dd6863bc4b249f191f41004a
raulmercadox/curso_python
/for_inverso.py
142
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 3 00:19:57 2019 @author: ezmerra """ print("Hello!") for i in range(10, 0, -2): print(i)
01d06d2f4054af3f9ee02aa5ff5b16948f04f587
ulaireatea/Python
/Exercicios/ex052(Números primos).py
449
4
4
num = int(input('Digite um número: ')) tot = 0 for c in range(1, num + 1): # python conta sempre um a menos por isso o +1 if num % c == 0: print('\33[33m', end=' ') tot += 1 else: print('\33[31m', end=' ') print('{}'.format(c), end=' ') print('\n\33[mO número {} foi divísível {} vez...
92598c296eebd43da138117b3f77ec3affcdadd5
ulaireatea/Python
/Exercicios/ex034(Aumentos múltiplos).py
201
3.703125
4
sal = float(input('Qual o salário do funcionário? R$ ')) if sal <= 1250: novo = sal * 1.15 else: novo = sal * 1.10 print('Quem recebia R$ {:.2f} passa a receber R$ {:.2f}'.format(sal, novo))
a9e2492f63b9faf35eea84a918d46872460e5cd5
ulaireatea/Python
/Exercicios/ex043(Índice de massa corporal).py
397
3.90625
4
p = float(input('Informe o peso em Kg: ')) a = float(input('Informa a altura em metros: ')) imc = p / (a**2) print('O índice de massa corporal desta pessoa é {:.1f}'.format(imc)) if imc < 18.5: print('Abaixo do peso') elif 18.5 <= imc < 25: print('Peso ideal') elif 25 <= imc < 30: print('Sobrepeso') elif 30...
b3de1e0ae07fb3b9bf5dcd5246b61ef4fc5e815c
wargul/Course_Python
/4.1lessonPyt.py
357
3.734375
4
s = "Hello its me \"call\" you" print(s) print(len(s)) print(s[0]) for i in range(len(s)): print(s[i], end="") print() print(s[0:4]) print(s) s = s.lower() print(s.lower()) print(s.replace("world", "taras")) print(s) print(s[1::4]) print(s) s[::-1] print(s) s = "hello 1111 2222 3333 4444" s_spl = s.split(0) ...
d7a0e0861df3224d8e10be8184bfca060cf3244c
wargul/Course_Python
/7.1Home_15_Pyt.py
619
3.640625
4
import os def check(ll): # check if the list is sorted return False def print_bord(ll): os.system("clear") # for windows you need to use "cls" instead of "clear" print("15\t14\t13\t12\n11\t10\t9\t8\n7\t6\t5\t4\n3\t1\t2\t_") def check_move(move, bb): return False if __name__ == "__main__": ...
2c74ce6306b3dd0f7141bbf6d458c42f6fda2c69
Gringeril/Python
/moon.py
252
4.0625
4
weight = input("What is your weight? ") weight = int(weight) year = 0 while year < 15: weight = weight + 1 year = year + 1 moon = weight * 0.165 moon = float(moon) print("Your weight on the moon in year %s is %s " % (year, moon))
ee8549863440f5c92a6abc80b55c7e0d4eb3b05f
brinquisruben/evaluacion1
/par y multiplo3.py
395
4.15625
4
# -*- coding: cp1252 -*- def par_y_divisble_para_tres(): a= input("introduzca n: ") if(a%2==0): if(a%3==0): print "multiplo de 2 y 3" else: print "par y no multiplo de 3" else: if(a%3==0): print "impar y multiplo de 3" else: ...
3fd5d23ab6212a0f5c9dc44d3e09206587ae1893
brinquisruben/evaluacion1
/ejercicio5.py
941
3.9375
4
# -*- coding: cp1252 -*- def ejercicio5(): a=input("introduzca una ao: ") rmes=True rd=True while (rmes==True): m=input("introduzca una mes: ") rmes=((m<0)or(m>12)) if (rmes==True): print m,"no es un mes" while (rd==True): d=input("introdu...
c541b7cde860e4595b33e1718cc7e2fe9365f449
ric-geek/code_wars_and_hackerrank_solution
/HackerRank/Python/capitalize/capitalize.py
156
3.546875
4
def solve(s): word = s.split(' ') for i in range(len(word)): word[i] = word[i].capitalize() return " ".join(word)
af04daa501072d53c0f1698d263c0456e69f5f4c
shinyamagami/what_grade_you_are_going_to_get
/what_grade_you_are_going_to_get.py
596
4.09375
4
# Shin Yamagami # Oct 13th, 2015 # This program tell you what grade you are going to get. # def get_score(): return int(input("What score did you get?: ")) def point_to_grade(point): if point >= 800: return 'A' elif point < 800 and point >= 700: return 'B' elif point < 700 and point >=...
caba08e693d00b9e6b629e5eb8e898572a4d60fa
PSAlmighty/InterviewBit-Practices
/Stacks And Queues/Stack simple/Simplify_Directory_Path.py
474
3.703125
4
class Solution: # @param A : string # @return a strings def simplifyPath(self, A): roots = A.split("/") initial = [] ignoreN = 0 for root in roots[::-1]: if root == "" or root ==".": continue elif root == "..": ignoreN += 1 ...
6c526352c1302ea582accb6ac930549a204d3025
PSAlmighty/InterviewBit-Practices
/Linked Lists/List 2 pointer/Palindrome_List.py
723
3.671875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param A : head node of linked list # @return an integer def lPalin(self, A): n = 0 curr = A while curr: n += 1 ...
51b78fff2bf8d710cf5b288238fcc8984cc6eea7
PSAlmighty/InterviewBit-Practices
/Linked Lists/List trick/Reverse_Link_List_II.py
990
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param A : head node of linked list # @param m : integer # @param n : integer # @return the head node in the linked list def reverseBetween(self, A, m, n): if m == n: return A...
7c7abba1b666ad93e5cf56dc95e0ba86ccbe93da
PSAlmighty/InterviewBit-Practices
/Binary Search/Simple Binary Search/Search_for_a_Range.py
2,627
3.53125
4
class Solution1: # @param A : tuple of integers # @param B : integer # @return a list of integers def searchRange(self, A, B): if B < A[0] or B > A[-1]: return [-1, -1] n = len(A) left_a, right_a = 0, n-1 #find anything match first while left_a <= right_a: ...
dddb15007e2f224195266c3717aa3b1f4b34d5c0
PSAlmighty/InterviewBit-Practices
/Linked Lists/List 2 pointer/Merge_Two_Sorted_Lists.py
1,102
3.96875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param A : head node of linked list # @param B : head node of linked list # @return the head node in the linked list def mergeTwoLists(self, A, B): if not (A or B): return None...
c7cf2872653d589489c670a4029b3e6789c62680
PSAlmighty/InterviewBit-Practices
/Linked Lists/List Cycle/List_Cycle_LN.py
656
3.78125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param A : head node of linked list # @return the first node in the cycle in the linked list def detectCycle(self, A): twox, onex = A, A wh...
17a99aeb6d1bc894a0594d6de02d33f72cf22f94
200504225/1803
/07-day/作业3.py
254
4
4
x = float(input("请输入数字")) y = float(input("请输入数字")) fuhao = input("请输入+-*/") if fuhao == "+": print(x+y) elif fuhao == "-": print(x-y) elif fuhao == "*": print(x*y) elif fuhao == "/": print(x/y) else: print("输入错误")
add05217ff840daa85fb7e9ea52c967f097ff2d7
200504225/1803
/07-day/作业7.py
280
3.828125
4
s_acc = "123456" s_pwd = "abc" acc = int(input("请输入账号")) pwd = str(input("请输入密码")) if acc == s_acc and pwd == s_pwd: print("登录成功") elif acc == s_acc: print("密码不正确") elif pwd == s_pwd: print("账户不正确") else: print("账号为空")
77a18369b552114db17f4301cc34b5e15a32cf0e
200504225/1803
/清明/作业4.py
72
3.65625
4
a = int(input("请输入高度")) for i in range(1,a+1): print("*"*i)
24366d95b6d302872193cd0af9ccc1f0d5ca6f59
200504225/1803
/08-day/猜大小.py
199
3.640625
4
import random a = random.randint(1,100) b = 1 while b<=10: c = int(input("请输入数字:")) if c>a: print("猜大了") elif c<a: print("猜小了") else: print("猜对了") break b+=1
c8d0cd1c4bbde8c5f2fa22aef7190b600b2076f4
200504225/1803
/14-day/天数.py
185
3.84375
4
year = int(input("请输入年份")) if year%4 == 0 and year%100 !=0: print("%d是闰年"%year) elif year%400 ==0: print("%d是闰年"%year) year else: print("%d是平年"%year)
e1243b5080aa09c0efdf8b4d53a7fd92292da79d
200504225/1803
/07-day/作业5.py
369
3.765625
4
money = int(input("请输入身价")) height = int(input("请输入身高")) nice = int(input("请输入颜值分")) if money >= 100000 and height >= 180 and nice >= 80: print("高富帅") elif money >= 1000000 and nice >= 85: print("富帅") elif nice >= 99: print("帅") elif money < 100 and height < 160 and nice < 60: print("矮穷矬") else: print("傻子")
66b9f35333627a01a89fdc519cc7c7f7786e34ad
200504225/1803
/11-day/数字.py
152
3.75
4
a = ['1','2','3','4','5','6'] for i in range(len(a)-1,-1,-1): a.pop(i) print(a) a = ['1','2','3','4','5','6'] for i in a[:]: a.remove(i) print(a)
b01deb016ea0f6033a45eaa060f853d169e3e792
dylanstout1/CS-1400
/array.py
334
3.90625
4
cars = ["Ford", "Chrystler", "Dodge", "Ram", "Jeep", "Chevy", "GMC"] print(cars) MyArrayLen = len(cars) print(MyArrayLen) cars.append("Buick") print(cars[3]) cars.insert(2, "Toyota") print(cars) cars.pop(4) print(cars) cars.sort() print(cars) cars.sort(reverse=True) print(cars) print"The length of the array is "...
d507737f61915b1b2ee8445f5d4a9818278b97eb
Myusuft/Alpro-part5
/PRAUTS/bearke2.py
263
3.5
4
Data = input().split() Data = list(Data) for i in range(len(Data)-1): for j in range(len(Data)-1): if Data[j] > Data[j+1]: tmp = Data[j] Data[j] = Data[j+1] Data[j+1] = tmp Data.reverse() print(Data[1])
28e6b03a0ed11794c26e4e38ab9d60bf15c03250
Myusuft/Alpro-part5
/BAB 8/latihan2.py
567
3.9375
4
#Buatlah sebuah fungsi yang memiliki sebuah parameter yang bertipe list dan berisi #daftar nama orang (hanya terdiri dari satu kata). Lalu kembalikan sebuah string yang #merupakan nama terpanjang. def mulai(): nama1 = str(input()) nama2 = str(input()) nama3 = str(input()) if len(nama1) >= len(n...
f665885c31ca27eb69ba6c8ed9a39e1e7fc48fa9
Myusuft/Alpro-part5
/BAB 9/latihan 2.py
217
3.78125
4
def anagram(t1, t2): if sorted(t1) == sorted(t2): #return True print("sama") else: print("tidak sama") kata = list(map(str,input().split())) print(anagram(kata[0],kata[1]))
5646dc9b135d4064a337f3da3e57a82f2bc674f0
jckostner/CIS640
/HW3/impl.py
2,091
3.734375
4
class Network(object): def __init__(self): # constructor self.persons = [] def create_person(self): # create a person in the network and return the person person = {} self.persons.append(person) return person def add_person_property(self, person, prop, valu...
2834231a29968f99473a6054bc50ca260f33bdd3
blakete/567-Final-Project
/data-processing/extract_anxiety.py
3,607
3.609375
4
# Author: Blake Edwards import time import datetime import pandas as pd import matplotlib.pyplot as plt # get symptom date range to parse workouts csv # PARSE perceived-symptoms.csv # load csv ps_df = pd.read_csv("./raw-data/export.csv") # get the date, period, anxiety columns anxiety_df = ps_df[["Date", "Period", "A...
3e3a6869cb6f74b2035bf3e35fd0d6f206ba0078
AhmedNader42/Python_Algorithms
/non-search-problems/fib-iterative.py
180
3.6875
4
def fib(n: int) -> int: if n == 0 : return n last = 0 next = 1 for _ in range(1, n): last, next = next, last + next return next if __name__ == "__main__": print(fib(1000))
cc3175d9cb6628bc995ac59f0ac01fe173df5875
OwlFlash/proste_cw_na_poczatek
/C to F.py
194
3.78125
4
Celcius = float (input("Podaj wysokość temperatury w Celciuszach")) Farenheit = (Celcius * (9/5)) + 32 print("Temperatura {} w C równa się {} w farenheitach".format(Celcius,Farenheit))
5297fa217dd23ad6928ad6f0491bab118dfd36bc
jeffkt95/ProjectEuler
/problem0002.py
405
3.78125
4
import sys import os import math def main(): sequence0 = 1 sequence1 = 2 sum = 0 while sequence1 < 4000000: # add the last two to the sum if they are even if sequence1 % 2 == 0: sum = sum + sequence1 sequenceNew1 = sequence0 + sequence1 sequence0 = sequence1 sequence1 = sequenceNew1 print("Sum ...
ecccdec592c1cccb123c9ab92170438df90e8fed
jeffkt95/ProjectEuler
/problem0005.py
945
4.15625
4
import sys import os import math def main(): highestNumber = 20 maxCheck = highestNumber * 100000000 # Starting with highestNumber, go up by multiples of highestNumber # e.g. if your highestNumber was 10, check 10, 20, 30, 40, etc. for numForCheck in range(highestNumber, maxCheck, highestNumber): #Assume it'...
502acda0ba63d9b0f5359af707c515718dbea1d4
kushalkoolwal/py_progs
/parse_files.py
1,050
3.5
4
#!/usr/bin/env python from __future__ import print_function import sys import re def main(): # open the file file = open('syslog') # reads entire file into memory # not good for large files log_data = file.readlines() #log_data = file..readlines()[4:] # skips first 4 lines # close the file file.close ...
6f04b2595b8bbf7a0a7f830e9878080b2138c1b3
gvnaakhilsurya/20186087_CSPP-1
/cspp1-assignments/m6/p3/p3/digit_product.py
388
4.09375
4
''' @author:gvnaakhilsurya Given a number int_input, find the product of all the digits example: input: 123 output: 6 ''' def main(): ''' Read any number from the input, store it in variable int_input. ''' n = int(input()) p = 1 i = 1 while n>0: a = n%10 n = n//10 ...
60cfdeffffb011a932a51daf21ddfb9d42c50bb4
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m10/biggest Exercise/biggest Exercise/biggest_exercise.py
1,025
4.125
4
#Exercise : Biggest Exercise #Write a procedure, called biggest, which returns the key corresponding to the entry with the largest number of values associated with it. If there is more than one such entry, return any one of the matching keys. def biggest(aDict): ''' aDict: A dictionary, where all the values a...
7f8b387a2251dab7dc8622dbf727a4658aa85d76
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/pratice/Practice_Assignments-2/Practice_Assignments-2/Min-Max Sum/Solution.py
904
3.796875
4
''' Input is [1,2,3,4,5] Output is 10 14 Explanation: For the above sample input, 1. If we sum all the values except 1, we get 14 2. If we sum everything except 2, we get 13 3. If we sum everything except 3, we get 12 4. If we sum everything except 4, we get 11 5. If we sum everything except 5, we get 10 So, the minim...
98efe9c52b371ad72672d95e3e36f6201c51b952
gvnaakhilsurya/20186087_CSPP-1
/remideal/CSPP-1_Question/Sudoko.py
515
3.71875
4
def check_duplicates(line): count = 0 if "." not in line: for i in line: count = line.count(i) if(count <= 9): print("Given sudoku is solved") break else: replace_digits(line) def length_verify(line): if(len(line)== 81): ...
f3b2c0443d86d4b7deedc30384e3a0aa7868b4c0
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m3/hello_happy_world.py
234
4.125
4
''' @author : gvnaakhilsurya Write a piece of Python code that prints out the string 'hello world' if the value of an integer variable, happy,is strictly greater than 2. ''' HAPPY = int(input()) if HAPPY > 2: print("hello world")
83db4781bc8f211e8466745934e7a5eabc286fa3
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m3/iterate_even_reverse.py
247
4.0625
4
''' @author : gvnaakhilsurya Write a piece of Python code that prints out Convert the following into code that uses a while loop. print Hello! print 10 print 8 print 6 print 4 print 2 ''' for A in range(10, 0, -2): print(A) print("Goodbye!")
49102ffc770584d0aa7b93479431a6f1dfb875f6
harshkothari410/Python-Stuff
/root.py
411
3.75
4
#Creater : Harsh Kothari number = float (raw_input("Enter the Number:")) a = number/4; count = 0 while(1): temp = a * a; count = count +1 temp = round(temp,2) if temp>(number + number*(0.001)) or temp<(number - number*(0.001)): #print "%d a:%f" % (count,a) b = number/a a = (a+b)/...
68cc3286321708fcf077d10f169acfbe5e326715
dineshagr/python-
/multiDimentionalLists.py
641
4.40625
4
# this is a one dimentional list x = [2,3,4,5,6,7,8] # this is a 2 dimentional list y = [[5,4], [3,4], [7,9], [2,8]] # 0 1 0 1 0 1 0 1 these are the individual positions of inner lists # 0 1 2 3 these are the positions of outer lists print(y) print(y[3][1]) # this is a multidimenti...
584ca6b4f04b736108d0c8fe79ebef03dcc7d693
Beatzoid/python-camp
/hello_world.py
836
4
4
# hello_world.py # By Beatzoid # 6/28/21 print("Welcome!\n--------") name = input("Please enter your name: ") age = int(input("Please enter your age: ")) height = input("Please enter your height (format 5'8\"): ") weight = int(input("Pleae enter your weight in pounds: ")) married = input("Are you married? ") driversLi...
e8f92b09226b9a05d717558489667962f3bb5ca7
Beatzoid/python-camp
/Day 3/for_loops_practice.py
558
3.84375
4
# for_loops_practice.py # By Beatzoid # 6/30/21 import random print("Print a different random integer between 1 and 100, ten times") for i in range(1, 11): print(random.randint(1, 100), end=" ") print("\n") print("Print the twelve times table up 12 x 12") for col in range(1, 13): for row in range(1, 13): # Image...
2b37509e7a585ff199943ad28530df7e6ec01b46
Gedanke/StudyNote
/Math/codes/module_1/l_1_2.py
98
3.546875
4
# -*- coding: utf-8 -*- a = 80 if a & (a - 1) == 0: print('yes') else: print('no') # no
ac481391fd70bdc9e4f010130f1f2a3f0b9a12eb
Gedanke/StudyNote
/DeepLearning/CourseOne/codes/module_1/l_1_5.py
268
3.875
4
# -*- coding: utf-8 -*- import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([[5, 6], [7, 8]]) print(a * b) # 对应位置相乘: Get array([[ 5, 12], # [21, 32]]) print(a.dot(b)) # 矩阵乘法,Get array([[19, 22], # [43, 50]])
7aa50a8dd2bbaed5881a752f464f1770bac733ee
Gedanke/StudyNote
/Math/codes/module_3/l_14_1.py
207
3.9375
4
# -*- coding: utf-8 -*- left = 0 left_temp = 0 right = 0 for k in range(1, 100): left_temp = 2 * k - 1 left += left_temp right = k * k if left == right: print(str(k) + " is right!")
dc2e0322779a54e2baeb106b68494edd56c25af4
eltonfonseca/algorithms
/python/dijkstra.py
1,554
3.640625
4
from collections import namedtuple, deque from pprint import pprint as pp inf = float('inf') Edge = namedtuple('Edge', 'start, end, cost') class Graph(): def __init__(self, edges): self.edges = edges2 = [Edge(*edge) for edge in edges] self.vertices = set(sum(([e.start, e.end] for e in edges2),...
cc56b87000515bde87e3de65a5727be60a8352b3
eltonfonseca/algorithms
/python/linearSearch.py
319
3.875
4
# Linear Search Algorithm in Python # # Author: Elton Fonseca def main(): if search([1,2,3,4,5,6,7,8,9,10], 7): print "Find!" else: print "Not Found!" def search(array, value): for i in range(len(array)): if array[i] == value: return 1 return 0 ...
648412ec9196e03e47537e80ffe519e5b25a8edd
nicholaslemay/AdventOfCode2017
/Day3/part1/day3.py
3,168
3.75
4
import unittest import math class SpiralMatrix(): def __init__(self, size): self.maximum_number = size * size self.current_number = 1 self.matrix = [[0 for column in range(size)] for row in range(size)] self.middle = size/2 self.current_x_position = self.current_y...
c88671bcddf0235232a833b8b4792779945fa9a7
goswamiprashant/Machine-Learning
/matplotlib_6.py
261
3.953125
4
# to draw a scatter graph import matplotlib.pyplot as plt x=[2,3,5,1,7,4] y=[2,4,10,13,5,16] plt.scatter(x,y,marker='*',label="stars",color="red") plt.xlabel("x-axis") plt.ylabel("y-axis") plt.title("Scatter graph") plt.grid() plt.legend() plt.show()
2d10576205f50813ba54df6136a18d47139c8286
goswamiprashant/Machine-Learning
/pandas_4.py
974
4
4
import pandas as pd df=pd.read_csv("nba.txt") print(df.head()) print(df.tail()) print(df.info()) # to get basic details of data frames print(df.index) print(df.shape) print(df.dtypes) print(df.columns) # to get the names of columns print(df.axes) # to get the names of columns #print(df.get_dtype_counts()...
aad6bf9a960e224b1048b81ee48662b27f714df8
adadlani1/PythonLibrarySys
/checkout.py
4,618
3.875
4
'''Written by Anmol Dadlani 4th December 2018''' import datetime import os ''' imported the date time module so that the Due column in the text file can be updated.''' ''' The code below is for the dates of today and the future so that it can be updated on the database and the logfile''' tdelta = da...
d1bb71c0790f61955272f6c8cf041ee2dbadd2f1
FernandoJPaz/PythonIntermedio
/clase4.py
1,946
3.890625
4
#Operaciones con cadenas y listas cadena1 = 'tengo una yama que Yama se llama' # declara variable lista1 = ['pera', 'manzana', 'naranja', 'uva'] # declara lista longitud = len(cadena1) # 32, devuelve longitud de la cadena elem = len(lista1) # 4, devuelve nº elementos de la lista cuenta = cadena1.count('yama') #...
a855641309f9bf16241a5b8dd4bb1c3f107f1946
mbrown1508/documentclassification
/cli/helperclasses/climethods.py
2,308
3.71875
4
__author__ = 'Matthew' def yes_no_question(question, default=None): question_answered = False result = False if default == True: default_string = 'Y/n' elif default == False: default_string = 'y/N' else: default_string = 'y/n' while not question_answered: answ...
e529506fca81875d2e2a0f83b738d21049c50daa
opiroi/Python-Practical-Projects
/Algorithms/factorial.py
150
4.125
4
def factorial(x: int) -> int: """ Returns the factorial of 'x' """ result = x while x != 1: result *= (x:=-1) return result
e4798f0a017b6017c5e8db7d6407cb58d3d66031
opiroi/Python-Practical-Projects
/Algorithms/binary_search.py
559
3.796875
4
def binary_search(target, sequence): while True: mid = len(sequence)//2 if target != sequence[mid]: try: halves = sequence[:mid], sequence[mid:] sequence = [i for i in halves if target in i][0] except IndexError: print(f'Cannot...
1ea18f6b0720a975f57d60aa5d311895563a1558
pmba/algorithms
/python/kruskal.py
1,687
3.640625
4
import heapq class UnionFind: def __init__(self, size): self.parent = [-1 for x in range(size)] def root(self, v): if self.parent[v] < 0: return v else: self.parent[v] = self.root(self.parent[v]) return self.parent[v] def sameSet(self, v, u): ...
16f3ead88dc564b697f437888feaf5d242fbf519
pmba/algorithms
/python/fibonacci.py
238
3.921875
4
#bottom_up def fib_bu(n): if n <= 2: return n memo = [0 for i in range(n+1)] memo[0] = 0 memo[1] = 1 memo[2] = 1 for i in range(2, n+1): memo[i] = memo[i-1]+memo[i-2] return memo[n] print('Fibonnacci =',fib(int(input())))
6bd6f08580f99488a37eff6e63c73a993cf6ef34
sunduda/python_alien_invasion
/ship.py
3,492
3.8125
4
import pygame import pygame.font from bullet import Bullet class Ship(): """ Draw and operate player's ship """ def __init__(self, game_settings, screen): self.screen = screen self.ship_reset(game_settings) # Initialise the moving flag self.lkey_down = False self.rkey_do...
cbeeeb5904aefdf1e1196a0dd232d949ebec14cc
ntkaggarwal/Two-Pointers-1
/Container with most water.py
1,055
3.53125
4
#Time Complexity : O(n) #Space Complexity : O(1) #Did this code successfully run on Leetcode : Yes #Any problem you faced while coding this :None # ============================================================================= #Solution: Take 2 pointers low at 0 index and high at last index. #Width will d...
84c2d24b989a751aa0db043899ae6e48ce248ee6
alexsavio/mars-rover-kata-exercise
/src/mars_rover/rover.py
2,750
3.609375
4
"""A rover.""" from copy import copy from enum import Enum from dataclasses import field, dataclass class Heading(Enum): """The four cardinal directions.""" N = "NORTH" W = "WEST" S = "SOUTH" E = "EAST" @dataclass class Location: """A point in a 2 dimensional plane.""" x: int y: i...
00c77da36ebb2a7442d2698fd07517f7f481584a
friendsQIA/Friends_QIA
/crowds_implementation.py
2,189
3.625
4
# General imports from tensorflow.keras import backend as K from tensorflow.keras.layers import Layer import numpy as np import tensorflow as tf # Function to set the initial weights of the layer # The size for Friends dataset is: 5x5x3 # the initial weights are the same for all annotators - these are identity matrice...
cf108fc7d5b54022363eb5d5ced17ec540c0256d
mfirmanakbar/python
/operators/comparation_operators.py
270
4.21875
4
a = 5 b = 10 print("a == b is", a == b) print("a != b is", a != b) print("a > b is", a > b) print("a < b is", a < b) print("a >= b is", a >= b) print("a <= b is", a <= b) ''' a == b is False a != b is True a > b is False a < b is True a >= b is False a <= b is True '''
04acf60a4d97dc23ddc43b30798db72ccdbbc549
mfirmanakbar/python
/data_types/string_operations.py
968
4.375
4
my_str = "welcome to the tutorial" my_str_2 = "this is my string" print(my_str) print(my_str_2, end="\n\n") print("print all: ", my_str[:]) print("from index 2 until index 9 and skip index 10: ", my_str[2:10]) print("from index 0 until index 13 and skipping 1 element: ", my_str[0:14:1]) print("from index 0 until index...
d27b6f69060213e580ebcc44c553ca409835ffda
mfirmanakbar/python
/flow_control/for_loop.py
685
3.96875
4
# loop basket_of_fruits = ["apple", "orange", "banana", "watermelon"] for fruit in basket_of_fruits: print(fruit) numbers = [1, 2, 3, 4, 5] sum_of_element = 0 for i in numbers: sum_of_element += i print(i) print(sum_of_element) for i in range(5): print(i) print("\n") for i in range(5, 10): print(...
03ed3c22fe20ae1738041d24a62001328a870734
mfirmanakbar/python
/data_types/tuple_operations.py
1,200
4.46875
4
# initialize tuples my_tuple = () my_tuple_2 = tuple() print("empty my_tuple:", my_tuple) print("empty my_tuple_2:", my_tuple_2) my_tuple = my_tuple + (1, 2, 3) print("init my_tuple from plus: ", my_tuple, end="\n\n") # initialize elements to the tuple my_tuple = (1, 2, 3) my_tuple_2 = tuple(("python", "for", "firman"...
ca76fb19d444e2c34b986bb6363c189721114803
wancong/leetcode
/tree/637. Average of Levels in Binary Tree.py
1,958
3.84375
4
""" 637. Average of Levels in Binary Tree Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11]. """ class TreeNode(object): def __init__(self, x): self.va...
13407b2818277c481e1d9da967aab81594582b7c
wancong/leetcode
/sort/quick_sort_02.py
1,815
4.09375
4
"""quick sort inplace 1 选中arr[0], 小的扔前面,大的扔后面 2 一次遍历,就可以确定arr[0]最后的位置 3 递归剩下的两部分 """ def quick_sort(arr): """quick sort inplace :type arr: list :rtype: list >>> quick_sort([3, 2, 1, 4]) [1, 2, 3, 4] >>> quick_sort([]) [] >>> quick_sort([1]) [1] """ def partition(arr...
869d999fa67b21736d88728ef567a811e0dd0cdb
wancong/leetcode
/listnode/delete_duplicate.py
780
3.796875
4
"""delete duplicate node exp: 1 1 2 3 3 1 2 3 """ class ListNode(object): def __init__(self, x): self.val = x self.next = None def delete_duplicate(head): cur = head while cur: while cur.next and cur.next.val == cur.val: cur.next = cur.next.next cur = cur.next # ...
a0f278c9cbf7d784952d1f68672208b64b3826b6
wancong/leetcode
/others/singleton.py
392
3.78125
4
class Singleton(object): """singleton by __new__ >>> one = MyClass() >>> two = MyClass() >>> one is two True """ def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): orig = super(Singleton, cls) cls._instance = orig.__new__(cls, *args, **k...
abe182013a557c4180cb4520197dba2de4f9fca6
royrishabh11/WOC_day1
/program4.py
257
4.09375
4
cost_price=int(input("Enter Cost Price: ")) selling_price=int(input("Enter Selling Price: ")) profit=selling_price-cost_price print("The Profit from sell is",profit) new_price=1.05*profit+cost_price print("Selling price at 5% profit is", new_price)
db6db43a6147185539bc216c3ce7dad0bb89619a
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-pildoras/Trabajo con regex3.py
1,407
3.875
4
import re lista_terminos = ["camión", "camion", "niñas", "niños", "ejemplo"] print("-----------------------------------------------------------") print("Buscar cadenas en un rango de letras en el rango [p-z]") print("-----------------------------------------------------------") #Buscar cadenas en un rango de letras f...
ffcec778b12168c97e4ef3458fe3b92519f44ad1
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-pildoras/Trabajo con poo2.py
827
3.84375
4
class Persona(): #Propiedades definidas nombre="" apellido="" edad=0 genero="Sin definir" #CONSTRUCTOR establece un estado inicial def __init__(self, nombre, apellido, edad, genero): self.nombre=nombre self.apellido=apellido self.edad=edad self.genero=genero...
0bfc1f879135c8c73a558f74f8ef39765f437223
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-Mintic/programaReto4ClasifiHuevos.py
1,318
3.5625
4
import random import moduloReto4ClasifiHuevos #------------------------------------ #Programa tamHuevo = [60, 100, 200, 250, 300, 600, 1001] resultado = moduloReto4ClasifiHuevos.clasificacion_huevos(tamHuevo) print("\nLa lista del volumen de los recipientes: " , tamHuevo) print("Resultado de la clasificacion de recip...
d8f798930bf6a29bb889818481e8068bcdfe80f1
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-pildoras/Trabajo metodos especiales argumentos indeterminados tuplas.py
538
3.6875
4
class Persona(): alamacen_datos=[] def __init__(self, *datos): #datos es una tupla, el * es el que me da esa indicación for dato in datos: self.alamacen_datos.append(dato) self.getDatos(self.alamacen_datos) def getDatos(self, info): for dato in info: pri...
70115b7beb6fea48c03fddc79b2aaf112bd8a441
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-pildoras/Trabajo con regex2.py
1,197
3.515625
4
import re lista_nombres = ["Antonio Banderas", "Salma Hayek", "Tomás Cruceros", "Antonio Resines", "Friedrich Hayek"] lista_nombres2 = ["http://www.pildorasinformaticas.es", "ftp://www.pildorasinformaticas.es", "http://www.pildorasinformaticas.com", "ftp://www.pildorasinformaticas.com"] lista_terminos = ["camión", "...
3497aae73a821f19a848d6f6a0ab42134263c51d
adelriscom/Python
/Python/AP-Python/Curso Tutorizado Python/Python-pildoras/Ejercecios/Ejercicio numero aleatorio.py
570
3.96875
4
import random cont = 0 aleatorio = random.randint(1,100) numero = 0 while numero != aleatorio: numero = int(input("ingrese un numero entre 1 y 100: ")) if numero < aleatorio: print("el numero aleatorio es mayor") elif numero > aleatorio: print("El numero aleatorio es menor") ...
8bee044c18222ff9379543ff6da0a1dc2fea9dac
pychthonic/unit-testing
/remove_file/test_remove_file.py
894
3.78125
4
"""This is a unit test script to test remove_file.py It creates a file called test_file, tests that it exists, then deletes it, and tests that it has been deleted.""" import os import unittest import remove_file class TestRemove(unittest.TestCase): """The setUp method creates test_file and writes a string t...
1e72c2bd94951ca304f86615b0c298ee92c250cf
amirrouh/genepy
/parse.py
4,132
3.5
4
def read(link, data_dim): """ This module downloads gene expression profile from NCBI GEO FTP website and parses it Parameters ---------- link : str This is the link to GEO soft_full.gz file on NCBI website data_dim : int This gets number of genes needed to be considered ( data_dim = 1...
7bf49e7f3253962d5cb6d349e8e6cb8522688895
rymo90/hackerrank
/calanderModule.py
148
3.875
4
import calendar month, day, year = map(int, input().split()) weekday = calendar.weekday(year, month, day) print(calendar.day_name[weekday].upper())
874b67231e74920aeb94b75ed86ddd026a91fb47
rymo90/hackerrank
/nameCollections.py
267
3.671875
4
from collections import namedtuple n = int(input()) k = input() info = namedtuple("Score", k) result = 0 for i in range(n): temp = input().split() data = info(temp[0], temp[1], temp[2], temp[3]) result += int(data.MARKS) print(result/n)
3dfe440ed7449de711b4d1cc0c21d666de3244ae
rymo90/hackerrank
/designerDoorMat.py
372
3.734375
4
n , m = [int(i) for i in input().split()] temp= ".|." odd= [ x for x in range(n) if x%2==1] middle= n//2 for i in range(n): if i < middle: pattern = temp*odd[i] print(pattern.center(m,"-")) elif i > middle: middle-=1 pattern = temp*odd[middle] print(pattern.center(m, "-")...
5316857fccbe88f454a8a03ec0ae14d8fe39b709
agnynureza/python-oop
/wijaya.py
928
3.90625
4
#class #konsep merupakan abtraksi atau blueprint yang mendefinisikan suatu object class Car: color = 'black' transmission = 'manual' def __init__(self, transmission): self.transmission = transmission print('engine is ready') def drive(self): print('Drive') def reverse...
c12b44e3588838904ec599ee6e9fbaba24331ab4
QYINAO/Python_data_structures
/data structure/Day-3/case2.py
2,489
3.9375
4
# 匹配{[()]} ( [ )] # 每一个开始的符号被压入栈,等待匹配结果 # 当出现结束符号的时候,必须检查栈顶部的开始符号是什么类型,如果两个符号不匹配,则字符串不匹配 # 整个字符串处理完并且栈为空,则字符串匹配 from pythonds.basic.stack import Stack def parChecker(symbolString): s = Stack() flag = True index = 0 while index < len(symbolString) and flag: symbol = symbolString[index] ...
5cf344de1b1b120ad524bc92035a1253a1d1cf06
apad20/parcial2
/AnyosBisiestos.py
901
3.8125
4
#Desarrolla un método que solicite un año y devuelva si es bisiesto o no. #Un año bisiesto es múltiplo de 4, pero no es bisiesto si es múltiplo de 100 #excepto si también es múltiplo de 400. #Análisis del problema, expresión lógica. # **** Si x MULTIPLO de 4 AND NOT MULTIPLO de 100 OR MULTIPLO de 400. # Si x es múlt...
b3e3e9bbe3ca56937770bb3410286f1a8ada99a8
apad20/parcial2
/Ciclos While.py
111
3.8125
4
nombre = "" while not nombre: nombre = str(input("Introduce un nombre \n")) print("Tu nombre es ",nombre)
131443ea6707e9d26bc6e6e7ed9ddee9424ba020
zanderp383/Z-repo
/RandomScale.py
491
3.90625
4
#!/usr/bin/env python3 import random import time starttime=time.time() Time = int(input("Enter Time in Seconds: ")) Note_Set = ["A","A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"] Scale_Set = ["MAJ", "min"] Position_Set = ["1", "2", "3", "4", "5"] while True: Note = random.choice(Note_Set) Scale =...
434cd02f202c24bf7a1af03393f5f52f58019d6f
Python-lab-cycle/Akhila-P-M
/CO1_02_leapyear.py
242
4
4
#leap year print("Print leap year between 2 given years") print("enter start year") syear=int(input()) print("enter last year") lyear=int(input()) print("List of years") for year in range(syear,lyear): if year%4==0: print(year)
5fdf0e14e1a3079cc6dd49f6d7937279f8368c8d
Colochenero/Collage-Assignments
/Concepts of Programming Languages/Assignment_1/problem_3.py
303
3.71875
4
def armstrong(x): digits = str(x) num_digits = len(digits) result = 0 for digit in digits: result += int(digit) ** num_digits return result == x start, end = input().split() start = int(start) end = int(end) for i in range(start, end + 1): if armstrong(i): print(i)
94bb32f121af97868c8ef40d74c3da1465ecf930
alanmmckay/KLEINcompiler
/src/k_token.py
1,764
3.546875
4
from enum import Enum class TokenType(Enum): NUMBER = 1 KEYWORD = 2 WORD = 3 OPERATORS = 4 DELIMETER = 5 BOOLEAN = 6 PRIMITIVE = 7 EOF = 8 class Token: def __init__(self, token_type, token_value=None): self.token_type = token_type self.token_value =...
640e2404d2682c1153038753f8a438c24441fa27
alanmmckay/KLEINcompiler
/programs/class-programs/python-equivalents/russian-peasant.py
392
3.71875
4
def MOD(m,n): return(m%n) def multWithAccum(m,n,accum): if n==0: return(accum) elif MOD(n,2)==1: return(multWithAccum(m*2,n//2,accum+m)) else: return(multWithAccum(m*2,n//2,accum)) def mult(m,n): return(multWithAccum(m,n,0)) def main(m,n): print(m) ...
de7a1c47fd38ebc387bbe691dc70a187a0e34bb7
alanmmckay/KLEINcompiler
/programs/class-programs/python-equivalents/circular-prime.py
1,085
3.71875
4
# maximum recursion depth exceeded in comparison import math def main(x): return circularPrimesTo(x) def circularPrimesTo(x): return circularPrimesToHelper(x+1,2,0) def circularPrimesToHelper(top,x,count): if x<top: if isCircularPrime(x): return circularPrimesToHelper(...
271a0ab2261a6cf44dae4f148ec3458efd052abb
alanmmckay/KLEINcompiler
/doc/parser/factoryConcept.py
462
3.703125
4
##This is the basic rundown of how the semantic action ##portion of the parse algorithm will create the node objects. class anASTNode(): def __init__(self, stack): self.test = stack.pop() def get_test(self): return self.test factory = { 1 : anASTNode } stack = [1,2,"three",4,(4+1...
ae168f775e7815df8449e8575a88ba5e376bcca9
jarehec/holbertonschool-webstack_basics
/0x01-python_basics/13-add_integer.py
432
4.0625
4
#!/usr/bin/python3 """ module containing add_integer function """ def add_integer(a, b): """ adds two integers or floats @a: integer or float @b: integer or float """ if a.__class__ is not int and a.__class__ is not float: raise TypeError('a must be an integer') if b.__class__ is n...