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
a02db2dc399b95c3e903c87b204c3d502813c9ee
Ingdanielsolano/python-course
/palindrome.py
396
3.953125
4
def palindrome(string): try: if len(string) == 0: raise ValueError("No se puede ingresar una cadena vacía") return string == string[::-1] except ValueError as ve: print(ve) return False def run(): try: print(palindrome("")) except TypeError: ...
d14f13b63744a5d5dd1966778a2da86af10b9168
JeffreyUrban/count-sequences
/iterate_and_count_using_sequence_trie.py
446
3.5
4
# Alternative approach for performance comparison using trie structure specific to this application. from collections import Counter import sequence_trie def iterate_and_count_using_sequence_trie(input_list, min_sequence_length, max_sequence_length) -> Counter: my_trie = sequence_trie.Trie(min_sequence_length, m...
5be41c60216ecaf1b6471f7eea4c9b900f4ac5c6
ktjosh/python_back
/HW00_joshi_ketan.py
2,563
3.984375
4
""" file name: HW00_joshi_ketan.py author : ketan joshi (ksj4205) """ import math import matplotlib.pyplot as mp def plot(x,y,best_fluxrate,best_speed): """ Te cuntion plots the curve using matplot lib :param x: an array of x coordinate :param y: an array of y coordinates :param ...
e3ebb85ecd24e1377c002063691b02ac2d6d12f8
Lschulzes/Python-practice
/ex033.py
610
4.1875
4
nums = int(input('Digite 3 números: ')) un = nums // 1 % 10 dez = nums // 10 % 10 cent = nums // 100 % 10 if un > dez: if un > cent: if cent < dez: print(f'O maior número é {un} e o menor é {cent}') else: print(f'O maior número é {un} e o menor é {dez}') else: ...
1dc886ea813c8f70ce228ee4964dff7acf51b855
Lschulzes/Python-practice
/ex070.py
599
3.5
4
menor = caros = soma = 0 while True: nome = input('Nome do produto: ').strip() preco = int(input('Preço: ')) soma += preco if preco < menor or menor == 0: nome_menor = nome menor = preco if preco > 1000: caros += 1 continuar = ' ' while continuar not in...
e9ff5180eda2ef4de822828a3b05fcde7edc30a4
Lschulzes/Python-practice
/ex060.py
218
4.03125
4
num_crescente = 0 num = int(input('Digite o número que você deseja fatorar: ')) total = 1 while num != num_crescente: num_crescente += 1 total *= num_crescente print(f'O fatorial de {num} é {total}')
738195771af411079b390b899c19f45eb13db24e
Lschulzes/Python-practice
/ex036.py
543
3.71875
4
idade = int(input('Qual a sua idade? ')) imovel = int(input('Qual o valor do imóvel? ')) tempo = int(input('Em quantos anos pretende pagar a casa? ')) sal_30 = int(input('Qual o seu salário atual? ')) * 0.3 mensalidade = imovel / (tempo * 12) if idade + tempo < 60: if sal_30 > mensalidade: print( ...
8da467620d03b99b73ed7a1720a299a75266fdfc
Lschulzes/Python-practice
/ex009.py
309
4.1875
4
n = int(input('Digite um número inteiro: ')) n1 = n * 1 n2 = n * 2 n3 = n * 3 n4 = n * 4 n5 = n * 5 n6 = n * 6 n7 = n * 7 n8 = n * 8 n9 = n * 9 print(f'{n} * 1 = {n1}\n{n} * 2 = {n2}\n{n} * 3 = {n3}\n{n} * 4 = {n4}\n{n} * 5 = {n5}\n{n} * 6 = {n6}\n{n} * 7 = {n7}\n{n} * 8 = {n8}\n{n} * 9 = {n9}')
36a3b8aca433264dbc39b6254dfeb450be638a94
Lschulzes/Python-practice
/ex099.PY
699
3.6875
4
from time import sleep def maior(): valores = [] while True: num = int(input('Digite um valor (999 p/ sair): ')) if num == 999: break else: valores.append(num) quantidade = len(valores) maior = 0 print('-=' * 30) print('Analisando o...
1114075a9cc331302664fc849ec13b5b530875b8
Lschulzes/Python-practice
/ex022.py
167
3.75
4
nome = input("Qual o seu nome? ").strip() print(nome.lower()) print(nome.upper()) print(len(nome) - nome.count(" ")) nome_1 = nome.split() print(len(nome_1[0]))
22146f28ed3c3bf72d534ab9b7bc3b3e6c809809
Lschulzes/Python-practice
/ex075.py
607
4
4
valores = (int(input('Digite um número: ')), int(input('Digite outro número: ')), int( input('Digite mais um número: ')), int(input('Digite o último número: '))) print(f'Você digitou os valores {valores}') nove = valores.count(9) par = 0 print(f'O valor 9 apareceu {nove} vezes') if 3 in valores: tres = v...
2c64b9ccdebbe785626b7f281f8638d90f7b11c9
Lschulzes/Python-practice
/ex059.py
901
3.984375
4
from time import sleep option = 0 while option != 5: if option == 0 or option == 4: num_1 = float(input('Digite o primeiro valor: ')) num_2 = float(input('Digite o segundo valor: ')) option = int(input( '''[1] Somar\n[2] Multiplicar\n[3] Maior\n[4] Novos Números\n[5]Sair do pr...
69a429e674972e00306825bbcda8b960b882c5e3
Lschulzes/Python-practice
/ex053.py
290
3.90625
4
frase = input('Digite uma frase: ').strip().upper() palavras = frase.split() junto = ''.join(palavras) inverso = '' for a in range(len(junto) - 1, -1, -1): inverso += (junto[a]) if inverso == junto: print('A frase é um palíndromo!') else: print('Nada demais aqui.')
06758f00f3b1ce885899102fe093651f6d0226b4
Lschulzes/Python-practice
/ex039.py
323
4.1875
4
ano = int(input('Qual o ano do seu nascimento? ')) idade = 2021 - ano passou = idade - 18 falta = 18 - idade if idade == 18: print('Você deve se alistar neste ano!') elif idade > 18: print(f'Você deveria ter se alistado há {passou} anos!') else: print(f'Você deverá se alistar em {falta} anos!')
2f54b78ca7d2e3f3452e6763417b481abab1e940
trimcao/mapnplace
/textInput.py
1,623
3.59375
4
""" Reading user data from text file for Mapping and Placement algorithm. Name: Tri Minh Cao email: tricao@utdallas.edu Date: May 2016 """ import placeTree as pt # create gate list and ios list # NOTE: later, input test file name by user filename = raw_input('Enter the input file name: ') print # initialize the list...
64744cb67ac8e2ce4f7631d458c41e189d4d8bce
nudging-SMDP/nudging-supplementary-material
/Microgrid/battery.py
1,030
3.609375
4
class EnergyStorage(): def __init__(self): self.efficiency = 0.9 self.cap_max_h = 9.125 #MWh self.charge = self.cap_max_h def discharged(self, p): """ Discharge battery Args p: percentage to discharge from the battery Returns: eDischarged: amount of energy delivered to the load or main...
9b386b4efd0228475728b621df7f374af590c221
brettmcgrath/pirate_game
/ships.py
1,461
3.78125
4
my_ships_list = [] other_ships_list = [] my_ship_dict = {} other_ship_dict = {} #These are the classifications of ships allowed in the game class Ship(): def __init__(self, name, my_ship, ship_class, attack, hp, gun_capacity, sails, weight, max_weight, cannon_balls): self.name = name self.my_ship = my_sh...
0c75dbba95125771824501bf81e2fc41cf3f5c5d
haseebkhan611/mitPython
/ps3/palindrome.py
404
3.703125
4
import string alpbets =string.ascii_lowercase def isPanlindrome(s): def toChar(s): s=s.lower() ans='' for i in s: if i in alpbets: ans=ans+i return ans def isPal(s): if len(s)<=1: return True else: return s[0]...
d4282f97c8693378e1b26bebb187892027ddfe32
coderMaruf/Problem_solving
/1017.py
131
3.625
4
#Fule Spent time = int(input()) avg_value = int(input()) fuel_spent = float((time * avg_value) / 12.0) print(f"{fuel_spent:.3f}")
2b443bac4f2ec3f758268efe288c9bf49186bff5
coderMaruf/Problem_solving
/1035.py
222
3.53125
4
#Selection Test 1 #if else problem a,b,c,d = list(map(int, input().split())) if b >c and d > a and (c+d) > (a+b) and c > 0 and d > 0 and a%2 == 0: print('Valores aceitos') else: print('Valores nao aceitos')
8dc818ce5e9602ada5a95b92fdfb2801d236199d
joescottengineering/Euler-Problems
/Euler probs - 58 number spiral primes.py
1,028
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 27 19:21:40 2015 @author: JKandFletch """ import math def memoize(f): cache = {} def decorated_function(*args): if args in cache: return cache[args] else: cache[args] = f(*args) return cache...
7bb2ff02d54b29079d3d1e4bfa9daa2535728485
joescottengineering/Euler-Problems
/Euler probs - 41 pandigital primes b.py
1,150
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 30 21:34:03 2015 @author: JKandFletch """ import math import itertools def memoize(f): cache = {} def decorated_function(*args): if args in cache: return cache[args] else: cache[args] = f(*args) ...
8c4b1ea0f72193e7941c59473cbed751e4658053
joescottengineering/Euler-Problems
/Euler probs - 46 other conjecture.py
1,526
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 01 16:39:12 2015 @author: JKandFletch """ def genPrimes(): """ Generate an infinite sequence of prime numbers. """ D = {} q = 2 while True: if q not in D: yield q D[q * q] = [q] else: ...
f83bbdb8edddfcb9d6580a5cd4342f7fe1f9d296
computerscienceioe/Midterm-Assessment
/teacher's code.py
4,744
3.953125
4
def q1(): # 2 marks print("This will calculate your age: ") name = input("Enter your name: ") yearOfBirth = int(input("Enter your year of birth: ")) # 2 marks birthdayThisYear = input("Have you had a birthday yet this year? y or n?") # 4 marks if birthdayThisYear == 'y': age = 2020-yearOfBirth ...
3193e2263299f0e264aabda00b72150304cc6c68
LeninGusqui/Programaci-n-en-Python-aplicada-a-la-Ingenier-a.
/Ej_conv_tip_dat.py
180
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 23 19:31:30 2021 @author: Lenin Gusqui """ x=3 print("El valor de x es: " + str(x)) print(type(x)) x=str(x) print(type(x))
bc604af06b1117f1fff2747bae0ce5c97d30a0fc
LeninGusqui/Programaci-n-en-Python-aplicada-a-la-Ingenier-a.
/Ej_for.py
313
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 23 23:20:10 2021 @author: Lenin Gusqui """ devices=["R1", "R2", "R3", "S1", "S2"] print(devices) for i in devices: if "R" in i: print(i) switches=[] for i in devices: if "S" in i: switches.append(i) print(switches)
64513b5984d5930c240606c56a49f829a0a389be
LeninGusqui/Programaci-n-en-Python-aplicada-a-la-Ingenier-a.
/Ejercicicio nombres.py
486
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 18 11:34:30 2021 @author: Lenin Gusqui """ nombre=input("Por favor ingrese su nombre:") print("Nombre: ", nombre) apellido=input("Por favor ingrese su apellido:") print("Apellido: ", apellido) ciudad=input("Por favor ingrese su ciudad:") print("Ciudad: ",...
f42836f34f8776ee48d5a0bf9e90ee571a8c71dd
amitjpatil23/simplePythonProgram
/guess_number.py
493
4.03125
4
import random import math x = random.randint(1,50) print("\n\tYou've only 5 chances to guess the integer!\n") count = 0 while count < 5: count += 1 guess = int(input("Guess a number:- ")) if x == guess: print("Congratulations you did it in ", count, " try(s)") # Once guessed, loop will break break elif x > ...
73e023a3d2ca6364b71fe2f99f19415477ff4c46
amitjpatil23/simplePythonProgram
/MatrixMultiplication.py
598
4.15625
4
# Program to multiply two matrices using nested loops # take a 3 by 3 matrix A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # take a 3 by 4 matrix B = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200]] result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, ...
f8f481911c4d3d8b79082899528af93978e92957
amitjpatil23/simplePythonProgram
/Atharva_35.py
620
4.25
4
# Simple program in python for checking for armstrong number # Python program to check if the number is an Armstrong number or not y='y' while y == 'y': # while loop # take input from the user x = int(input("Enter a number: ")) sum = 0 temp = x while temp > 0: #loop for ...
0c8893cdaadd507fb071816a92dd52f2c8955d65
amitjpatil23/simplePythonProgram
/palindrome_and_armstrong_check.py
630
4.21875
4
def palindrome(inp): if inp==inp[::-1]: #reverse the string and check print("Yes, {} is palindrome ".format(inp)) else: print("No, {} is not palindrome ".format(inp)) def armstrong(number): num=number length=len(str(num)) total=0 while num>0: temp=num%10 ...
028e9902fae22f2348d952d3e513d41a2c188d1f
juliascript/performance_analysis
/sorted_singly_linked_list.py
5,019
3.75
4
import time start_time = time.time() class Node(object): def __init__(self, data): """Initialize this node with the given data""" self.data = data self.next = None def __repr__(self): """Return a string representation of this node""" return 'Node({})'.format(repr(self....
9aa5044073a79545cf42ca9c9cd0e9a1f853e1f7
yehudasapir/data_structures
/sort/merge_sort.py
1,438
3.90625
4
import sys, getopt def sort_arr(source_arr): print "start:", source_arr size = len(source_arr) print size if(size < 2): return source_arr sorted_arr = [] if (size == 2): num1 = source_arr[0] num2 = source_arr[1] if (num1 > num2): sorted_arr.append(num2) sorted_arr.append(num1) return sorted_ar...
ca1d4a7a9a2c953b1939a775f435708dd07dee72
yehudasapir/data_structures
/sort/binary_tree.py
2,431
3.65625
4
import numpy as np class Node(): def __init__(self,value): self.node_value = value self.left_child = self.right_child = None def add_child(self, new_node): #print "add child to:", self.node_value if new_node.node_value > self.node_value: self.right_child = new_node #print "add right child:", new_node...
eeab736721ad56db5eb825b0a94db1cdeffc9eef
waltercoan/ALPCBES2016
/bolha.py
454
3.75
4
__author__ = 'Walter' numeros = [9,8,7,3,2,2,5,10,294,2,5,635728,6] for i in range(0,len(numeros)-1): print(numeros[i],end="-") for j in range(i+1,len(numeros)): print(numeros[j], end=" ") if numeros[i] > numeros[j]: aux = numeros[i] numeros[i] = numeros[j] n...
52e9b4bd015b79dc0650562ef385b2bb5e9b5809
waltercoan/ALPCBES2016
/convdolar.py
229
3.703125
4
__author__ = 'Walter Coan' print("Digite o valor em dolar") dolar = float(input()) #float = tipo decimal print("Digite a cotacao do dolar") cotacao = float(input()) valorreal = dolar * cotacao print("O valor em reais e: ", valorreal)
e37fdeeecf3766d35fe48b137f049cdb4a7fc72e
SongYippee/leetcode
/Stack/最大频率栈.py
1,647
3.921875
4
# -*- coding: utf-8 -*- # @Time : 2019/4/9 21:33 # @Author : Yippee Song # @Software: PyCharm ''' 895 Maximum Frequency Stack FreqStack 是一个类似栈的数据结构,它的 pop返回离栈顶最近的出现频率最大的元素。 ''' import collections class FreqStack(object): def __init__(self): self.freq = collections.Counter() # 用来存储元素频率 self...
fe7b81a5b7a7bc95de10d80d29f1d983fda48f82
SongYippee/leetcode
/Array/605 可否种花.py
749
4.03125
4
# -*- coding: utf-8 -*- # @Time : 2019/3/28 17:09 # @Author : Yippee Song # @Software: PyCharm ''' 605 Can Place Flowers, 相邻两个1是不允许的,中间必须隔开至少一个0 Example 1: Input: flowerbed = [1,0,0,0,1], n = 1 Output: True Example 2: Input: flowerbed = [1,0,0,0,1], n = 2 Output: False ''' class Solution(object): def canPlac...
2cdb44d805812020a79eb3dc836fb88eca37831c
SongYippee/leetcode
/String/14_最长公共前缀.py
1,284
3.875
4
# -*- coding: utf-8 -*- # @Time : 2019/2/12 17:04 # @Author : Yippee Song # @Software: PyCharm ''' 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前缀。 说明: 所有输入只包含小写字母 a-z 。 ''' class Solution(object): def longe...
89c8f8945c49a4a3aed7ee34fc328e9d3fc9a665
SongYippee/leetcode
/Array/数组深度.py
902
3.703125
4
# -*- coding: utf-8 -*- # @Time : 2019/3/26 10:57 # @Author : Yippee Song # @Software: PyCharm ''' 697 Degree of an Array 找出非空非负数的数组 A中的子数组 A' 使得 A'的 degree和 A的 degree相同 ''' class Solution(object): def findShortestSubArray(self, nums): """ :type nums: List[int] :rtype: int """ ...
5d2dcca3ee7af1a8b3bc7a6096f2d2934c821023
SongYippee/leetcode
/Tree/二叉搜索树范围之和.py
1,088
3.671875
4
# -*- coding: utf-8 -*- # @Time : 2019/4/10 16:59 # @Author : Yippee Song # @Software: PyCharm ''' 938 Range Sum of BST 给定 BST的根节点和 L,R两个值,返回 BST中节点值在范围[L,R]的和 ''' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # ...
4d0db61f11f02d220a07ce28014b2dd5e8b95ecd
SongYippee/leetcode
/Tree/寻找重叠子树.py
2,090
3.765625
4
# -*- coding: utf-8 -*- # @Time : 2019/3/11 11:16 # @Author : Yippee Song # @Software: PyCharm # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None from collections import Counter from collections import de...
d15f52f6d8ef6c7b597012f683739be6645f8c2f
SongYippee/leetcode
/LinkedList/82 在有序列表中删除重复项 II.py
1,098
3.9375
4
# -*- coding: utf-8 -*- # @Time : 1/13/20 10:16 PM # @Author : Yippee Song # @Software: PyCharm ''' Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2->5 Example 2: Input: 1->1->1->2->...
e7c66be2e1a9bdc5d12081089678885933da93d4
SongYippee/leetcode
/String/字符串相乘.py
1,240
4.1875
4
# -*- coding: utf-8 -*- # @Time : 2019/2/13 16:51 # @Author : Yippee Song # @Software: PyCharm ''' 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", num2 = "456" 输出: "56088" 说明: num1 和 num2 的长度小于110。 num1 和 num2 只包含数字 0-9。 num1 和 nu...
a26e88d420464e4c075984303274738ce61db468
SongYippee/leetcode
/LinkedList/86 分片链表.py
1,529
4.15625
4
# -*- coding: utf-8 -*- # @Time : 1/14/20 10:17 PM # @Author : Yippee Song # @Software: PyCharm ''' Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitio...
89c943cb44900211e101a5f4eb60544c72cbc8e8
SongYippee/leetcode
/UnknownSet/34 SearchRange.py
1,483
3.515625
4
# -*- coding: utf-8 -*- # @Time : 10/25/20 5:25 PM # @Author : Yippee Song # @Software: PyCharm ''' 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 你的算法时间复杂度必须是 O(log n) 级别。 如果数组中不存在目标值,返回 [-1, -1]。 示例 1: 输入: nums = [5,7,7,8,8,10], target = 8 输出: [3,4] 示例 2: 输入: nums = [5,7,7,8,8,10], target = 6 输出:...
553d882e8e0f8e7588b69d8ea491e2b54ecf4689
SongYippee/leetcode
/String/翻转字符串里的单词.py
881
4.15625
4
# -*- coding: utf-8 -*- # @Time : 2019/2/13 16:54 # @Author : Yippee Song # @Software: PyCharm ''' 给定一个字符串,逐个翻转字符串中的每个单词。 示例: 输入: "the sky is blue", 输出: "blue is sky the". 说明: 无空格字符构成一个单词。 输入字符串可以在前面或者后面包含多余的空格,但是反转后的字符不能包括。 如果两个单词间有多余的空格,将反转后单词间的空格减少到只含一个。 进阶: 请选用C语言的用户尝试使用 O(1) 空间复杂度的原地解法。 ''' class Solution...
180433f66f443a3ab6685b6880723f885350fdc0
SongYippee/leetcode
/Tree/112 二叉树路径和查找.py
1,913
4.0625
4
# -*- coding: utf-8 -*- # @Time : 10/28/20 2:55 PM # @Author : Yippee Song # @Software: PyCharm ''' 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和。 说明: 叶子节点是指没有子节点的节点。 示例:  给定如下二叉树,以及目标和 sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ ...
a3b4a5346007a868dfceab1ccf718c9d8d89f594
rawlini/STGAutomationProject
/challenges/Challenge4/Fibonnaci.py
116
3.84375
4
def Fibonnaci(Number): a=0 b=1 i=1 while (i<= Number): a,b= b+a,a i=i+1 return b
a3cd96516d75318ec4b2a934fec09a4ef6675ed7
Pepsico-Python-PEP-Club/PANDAS_ADVANCED_TRAINING_2021
/ppc_pandas_advanced.py
4,313
3.59375
4
#################################################################### # Python PEP Club - Pandas Training Beginners ######## # by Mat and TJ ######## # 2021-06-24 ######## ########################################...
04a19b417325d45e3b776f200eed3d80042a2159
uran001/Small_Projects
/Hot_Potato_Game/hot_potato_classic.py
1,236
4.125
4
# Note the import of the Queue class from queue import ArrayQueue def hot_potato(name_list, num): """ Hot potato simulator. While simulating, the name of the players eliminated should also be printed (Note: you can print more information to see the game unfolding, for instance the list of players to w...
aa1318cc39b8b20bf29f4776785437d20af0e29d
uran001/Small_Projects
/Twitter_streaming/twitter_streaming.py
3,485
3.84375
4
""" The code in this file can be used to create a "stream" to track live tweets. This "stream" is a wrapper to the standard Twitter API. Moe info about the Twitter API at: https://dev.twitter.com/overview/api You should try to understand the code and, most importantly, understand how you can reuse (part of) this code ...
83136a7f7c1242ef28f90b1177573f4d02a675ba
ShahedMazhar85/pythonpractice
/itr_clas.py
272
3.546875
4
import itertools for i in itertools.count(10, 10): if i > 50: break else: print(i, end=" ") import itertools temp = 0 for i in itertools.cycle("12345"): if temp >= 10: break else: print(i, end=' ') temp = temp + 1
5ea96aab0e7110cbf234ea409328e29d7929b0ee
ShahedMazhar85/pythonpractice
/jason_exp.py
355
3.640625
4
import json ''' student = {} # Key:value mapping student['peter'] = { "Name": "Peter", "Roll_no": "0090014", "Grade": "A", "Age": 20 } s = json.dumps(student) with open("c://data//a.txt", "w") as f: f.write(s) ''' f=open("c://data//a.txt", "r") s=f.read() print(s) print(type(s)) book=json.loads...
83df2bc43893f3c5509d0a4c5320cfa57fcf86cf
goelShweta/python
/str_palindrome.py
440
3.8125
4
def str_rev(str1,str2,pos,i): if len(str1)==pos : if str2==str1 : return "palindrome" else: return "not palindrome" else: a=str1[i-1] str2=str2+a pos=pos+1 i=i-1 return str_rev(str1,str2,pos,i) str1="shweta" str2="" ...
72a8fbb66d0ce172f59064981241ea19573c6e7c
goelShweta/python
/dictionary_intersection.py
972
3.9375
4
def dict_inter(dict1,dict2,dict3,pos1,pos): ''' intersecting two dictonary first : adding elements of 1st list and then of second list the same key value pair will be replaced ''' if len(dict1)==pos1 and len(dict2)==pos : return dict3 else: if...
44eed55f97da399862b8304fd86bd4c69f9d2ff9
goelShweta/python
/sum_fun.py
392
3.9375
4
def sum_fun(*var): ''' objective: to print the sum of variables ''' sum=0 for i in var : sum=sum+i print(sum) #************************************************* def sum_fun2(a,b,c): ''' printing the elements ''' sum=0 sum=a+b+c return sum...
6f73bce15f71e04074d79384e0a3d4b0165ff99b
goelShweta/python
/longest_word_in_list.py
492
4.0625
4
def longest_word(list1,pos,max_ele): #max_ele=list1[pos] if(pos==len(list1)): return max_ele else: if len(list1[pos])>len(max_ele) : max_ele=list1[pos] pos=pos+1 return longest_word(list1,pos,max_ele) else: pos=pos+1 ...
12708da847d8ff40aeb62f1bd7ff7a274c97e255
goelShweta/python
/triangle_area.py
487
3.984375
4
def ar_tri(h=4,b=3): ''' objective: area of triangle input parameters:height and base return value: area of triangle ''' #approach: not using recurrsion area = 1/2*h*b return(area) def ar_tri_recc(h,b,hnew): #using recurrsion assert h>=0 & b>=0 i...
10edb125ded1a5c9be2c99fd2bbcda97a3676830
Jing233/thinking-recursively_byEricRoberts
/Ex3.2_cannonball.py
352
3.625
4
''' implement cannonball: 1 + 2 + 4 + 8 + 2^(N-1) == 2^N - 1 ''' def cannonball(N): if N == 0: return 1 else: return 2*cannonball(N-1) result = 0 if __name__ == '__main__': N = int(raw_input("Enter the number of layers:")) for i in range(N): result +=...
b94d288c2704d8e47ec11b1a1ca9e9ff47ec5c65
Jing233/thinking-recursively_byEricRoberts
/Ex5.2_nHanoiMoves.py
256
3.796875
4
''' nHanoiMoves(n) returns the number of moves required to solve the Tower of Hanoi Puzzle for a Tower of size n ''' def nHanoiMoves(n): if n == 1: return 1 else: return 2*nHanoiMoves(n-1)+1 print nHanoiMoves(8)
6127b6d8f8c3a8eb7bb1b2896eec9a4804d0f919
stat-ki/Python_practice
/matplot/use_matplotlib_scatter.py
448
3.5
4
import matplotlib matplotlib.use("tkagg") import matplotlib.pyplot as plt import numpy as np datax = np.random.randn(100) datay = datax + np.random.randn(100)*0.3 plt.scatter(datax, datay, label = "Data 1") datax = np.random.randn(100) datay = 0.6*datax + np.random.randn(100)*0.4 plt.scatter(datax, datay, color = ...
56fd1fc7e0d6c68dfe2be4802a08b0d71092e607
Caff1982/Reinforcement-Learning-Solutions
/dyna_q.py
12,845
3.5
4
import numpy as np import matplotlib.pyplot as plt import random class Environment: """Used to represent gridworld environment # Arguments width: integer. The width of the grid height: integer. The height of the grid start: tuple. The start location on grid, (col, row) goa...
e363670f583b553533cc2082ed03e231630dd736
joshuaagbo/QRcode-generator
/qrcode.py
860
3.828125
4
import pyqrcode as pqr import png; from pyqrcode import QRCode # a string to store generated QRCode url_string = input("Enter the url to generate QRCode: ") # name for the qrcode image file qrcode_name = input("Enter name to save your file: ") def concate_secure(url_str):#add https|http and (.com) to url string if ...
fdcaa5624ee99e3f24c9db2fa6c86161d4989ce8
H-H2648/foobar
/Stage 2/ion-flux-relabeling.py
884
3.578125
4
def solution(h, q): def power_2(num): if num == 0: return False else: power = 1 while power < num: power *= 2 if power == num: return True else: return False sol = [] for elem in q: ...
eec9d9d7b93a9be2efe05d49e29edd29b36e8bd1
vgpprasad91/My_own_tensorflow
/neuron_subclasses/_2._calculation_with_neuron_subclasses.py
217
3.53125
4
# create a neuron subclass to perform addition class Add(Neuron): # Instantiate all the values def __init__(self,x,y): Neuron.__init__(self, [x,y]) # Create a code to perform forward propagation
474cc9eb3ba257339e9b726479cfa10f03c14e29
rbarrette1/Data-Structures
/LinkedList/LinkedList.py
2,055
4.21875
4
from Node import * # import Node class head = "null" # first node of the linked list class LinkedList(): def __init__(self): self.head = None # set to None for the time being # insert after a specific index def insert_after_index(self, index, new_node): node = self.head # get the first no...
ddc3e22fedd3e5aca76f0f761153b32332aa3804
muneebulislam/eta_project
/app/forms.py
2,114
3.65625
4
""" This module perform the functionality of creating the Login forms and Sign up forms. It makes use of the functionality of built in wtforms modules adopted for the Flask applications. """ from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, SubmitField,BooleanField from wtforms.validato...
642410d99d761e9565cd2829893d08bf901e7c7b
Johnscar44/code
/python/notes/elif.py
331
4.125
4
secret_num = "2" guess = input("guess the number 1 - 3: ") if guess.isdigit() == False: print("answer can only be a digit") elif guess == "1": print("Too Low") elif guess == "2": print("You guessed it!") elif guess == "3": print("Too high") else: print("Guess not in rage 1 - 3") print("please t...
a2b2da73552e61cc2a3fbae380186374984d0b0f
Johnscar44/code
/compsci/moon.py
1,207
4.1875
4
phase = "Full" distance = 228000 date = 28 eclipse = True # - Super Moon: the full moon occurs when the moon is at its closest approach to earth (less than 230,000km away). # - Blue Moon: the second full moon in a calendar month. In other words, any full moon on the 29th, 30th, or 31st of a month. # - Blood Moon: a lu...
c0dd01899f778a248f1b52574e5f574f3135c6f7
Johnscar44/code
/python/games/time.py
641
3.96875
4
import time import threading print("start time") start_time = time.time() print(start_time) stoppper = input("press enter to stop") end_time = time.time() print("You have finished") print(end_time) print ("--------------------") duration = int(end_time - start_time) print(duration) while True: if duration > 3: ...
6d5973a7a0d3b23b31f00d656c6e6d8a5905fcfb
Johnscar44/code
/python/projects/escape2.py
513
3.90625
4
my_bird = "sparo" def get_guess(): """Get a guess from the user """ return input("Guess a type of bird!: ") # try 3 times max for i in range(2): guess = get_guess() if guess == my_bird: print("You gues the Motha fuckin bird") break else: if i == 0: print("Incor...
6d2ddc65b018e810f4e4e6dc4424cc6025853faa
Johnscar44/code
/compsci/newloop.py
562
4.375
4
mystery_int_1 = 3 mystery_int_2 = 4 mystery_int_3 = 5 #Above are three values. Run a while loop until all three #values are less than or equal to 0. Every time you change #the value of the three variables, print out their new values #all on the same line, separated by single spaces. For #example, if their values were ...
f62b05281426e2771e9725e810ad2ec36ac901ae
Johnscar44/code
/python/testing/test.py
209
3.921875
4
greeting = "Hello" print(greeting) input_test = input("Enter somethings eaten in the last 24 hours?: ") print("It is" , "dairy".lower().upper() in input_test.lower().upper() , input_test , 'contains "dairy"')
570a915a233eee00cc23b34d7ce3cf2c78940d75
Johnscar44/code
/compsci/forloop.py
957
4.71875
5
#In the designated areas below, write the three for loops #that are described. Do not change the print statements that #are currently there. print("First loop:") for i in range(1 , 11): print(i) #Write a loop here that prints the numbers from 1 to 10, #inclusive (meaning that it prints both 1 and 10, and all #the...
ba6ed7504ec5549570fb51d253335e21d8696906
Johnscar44/code
/python/projects/password.py
1,297
4
4
def get_username(): chances = 0 while True: user_name = input("user name: ".title()) if user_name.lower() == "e": print("goodbye".title()) return False elif user_name == "John Scarpino": print("correct") return True elif user_name !...
a6988448e3d001f48b234811a17b8733205474ce
avikay/data-frame-III
/Pandas - Data Frames - III.py
1,325
3.765625
4
#!/usr/bin/env python # coding: utf-8 # In[18]: import numpy as np import pandas as pd from numpy.random import randn # ### Multi-level Indexed DataFrame # In[28]: a = ['Z1','Z1','Z1','Z0','Z0','Z0'] b = [1,2,4,1,2,4] hierarchical_index = list(zip(a,b))#here we are creating a list of tuples using zip function a...
0f4512054a93918250d1a1f69f3fb6ff46fda220
vijayjayakumar02/python.program
/stack.py
544
3.859375
4
from collections import deque class stack: def __init__(self): self.container = deque() def push(self, data): self.container.append(data) def pop(self): self.container.pop() def size(self): return len(self.container) def is_empty(self): if len(self.conta...
1505e0d9e27d1b20670da4c4667fc9189fe151a5
Fernando23296/l_proy
/angle/ayuda_1.py
461
4.21875
4
from turtle import * from math import * import math a = float(input("enter the value for a: ")) b = float(input("enter the value for b: ")) c = float(input("enter the value for c: ")) if (a + b >= c) and (b + c >= a) and (c + a >= b): print("it's a triangle") A = degrees(acos((b**2 + c**2 - a**2)/(2*b*c))) ...
691d922adfbb58996dabc180a1073ef06afa000a
choprahetarth/AlgorithmsHackerRank01
/Python Hackerrank/oops3.py
827
4.25
4
# Credits - https://www.youtube.com/watch?v=JeznW_7DlB0&ab_channel=TechWithTim # class instantiate class dog: def __init__(self,name,age): self.referal = name self.age = age # getter methods are used to print # the data present def get_name(self): return self.referal de...
5960a9e747851838f2823ab0b3b5027275d12b97
choprahetarth/AlgorithmsHackerRank01
/Old Practice/linkedList.py
1,093
4.46875
4
# A simple python implementation of linked lists # Node Class class Node: # add an init function to start itself def __init__(self,data): self.data = data self.next = None # initialize the linked list with null pointer # Linked List Class class linkedList: # add an init function to initial...
42f3adb969d10c4ea556bba3c202cfd81d23bfc7
mspronesti/simple-snake
/snake.py
1,557
3.578125
4
from config import * class Snake: def __init__(self): self.head = Head() self.queue = list() def add_piece(self): self.queue.append(Piece()) def up(self): self.head.direction = Direction.UP def down(self): self.head.direction = Direction.DOWN def left(se...
2ceb25033631252e675d9d4bfa454d65c34ac1cb
Mohini-2002/Python-lab
/TableByWhileLoop/main.py
223
4.0625
4
#To print the N number of table: N = int(input("Enter the limit of table :")) a = 1 while a <= N: i = 1 while i <= 10: t = i*a print(t, end=" ") i += 1 print("\n") a += 1
b499e6ecc7e711bf74441b89fec4fcc49712b4a3
Mohini-2002/Python-lab
/Method(center,capitalize,count,encode,decode)/main.py
702
4.28125
4
#Capitalize (capital the first of a string and its type print) ST1 = input("Enter a string :") ST1 = ST1.capitalize() print("After capitalize use : ", ST1, type(ST1)) #Center (fill the free space of a string and and its type print) ST2 = input("ENter a string :") ST2 = ST2.center(20, "#") print("After center u...
5193d07c342b6d7b4ac9b667be34f9c49903f8b1
fzy0728/LeetcodeStudy
/leetcode/ReverseNodesinkGroup.py
1,913
3.828125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None def printL(head): while(head!=None): print head.val, head = head.next print '' class Solution(object): def confire(self, head, k): if (head == None)...
dbb7ed2dfb5cd24fdb5b4c3ebf0db9ec6cbf9e33
fzy0728/LeetcodeStudy
/2023_leetcode/7_4/swapPairs_24.py
1,152
3.859375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ # if head is None o...
d921b36640640b3094722fa6c990225e8901b903
Yuzu28/Week_1_Python
/Dictionary_Python/letterSummary.py
496
3.921875
4
def letter_histogram(word): dict = {} for letter in word: keys = dict.keys() if letter in keys: dict[letter] += 1 else: dict[letter] = 1 return dict print(letter_histogram('gkllkjljljljlglejmnsfksjfz')) #another solution, but ask for the user inputs user...
24df0e1c39c3c6915dfa560cf81dcddc033e96ff
asimihsan/challenges
/rosalind/grph/grph.py
1,399
3.546875
4
import itertools from pprint import pprint MATCH_LENGTH = 3 def get_dna_strings_from_fasta_file(lines): dna_strings = {} with open("rosalind_grph.txt") as f: current_dna_name = None current_dna_string = [] for line in f: if line.startswith(">"): if current_d...
d12a5b035b0acf1fcd995611473dc6d0daf6cb6c
asimihsan/challenges
/interview/careercup_array_two_numbers_odd_times.py
857
4.03125
4
""" You are given an integer array, where all numbers except for TWO numbers appear even number of times. Q: Find out the two numbers which appear odd number of times. """ import unittest def two_numbers_odd_times(arr): def xor(a, b): return a ^ b xor_1 = reduce(xor, arr) bit_position = 1 w...
718d8989750b21513fff2c0eea78016432b90a4d
asimihsan/challenges
/epi/ch12/dictionary_word_hash.py
2,509
4.15625
4
#!/usr/bin/env python # EPI Q12.1: design a hash function that is suitable for words in a # dictionary. # # Let's assume all words are lower-case. Note that all the ASCII # character codes are adjacent, and yet we want a function that # uniformly distributes over the space of a 32 bit signed integer. # # We can't simp...
e365078e755a74a4c6ad97bfc367a14d03d161a8
asimihsan/challenges
/interview/boggle1.py
3,801
3.8125
4
""" Solve boggle! """ boggle = [['a', 'r', 'e'], ['d', 'f', 'g'], ['d', 'f', 'g']] # 'add', 'egg', 'fad', ... # (any square board, letters don't 'wrap over the edge' # 1. for each letter on board, DFS to neighbours. # 2. if prefix is valid only then continue on path. # 2a. if prefix is not valid...
7a5a428427a1c18ff9932a615d4fb3404581925a
asimihsan/challenges
/interview/geeksforgeeks/geeksforgeeks_left_view_of_binary_tree.py
1,387
4.09375
4
""" Given a Binary Tree, print left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from left side. Left view of following tree is 12, 10, 25. 12 / \ 10 30 / \ 25 40 """ class BinaryTree(object): def __init__(self, ...
8e640bc438b57cbbf14d14f0184521d32e2e6c99
asimihsan/challenges
/interview/towers_of_hanoi.py
386
3.8125
4
def recursive_move_tower(height, from_pole, to_pole, with_pole): if height >= 1: recursive_move_tower(height - 1, from_pole, with_pole, to_pole) recursive_move_disk(from_pole, to_pole) recursive_move_tower(height - 1, with_pole, to_pole, from_pole) def recursive_move_disk(from_pole, to_pol...
15a80451deb578e1e4fa47e6c9716532423384cb
asimihsan/challenges
/topcoder/problems/12545_GooseInZooDivTwo/GooseInZooDivTwo.py
4,355
3.90625
4
#!/usr/bin/env python """ SRM 578 - Goose In Zoo Division Two (problem 12545) Suppose we have the following grid, with dist=1: vvv ... vvv If any cell in the top has a goose, then the rest must have geese. Conversely, if any cell in the top does not have a goose, the rest must not have geese. The top row has only t...
fc7dd042553a44038a966fae8f432daa0ef5c5d3
Mariani-code/PythonProjects
/ProjectEuler/EP29.py
469
3.53125
4
from math import pow def distinct_powers(low_lim, upp_lim): combination_list = [] amount_combination = 0 for numb in range(low_lim, upp_lim+1): for power in range(low_lim, upp_lim+1): combination = pow(numb, power) if combination not in combination_list: combination_list.append(combination)...
92d40b4d7f802c3b0d552c3462926b55234c8e7a
Mariani-code/PythonProjects
/ProjectEuler/EP10.py
407
3.546875
4
limit = 2000000 is_prime_array = [True] * limit def prime_sieve(prime_array): the_sum = 0 for i in range(2, len(prime_array)): if prime_array[i]: the_sum += i k = i + i while k < len(prime_array): prime_array[k] = False k ...
299d350584926ca9c97fb80b871471a7cff4627a
anshu3769/KeplerGroup-CodingExcercise
/app/models.py
5,783
4.09375
4
""" Kepler Group Coding Excercise -------------------------- Model class for Words API -------------------------- This file contains three classes - 1. RandomWord - It contains method for generating a random word from the given list of words 2. Rhyme - It contains method for generating rhyming words for a given wor...
d40eea8bea53095e45f4061435ba1ca65ea1393c
fishhuman/find_max_number
/find_max.py
365
3.984375
4
def find_max(a_list): if a_list == False: return 0 count = 0 max_number = 0 for number in a_list: if number > max_number: max_number = number return max_number print(find_max([1, 2, 3]), '為最大值') print(find_max([1, -1, -5]), '為最大值') print(fin...
08a22aba3d6a19714cc99eec376dcea66c507e0b
paul-manjarres/coding-exercises
/python/com/jpmanjarres/hackerrank/algorithms/strings/SuperReducedStringEasy.py
412
3.625
4
def reduce_string(s): temp = "" i =0 while i < len(s): if(i == len(s)-1 or s[i] != s[i+1]): temp = temp+s[i] i = i+1 elif s[i] == s[i+1]: i = i+2 return temp s = input().strip() s2 = reduce_string(s) t = "" while len(s2) != 0 and s2 != t: t = ...
321bd20138863f06653a54184655bf3c811b2fb4
paul-manjarres/coding-exercises
/python/com/jpmanjarres/hackerrank/algorithms/implementation/FormingAMagicSquare.py
230
3.578125
4
s = [] for s_i in range(3): s_t = [int(s_temp) for s_temp in input().strip().split(' ')] s.append(s_t) # Print the minimum cost of converting 's' into a magic square vals = [] for i in range(3): s[0][i] print(s)