blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
57d49cb4a07b569af6da2c658abb4fb16c6b7fc9
maatheusgouveia/python-exercises
/aula07.py
275
3.890625
4
# nome = input('Qual é o seu nome? ') # print('Prazer em te conhecer, {:=<^>20}!'.format(nome)) n1 = int(input('Um valor: ')) n2 = int(input('Outro valor: ')) d = n1 / n2 print('O resultado é {:.3f}'.format(d), end=' ') print('Uma string para testar a quebra de linha, ')
a45fb1028326a73188d148aaade380381572b5e2
prateksha/Source-Code-Similarity-Measurement
/Datasets/py-if-else/Correct/053.py
209
4
4
#!/bin/python3 number = int(input()) if ((number%2 != 0) or ((number%2 == 0) and (6 <= number <= 20))): print ('Weird') elif ((number%2 == 0) and ((2 <= number <= 5) or (number > 20))) : print ('Not Weird')
f3edc09933dc4e158222c2c022f8ebfe96ff5a22
Neenu1995/CHPC-PYTHON
/newton_cuberoot.py
228
3.78125
4
number = input('Enter the number : ') number = float(number) change = 0.000000001 guess=0.3*number while ((abs(guess**3)-number)>change): fx = guess**3-number fxx = 3*(guess**2) guess = guess - (fx/fxx) print guess
1903ef2b9d5c8a44777ca12a4e9b8b8f09f76e14
ozzcodes/MyPersonal_Budget
/create_budget.py
1,659
3.875
4
# Imports from payday_budget.models.budget import Account, Budget from sqlite3 import connect, OperationalError # Check for existing budget conn = connect('data/budget.db') cursor = conn.cursor() # If a table already exists, take note and ask if they want to overwrite try: cursor.execute('SELECT * FROM bu...
8d0b23909fc9b195ee2b9a9c6977ec5df26b007c
arbyadav/Python_Program_Basics_StepbyStep
/Python/DATA STRUCTURES/Lists.py
577
4.09375
4
#Lists in python represented by [] square bracket ###Lists are mutable #LISTS animals=['TIGER','LION','WOLF','DOG'] print(animals) #list in lists rl=['DOG',1,3,5,['amit','key','5','PYTHON']] print(rl) #length of list print(len(rl)) # #callinglist by index # a=animals[0] # b=rl[4][3] # print(b) ...
de78b34d40b26699ed5dd22ba7f6cf60f303e7da
eduardodanielparedesjacobo/Primer-parcial-
/ejercicio 6.py
210
3.640625
4
C=1 X=0 i=0 Z=0 m=int(input("ingrese su numero entero =")) while i<m: Z=C+i print(i,'+',C,'=',Z) X=i*(i+1)/2 print('SUMA',i,'(',i,'+ 1 )','/','2 =',int(X)) i += 1
c838d8701727936b9b7134468b879573e9fd3cd3
solandmedotru/Python_Tutorials
/useless_trivia.py
942
4.15625
4
# Программа бесполезные факты # name = input("Привет. Как тебя зовут? ") age = int(input("Сколько тебе лет? ")) weight = int(input("И последний вопрос. Сколько ты весишь в кг? ")) print("\nЕсли бы маленький ребенок захотел привлечь твое внимание.") print("Он произнес бы твое имя так: " + name * 5) seconds = age * 36...
83387c80321a20c0b478cf6fb346657436e2e438
Mehvix/competitive-programming
/ProjectEuler/Problem001.py
133
4
4
num = 0 for user_input in range(1000): if (user_input % 3 == 0) or (user_input % 5 == 0): num += user_input print(num)
5d7160c8636c0a4017f1ed104882e779ca3bb52e
kwunkau/Python_2019Year
/剑指Offer/reference/面试题17 合并两个排序的链表.py
1,560
4.09375
4
# -*- coding: utf-8 -*- ''' @Author: kabuto @Date: 2019/06/26 ''' ''' 【题目】: 输入两个递增的排序链表,合并这两个链表使得新链表中的节点仍然是递增的。 【解题思路】: 使用递归的思想: 先判断两个头节点,其值小的作为头节点; 再判断头节点的下一个节点与前一个链表头节点的大小。 ''' # define the linklist class ListNode(): def __init__(self, val): self.val = val self.next = None # create...
4136c665a8b6342e6803c59903a69b874ed2c09d
Kieran-Murdocca/Homework1
/main.py
2,726
4.03125
4
# Author: Kieran Murdocca kkm5754@psu.edu lg1 = input("Enter your course 1 letter grade: ") c1 = float(input("Enter your course 1 credit: ")) if lg1 == "A": print("Grade point for course 1 is:" , (4.00)) lg1=float(4.00) elif lg1 == "A-": print("Grade point for course 1 is:" , (3.67)) lg1=float(3.67) elif lg1 ...
3c69f72f23ffc637e29756069b2584b9d12eeeb2
yk-hts/AtCoder
/c_29.py
117
3.734375
4
import itertools n = int(input()) l = 'abc' a = itertools.product('abc',repeat = n) for i in a: print(''.join(i))
72d1263136209bb38441313e8ed597726331cf5f
juancebarberis/algo1
/practica/9-2.py
527
4.0625
4
#Ejercicio 9.2. Diccionarios usados para contar. #a) Escribir una función que reciba una cadena y devuelva un diccionario con la cantidad #de apariciones de cada palabra en la cadena. Por ejemplo, si recibe ”Qué lindo día que #hace hoy” debe devolver: { 'que': 2, 'lindo': 1, 'día': 1, 'hace': 1, 'hoy': 1} . #a) def ...
e8f1e82ccbc260d88a0a340cf9e8ccd8ea23f57e
skirmer/python
/newproject2.py
2,956
4.125
4
import random import string import csv def weasel(): print('''This program will generate a set of randomized passwords to your specifications, and save them for you to import into the password manager of your choice.''') print("") a=raw_input('Do you want symbols? ') while (a.upper()=='Y' or a.upper()=="YES" o...
536d90e5c7036f4dacbea0b87d299a1e753e7e26
nicolasalliaume/python-bootcamp
/Module_2/exercises/05-sublists/exercise.py
464
4.0625
4
############################################# # # It's really easy to get a portion of a list. # You can use the_list[<from>:<to>], where <from> # is one index and <to> is another index. # # Try to print from index 2 to 5 of the given # list. # # Tip: using print() with a list as a parameter will # do fine. # #########...
3951ba3c88ca29a432c1f26402a70161e0c1270c
gabriellaec/desoft-analise-exercicios
/backup/user_377/ch121_2020_10_07_14_50_24_103101.py
259
3.65625
4
subtracao_de_listas = True def subtracao_de_listas(lista1, lista2): lista1 = [] lista2 = [] lista = [] if lista1 < lista2: return lista[0] elif lista2[0]: return lista1 else: lista = lista1 - lista2 return lista
da458aef38ba81eb0bf93a7b7c4e047113ef7813
aprvh1/Python
/My Python Program/class_Inheritance.py
337
3.71875
4
class apoorv: def __init__(self): print "This is my base class" def take(self,name): self.name=name def printname(self): print "NAME: ",self.name class ape(apoorv): def __init__(self): print "This is my derieved class" a=ape() a.take("Aman")...
7ceac2292707d30665ae112b4720c9a1e047826e
rhgrant10/advent-of-code
/2017/03/spiral-memory-2.py
1,096
3.5625
4
# -*- coding: utf-8 -*- import sys import collections LEFT = -1, 0 RIGHT = 1, 0 UP = 0, 1 DOWN = 0, -1 UP_LEFT = -1, 1 UP_RIGHT = 1, 1 DOWN_LEFT = -1, -1 DOWN_RIGHT = 1, -1 CARDINALS = [UP, DOWN, LEFT, RIGHT] DIAGNOALS = [UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT] values = collections.defaultdict(int) values[0, 0]...
b854b90c6570a8b19304bdb62de91499eff5848c
ashleyabrooks/code-challenges
/asana_bot/asana_recurring_task.py
2,045
3.859375
4
from datetime import date def recurringTask(firstDate, k, daysOfTheWeek, n): """Return first n dates for a recurring task.""" def get_deltas(days_of_the_week, start_day): """Return list of deltas - numbers that will be added to firstDate to get recurring task dates.""" deltas = [] ...
99247f23f12fca246b158ec61e8b1fc1b63b0bf1
jyleong/DailyCodingProblems
/daily_coding_problem_201.py
1,680
4.1875
4
''' You are given an array of arrays of integers, where each array corresponds to a row in a triangle of numbers. For example, [[1], [2, 3], [1, 5, 1]] represents the triangle: 1 2 3 1 5 1 We define a path in the triangle to start at the top and go down one row at a time to an adjacent value, eventually ending with...
bc8d01dbc657ba1d83ac685c4e0ae9dd15afee12
maknetaRo/python-algo
/bubble-sort/bubble1.py
693
4.3125
4
def bubble_sort(arr): end_index = len(arr) - 1 sorted = False counter = ( 0 # to count how many times it goes through the loop until sorts the array ) while not sorted: sorted = True for i in range(0, end_index): if arr[i] > arr[i + 1]: # if firs...
ad5861c1b9650e14342be34534bdf101a969e748
yanir2007/aodisea
/4.py
145
4.03125
4
num = int(input("enter a number: ")) if num > -10 and num < 10: print("Single digit number") else: print("Non-single digit number")
2f7847f282ea9b1830142860d5b1179ad3e71ac4
yogeshg/small-projects
/streamlit_apps/advent2022/pages/day2.py
1,805
3.59375
4
import streamlit as st def is_win(they, you): if they == "A" and you == "Y": return 6 if they == "B" and you == "Z": return 6 if they == "C" and you == "X": return 6 if they == "A" and you == "Z": return 0 if they == "B" and you == "X": return 0 if they =...
ccbe516c628efc1ec1993402e51da9de7eadeae7
sbedell/CodingChallenges
/ProjectEuler/euler30.py
366
3.703125
4
import math def digitFifthPowers(n): totalSum = 0 for i in range(2, n): tot = 0 for dig in str(i): tot += int(math.pow(int(dig), 5)) if i == tot: # print("FOUND ONE: " + str(tot)) ...
abd8c2122c24e2e38f63b467595e06a6cfa2cea1
kiir33/basicPython
/Fundamentals/5.stepSize.py
1,102
4.4375
4
#accessing sub-strings by step size #Index Slicing [:], [::2] #[:] returns the entire string #[::2] returns the first char and then steps to every other char in the string #[1::3] returns the second char and then steps to every third char in the string #the number 2, in the print statement below, represents the step l...
cc6d51ad17891f9b0bffba9d9c3046582dd7dffd
jackiezeng01/Coding_Practice
/PM_Interview/16_5.py
981
4.125
4
''' Insert an element into a binary search tree (in order). You may assume that the binary search tree contains integers ''' class Node: def __init__(self, data) -> None: self.left = None self.right = None self.data = data def insert(self, val): if val < self.data: #...
c8d0986293b2f8eb4cc41164a29a6a4b02596f55
Rivenatti/Python
/tutorials/14-while-loop.py
132
4.0625
4
# With the while loop we can execute a set of statements as long as a condition is true. i = 1 while i < 10: print(i) i += 1
63345a85a6a280872d12e14b240deda95485dfab
pyjones/python
/congress_test.py
592
4
4
def spaces_spare(cars, people, space): cars * space = total_space total_space / cars = spare_spaces return spare_spaces prompt = ">>>" space_in_car = 5 ### SCRIPT STARTS HERE print "Number of people travelling to Congress" ppl_to_congress = raw_input(prompt) print "Number of cars" cars_to_congress = raw_input...
63f55ad8cfef5c9300e1321384cc4d4ac6b813d5
saideepshetty/leet-code-easy
/moveZeroes.py
612
3.890625
4
''' Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a copy of the array. Minimize the total number of operations Code By Sa...
2dc2cf0524500115241dac24bd4398cee85be899
frestea09/latihan-python-november
/src/belajarSubstring.py
382
3.5625
4
from __future__ import print_function def main(): kalimatPertama = 'ilman' kalimatKedua = input('Kalimat Kedua : ') print('Substring Pertama : %s'%kalimatPertama[0]) print('Substring Pertama : %s'%kalimatPertama[:2]) print('Substring Pertama : %s'%kalimatPertama[2:]) print('Substring Pertama : ...
61aba40ef542cf634666011975723973e2080bee
zamudio/learning-python
/03-Numbers-Booleans-and-Equality/type-conversion-with-the-int-float-and-str-functions.py
155
3.84375
4
# type conversion inside brackets print(int(3.14)) # returns 3 print(int('3')) # returns 3 print(str(3.14)) # returns '3.14' print(float(3)) # 3.00
d76a6f4bd57937a0110edf7c7637a9f50a29c45b
Ahsanhabib1080/MLCoronaPredictorBangladesh
/main.py
1,809
3.609375
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.preprocessing import PolynomialFeatures from sklearn import linear_model #### LOADING DATA #### data = pd.read_csv('Covid19_data.csv', sep=',') data = data[['Listofcases', 'total_cases']] print('-' * 10); print('Head'); print('-' * 10)...
2c4de1db3e60597363eec801bf10e5b48aea13df
mdengler/cs373
/unit2_12_quiz.py
407
3.8125
4
# CS 373 Unit 2.12: Evaluate Gaussian import math def gaussian(mean, variance): """variance is sigma-squared""" def f(x): decay = 1 / math.sqrt(2. * math.pi * variance) exponent = -((x - mean) * (x - mean)) / (2. * variance) return decay * math.exp(exponent) return f mean = 10. va...
dc4a068794f9fa743e41562d7584eaee87a02345
rafaelperazzo/programacao-web
/moodledata/vpl_data/78/usersdata/161/40363/submittedfiles/divisores.py
280
3.859375
4
# -*- coding: utf-8 -*- n=int(input('Quantidade de divisores a serem mostrados:')) a=int(input('Número 1:')) b=int(input('Número 2:')) múltiplo=1 for termo in range(a,n+1,1): if múltiplo%a==0 or múltiplo%b==0: múltiplo=múltiplo+1 print(múltiplo)
f3cd6332c221dfbff6f1804e1ff418023cffdc30
surajsoni2/python-basic
/factorial.py
515
4.21875
4
# Python Program for factorial of a number choice = 'y' while choice == 'y': num1 = int(input("enter a number ")) fact = 1 if num1 < 0: print("factorial is not possible for negative numbers") elif num1 == 0 or num1 ==1: print("factorial of ",num1,"is 1") else: for...
fe0adfaf9979aa4dfa4fd797b8a4ddd2743b38b2
keyhamilton/algo-especial
/fabio_lista01/fabiol1q1.py
166
3.890625
4
# entrada veloms = int(input('digite velocidade em m/s: ')) # processamento velokmh = veloms * 3.6 # saida print('{}m/s equivale a {}km/h'.format(veloms,velokmh))
edc06bd4a0023b12cdbd72dc74cd40527d65273d
JasThiara/Asset-Bubbles
/old/scripts/script5.py
289
3.71875
4
import csv #imports csv file from system c = csv.writer(open("BBRY_2013-04-29.csv","wb"))# function csv.writer open the file BBRY csv file and writes it c.writerow(["Time","Close","High","Low","Open","Volume"]) cr = csv.reader(open("BBRY_2013-04-29.csv","rb")) for row in cr: print row
b4f0d06ee5a7dab72d6f429360bb450f65e2e6e8
bigtreeIan/Programming-with-Software-Libraries
/hw4/class.py
2,428
3.703125
4
###Using of class class info: def row_input(self): while True: self.row_num = input('Please input total row number: ') if self.row_num >= 4 and type(self.row_num) == int: break else: continue def col_input(self): w...
0ee926a59446609a75b45d041c1e7a25f0b3f6fa
AtieDag/Project-Euler
/Problem15Slow.py
1,715
3.84375
4
# Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down. # There are exactly 6 routes to the bottom right corner. # How many such routes are there through a 20×20 grid? class Node: routes = 0 size = 0 def __init__(self, x, y): self.x = x self.y =...
816250f28ce2a21d16214cd985278fa4bd61d7a6
Vikasjce/MachineLearning
/MultipleLinearRegression/multiple_linear_regression.py
1,802
3.625
4
# Multiple Linear regression # Import Libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt # Import the Dataset dataset = pd.read_csv("50_Startups.csv") X = dataset.iloc[:,:-1].values y = dataset.iloc[:,4] # Taking care of missing data #from sklearn.preprocessing import Imputer #imputer ...
7022d42c1355088533660be52b06d23b3e98a78d
magdaborkowska/python-exercise
/exercises.py
3,957
3.75
4
print((9*7) + (5*7)) print((17*6) - (9*7 + 5*7)) x = 2 y = x print(y) mv_population = 74728 mv_area = 11.995 mv_density = mv_population / mv_area print(mv_density) reservoir_volume = 4.445e8 rainfall = 5e6 # decrease the rainfall variable by 10% to account for runoff rainfall *= .9 # add the rainfall variab...
0214869c7e32ab6b2f0159f54cbb7cbe591273cc
Aashutosh180/python-code
/day4assgn1.py
328
4.15625
4
def fibo(num): if(num<=1): return num else: return(fibo(num-1)+fibo(num-2)) numterms=int(input("enter number to get fibonacci sequence: ")) if (numterms<=0): print("please enter a positive number:") else: print("Fibonacci sequence:") for i in range(numterms): print(fi...
da5f9598838f6965560e2ad17aaf4acea6a7f0a8
KshitijRajvanshi/Sudoku-Solver-AI
/P2.py
6,245
3.640625
4
import sys def constraint(example): flag=[0 for i in range(9)] for i in range(9): if example[i] > 0: flag[example[i]-1] += 1 for i in range(9): if flag[i] > 1: return True return False class Sudoku: def __init__(self): self.board=[[0 for j in ...
e2b738d9ca117b7ea7d36db0e203055a701c80eb
thinklabph/imakewemake2021
/6.5 Raspberry Pi Python Dictionary/01_dictionary.py
953
4.625
5
# Empty Dictionary student = {} print(student) print(type(student)) # Dictionary Key Value pairs student = { "Key": "Value" } print(student) # 2 key value pairs student = { "Name": "Juan Dela Cruz", "Age": 13 } print(student) # Accessing a specific value based on the key print(student["Name"]) print(s...
b8f0b1692e9d434b26af5f3630e89498b7024853
N0mansky/StudyNotes
/Python/codes/coin_charge.py
3,279
4.21875
4
import unittest """ Recursive time complexity:O(2*N) """ def coins_change(coin_values,money): min_count = money # Set money as changed by 1 as default if money in coin_values: # Define the boundary return 1 # The best situation is money equal to coin_values for value in [i for i in co...
c9449140635a3708480be2a209cf9e34b5e6e247
LucasLins/IntroducaoProgramacao
/TED01/Questão3.py
186
4.25
4
numero = float(input('Insira um valor: ')) if numero >= 1 : print('O número é positivo.') elif numero <= -1 : print('O número é negativo') else: print('0 é um número neutro')
603a99d9d34120b076cb5fcead8ce3b59cabd2c2
SkyAlumny/Python-Games
/red/red.py
3,084
3.53125
4
import random FONT_COLOUR = (255, 255, 255) WIDTH = 800 HEIGHT = 600 CENTRE_X = WIDTH / 2 CENTRE_Y = HEIGHT / 2 CENTRE = (CENTRE_X, CENTRE_Y) FINAL_LEVEL = 6 START_SPEED = 10 COLOURS = ["green", "blue"] game_over = False game_complete = False current_level = 1 stars = [] animations = [] def draw():...
de0bf24871b510ca4fa7b829477814f7096e36ee
Kippiii/CSE2050
/Project 3/fizzbuzz.py
488
3.875
4
"""Prints fizz, buzz, or fizzbuzz depending on divisibility of numbers.""" # Author: Ian Orzel, iorzel2019@my.fit.edu # Course: CSE 2050, Fall 2020 # Project: Fizz Buzz from sys import stdin, stdout x, y, n = map(int, stdin.readline().split()) for i in range(1, n+1): fizz = i % x == 0 buzz = i % y == 0 i...
278772c430cd27a09a5cc17544749b57a849deac
sockduct/CS262
/current.py
676
3.609375
4
import time def wrapper(s): start = time.clock() result = eval(s) runtime = time.clock()-start return result,runtime def fibo(n): if n<=2: return 1 else: return fibo(n-1)+fibo(n-2) def cacheproc(chart,f,n): # Best approach since must return chart[n] in either case if n not in char...
b18e8aacbc39d3f56e2869e55042751bc7923193
enotikk/homework
/дз к 24.01.17 Словари/zagadki.py
929
3.703125
4
def split_text(filename): f = open(filename, 'r', encoding='utf-8') words = [] s = f.read() a = s.split() for word in a: word = word.strip() word = word.lower() words.append(word.strip(',.!?"()-:;/\|“—”')) f.close() print(words) retur...
1f6442c3cb1078f332e2fc8003f8df8c26ba55d6
redcatone/random-minecraft-scripts
/mahou-tsukai/mahou-tsukai-greater-grail.py
2,119
4.03125
4
from itertools import combinations from collections import defaultdict import math def sum_of_product_combinations(num_list): total_dict = {} # Key containing final sum of the two products; Value containing three nested lists: 1st) product pair, 2nd) product 1 factors, 3rd) product 2 factors for i in range(1, ...
9c167fa366f6b3818764ddff2870e22193e801e9
Monoclinico/Project-Euler-Solutions
/euler_1.py
715
4.375
4
""" Se listarmos todos os números naturais abaixo de 10 que são múltiplos de 3 ou 5, obtemos 3, 5, 6 e 9. A soma desses múltiplos é 23. Encontre a soma de todos os múltiplos de 3 ou 5 abaixo de 1000. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these m...
46fe072aa1950ae7504b307301e56c071313b877
uwnrg/minotaur
/snippets/camera_output_demo.py
577
3.625
4
import cv2 as cv2 import numpy as np # Create a video capture feed from first available video input vc = cv2.VideoCapture(1) # Create OpenCV window to show output cv2.namedWindow("Camera Feed - Press ESC to Exit") while (True): key = cv2.waitKey(1) if key == 27: # exit on ESC break # Read a f...
c4ad1a341a22fe822b553b7fa70f62168f5c6e76
San1357/Leetcode-March-Challenge2021
/3Sum_With_Multiplicity.Py
1,460
3.53125
4
'''Problem : 3Sum With Multiplicity ''' #CODE : MOD = 10 ** 9 + 7 class Solution: def threeSumMulti(self, A: List[int], target: int) -> int: """ Adapted from 3 sum 3 pointers O(N + K^2) j, k scan each element once """ counter = defaultdict(int) for a in A: ...
8c7de58be18e8f0ae60fc262904bc66e11ae4ea6
pranav-kural/Python-Practice
/str_find_bob.py
977
4.21875
4
""" Assume s is a string of lower case characters. Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print Algorithm: 1 - s is lower case string 2 - check characters in sets of 3, starting from beginning of string s, and compa...
6e81a6735db532a863ef35bac36b897e6be0e321
nishants17/Python3
/main.py
1,319
3.8125
4
#import User_input import Lottery_winner import dictionaries import Lists.lists import tuple import sets row_number = 235 result = row_number % 2 print(result) x = 15 // 2 # Floor division print(x) var1,var2= 10,10 print(str(var1)+' '+str(var2)) my_string = "Hello, world!" print(my_string) """ This is a multi...
2c52c45fc4898597dfa4cc9d3ced35fb55ccf79b
algoORgoal/ICPC-Training
/Baekjoon/num_5639_별찬.py
2,470
3.765625
4
# name: Binary Search Tree # date: July 20, 2020 # status: solved import sys sys.setrecursionlimit(10 ** 4 * 2) class Node: def __init__(self, key, left=None, right=None): self.key = key self.left = None self.right = None class Tree: def __init__(self, root=None): self.root ...
f63b5ca42944288014bd5672af88cf629760ba9d
0xrutvij/MLfinalProject
/5_models/NeuralNet.py
8,975
3.796875
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.metrics import mean_squared_error import math import sys import numpy_ml # Create the neural network class class neuralNetwork: # Constructor method with instance variables def __init__(self, input, output,numOfHidde...
67ad44368255b4b7b91034f424a7a598a1e586de
ZVR999/ZVR999.github.io
/Python_Practice/Practice.py
1,218
4.1875
4
##Print Stuff print("Hello world") #Create a tuple x = (5, 6, 'cupcakes', 'frosting') print(x[2]) print(len(x)) #Create a list y = [5, 6, 'cupcakes', 'frosting'] print(y[3]) print(len(y)) y.append("Last Value") y.insert(0,"First Value") y.insert(3,"Forth Value") print(y) #Remove value in 3rd index position y.po...
dd6516ff5ea0d8be4007aebbf929e4fc7230c60a
esmanur/programlama1
/while/3.soru_sayi.py
223
4.03125
4
sayi=' ' kalan=0 while(sayi!=0): sayi = int(input("Bir sayi girin: ")) if sayi == 0: break kalan += (sayi%3) print ("0 girene kadar girdiğim sayıların 3'e bölümünden kalanların toplamı=",kalan)
7b9bde6f263b5e1282ea850808afbf011244d2ed
andrabogildea/cci
/ch4/1.py
1,442
3.53125
4
class Solution: def isBalanced(self, tree, cache={}): if tree is None: return True if abs(self.height(tree.left) - self.height(tree.right)) > 1: return False return self.isBalanced(tree.left) and self.isBalanced(tree.right) def height(self, tree): if tree...
70cec17bc62b38dbe8c1801bfc6dc7b938f5488e
ramangugnani/python-ds
/14-LongestCommonPrefix.py
1,068
3.640625
4
from typing import List # https://leetcode.com/problems/longest-common-prefix/ class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: if len(strs) == 0: return "" else: result = "" for i in range(0,len(strs[0])): alphabect = strs[...
3d5c1b12ff9e7e1956559ef6f95fc38c83246cef
vishrutkmr7/DailyPracticeProblemsDIP
/2023/04 April/db04012023.py
1,076
3.90625
4
""" You are given a list of intervals as a two dimensional matrix. Each interval contains two values, first a start time and second an end time. An interval [a, b] is “covered” by another interval [c, d] if and only if c <= a and b <= d. Given these intervals, return the count of intervals that are not covered by any o...
f31021cffa34b7ad732a2b45fc4260f0deaf2d03
melank/atCoder
/abc153/d/main.py
216
3.59375
4
h = int(input()) cnt = 1 def battle(n): global cnt if n == 1: print(cnt) exit() else: n //= 2 cnt *= 2 cnt += 1 # print(n, cnt) battle(n) battle(h)
9cd1c35a4394ccbcd508cd00d1dec5c4166011f7
betty29/code-1
/recipes/Python/578042_Restricted_dictionary/recipe-578042.py
3,523
4.09375
4
class RestrictedDict(dict): """ Stores the properties of an object. It's a dictionary that's restricted to a tuple of allowed keys. Any attempt to set an invalid key raises an error. >>> p = RestrictedDict(('x','y')) >>> print p RestrictedDict(('x', 'y'), {}) >>> p['x'] = 1 >>> ...
a963028ff399b18d2ccc84747afc03bcf31af0cf
m1ghtfr3e/Competitive-Programming
/Codewars/Python/nthtermSeries.py
303
3.890625
4
# sum of the nth term series # Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +... def series_sum(n): if n <= 1: return '%.2f' %n div = 4 s = 1 for _ in range(n-1): s += 1/div div += 3 return '%.2f' %s if __name__ == '__main__': print(series_sum(0))
6ac9cb8eca665559f942fe7add4a58aa43b51b05
FreshTaker/PythonChallenge
/02_challenge.py
1,227
3.5
4
# Problem 2: Decode rawString = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj." print(ord('a')) print(ord('z')) print(chr(ord('z')+4)) def moveForwardTwo(lette...
95adbc8ba06792c09b0b39e0c8765a3a9700fba8
vzDevelopment/text_statistics
/example.py
1,051
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ A simple script demonstrating how to use the text_statistics module. Usage: ./example $text_file """ import argparse import text_statistics arg_parser = argparse.ArgumentParser('Produce statistics on a text file.') arg_parser.add_argument( 'file', type=str, ...
4f61f49e6d4942fd3cdb84d68ba6bd8b8863dd9f
shayanng/OOP-Python3
/oop1.py
939
4.0625
4
#Employee class Credit to: Corey Schafer Youtube Channel ~~ class Employee: num_of_emps = 0 raise_amount = 1.035 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + "." + last + "@dreamber.com" ...
46dd63921912b118cf485a4b2836ba031febf164
umeshP2412/pythonPrograms
/decoreator_Example.py
1,009
4.53125
5
# -*- coding: utf-8 -*- """ Created on Fri Jun 5 21:33:17 2020 @author: LENOVO """ ''' Decorators can be called modifiers also Suppose you have written a program and made many functions But now you/someone :) wants a bit change (same for every func.) in every function then will you go to modify every function one b...
0dd9235ca0a01600ed7d7010159c3e8ea812b7a8
KfirWilfand/Bootcamp
/week9/ex2.py
429
3.8125
4
def find_max(list,index): if index == len(list): return 0 nextItem = find_max(list, index + 1) return nextItem if nextItem > list[index] else list[index] assert(find_max([1, 2, 3], 0) == 3) assert(find_max([100, 2, 100], 0) == 100) assert(find_max([], 0) == 0) # what is your return value for empty l...
30c2214cba3f284dba61d219d3385394e8460061
manjunath2019/Python_7am_May_2019
/OOPS/Class_Object_init_self.py
643
3.953125
4
class Human: def __init__(self, n, o): # Constructors self.name = n # Properties of Human Class self.occupation = o # Properties of Human Class def do_work(self): # Method of Class if self.occupation == "singer": print(self.name,"is a Singer") ...
3a166680a4ed55d9a2661028a74dc38a3f3b3fa8
nitishkr72/crypto
/Fast-Modular-Exponentiation.py
1,810
4.5
4
''' Using repeated Squaring modulo to calculate modular exponentiation function uses: CalcSmallExpo(memo, A, B, C) it will do all smaller modular exponentiation get2PowerN(B) it is a helper function to calculate B in form of sum of power of 2's ...
2868864ba9a9cad8cb34493216e5b9d00559b3fc
tennessysherry/ds2
/DataScienceProject/part2/FlowerPredictor.py
2,226
3.9375
4
# Supervised and unsupervised learning in ML # Supervised - Classification, Regression # Unsupervised - Clustering of Data import pandas import matplotlib.pyplot as plt import sklearn dataframe = pandas.read_csv('https://modcom.co.ke/data/datasets/iris.csv') print(dataframe) # cleaning. # Step 1: split data into featu...
dbcb416f7c952d0b2e46d0bef9792273d34a39ea
adityakpranav/codehub
/contact_search/Trie.py
1,545
3.84375
4
class Trie: def __init__(self): self.trie = {} def insert(self, word: str) -> None: word = word + "$" self.addToTrie(word,self.trie) def search(self, word: str) -> bool: word = word + "$" return (True if self.findInTrie(word,self.trie)>0 and self.len==1 else...
9dce3bd10e887f146c02536a5fa6fa98c850b568
calazans10/algorithms.py
/basic/break.py
171
3.828125
4
# -*- coding: utf-8 -*- while True: s = input('Entre com alguma coisa: ') if s == 'sair': break print('Tamanho da string é', len(s)) print('Feito')
1bab0a7822fa43bee390e64b6eaedcc3bec59c86
aaakashkumar/competitive_programming
/leetcode/two-sum.py
1,008
3.78125
4
# https://leetcode.com/problems/two-sum/ # @author Akash Kumar from typing import List class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: """ :param nums: A list of integers :param target: The target to sum up to :return: A list of integers, representing t...
c2e4fa36c9d772ef7cf3d21fc60ba5d92481735f
luisvmpcl/PYTHON3
/funciones_lista.py
1,826
4.40625
4
#17 """ lista = [1,2,3,4,5,6,7,8,9,10] tupla =("Hola", "Luisvmpcl", "Instagram") lista_to_tupla = tuple(lista) #convertir una lista en tupla #palabra reservada tupla_to_list = list(tupla) # convierte una tupla en lista # palabra reservada list print(lista_to_tupla) # al momento de imprmir nos deberia imprimir ...
8812bfd65b5ffc94866aaba86b442ba07831f8f1
Kupriienko/Praktychni_Python_C-
/Praktychna2/PTask1.py
695
3.734375
4
''' Дано список чисел. Порахувати скільки в ньому пар чисел (тобто два однакових числа утворюють пару) . Наприклад: 1 2 3 5 3 2 Результат має бути: 2 ''' def count(l, numb): c = 0 for i in l: if i == numb: c += 1 return c l_numb = [3, 4, 4, 4, 3, 3, 2, 1, 5, 7, 7, 4, 4, 4] rez = {} f...
dd0cabbcaf78f8e42aaa0725c5bc585c4a66e502
bacasable34/formation-python-scripts-exemples
/is_what.py
1,353
3.9375
4
#! /usr/bin/env python3 # # is_what.py - Mickaël Seror # Détermine et affiche la composition du mot saisi par l'utilisateur # si ce mot contient des lettres, on veut savoir si il y a # uniquement des lettres, uniquement des minuscules, et uniquement des majuscules # et si ce mot contient des chiffres on veut savoir s'i...
2e2cec1d3a9c4458c3b5577ccc3ecc0e9568cccf
darthc9/mini_challenges
/AoC/2018/day3/day_three.py
5,169
3.796875
4
""" Advent of code 2018 - python coding contest challenge for day 3 - https://adventofcode.com/2018/day/3 The problem outline: ------------------------------- Each Elf has made a claim about which area of fabric would be ideal for Santa's suit. All claims have an ID and consist of a single rectangle with edges paral...
588ca4b529f68133d0d1e1565b4e122e31cbf7df
b166erbot/300_ideias_para_programar
/soma_das_idades2.2.7.py
247
3.953125
4
def fatorial(n): if n <= 0: return n return n + fatorial(n-1) def main(): soma = fatorial(int(input('Idade: '))) print(f'a soma de todas as idades que você já teve é de {soma}') if __name__ == '__main__': main()
fc143f75cf201ad2690c2f0ba528698ae3686108
AlyoshaS/codes
/startingPoint/Inicial/00.py
202
4.03125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Faça um programa que leia um número inteiro e o imprima: def main (): numero = int(input("Digite um número: ")) print (numero) main()
7796faa1c84cf9a4e33b7ab24cca9c9cd1ba0caf
davidbriddock/rpi
/learn-python/MicroMartSeries/guess.py
953
4.125
4
# A number guessing game # Created by David - July 2012 import random # generate a random number between 1 and 20 def generate_number(): return random.randint(1, 20) # try to guess the number def guess_number(number): guessCount = 0 # start at zero # allow up to five attempts while guessCount < ...
883df74110871808709c2c0f512975870c1f831e
sifei/CodingPractice
/Longest_Consecutive_Sequence.py
433
3.71875
4
def main(nums): dic = {} for num in nums: dic[num] = 1 longest = 0 for key in dic.keys(): length = 1 up = key+1 while up in nums: length += 1 dic.pop(up,None) up += 1 down = key-1 while down in nums: length += ...
db5f948ae890ff3f3df3656b9d16ef8d557cee4c
ppakorn/dotaIsDown
/Codewars/6kyu/equals_side_of_array.py
356
3.65625
4
def find_even_index(arr): sum_ = 0 left = [] for i in arr: left.append(sum_) sum_ += i sum_ = 0 l = len(arr) right = [None] * l for i, v in enumerate(reversed(arr)): right[l - i - 1] = sum_ sum_ += v for i in range(0, l): if left[i] == right[i]: ...
f32d77d843173eae873e1e33ad94409a442eb8fd
nervylof/GloAcademy_python
/Урок 3/Задание4.py
200
3.96875
4
melon = int(input()) if (2 < melon < 100) / 2: print('Ребятам удастся поделить дыню!') else: print('Ребятам не удастся поделить дыню:(')
26d59f5467ef24da887228377fb014240b0500dd
mrech/LearnPython_TheHardWay
/ex40.py
867
4.03125
4
## Modules, Classes, and Objects # Modules Are Like Dictionaries mystuff = {'apple': "I AM APPLES!"} print(mystuff['apple']) # get X from Y # Common pattern in Python: # 1. Take a key=value style container # 2. Get something out of it by the key's name # In the case of the dictionary, the key is a string a...
626324194251bd743fb8c1227e4a4d7726a1b27e
GH-Edifire/GH-JK-practice-problems
/LeetCode/Python3/Problem 1.py
1,129
3.6875
4
# LeetCode: Problem 1 # Jonathan Kosasih #Given an array of integers, return indices of the two numbers such that they add up to a specific target. #You may assume that each input would have exactly one solution, and you may not use the same element twice. #Example: #Given nums = [2, 7, 11, 15], target = 9, #Because...
f4f7e0b67c8f3ed4167ba6445205a4bce9af7030
ziyang-zh/pythonds
/04_Recursion/04_14_Jar.py
446
3.53125
4
class Jar: def __init__(self,label,v): self.label=label self.v=v self.current=0 def __str__(self): return "jar "+self.label+": ("+str(self.current)+" / "+str(self.v)+")" def addFull(self): addv=self.v-self.current self.current=self.v return addv def pullAll(self): pullv=self.current self.curren...
61fc2089df4bf5cc72e6bae0f55b578fb9b32536
stavanmehta/leetcode
/educative_dot_io/two_pointers_pattern/squaring_a_sorted_array.py
1,126
4.15625
4
""" Problem Statement Given a sorted array, create a new array containing squares of all the number of the input array in the sorted order. Example 1: Input: [-2, -1, 0, 2, 3] Output: [0, 1, 4, 4, 9] Example 2: Input: [-3, -1, 0, 1, 2] Output: [0 1 1 4 9] """ def make_squares(arr): squares ...
53bfbf1528e1fa89e8b098bb87c663e009297325
harshrajm/Python-Algo-DS
/05 LinkedList/LLnthToLastNode.py
989
3.78125
4
class Node: def __init__(self,value): self.value = value self.next =None a = Node(1) b = Node(2) c = Node(3) d = Node(4) e = Node(5) a.next = b b.next = c c.next = d d.next = e def nth_to_last_node(num,head): current = head count = 0 while current: ...
666ad250597f95364a0e36a16ea4e5e61de17166
LisaAlverson/BIOL5153
/nucleotide_composition.py
1,238
3.78125
4
#! /usr/bin/env python3 # set the name of DNA sequence file filename = 'dna.txt' #open the input file infile = open(filename, 'r') # read the file dna_sequence = infile.read() dna_sequence = dna_sequence.rstrip() #print(dna_sequence) # close the file infile.close() #print(dna_sequence) # print DNA sequence length ...
1720eb73178f121f45f74164960a7209947c7f78
Anap123/python-repo
/roteiro5/PedraPapelTesoura.py
1,156
3.609375
4
# Miguel e Maria Rita # Pedra= 1, Papel= 2, Tesoura = 3 # Jogador 1 venceu: 1, jogador 2 venceu: 2, empate: 0 def pedraPapelTesoura(j1, j2): res = 0 if j1 == j2: res = 0 elif j1 == "pedra": if j2 == "tesoura": res = 1 elif j2 == "papel": res = 2 elif j1 ==...
4a3818c4b1c3f9721a4992398e1f3a552f3c3bbf
Niranjan-Ananth/DS-and-Algorithms
/CLRS/Chapter2/linear_search.py
1,314
3.84375
4
import time from utils.array_generator import sorted_array_generator, random_number_generator def linear_search(arr, key): if arr is None: return None for i in range(0, len(arr)): if arr[i] == key: return i return None def test_linear_search_performance(): print("Starting ...
3c4f4279850d8e2f0bb240fa3c2703b54f2796bc
simiss98/PythonCourse
/UNIT_1/Module1.2/MOD01_1-2.2_Intro_Python.py
1,583
4.21875
4
#creating name variable name = "Petras" # string addition print("Hello " + name + "!") # comma separation formatting print("Hello to",name,"who is from Vilnius.") print("Hello to","Petras","who is from Vilnius.") # [ ] use a print() function with comma separation to combine 2 numbers and 2 strings print("I was born at...
70bc1f7c81cac160c51948e32aa1a276bcf03d24
mendes-davi/MN
/mn/rev/secante.py
472
3.75
4
from scipy.optimize import minimize import numpy as np def g(x): return x**4 - 10*x**3 + 8*x # Código com erro e crashado devido a entrada proposta do problema e fabio é foda x0 = float(input("a: ")) x1 = float(input("b: ")) xa, xb = x0, x1 ga, gb = g(x0), g(x1) for i in range(0,8): xc = (xa * gb - xb * ga)...
704663b3601c533306b65ce5e3648152bd524863
mavb86/ejercicios-python
/seccion4/if/ejercicio13.py
706
3.890625
4
# Ejercicio 13 # # Escribe un programa que pida una fecha (día, mes y año) y diga si es correcta. dia = int(input("Introduzca el dia: ")) mes = int(input("Introduzca el mes: ")) year = int(input("Introduzca el año: ")) dias_del_mes = 0 if mes == 1 or mes == 3 or mes == 5 or mes == 7 or mes == 8 or mes == 10 or mes =...
7fe9a757048fba414668f7ed4f9ad7fb5fc45182
Jesusml1/150_python_challenge
/09_Tuples_Lists_and_Dictionaries/Problema_072.py
246
3.90625
4
school_list = ["P.E.", "Math", "Biology", "Physics", "Social studies", "Chemistry"] print(school_list) subject = str(input("Which of this you want to get rid of?\n")) school_list.remove(subject) print("There you have it.") print(school_list)
cbe8a292d4eb05c07111bbb76bc0eeaf5112127b
cgcaruzo/frro-soporte-2019-10
/practico_02/ejercicio_06.py
1,020
3.859375
4
# Implementar la clase Persona con un constructor donde reciba una fecha de nacimiento. # La clase además debe contener un método edad, que no recibe nada y devuelva la edad de la # persona (entero). # Para obtener la fecha actual, usar el método de clase "now" de la clase datetime (ya importada). from datetime import...
6fff365327613f69d8af4209cb261a3baae8055f
vrthra/xchains_json
/parsers/python_json_3_7_4/TestJSONParsing.py
2,219
3.875
4
#!/usr/bin/env python3 # coding: utf-8 # wrapper for Python JSON parser COMPLETE = 0 INCOMPLETE = 1 WRONG = 2 import json def validate(input_str): """ return: rv: "complete", "incomplete" or "wrong", n: the index of the character -1 if not applicable c: the character where error happened...