blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
396aff6eaa9b511376eecfa032ddf45281f65548
LeoManzini/CS50-2020
/Pset6/DNA/dna.py
1,275
3.796875
4
from csv import reader, DictReader from sys import argv, exit if len(argv) != 3: print("Usage: python dna.py data.csv sequence.txt") exit(1) with open(argv[2]) as csv_file: csv_reader = reader(csv_file) for row in csv_reader: line_count = row dna = line_count[0] count = {} wit...
d6b1cbf8a5fe6fc205f28eafd4f0dec33975818d
DanielDavid48/Exercicios-PY
/ex50.py
240
3.6875
4
lista = [] for x in range(1, 7): n = int(input(f'Insira o {x}° valor: ')) if n % 2 == 0: lista.append(n) soma = 0 for i in range(len(lista)): soma += lista[i] print('') print(f'A soma dos valores é {soma}')
6f0edbc2aa8be009ac6d42ed35d3235195ca890d
Software-Cat/PythonMiniProjects
/Knots and Crosses/blockwinai.py
2,775
3.5625
4
import random def best_spot(grid, playerTurn, computerTurn): emptySpots = [] for x in range(3): for y in range(3): if grid[x][y] == '': emptySpots.append([x, y]) if [0, 0] in emptySpots: if grid[1][0] == playerTurn and grid[2][0] == playerTurn: r...
fd5e3c456d15f8002d47abbab116479006dbfb20
ButterflyBug/Exercise-files
/gra_w_wojne.py
2,097
3.5625
4
# jeżeli obaj gracze mają taką samą kartę, # to karty te wracają do graczy na dół ich talii. import random ''' aCard = {"Figure":"King", "Power":12} print(aCard) print(aCard["Figure"]) print(aCard["Power"]) aCard['Color'] = 'Heart' print(aCard) ''' colors = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] figures = [ ...
ddf420405028668bd9e6adb7a88158c3f1b1d064
DheerajJoshi/Python-tribble
/PythonString/src/isnumeric.py
109
3.578125
4
#!/usr/bin/python str1 = u"this2009"; print (str1.isnumeric()); str1 = u"23443434"; print (str1.isnumeric());
1b5e6595271adb23d2b07b3e49b4c3667edd6986
champs/LRUcache
/lru.py
2,916
3.75
4
""" LRU = least recently used cache - cache = key/value pair - linked list = left is the newest - indext_hash = point from key to every node to look up N(1) """ class Node: def __init__(self, key, next=None, prev=None): self.key = key self.next = next self.prev = prev def _...
800446b88c50b7e2cbbff405a8745621ab763512
suraj0803/MachineLearning
/MACHINE LEARNING/7.DecisionTree/DecisionTreeImplementation.py
1,336
3.609375
4
import pandas as pd import sklearn from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import classification_report,confusion_matrix,accuracy_score names = ['pregnant','glucose','bp','skin','insulin','bmi','pedigree','age','label'] data = ...
ae2ec782869391b1c25a4af6b7618da478b5bc58
jleemur/Advent-Of-Code
/2019/5.py
912
3.796875
4
import copy ADD = 1 MULTIPLY = 2 INPUT = 3 OUTPUT = 4 HALT = 99 def part_one(intcode_in): intcode = copy.deepcopy(intcode_in) # do not modify original # for i in range(0, len(intcode), 4): # opcode = intcode[i] # pos_val1 = intcode[i+1] # pos_val2 = intcode[i+2] # pos_outpu...
67172bc40ff5d4fed5a0faa7ce31a736ff6f281a
mag389/holbertonschool-machine_learning
/math/0x00-linear_algebra/5-across_the_planes.py
757
4.25
4
#!/usr/bin/env python3 """ add matrix by element""" def add_matrices2D(mat1, mat2): """adds the elements for two matrices, assume same type """ if len(mat1) != len(mat2) or len(mat1[0]) != len(mat2[0]): return None if matrix_shape(mat1) != matrix_shape(mat2): return None newmat = [...
c9231c675a2291c8bca822ef617aa753793cf5ef
anshumanmor/Tutored-work
/Classes and Objects.py
493
3.75
4
#Classes and Objects #Sit with end user first and figure out what the purpose of the program is #This creates a bank account object class BankAccount: def_init_(self, name, accNo, balance): self.name=name self.accNo=accNo self.balance=balance def deposit(self, amount): self.balance=self.balance+amo...
06e17b7872ec5027d960c0fdcfe68ad7a20c24e1
lolzao/aprendendoPython
/desafioCondicoes01.py
1,934
4.21875
4
''' 28 - Computador vai pensar em um número inteiro de 0 a 5 e pedir pro usuário tentar descobrir qual o número escolhido e o programa fala se o usuário venceu ou perdeu. dica: escolher numero aleatório da lista(pensar) ''' import random from time import sleep n = [0, 1, 2, 3, 4, 5] pc = random.choice(n) print(f'Pense...
31e9235976368e259108d2e240b29bf605442737
caleb-kahan/silverLining
/draw.py
1,163
3.875
4
from display import * def draw_line( x0, y0, x1, y1, screen, color ): #Always draw left from right if x1-x0<0: x0,y0,x1,y1=x1,y1,x0,y0 x0,y0,x1,y1=round(x0),round(y0),round(x1),round(y1) A = y1-y0 B = -(x1-x0) x = x0 y = y0 if(B==0): QuadVersionY(x,y,y1,A,B,s...
cb01c5cf0e577c56df3c6f1e67c6f45226343a12
Igglyboo/Project-Euler
/1-99/30-39/Problem33.py
1,288
3.5625
4
from time import clock from decimal import Decimal def timer(function): def wrapper(*args, **kwargs): start = clock() print(function(*args, **kwargs)) print("Solution took: %f seconds." % (clock() - start)) return wrapper @timer def find_answer(): product = 1 for num in rang...
24d9cb7e84ee7bb9ceac67e7d4f4deccbef5c96f
finderkiller/CrackingCodeInt
/ch8/8-8.py
737
3.625
4
#! /usr/bin/python3 import sys def buildFreqTable(string): table = {} for value in string: if value not in table: table[value] = 1 else: table[value] += 1 return table def getPer(hashmap, prefix, remainder, result): if (remainder == 0): result.append(pre...
878429e85cf77fb00bc28989c75f98d4517852ac
luis-martinez/Coursera-Programming-for-Everybody-Python
/Assignments/assignment-9-4.py
1,113
3.84375
4
# 9.4 Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a co...
e9aab90093d4c82ba94b1e19c8ee3e94db2acb72
antondelchev/Python-Basics
/Nested-Loops---More-Exercises/05. Challenge the Wedding.py
274
3.734375
4
men_total = int(input()) women_total = int(input()) tables_total = int(input()) counter = 1 for i in range(1, men_total + 1): for j in range(1, women_total + 1): if counter <= tables_total: print(f"({i} <-> {j})", end=" ") counter += 1
8d123566ae3030f5759cd47243256b34b40590c1
Brancorpse/python-game
/UnitTest.py
1,283
3.875
4
""" UnitTest class first imports unittest module then imports PandasToList class """ import unittest from PandasToList import PandasToList class UnitTest(unittest.TestCase): """ The UnitTest class runs two unit test on the PandasToList class """ def test_upright_deck_list(self): """ ...
789b78c95c5d5027f5274a4599b026329f3d164a
kacl780tr/carnd_project_05
/code/display.py
2,506
3.5
4
import matplotlib.pyplot as plt def display_images(lefthand, righthand, titles=(None, None), asgray=(False, False)): """ Display two images side-by-side param: lefthand: the left-hand image param: righthand: the right-hand image param: titles: 2-tuple of string image titles param: asgray: 2-tuple of bo...
d437f2be8bab2ce455aa21e6a390cadf4fc2d7e5
Nandan093/Python
/All String methods.py
4,996
4.28125
4
#Capitalize() ( Converts the first character to upper case ) a = "nandan" print(a.capitalize()) #casefold() (Converts string into lower case) a = "NANDAN" print(a.casefold()) #center() (Returns centered string, it will make thr string to center of the length given in()) a = "Nandan" print(a....
5521fd8c3b8fcc22827a8829dd937223aa068133
aschiedermeier/Python_Crash_course
/6_2_Nested_Dictionaries.py
1,877
4.1875
4
########################################### # Book "Python Crash course" - Eric Matthes # Chapter 6: dictionaries ########################################### # nested dictionary # friends dictionary # every friend is dictionary # some values can be list # using excel function to created nested dictionary "friends" # e...
05884683256711ec87ca96f304f6b067a70a3233
JohnShaw4/Python-Algorithms
/Q1.py
122
3.515625
4
lines = int(input()) words = [] for _ in range(lines): words.append(input()) for item in words: print(item)
ed2c50f9a30d9278407276a7529e4ff1b173ea19
bibekkakati/Python-Problems
/33-Reverse-Word-Order.py
348
4.21875
4
# Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to # the user the same string, except with the words in backwards order. userInput = input("Write something : ") def reverseSentence(): rev = userInput.split() rev.reverse() return " ".join(rev...
e90e795672cbbdc525321e694a7961dd26d7ee62
SraboniIbnatAddri/python-problem-solve
/leap year.py
273
4.09375
4
if __name__ == "__main__": year = input("Enter any year:") year = int(year) if year%4==0 and year%100!=0: print(year,"is leap year") elif year%100==0 and year%400==0: print(year,"is leap year") else: print(year,"not leap year")
5ee5eb42fbb45624105f6632abb4b55cdccc989a
ofirtal/alice_google_wordcount
/txt_word_counter.py
1,333
3.828125
4
from print_dict_results import PrintDictResults from wordcount import WordCounter import argparse class MainWordCounter: """ WordCounter takes a txt file and counts the app""" def __init__(self, filename, results_to_return): self.results = results_to_return self.sorted_dict_of_words = WordCoun...
33110a6df4e4a37dd4a9976e39979024f8e2ceda
petef4/payg
/grader.py
8,337
3.796875
4
import re class Grader: def __init__(self, grading): self.grading = grading def grade(self, data): """Amend data with scores, keys (for sorting columns) and grades. Scores are determined for most columns. Sort keys start with the column score but then may draw on other column...
079621294e5bde7acb17340e79709101eba1e7b1
xujackie1993/TheAlgorithms
/Stack/20valid_parentheses.py
1,363
3.71875
4
# -*- coding=utf-8 -*- #[20] 有效的括号 # 栈 后进先出 # 配对 消除 class Solution(object): def is_valid(self, s): """ :type s: str :rtype: bool """ if not s or len(s) == 0: return True if len(s) % 2 == 1: return False t = [] for c ...
9fae49bba5bbe6024fe625376f8a7cd0eb573054
oceaninit/CodeSlice
/algorithm/Swap_Nodes_in_Pairs.py
1,204
3.78125
4
""" Swap Nodes in Pairs Total Accepted: 14822 Total Submissions: 46443 My Submissions Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the lis...
d3b320f24919c14ded0417eeba56312153db4c43
DRoss56/MyFirstRepo
/guesswordDR.py
1,063
4.0625
4
import random words = ["intricate","i cup","innovitation","vsauce"] hint1 = ["The best word","if apple made a cup","the future, what drives the world","hey ______ Michael here"] hint2 = ["I always love to say it ","what you see with and what you drink out of","flows like a river","A great source of spit facts"...
dda2766deafcd9aa4024c002cae8fc8bd99254b8
UCL15050994/AMLSassignment
/preprocess_noise_color.py
3,128
3.59375
4
""" ELEC0132: Applied Machine Learning Systems Student Number: 15050994 This is the module used for removing the noise/outliers (mostly corresponding to nature images) from the original celebsa dataset before any further preprocessing/classification is carried out. In this module, the images are NOT grayscaled. Refer ...
d824e7fecafaa8e2c03c97833e81b66b53e82777
edoric/test
/checkCalc.py
289
3.796875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- def calc(val): v = int(val) if v < 20 : price = 800 else : price = 750 sm = v * price print 'summary : ', sm if __name__ == '__main__' : print 'Enter number : ', val = raw_input() calc(val)
70f09332170209610366b32f51a438b1583cc7f3
kelly-olsson/Horror-Movie-Escape
/test_light_attack.py
1,577
3.578125
4
""" Name: Kelly Olsson & Hannah Kuo Student number: A01030513 & A01068509 Date: March 27, 2021 """ from unittest import TestCase import unittest.mock import io import game class Test(TestCase): @unittest.mock.patch("sys.stdout", new_callable=io.StringIO) def test_light_print_messages(self, mo...
162f361ed3ce82b5e1e2c20669d824b69723f1b0
arthurxuwei/Study
/coding/python/basic/funcprogram.py
508
3.78125
4
def outer(): i = 10 def inner(): return i return inner print outer()() def outer(): i = 10 return (lambda : i) print outer()() print map(lambda x : x**2, [1,2,3,4,5,6]) print map(lambda x,y: x + y, [1,2,3], [4,5,6]) print map(None, [1,2,3], [1,2,3]) #equal print zip([1,2,3], [1,2,3]) print filter(lam...
906717b3dbcdab2219383cb106a2a9c99ece6bad
FlorianLudwig/learn-python
/human-interpreter/00-hello-world/for.py
230
4.0625
4
print('00/for.py') for char in ['a', 'b', 'c']: print(char) # for i, char in enumerate(['a', 'b', 'c']): # print(char) text = 'hello' for char in text: print(char) for i in range(3): print(i) print(text[i])
b64dc45b1736aa92063d2e31f05e9f03407ee2c6
CharlieWeld/OOP
/Lab 4/Q4_Q5_compound_interest_class.py
5,201
4.15625
4
#Calculate the average of three numbers #Create a class to encapsulate the banking functions class Banking(): """ Calculates simple and compound interest """ def __init__(self, principle=0, rate=0, years=0, periods=0): #Create instance variables self.principle = principle self.rate = ra...
2e5b6c34f32e0cfb7e344ee8810463c4180fbbdd
kasaiee/Python-Exercise
/10. functions/simple functions/12/III.py
78
3.71875
4
def upper_count(text): return len([char for char in text if char.isupper()])
0664cf2bba7c7115054d3ced15fa36d0bddd5286
ayuratuputri/I-Gst-Ayu-Ratu-Putri-M_I0320049_Andhika_Tugas-7
/I0320049_Soal 1.py
214
3.921875
4
str = "selamat pagi!" a = str.capitalize() print(a) b = str.count('a') c = str.count ('i') print("banyaknya huruf a= ", b) print("banyaknya huruf i= ", c) print(str.endswith("pagii")) print(str.endswith("pagi!"))
601ae896e48a816448bb15da2935d05046a015a7
folajimia/udacityProjects
/square.py
875
3.625
4
import turtle def draw_square(): #window = turtle.Screen() #window.bgcolor("white") draw=0 turtle.register_shape("C:\prank\poke.gif") brad=turtle.Turtle() brad.shape("C:\prank\poke.gif") brad.color("yellow") brad.speed(1) while draw < 4: brad.forward(100) brad.right(90) draw+=1 def create_background():...
a1c0968afe9a77535d3892037f83c6eb97e8f518
marcinpgit/Python_days
/day10/specjalne.py
596
3.875
4
# metody specjalne from ogloszenia import Ogloszenie o1 = Ogloszenie(2000, miejscowosc="Sopot") o2 = Ogloszenie(3000, miejscowosc="Gdańsk") print(o1) print(o2) suma = o1 + o2 print() print("Suma wynosi: ", suma) # jak zakomentuję del poniżej to też pokaże co na koniec pousuwał bo w pliku # oglos...
f8171f5a5741373f3e8ae276149bef4624f8948c
hellochmi/google-coursera
/week5_dynamic_programming1/3_edit_distance/edit_distance.py
2,150
3.5625
4
# Uses python3 """ def d(i,j,A,B): if d(i,j-1,s,t)+1 """ # A Dynamic Programming based Python program for edit # distance problem def edit_distance(s, t): m = len(s) n = len(t) # Create a table to store results of subproblems a = [[0 for x in range(n+1)] for x in range(m+1)] # Fill d[][] ...
a609b75173bb197fde44fef774bf33fe6d21737f
qeedquan/challenges
/edabit/making-a-box-2.0.py
1,753
3.984375
4
#!/usr/bin/env python """ This is based on Helen Yu's Making a Box challenge. This challenge is the same except that instead of an array of strings, your function should output a matrix of characters. Examples charBox(1) ➞ [ ["#"] ] charBox(4) ➞ [ ["#", "#", "#", "#"], ["#", " ", " ", "#"], ["#", " ", " ",...
0fdd4ddc08b7453f18c5e6849b3ea095f251c6ad
abronytska/leetcode_python
/560_Subarray_Sum_Equals_K.py
536
3.546875
4
def subarraySum(nums, k): result, current_sum, sums = 0, 0, {} for num in nums: sums[current_sum] = sums.get(current_sum, 0) + 1 current_sum += num if sums.get(current_sum - k): result += sums[current_sum - k] return result print(subarraySum([1, 2, 3, 4], 3)) # print(su...
c91846cbf4dbbb269b75cf800302a4b331ebac85
chetandeshmukh87/Voice-Assistant
/friday.py
3,993
3.625
4
import pyttsx3 import datetime import speech_recognition as sr import wikipedia import webbrowser import os from random import randint import pywhatkit # create a text-to-speech engine engine = pyttsx3.init('sapi5') engine.setProperty('volume', 1.0) # Getting available properties: engine has inbuilt voice...
19b15acec8b74648713af5973d92f3b408b716f7
nikipr1999/Python-Patterns
/ReversePyramid.py
330
3.78125
4
n=6 for i in range(n): for j in range(2*n): if(j>=i+1 and j<=(2*n-i-1)): print('*',end=' ') else: print(' ',end=' ') print() print() for i in range(n): for j in range(2*n): if(j>=i+1 and j<=(2*n-i-1)): if(j-i-1)%2==0: print('*',end=' ') else: print(' ',end=' ') else: print(' ',end=' '...
d5affb9a86a254033c9148f86b3e24f4345a02a4
Pratik3199/Python
/guessgame.py
389
3.890625
4
#Pratik guess_word="Pratik" guess="" guess_count=0 guess_limit=5 out_of_guesses=False while guess != guess_word and not(out_of_guesses): if guess_count < guess_limit: guess=input("Enter guess: ") guess_count+=1 else: out_of_guesses=True if out_of_guesses: ...
d6ec2ffffa2cf206e1aa317313660b87a77ea952
FoctoDev/Learning_Python_3
/zed_a_shaw/learn_python_3_the_hard_way_2019/ex39/ex39-1.py
3,591
3.53125
4
# словарь регионов regions = { 'Челябинская область': 'CL', 'Курганская область': 'KGN', 'Свердловская область': 'SVE', 'Республика Башкортостан': 'BS', 'Республика Татарстан': 'TA' } # словарь столиц регионов capital_сities = { 'CL': 'Челябинск', 'KGN': 'Курган', 'BS': 'Уфа', 'TA'...
125aa2b9800727d76dccfaf43e3cdbd1fb816b17
Arturou/Python-Exercises
/python_demos/function_exercises/level_two_two.py
581
4.40625
4
""" Description: Given a string, return a string where for every character in the original there are three characters """ def char_times_three(text): #We iterate through each character of our list and multiply it times 3 so we can have 3 times each character. result= [(x*3) for x in text] #Single line for is so ...
1ebec4840d8a68ce233277e73f64d10b9e920aa7
xuezy19826/study20200616
/basic/day06/02.py
1,167
3.90625
4
# -*- coding:utf-8 -*-# # -------------------------------------------------------------- # NAME: 02 # Description: 实现判断一个数是不是回文数 121 倒过来 是 121 所以是回文数 # Author: xuezy # Date: 2020/6/29 17:52 # -------------------------------------------------------------- def hws(num): """ 判断...
b0c2eaca0008555c2a4394ae7cd4bba9812684db
iqbal128855/OpML19-DNNPerfModeling
/ConstructPerfModel/Src/RandomSampling.py
2,246
3.8125
4
import random import numpy as np from operator import itemgetter class RandomSampling(object): """This class is used to implement different types of random sampling techniques """ def __init__(self,data,num): print ("Initialzing Random Sampling Class") self.data=data self.num=num ...
626aaad806b54338b653b6639268078092c68f3a
KingKerr/Interview-Prep
/Arrays/pivotIndex.py
1,373
4.15625
4
""" Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index. If no such index exists, we should return -1. If there are multi...
4754dc9031f10b0be60a5fb8dffe2dbf43e4c3c9
ashu-vyas-github/AndrewNg_MachineLearning_Coursera
/python/ex1_linear_regression_uni_multi/ex1.py
4,219
4.40625
4
# Machine Learning Online Class - Exercise 1: Linear Regression # Instructions # ------------ # # This file contains code that helps you get started on the # linear exercise. You will need to complete the following functions # in this exericse: # # warmup_exercise.py # plotData.m # computeCost.m # ...
af5c38aadbe57811ecebd1dccb92dd73a834192e
arronrose/offer-interview
/solution/10.py
1,183
3.53125
4
#!/usr/bin/env python # encoding: utf-8 """ 描述: 请实现一个函数,输入一个整数, 输出该数二进制表示中的1的个数。 例如把9表示成二进制1001, 有2位是1。如果输入9就输出2 思路: 把一个整数减去1, 再和原整数做与运算,可以把整数最右边的一个1变成0,有多少个1,便可以做多少次这样的操作 C++ 次思路没问题, Python 上问题(负数会出现死循环) """ def solution(n): count = 0 while n: count += 1 n &= (n -1) retu...
f8cb84011d46e2ce3def455c2200d0c2d3b80231
shreyjain1994/project-euler
/euler/29.py
311
3.671875
4
""" Problem 29: How many distinct terms are in the sequence generated by a^b for 2<=a<=100 and 2<=b<=100 """ def solve(): sequence = set() for a in range(2, 101): current = a for b in range(2, 101): current *= a sequence.add(current) return len(sequence)
218f9f8383775ccc5d96b9871d0571bce925db34
SouriCat/pygame
/11_Avancé __ Mise en abime des boucles _for et _while_ et récursives.py
1,144
3.71875
4
# L'indentation est ultra importante pour ne pas se perdre entre les 2 boucles tableau_chiffre = ["un", "sept", "huit", "deux", "quatre", "zero", "cinq", "six", "trois", "neuf"] tableau_a_2_niveau = [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]] i = 0 while tableau_chiffre[i] != "sept": ...
710695c701e7e9a72b75c9f776742284eb14956f
mingo-doer/AlgorithmQIUZHAO
/Week_02/课后作业/144 二叉树的前序遍历.py
1,443
3.75
4
# 给定一个二叉树,返回它的 前序 遍历。 # # 示例: # # 输入: [1,null,2,3] # 1 # \ # 2 # / # 3 # # 输出: [1,2,3] # # # 进阶: 递归算法很简单,你可以通过迭代算法完成吗? # Related Topics 栈 树 # 👍 314 👎 0 # leetcode submit region begin(Prohibit modification and deletion) # Definition for a binary tree node. class TreeNode: def __init__(sel...
86eaf957b8f010ed863b163e28cc3f4f092c2e8a
imjs90/Python_Exercises
/Even_Odd.py
175
4.40625
4
#Creating a function that Checks Whether a Number is Even or Odd def Even_Odd(a): if a % 2 == 1: return 'Odd' else: return 'Even' print(Even_Odd(5))
f6386009b11008d7955baff118b7cc8b32b26906
arjun-sarath/luminarpythonprograms
/files/wordcount1.py
325
3.59375
4
f = open("data", "r") dict1 = {} for lines in f: words = lines.rstrip().split(" ") # to remove next line character (\n) after each line and split each words and store it to words for word in words: if word not in dict1: dict1[word] = 1 else: dict1[word] += 1 print(di...
b4d2238bf805653d936bfea378b97dfe3c923a86
MrHamdulay/csc3-capstone
/examples/data/Assignment_9/srdpra001/question2.py
1,418
4.15625
4
''' Prashanth Sridharan SRDPRA001 Assignment 09 Question 02 ''' file_input = input("Enter the input filename:\n") #variable file_input asks the user for the input file name f = open (file_input,"r") #variable f opens the input file and reads it at this point intervals=f.read() #Variable intervals stores the f...
3cad2ac32b411da4dc38a3942c1161f9eb01a4e2
Anandkumarasamy/Python
/evennum_compri.py
387
4
4
def even_num(lis): eve_lis=[] odd_lis=[] mode=input("Enter the mode(even or odd):") if mode == 'even': for num in lis: if num%2==0: eve_lis.append(num) else: for num in lis: if num%2!=0: odd_lis.append(num) result=eve_lis or...
b84d248647ead18b66d3a468e18e93cde922b87e
ikinoti/password-locker
/run.py
6,840
3.953125
4
#!/usr/bin/env python3.8 from password import User, Credentials def create_newUser(username, password): ''' Method to create a new user ''' new_user = User(username, password) return new_user def save_user(user): ''' method to save user created by create newUser method ''' user.save_user() def sho...
4a66f4999dc1af01f4cd86e01e8cef6b3fe4a6ec
ninenine999/new
/test/learn/hello.py
1,041
4.0625
4
classmates = ['Michael', 'Bob', 'Tracy'] classmates.insert(1, 'wang') classmates.pop(-1) classmates[0]='xin' x =('1','2','3',['6','7']) x[3][0]='a' print(classmates,x) L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python', 'Ruby', 'PHP'], ['Adam', 'Bart', 'Lisa'] ] print(L[0][0]) print(L[1][1]) print...
569972d103c0d5be41df94ea535678946c5ce3b2
Fabrizio-Yucra/introprogramacion
/Practico_1/ejercicio 13.py
257
3.734375
4
valor = int(input("Ingrese un valor: ")) suma = 0 for termino in range(1, valor + 1): if termino % 2 == 0: i = -1 else: i = 1 operacion = i / (1 + 2 *(termino - 1)) suma = suma + operacion valor_pi = 4 * suma print(valor_pi)
acf5d30a8b7e832f81f3c743c8f165d125fcafa8
vivek-bharadwaj/Machine-Learning
/1. KNN/utils.py
14,378
4.3125
4
import numpy as np from knn import KNN ############################################################################ # DO NOT MODIFY ABOVE CODES ############################################################################ # TODO: implement F1 score def f1_score(real_labels, predicted_labels): """ Information...
5965f8606bef0e14283c0fe55d2e64195f52bcc4
tarv7/Trabalhos-da-faculdade-UESC
/Codecademy/Python/07 - Listas e Funções/07.2 - Batalha Naval/06 - Exibindo Esteticamente.py
179
3.640625
4
board = ["O"] * 5 for i in range(len(board)): board[i] = ["O"] * 5 def print_board(board): for linha in board: print " ".join(linha) print_board(board)
2e3430076b10bfa270155649f89ff8cbb509d514
pandey-ankur-au17/Python
/coding-challenges/week14/Q5.py
885
3.625
4
class Solution: def searchMatrix(self, matrix, target: int) -> bool: start = 0 end = len(matrix) if end == 0: return False while start < end: mid = (start + end) // 2 s = 0 e = len(matrix[mid]) ...
c88a23c3a5de5b3ec0959cfe06b905912dff9082
tavonga1/variables
/advanced if statements.py
281
4
4
#Tavonga Mudzana # #SelectionR&R_ number=int(input("please enter a number: ")) if number >= 20: print("number entered is too high") elif number < 0: print("number is too low") elif number<=20: print("number is within range")
b0a97efc50d3d838893b1ea798c676b1d8fd4f29
prayas2409/Machine_Learning_Python
/Week2/ListQ15.py
674
3.984375
4
flag: bool = True while flag: try: list1 = ['Red', 'yop', 'der', 'poy', 'op', 'edr'] print("l1 is ", list1) list2 = ['pop', 'poy', 'Red'] print('l2 is ', list2) list3 = [] for string in list1: # storing just the common elements in the list1 and list2 ...
ddfe5734ba8b82aae03f72d27b1e0002decff221
Himanshu03K/python3.10.0
/Basic Programming/looping/all_divisor.py
184
4
4
s=int(input("entre the number")) c=0 for i in range(1,s+1): if s%i==0: c=c+1 if c==2: print("Number is prime") else: print("Number is not prime")
534fc67d618b5b4af4bd318fb789c376a467dea4
weichungw/meishiTackling
/78_subsets/sol1.py
400
3.59375
4
class Solution: def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result= [[]] for n in nums: for r in range(len(result)): result.append(result[r]+[n]) return result if __name__ =="__main__": nums ...
f2c1d29ecac51ba97147c9688398f72a7b7e7261
adam-weiler/GA-Object-Oriented-Programming-Bank-Account
/exercise1.py
3,157
4.3125
4
class BankAccount: #A Bank Account class. def __init__(self, balance, interest_rate): #Every bank account has instance variables balance, and interest_rate. self.balance = balance self.interest_rate = interest_rate def __str__(self): #Returns a meaningful string that describes the instance. ...
8b71a106dcb6e8fb610975efb8ad7193036cff19
Lechatelia/python-learning
/project1/test.py
291
3.5625
4
import numpy as np array = np.arange(0, 20, 1) array = array.reshape([4, -1]) bb = array[[1,3,6]] print(bb) print('number of dim:', array.ndim) print('shape:', array.shape) print('size:', array.size) print(array) print(array[:, 2]) print(array[..., 2]) print(array[:array.shape[1], 2:])
c70f50b17a304977e0ec7ae1f35414f6683f07de
chriskok/MachineLearningMastery
/PythonLearning/dataframeExample.py
249
3.953125
4
#dataframe import numpy import pandas myarray = numpy.array([[1,2,3], [4,5,6]]) rownames = ['a','b'] colnames = ['one','two','three'] mydataframe = pandas.DataFrame(myarray, index=rownames, columns=colnames) print(mydataframe) print('hello world!')
adcefe1faecadcdc767a44d273c2a424c1e7f112
ljbradbury/python3
/Python Crash Course/Chapter 10 Files and Exceptions/write_message.py
188
3.5
4
''' Writing to an empty file: 'w' = Write 'r' = Read 'a' = Append ''' filename = "programming.txt" with open(filename, 'w') as file_object: file_object.write("I love programming")
574d56720fdea31430f24e075e94ac84e2ef0c1e
heshibo1994/leetcode-python-2
/131分割回文串.py
815
3.5625
4
# 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 # # 返回 s 所有可能的分割方案。 # # 示例: # # 输入: "aab" # 输出: # [ # ["aa","b"], # ["a","a","b"] # ] # class Solution: def partition(self, s): """ :type s: str :rtype: List[List[str]] """ ans =[] length = len(s) def dfs(start,l): ...
54e5de673da6738ab43fffb11f76ceca0d5b39db
KevinHaoranZhang/Leetcode
/Sequence/q1-q99/q10-q19/q17/q17.py
712
3.5
4
from queue import Queue class Solution: def letterCombinations(self, digits: str) -> List[str]: solution = [] if not len(digits): return solution phone = [ " ", " ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] q = Queue() q.put("") for char i...
b9f0921930b49100094b7da9be7505a4b9aa9386
dursk/lending-club-trading
/scanner/validators.py
427
3.5
4
import csv def validate_config(config): for key, value in config.iteritems(): assert isinstance(key, int) assert len(value) == 2 assert 'value' in value assert 'condition' in value assert hasattr(value['condition'], '__call__') def config_matches_csv(config, csv_file): ...
02f068c96db08cdef97fd03d98d3d299207a4d03
zoushiqing/python
/基础/数据结构.py
514
3.59375
4
''' list: append(x):把一个元素添加到列表的末尾 extend(L):通过添加指定列表的所有元素来扩充列表 insert(i,x):在指定元素插入一个元素 remove(x):删除列表中第一个为x的元素 pop():从列表的指定位置移除元素,并将其返回。如果没有指定索引,会返回最后一个元素。 clear():清除列表 index(x):返回第一个值为x元素的索引。 count(x):返回x在列表中出现的次数 sort():排序 reverse():倒排 copy():返回浅复制 '''
54680884a7d9f76d07e1c5d915f0d02bb62a0850
szsctt/AOC_2020
/D9/xmas.py
1,291
4.03125
4
#!/usr/bin/env python3 import pdb preamble_length = 25 def main(): nums = [] with open('input', 'r') as handle: for line in handle: if len(nums) < preamble_length: nums.append(int(line.strip())) continue if not valid_number(nums[-preamble_length:], int(line.strip())): print(f"number {line...
ed8751716f51d069409aa41608388a4364c92784
SbasGM/Python-Exercises
/Solutions/E06.S01/Solution-E06.S01.py
859
3.765625
4
# coding: utf-8 # # Solution: Exercise 6.S01 # In[16]: # Request user input percentage = input("Please enter the percentage of points achieved: ") # In[17]: # Convert the input into a number percentage = int(percentage) # In[18]: # Case 1: Student will receive grade A if((percentage >= 90)): print("The st...
eac0b6c91e981f9885f1368c2437540c267dbed1
Shisan-xd/testPy
/python_work/循环嵌套练习.py
361
3.859375
4
# 下雨就在家,不下雨就打伞出去 # 是否需要打伞 """ 1、将来要做判断的一句:天气和伞 2、判断是否能出门:下雨就在家 不下雨就出去 3、判断是否有伞;没伞 和 有伞 """ rain = int(input('请输入今天天气:')) umbrella = 0 if rain != 1: print('在家呆着吧') else: print('出去')
e6f9af3db1ae869a328dfad22ff98df597a95481
AakSin/CS-Practical-FIle
/Reference/Lab Reference/tuple/dictionaries/q22.py
434
3.640625
4
a=dict() n=int(input('Enter the number of customers')) i=1 while i<=n: b=input('Enter the name of the customer') c=input('Enter the items bought by the customer') d=float(input('Enter the cost of the items bought in dollars')) e=int(input('Enter their phone number')) a[b]=c,d,e i+=1 print('Name ...
4fb81e76921a45005e6f3bf4d7cff428d32c0ee0
SebastianGo50/LearningPython
/D27 Tkinter, args kwargs/main.py
1,037
3.984375
4
from tkinter import * def button_clicked(): miles_input_number = float(miles_input.get()) km_output = round((miles_input_number * 1.60934), 2) km_output_label.config(text=km_output) km_output_label.grid(column=2, row=1) window = Tk() window.title("My distance converter") window.minsize(width=400, he...
20fdd680a647f1608b5e4a6f849a0f26991fd4bb
syhewanglan/HC-TimeCounter-BackHand
/Tools/Timer.py
3,141
3.609375
4
from app import * import time import datetime def getCurrentSemester(): """ 查询当前的学期 @:return 这学期开始的那一天 """ this_year = datetime.date.today().year today = datetime.date.today() this_semester_start = "" if today <= datetime.date(this_year, 9, 1): if today <= datetime.date...
f834e3ea1f5b0d4cd854e88c1840db16475843dc
Rbeninche/vigenere_cypher
/vigenere.py
802
4.15625
4
from helpers import alphabet_position, rotate_character def encrypt(original_text, key): encrypted = [] starting_index = 0 for letter in original_text: rot = alphabet_position(key[starting_index]) if not letter.isalpha(): encrypted.append(letter) continue # ...
a130eee6c3621b4e5330c1ad5a2c54c339ff9e92
spathical/scripts
/python/dict.py
490
3.71875
4
def set_value(d, key): s = key.split(".") value = d[s[1]] for i in s[2:-1]: value = value[i] print value[s[-1]] value[s[-1]] = str(value[s[-1]]) def walk(d, root, t): ''' Walk the dict and stringify values ''' for k, v in d.items(): if type(v) == t: set_value(d, root + '.' + k) if ty...
1e6c8ea6ce080d02585aa4bfa219a1d7e4704af1
rileyworstell/PythonAlgoExpert
/selectionSort.py
265
3.828125
4
def selectionSort(array): for j in range(len(array)): for i in range(len(array)): if i < j: pass elif array[j] > array[i]: array[j], array[i] = array[i], array[j] return array
b5782c5194c6af2b44f0f603dd7787de9a6bc235
gong1209/my_python
/Loop/while_.py
281
3.9375
4
text = ["apple","apple","Finished","apple","apple", "while", "apple" , "apple","loop", "apple", "apple"] while "apple" in text : # 當text串列中含有apple字串時,迴圈就會一直執行 text.remove("apple") # 將text串列中的apple字串移除 print(text)
09f1f8f5741c04bbe09e60c709051d1c56cd6aa1
alexander-colaneri/python
/studies/curso_em_video/ex020-sorteando-uma-ordem-na-lista.py
813
3.875
4
from random import shuffle def ordenar_alunos(): ''' Ordem de apresentação de alunos.''' print('Ordem de apresentação de alunos:\n') alunos = [input('Estudante: ') for a in range(4)] shuffle(alunos) ordem = ', '.join(alunos) print('\nA ordem de apresentação é:', ordem) ordenar_alunos() """ ...
53f77725462129fa19ddd27198b052938d2dec2a
elizebethshiju/Diabetics-detection-
/Diabetes.py
3,125
3.59375
4
#!/usr/bin/env python # coding: utf-8 # # Correlation Analysis for Diabetes Detection # This notebook contain the predictions made for diabetic and non-diabetic patients. # In[2]: import pandas as pd from pandas import DataFrame # In[39]: bank = pd.read_csv('diabetes.csv') bank.head() # In[40]: bank.shape ...
9fd9935aa43f6ce702898a93b324622ab0b35729
eaglerock1337/realpython
/part1/1.1-1.9/enrollment.py
1,245
3.9375
4
def enrollment_stats(unis): students = [] tuition = [] for university in unis: students.append(university[1]) tuition.append(university[2]) return students, tuition def mean(numbers): sumup = 0 for i in numbers: sumup += i return int(sumup / len(numbers)) def median(numbers): numbers.sort(...
7af2b52fb115033564de1755c71ddec2fbe32687
gasobral/python_codes
/Introduction to Programming/CadernoExerciciosUSP/exe_1_24.py
1,356
4.21875
4
#! /usr/bin/env python3 # # -*- coding: utf-8 -*- # # Implemenetação de Funções - - - - - - - - - - - - - - - - - - - - - - - - - # def main(args): """ São dados dois números inteiros positivos p e q, sendo que o número e dígitos\ de p é menor igual ao número de dígitos de q. Verificar se p é um subnúmero\ de q. ...
4f7f5fae3aa81f3270feeb7ce949947805888aff
umairnsr87/Data_Structures_Python
/kthlargestelement.py
803
4.09375
4
from collections import Counter def kthlargest(array,number): #step1: sort the array first in the increasing order sort_dict={} for ele in array: ele=str(ele) if ele in sort_dict: sort_dict[ele]=sort_dict[ele]+1 # print("The element is {}" .format(sort_dict[ele])) ...
5a2284b2b20d83e55e0534bee0b51f61030edece
Dirac156/alx-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
699
3.96875
4
#!/usr/bin/python3 """ Rebel int class """ class MyInt(int): """class that inherits from int""" def __init__(self, my_int): """for initialize a value my_int""" self.my_int = my_int @property def my_int(self): """something""" return self.__my_int @my_int.setter ...
f725866c2e6f848a756fe646984e44e688355faa
xlyang0211/learngit
/Candy.py
2,278
3.640625
4
class Solution: # @param ratings, a list of integer # @return an integer def candy(self, ratings): mark = 0 sum = 0 previous = 0 length = len(ratings) if length == 1: return 1 for i in xrange(length): if i == 0: if ratin...
468fa9ef1b114fa8c873aa42b0d2fde2f5fef7fa
Deb001/eulerProblems
/euler6.py
192
3.515625
4
def sumSquare(n): s = n * (n+1)/2 return (int) (s * s) def squareSum(n): s= 0 for i in range(1,n+1): s = s + i *i return s print(sumSquare(100) - squareSum(100))
73c100805b32d651132ff202810fd889be2cf7a8
tliu57/Leetcode
/fAlgorithms/216/test.py
489
3.5625
4
class Solution(object): def combinationSum3(self, k, n): res = [] self.combinationSum3Helper(k, 1, [], n, res) return res def combinationSum3Helper(self, k, start, sub, target, res): if len(sub) == k and target == 0: sub_res = [elem for elem in sub] res.append(sub_res) for i in range(start, 10): ...
9cc85b770758d276723b10c4b9ab41cd395a7e22
joeyuan19/misc-projects
/StackOverflow/input.py
351
3.875
4
input = raw_input("Please provide your title and name: ").split() if len(input) > 1: # at least two entries provided title = input[0] # the first is the title name = input[1] # the second is the name elif len(input) > 0: # one input provided title = "" # Or another default name = input[0] # a...
80fe5a3d3ff81dfc8e9ed40910dcd69a855e7ef2
HeyIamJames/sea-c28-students
/Students/JamesHemmaplardh/AssignmentsFolder5/PyTests/count_evens.py
129
4.15625
4
"""return the number of even numbers in a given array""" def count_evens(nums): return len([i for i in nums if i % 2 ==0])
cb89d74f5b26afa80828bd4b669eaf95b3bc6e06
chenchals/interview_prep
/amazon/online_test2.py
1,296
3.703125
4
def RepresentsInt(s): try: return int(s) except ValueError: return 0 def totalScore(blocks, n): if len(blocks) == 0: return 0 # This is like the calculator question, use a LIFO stack to store the operators and numbers results = [] for cur in blocks: if cur in ['Z...
05c42fcb735509c574dd055407f576d85b5fcf33
thecheebo/Data-Structures-and-Algorithms-in-Python-
/Maps/MapBase.py
688
3.90625
4
class MapBase(MutableMapping) """Abstract Base class that includes nonpublic _Item class""" class _Item: """Stores Key-value pairs as map items""" __slots__ = '_key', '_value' def __init__(self, k, v): self._key = k self._value = v ...
ac26b220a89bae6444ea3ba271e0680b6fac9225
kabitakumari20/dictionary
/dict_is_empty_yanot.py
85
3.625
4
dict1 = {} if dict1: print("dict1 Not Empty") else: print("dict1 is Empty")