blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
98cd123f2d8dd7eb0fed9402d376ff57b797f5c3
dahyunhong/CCSF_Classes
/CS110A/midterm/midterm3.py
154
4.125
4
# Question 2 num = int(input('enter a number: ')) sum = 0 while(num >= 1): sum += num num = int(input('enter a number: ')) print("sum is ", sum)
7ef49518cd62c5c43e8cf2c1d7ae21608a107b3c
sumitkumar261/CS308_Project
/Group10/User_data.py
203
3.578125
4
import pandas as pd import os def data_to_csv(): df=pd.DataFrame(columns=['Name','Email','Age','Gender','Major','']) print(df) df.to_csv('./user_data/test.csv',index=False) data_to_csv()
154b2f81bb967ae19216b1c4b328f07b315a0bc8
memicq/ProgrammingContestAnswers
/aizu/JOI/nearest_two_point.py
488
3.65625
4
#! python3 class Point(): def __init__(self, x, y): self.x = x self.y = y def norm(self, pnt): return (pnt.x - self.x)**2 + (pnt.y - self.y)**2 n = int(input()) points = [] for i in range(n): x, y = list(map(int, input().split(' '))) points.append(Point(x, y)) min_dist = floa...
3e40469cf1848b1363ee8161117faa8332cd4e08
zhaoyu20150930/leetcode-test
/LeetCode/v40.py
1,525
3.71875
4
from typing import List """ 输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。 示例 1: 输入:arr = [3,2,1], k = 2 输出:[1,2] 或者 [2,1] 示例 2: 输入:arr = [0,1,2,1], k = 1 输出:[0] 限制: 0 <= k <= arr.length <= 10000 0 <= arr[i] <= 10000 """ class Solution: def PARENT(self, i): return i // 2 ...
21b42253ab75040c02e309a68181d0ce5e1df1bd
dineshviswanath/py-text-search
/py_text_search/main.py
4,504
3.609375
4
from collections import defaultdict from os import listdir from os.path import isfile, join from string import punctuation class TextSearchException(Exception): pass class InvalidFilePath(TextSearchException): pass class UnableToProcessFile(TextSearchException): pass class NoMatchesFound(TextSearchE...
04396d6fe504352e5c3183b1958107c2b2bb1314
Ryder-987/python
/homework/8/t1_lcm.py
298
3.96875
4
''' 使用者輸入兩個數num1 and num2, 並使用function def 求最小公倍數 value = lcm(num1, num2) ''' def lcm(a, b): for i in range(max(a, b), a * b + 1): if i % a == 0 and i % b == 0: return i num1 = int(input("")) num2 = int(input("")) print(lcm(num1, num2))
9132e21d18497591a660cc1386400515c43c7201
aishvaryagupta/pyscripts
/15_input_in_a_single_line.py
232
3.71875
4
a,b = [int(x) for x in input("Enter 2 number integer with space : ").split()] print("A : ",a) print("B : ",b) c,d = [float(x) for x in input("Enter 2 float values with , as delimiter: ").split(',')] print("C : ",c) print("D : ",d)
fd3110609d4e12bbb4c5c3a6abe47a69d9409456
tsuruhisayukina/AtCoder
/過去問精選 10 問!類題/already.py
52
3.71875
4
S = list(input()) S[3] = "8" S = ''.join(S) print(S)
05a0c06e4b77ea0add5154d62682c51b5f0389ff
Nehanavgurukul/whileloop_ques_python
/userinuser.py
124
3.765625
4
i=1 n=int(input("enter value")) sum=0 while(i<=n): user=int(input("enter value")) sum=sum+user i=i+1 print(sum)
b5e6844b6b2b8dd83a782527ab3e17c2e2543230
iamaleks/Paper-Image-Extractor
/PaperImageExtract.py
4,627
3.796875
4
#!/usr/bin/env python3 import argparse import os import sys import re import urllib.request def convert_textfile_to_list(file_path): """Read text file and return each line in a list. Args: file_path (str): Full path to the text file. Returns: list: List where each index is a line from th...
7de9c36684c48f076215ef83f771b80d5d5aa8cc
asitang/sklearn-hierarchical-classification
/sklearn_hierarchical/decorators.py
290
3.578125
4
from logging import getLogger def logger(obj): """ logging decorator, assigning an object the `logger` property. Can be used on a Python class, e.g: @logger class MyClass(object): ... """ obj.logger = getLogger(obj.__name__) return obj
4a4c1bd4ebe8396ab6937a1125495aa4c5e7c18f
mathankrish/Infy-Programs
/InfyTq Basic Programming/Practice Programs/Level 3/LCM.py
307
3.703125
4
# from math import gcd # a = [12, 14] #will work for an int array of any length # lcm = a[0] # for i in a[1:]: # lcm = lcm*i//gcd(lcm, i) # print(lcm) from math import gcd from functools import reduce def find_gcd(list): x = reduce(gcd, list) return x print(find_gcd([2,4,6,8]))
f9a680fa16aa2f5ac95f3de53f00bb1e54bd58ce
NieGuozhang/Python-Spider
/03.数据解析/02.正则解析.py
1,435
3.53125
4
""" 需求:爬取糗事百科中糗图板块下所有的糗图图片 """ import requests import re import os def main(): # 创建一个文件夹,用来保存所有图片 if not os.path.exists('./qiutuLibs'): os.mkdir('./qiutuLibs') # UA伪装 将对应的User-Agent封装到一个字典中 headers = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.1...
fa59e5026b5a4ee4903d5a2881adfdc6e5a653c0
fiftyfivebells/truck-delivery-optimizer
/Graph.py
2,855
4.1875
4
class Graph: def __init__(self, vertices): # creates a 2d list of vertices, where each entry in the table is a # weighted edge between the row vertex and the column vertex self.graph = [[0 for col in range(vertices)] for row in range(vertices)] # total number o...
18c4666474d1a96e480989d2b980d70757afe655
kjh03160/Algorithm_Basic
/Programmers_Monthly_Test/April/1.py
194
3.59375
4
def solution(absolutes, signs): answer = 0 for i in range(len(signs)): num = absolutes[i] if not signs[i]: num = -num answer += num return answer
af77f3d8642a9a41977f06aaeb9bdae9950c7454
forestnlp/vippython
/ch7/op.py
273
3.78125
4
dic = {"name":"liujie","age":35,"gender":"male"} for item in dic.items(): print(item) for key in dic.keys(): print(key) for val in dic.values(): print(val) for k,v in dic.items(): print(k,v) print(type(dic.items()),type(dic.keys()),type(dic.values()))
5c7430820d12bf3f4bb28ac99f7efe523df25106
wangbin122120/TensorFlow
/TensorFlow/莫烦tensorflow视频笔记/练习/p37_39_RNN循环神经网络.py
3,606
3.859375
4
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # Youku video tutorial: http://i.youku.com/pythontutorial """ This code is a modified version of the code from this link: https://github.com/aymericdamien/TensorFl...
ba15507bfc4e12f508970c6c7e44c8339cf67f41
yangzongwu/leetcode
/20200215Python-China/0367. Valid Perfect Square.py
591
3.96875
4
''' Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Output: true Example 2: Input: 14 Output: false ''' class Solution: def isPerfectSquare(self, num: int) -> bool: ...
69a8905c2fc021e331f77b91cd00e9154789fa25
JavaPhish/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/6-print_comb3.py
195
3.75
4
#!/usr/bin/python3 for frst in range(0, 9): for scnd in range(frst + 1, 10): if ((frst + scnd) != 17): print("{}{}".format(frst, scnd), end=", ") print("{}".format(89))
ca62c3c0c53533ce89a81fe532b0974accbc1544
mccroarK/cti110
/P5HW2.py
1,662
4.1875
4
# This program quizzes users on their ability to add and subtract # 10/24/2019 # CTI-110 P5HW2 - Math Quiz # Kevin McCroary # import random MIN = 1 MAX = 100 ADD_NUM = 1 SUB_NUM = 2 EXIT = 3 def main(): choice = 0 while choice != EXIT: display_menu() choice = int(input('En...
358870a8876eaf0f5b4eda738862f308a378d281
ArturoRuge/python-exercises
/ciclicos2/5-5.py
428
3.921875
4
#5. Obtener el promedio de calificaciones de un grupo de n alumnos. cantAlumnos = int(input("Digite la cantidad de alumnos: ")) calificacion=[] contador = 0 for i in range(1, cantAlumnos +1): calificacion.append(int(input("calificacion estudiante " + str(i) + " "))) for i in calificacion: contador = contador + i prom...
76a75cbb96eb1edf949f92ac3eeef2b3dd850e4f
QinHaoChen97/python_leetcode
/非递减数列_665.py
1,921
3.609375
4
''' 给你一个长度为n的整数数组,请你判断在最多改变1个元素的情况下,该数组能否变成一个非递减数列。 我们是这样定义一个非递减数列的:对于数组中任意的i(0 <= i <= n-2),总满足 nums[i] <= nums[i + 1]。 示例 1: 输入: nums = [4,2,3] 输出: true 解释: 你可以通过把第一个4变成1来使得它成为一个非递减数列。 示例 2: 输入: nums = [4,2,1] 输出: false 解释: 你不能在只改变一个元素的情况下将其变为非递减数列。 ''' # ! /usr/bin/env python3 class Solution: def checkPoss...
ab4a5f434ffbf70810edca1923d031415e9a53f2
geniousisme/CodingInterview
/leetCode/Python2/258-addDigits.py
602
3.84375
4
class Solution(object): def addDigitsJunior(self, num): """ :type num: int :rtype: int """ final_digit = num while final_digit > 9: final_digit = 0 while num > 0: final_digit += num % 10 num //= 10 nu...
9ca240eb739fb7e099e2a0be8b3043c1ed79610a
bonn1112/python_algorithm
/sort/buble_sort.py
397
4.3125
4
import random from typing import List def bubble_sort(numbers: List[int]) -> List[int]: len_numbers = len(numbers) for i in range(len_numbers): for j in range(len_numbers - 1 - i): if numbers[j] > numbers[j+1]: numbers[j], numbers[j+1] = numbers[j+1], numbers[j] return ...
dda2f7290bcfef5a025d6aa965fe536f8ba90f2e
EdgarEmmanuel/TD1-In-Python
/exo4.py
368
4.03125
4
import math #exercice sur les exposants number = int(input("saisir la valeur du nombre : ")) exposant = int(input("saisir la valeur de l'exposant : ")) #with function pow #print("le resulat est egal a : ",math.pow(number,exposant)) #with the while loop result =1 i=1 while(i<=exposant): result=result*number...
a158063f2203bc8429aa9cdb1c82481755baa9c9
YoshinoriIwaki/DeepLearning
/3_NeuralNetwork.py
5,476
3.625
4
import numpy as np import matplotlib.pylab as plt def StepFunction(x): return np.array(x > 0, dtype = np.int) x = np.arange(-5.0, 5.0, 0.1) y = StepFunction(x) plt.plot(x, y) plt.ylim(-0.1, 1.1) plt.show() def sigmoid(x): return 1 / (1 + np.exp(-x)) x = np.array([-1.0, 1.0, 2.0]) print("sigmoid(x) ", sigmoi...
971485c43650eae56fd4289d1bc947f2d723c659
llylouise/Games-object-oriented-
/ChopsticksState.py
3,477
3.71875
4
from GameState import GameState class ChopsticksState(GameState): """ The state of a game at a certain point in time. """ def __init__(self, is_p1_turn, p1_hand, p2_hand): """ Initialize this game state and set the current player based on is_p1_turn. :param is_p1_turn:...
d0f3e80fe3da47a6e6912594c6ccc4c4d9a9f37a
sonhle/python-tutorials
/string.py
345
4.03125
4
# escape str = "Hello \"there\"" print(str) # raw string str = r'C:\some\name' print(str) # concat and repeat str = 3 * "learning" + " python" "one more time" print(str) #position word = 'Hello python' print(word[2]) print(word[-2]) print(word[2:8]) print(word[:3]) print(word[3:]) print(word[:3] + word[3:]) print(wo...
e98a551af022a85daf9438438eda8ed2f8ccfd34
Ezi0aaudit0re/Python_Stats
/driver.py
2,113
3.65625
4
""" This file is the main driver of the program. This file imports logic.py. THe reason for doing this is to keep the code organized and prevent clustering in one file """ __author__ = "Aman Nagpal" __email__ = "amannagpal4@gmail.com" import logic import sys from helper import check_quit DEBUG = False def main...
31e843775d9318bcc1a59557ef9f8c1be96510bf
Tanmay53/cohort_3
/submissions/sm_102_amit/week_13/day_4/session_1/count_occurences_string.py
310
4.03125
4
# Given a string print the number of times each character appears in the string string = input("Enter string: ") dictionary = dict() for s in string: if s == " ": continue if s not in dictionary: dictionary[s] = 1 elif s in dictionary: dictionary[s] += 1 print(dictionary)
fe15793930a0f3f732b1f104143b1da387cf560f
akshaybosamiya/hackerrank-solutions
/Practice/Algorithm/2-Implementation/bon-appetit.py
316
3.546875
4
#https://www.hackerrank.com/challenges/bon-appetit n,k = map(int, input().split()) costI = [int(costI_tmp) for costI_tmp in input().strip().split()] bCharged = int(input().strip()) bActual = (sum(costI)-costI[k])//2 if(bCharged - bActual): print(bCharged - bActual) else: print("Bon Appetit")
188839f5d8c6ea31d7fff9357380584b0f8899f9
ruhigit/Perceptron
/perceplearn.py
3,325
3.625
4
##This is Averaged Perceptron classifier. Will be invoked as: ##python3 perceplearn.py TRAININGFILE MODELFILE ##where trainingfile contains a label and document features. Each line represnts one training example. ##In this program we compute the dot product of the features and it's weights for every document. ##We assu...
84e3aeb534da031665e2f3f5105266fda09f4411
alqamahjsr/InterviewBit-1
/02_Arrays/largest_number.py
933
4.0625
4
# Largest Number # https://www.interviewbit.com/problems/largest-number/ # # Given a list of non negative integers, arrange them such that they form the largest number. # # For example: # # Given [3, 30, 34, 5, 9], the largest formed number is 9534330. # # Note: The result may be very large, so you need to return a str...
9a6523ec4be94f7f3b298610f5e1de87300e1caf
apurvaumredkar/Object-Oriented-Programming-Lab
/expt 9.py
4,197
3.84375
4
#retail info of customers class Customers(object): def __init__(self,id = None): self.cust_id = id self.cust_phone = None def setID(self,new_id): self.cust_id = new_id def setPhone(self,new_phone): self.cust_phone = new_phone def __str__(self): return "ID: "+s...
f913bbab6b82f2496d3e47c39d85ce3aa7735280
juanedflores/Code-Katas
/python/007_alphabetposition.py
975
4.4375
4
# Code Kata #7 - 6 kyu # In this kata you are required to, given a string, replace every letter with its position in the alphabet. # If anything in the text isn't a letter, ignore it and don't return it. # "a" = 1, "b" = 2, etc. # My Solution: def alphabet_position(text): alphabet = "abcdefghijklmnopqrstuvwxyz" ...
9f4e00028cd0644cd3da71090bbd086d0217f5e5
valerpenko/Misha
/Homework/Лр/list_7.py
346
3.546875
4
from random import randint n = 4 multiply = 1 matrix = [[randint(1, 9) for j in range(n)] for i in range(n)] # for i in range(n): # for j in range(n): # if i > j: # multiply *= matrix[i][j] for i in range(1, n): for j in range(i): multiply *= matrix[i][j] for el in matrix: p...
91eb1ab6328e3d0ddfa75d6f57a24d551856b837
jpsilverio1/bigData20162
/trabalho3/normalizeDataset.py
695
3.546875
4
import pandas as pd import numpy as np from sklearn.preprocessing import normalize def normalizeDatasetByColumns(dataset): return normalize(dataset, axis = 0) def getDatasetFromCSV(fileName): raw_data = open(fileName) header = raw_data.readline() return [header, np.loadtxt(raw_data, delimiter=",")] d...
dbbe1bac7b7005c79b979675f086a3a1fdf0eadf
JerryHu1994/CS838-Data-Science-Project
/Stage-1-IE-from-natural-text/data/replaceLabel.py
749
3.5625
4
#!/usr/bin/python import sys import os def main(): if len(sys.argv) != 3: print "Error: Please give an input name and an output name." folderName = sys.argv[1] outputName = sys.argv[2] filelist = os.listdir(folderName) #loop through the file list, open each file, replace $$$ for i in filelist: inputpath = "...
cb5cfb2a0b297ce4d006cc64407a707a3420a630
walleri18/Programming-tasks-Python-3.x
/Programming tasks/The first paragraph/Twenty two tasks/Twenty two tasks.py
1,617
4.03125
4
# Импортирование математической библиотеки import math # Основания равнобедренной трапеции a, b = 0, 0 # Угол alpha при большем основании a alpha = 0 # Получение данных while a == 0: a = math.fabs(float(input("Введите большее основание" " равнобедренной трапеции: "))) while b == 0 ...
61bdf4338c7efae7f83fa4ec736a0b1c06d3fac0
adishijha/Algorithms-and-Data-Structures
/warmup/fibonacci_last_digit.py
352
3.8125
4
# Uses python3 #pisano's period import sys def get_fibonacci_last_digit_naive(n): if n <= 1: return n F=[0 for i in range(60)] F[0]=0 F[1]=1 for i in range(2,60): F[i]=(F[i-1]%10+F[i-2]%10)%10 d=n%60 return F[d] if __name__ == '__main__': n = int(input()) print(get...
f238c29c7c4d4c511ec264bc96b4af20b8a57305
mchobby/pybstick-projects
/keybow/keybow3.py
4,934
3.75
4
""" Keybow mini-keyboard sending custom key code to your computer. Use an AZERTY keymap for the Keyboard. Do not forgot to change the boot.py file to activate USB HID support with pyb.usb_mode('VCP+HID', hid=pyb.hid_keyboard) usbhid lib on https://github.com/mchobby/pyboard-driver/tree/master/usbhid exampl...
0ffaae39055931f40ba25e86ceb5ac46973b3361
pymft/mft-04
/S02/methods/str_methods.py
118
3.984375
4
text = "hello" word = "whatever" text2 = text.upper() print(text2) word2 = word.upper() print(word2) text.split()
913f6ce09095a62b92b3c45a66c6355fdd152663
qink1986/leetcode
/p002.py
1,065
3.65625
4
''' @Author: qink-DN493 @Date: 2019-12-23 10:08:18 @LastEditors : qink-DN493 @LastEditTime : 2019-12-24 13:30:53 @Description: ''' class ListNode(object): def __init__(self, x): self.val = x self.next = None def addTwoNumbers( l1: ListNode, l2: ListNode) -> ListNode: head = node = Lis...
94fc6bf3862c43e033d57a74c10ee6855cf8e2c3
ieeecomputeruni/taller-python
/ejercicios-python/2/2.2.py
101
3.6875
4
f = input("el numero de grados farenheit ") # f =((9/5) * c) + 32 c = (f - 32) * (5.0 / 9) print c
d4fe1eaf397802a0832d96ebd654c221f4e403a7
TeaaPartyy/Basic_Gui_Tutorials_Python
/2_images.py
1,494
4.375
4
#program done by Hamza Slaoui Habib #Basic program to show how to change an icon in a program and how to upload a picture using tkinter #beginners guide // functions not optimized #this guide and the following others in the same file are inspired by the course offered by freecodechamp.org from tkinter impor...
63b146626418d985bc89d6d2fbe1a32aa80e6e06
iezyzhang/Project
/Demo/第一季案例/第八章tuple集合/8.1集合.py
1,231
3.609375
4
""" 输入一个数字,转换成中文数字 """ def transfer_number(number): """ 数字转大写 :param number: :return: """ string_result="" for item in number: if "0" in item: string_result += "零" elif "1" in item: string_result += "壹" elif "2" in item: string_re...
7bc8bcdf980a3ca9000497f95acd7c875266fc0a
zewuchen/data-analysis
/Funcoes Pandas/Logica CSV 03.py
233
3.8125
4
import pandas as pd nome = [] df = pd.read_csv("Logica CSV 01-06.csv") minimo = df["Cars Sold"].min() for i in range(len(df)): if(df["Cars Sold"][i] == minimo): nome.append(df["Fname"][i]) nome.sort() print(nome)
64291f62c35014d8748d02685267449e1e537211
srihariprasad-r/leet-code
/leetcode-solutions/P1302.Deepest_leaves_sum.py
2,727
3.859375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution(object): def deepestLeavesSum(self, root): """ :type root: TreeNode :rtype: in...
f412ce970f681981ade8570d4d29892b431ee40f
michaelgraemeshort/py_bootcamp
/scribbles.py
844
3.5
4
''' update_users("Grace", "Hopper", "Hello", "World") # Users updated: 1. update_users("Colt", "Steele", "Boba", "Fett") # Users updated: 2. update_users("Not", "Here", "Still not", "Here") # Users updated: 0. ''' from csv import reader, writer def update_users(first_name, last_name, new_first_name, new_last_na...
9c9b2d6a37eeef778efad948f19e7df76e70b0ff
SickJoke282/python34-programs
/app.py
2,187
3.75
4
import tkinter as tk from tkinter import ttk from tkinter import * import webbrowser # Создание приложения app = tk.Tk() app.title("Поисковая система") # Создание текстовой надписи app_name = ttk.Label(app, text="Поисковое приложение", font="verdana 20 bold italic", foreground="#333") app_name.grid(row=0, ...
9e7058d7bf059e05ff4548ddeb2410d98819a7f0
tucksa/PythonPractice
/OOP_HW.py
1,868
4.25
4
#create a class for a line that includes methods to find the distance and slope of the line class Line: def __init__(self, coor1,coor2): self.x1, self.y1 = coor1 self.x2, self.y2 = coor2 def distance(self): import math return math.sqrt((self.x2-self.x1)**2 + (self.y2- self.y...
f7689b731ace5da417214c7aa9ba4e0100032cbb
libus1204/bigdata2019
/01. Jump to python/chap03/squre_3.py
587
3.59375
4
# coding: cp949 print(" α׷ ver2.0\n") while True: num = int(input("Ȧ Էϼ(0 <- ): ")) num2 = int((num/2)+1) if num == 0: print("\n α׷ ̿ ּż մϴ.") break else: print(" "+"-"*num+" ") for i in range(1, num2+1): print("|"+" "*(num2-i)+"*"*(2*i-1)+" "*(num2-i)+"|")...
4e0f915107528f5cb12bf7c88db41179cfc7c323
lord12-droidd/Colokvium-AP
/Coloc 26.py
980
3.953125
4
"""Напишіть програму аналізу значень температури хворого за добу: визначте мінімальне і максимальне значення, середнє арифметичне. Заміри температури виробляються шість раз на добу і результати вводяться з клавіатури у масив T. Мельник Д.В. 122А """ massive_t = [int(input('Введіть температуру: ')) for i in range(6)] #...
b84e0dccfdd1a1dbec06b4422714a0e4757a88eb
moran-ai/Reptile
/数据存储/Excel存储/demo读取Excel文件.py
658
3.53125
4
import openpyxl # 加载Excel文件 wb = openpyxl.load_workbook('我的工作薄.xlsx') # 获取工作表对象 # sheet = wb.active sheet = wb['Sheet'] # 获取指定的单元格中的内容 cell = sheet['A1'] # 获取A列的所有数据 columns = sheet['A'] for i in columns: print(i.value) print('-----------------------------') # 获取特定的一行数据 row = sheet[3] for r i...
41f7f5bd35b7cde2aff0d15699f1215c27d6ba79
gayu2723/python-1
/factofnum.py
95
3.625
4
f=int(input()) factfact= 1 for n in range(1,f+1): factfact = factfact*n print(factfact)
a8711e99bd3d0c202fe5ddf1dbfca77d7d930dbb
rohitkv77-g/Assignments
/IR/assig2.py
1,588
3.546875
4
import math def trans(X, Y): #initial matrix final edit result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for i in range(len(X)): for j in range(len(Y[0])): for k in range(len(Y)): result[i][j] += X[i][k] * Y[k][j] return result def new_pointt(X, Y): result = [0, 0, ...
4cc9c38550194164e39fc82a17037a4a1ede0d6a
dzackgarza/ds
/rsa_implementation.py
4,385
3.96875
4
import random """ Given a string, return a list of numbers (ASCII values). """ def encode(s): """ >>> encode('discrete') [100, 105, 115, 99, 114, 101, 116, 101] >>> encode('abc') [97, 98, 99] >>> encode('zyx') [122, 121, 120] """ return [ord(c) for c in list(s)] """Given a list of...
7953d9d4df2e9c23b25009b33c4efb9c6af82a4c
thiagor83/estudos
/PhytonExercicios/ex034.py
190
3.890625
4
salario = float(input('Qual é o salário do Funcionário? ')) aumento = salario * 1.15 if salario <= 1250 else salario * 1.10 print('O salário com aumento é de R$ {:.2f}'.format(aumento))
36cd235d8c87bab242a8fc8c5291b069c3feb6ac
nyongja/This-is-the-Coding-Test
/Part3/Ch18 Graph/18-1.py
1,051
3.90625
4
def find_parent(parent, x) : if parent[x] != x : parent[x] = find_parent(parent, parent[x]) return parent[x] def union_parent(parent, a, b) : a = find_parent(parent, a) b = find_parent(parent, b) if a < b : parent[b] = a else : parent[a] = b if __name__ == ...
15e6821b5c5251578f0ed374990064d7069a1b60
Aasthaengg/IBMdataset
/Python_codes/p03455/s725947865.py
106
3.953125
4
x,y = (int(x) for x in input().split()) z = x * y if z % 2 == 0: print('Even') else: print('Odd')
69d9e2afd9c0b5a54b92b45a511a2a56e1567543
nitendragautam/python_apps
/python_core/pythontutorials/dictionaries.py
1,437
4.34375
4
#========================== # Dictionaries in Python #========================= """ A dictionary is a type of collection in which we store unordered,changeable and index value. Dictionaries have multiple values written with curly braces in which each item has keys and values. """ ## A Simple dictionaries of Person ...
cabd7935712e3ab92b23ba4495699570ebdfd380
Ebukaar/myISM209CA2
/myISM209CA2/models.py
827
3.625
4
from main import db from datetime import date class User(db.Model): #notice that our class extends db.Model __tablename__= 'userregister'#this is the name we want the table in database to have. id=db.Column(db.Integer, primary_key=True) firstname=db.Column(db.String(20), unique=False, nullable=False) Surname= d...
b27a21195166d5c0dd6710d02bd9009488c392dc
Htrams/Leetcode
/convert_binary_number_in_a_linked_list_to_integer.py
748
3.65625
4
# My Rating = 1 # https://leetcode.com/explore/challenge/card/november-leetcoding-challenge/564/week-1-november-1st-november-7th/3516/ # Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. # The linked list holds the binary representation of a numbe...
f942b48620256d46642ddde225cb733d2a7fe638
m4rkuus/Scan-Ports-On-Py
/which_is_your_ip.py
189
3.515625
4
#Autor @mmunoz28 import socket hostname = socket.gethostname() ip = socket.gethostbyname(hostname) print("El Nombre de tu pc es : " + hostname) print("Tu dirección IP es : " + ip)
b46e7e51a82d6a4e86b34baf72cc615fe2c33048
opentechschool-zurich/resources
/15-min-projects/ale/rock-paper-scissor/rock-paper-scissor.py
1,398
4.25
4
# scissor - rock -paper import random moves = ['scissor', 'rock', 'paper'] human_move = "" while human_move not in moves: print('please write scissors, rock or paper') human_move = input('your move: ') computer_move = random.choice(moves) print('computer move: ' + computer_move) if human_move == computer_...
c166e468e46aa722c53c3875a23e53a8efe5dd28
cabrerosj/Angela-Yu-Bootcamp
/forLoop.py
162
4.03125
4
fruits = ["Apple", "Banana", "Pear"] for fruit in fruits: if fruit == "Banana": print(f"{fruit} cream pie.") else: print(f"{fruit} pie.")
18f3a2bb55ffa851a3038fb08a62268e4fb24fd1
AxentiAndrei2004/Instructiunea_IF
/Problema_2_IF.py
189
3.8125
4
a=int(input('Primul numar=')) b=int(input('Al doilea numar=')) c=int(input('Al treilea numar=')) if(a<b+c) and (b<a+c) and (c<a+b) and (a<b<c): print ('DA') else: print('NU')
02baee84fe46108aa1d59f997a94e5fbf631fb1b
harshuvj/ga-learner-dst-repo
/Visuaization_101/code.py
2,317
3.828125
4
# -------------- #Importing header files import pandas as pd import numpy as np import matplotlib.pyplot as plt #Reading the file data=pd.read_csv(path) #Code starts here # Step 1 #Reading the file #Creating a new variable to store the value counts loan_status = data['Loan_Status'].value_counts() #Plotting bar ...
7d24256dd4ef758bf70905526f197fc89a0daf95
ytatus94/Leetcode
/python3/261_Graph_Valid_Tree.py
2,443
3.921875
4
# Tree 可以是多元樹,不一定要是 binary tree # Tree 是 graph 的條件是: 有 n 個點,有 n-1 條邊,並且 n 個點要互相連通 # 互相連通是說從某個點,都可以走到圖上的另一個點 # Graph 的 BFS 需要一個 hash map 並且和 queue 連動 # queue 做了什麼動作,hash map 就要做一樣的動作 # Graph 常常需要建立鄰接矩陣 adjacency matrix # 這題就是先用簡單的 if 判斷是否滿足 n 個點 n-1 條邊 # 然後再用 BFS 來判斷 n 個點是否互相連通 # lintcode 178 class Solution: ...
546520607f79652e68675a37d5f2c411368e2808
juliano60/scripts_exo
/ch2/exo2.py
503
4.09375
4
#!/usr/bin/env python3 ## read a list of numbers ## for each number print the corresponding ## person's name from the list people = ['fred', 'betty', 'barney', 'dino', 'wilma', 'pebbles', 'bamm-bamm'] print("Enter a list of numbers: ") indices = [] while True: try...
692f398794284de0eeda3480bddd0a4facfc7ace
FuJames/leetcode
/python/Pascal's Triangle II.py
556
3.71875
4
# coding:utf8 # Given an index k, return the kth row of the Pascal's triangle. # For example, given k = 3, # Return [1,3,3,1]. # # Note: # Could you optimize your algorithm to use only O(k) extra space? class Solution(object): def getRow(self, rowIndex): if rowIndex < 0: return [] a =...
17fc4b3597afb76196461aa3a883080f6fe75961
afshanfathima123/guviprograming
/queue.py
840
4.28125
4
print("QUEUE IMPLEMENTATION") queue= [] while True: print("What you want to perform?\n 1.Enqueue,2.Dequeue,3.check size of queue,4.Emptiness of queue,5.EXIT") n=int(input()) if n==1: print("Enter the element to insert:") l=input() queue.append(l) print("Enter the element in...
4df7610d43329042a1c7ffe19ac258fc93744e85
AbdelhamidElKrem/Day2_Tip_Calculator
/main.py
577
4.125
4
#show the message of Intro print("Welcome to the Tip calculator"); #save the input total bill in variable totale totale = float(input("what was the total bill $")); #save the input percentage in variable percentage percentage = float(input("what percentage tip would you like to give? 10, 12, or 15? ")); #save the in...
f442780ee8606438744392d2d51e44526bdb7a15
jacoduplessis/adventofcode
/2022/02.py
1,188
3.5
4
import pathlib input_string = pathlib.Path('./02.txt').read_text() lines = input_string.splitlines() """ A X - Rock Lose B Y - Paper Draw C Z - Scissors Win """ points = { 'X': 1, 'Y': 2, 'Z': 3, 'A': 1, 'B': 2, 'C': 3, } score = 0 score2 = 0 for line in lines: op, pl = line.split(' ') ...
b66743981284c3a18a290b6f92ea6b660b7c1a62
AJPassDe/dataVisualization
/dataVisualizationMicroCourse/03-bar-charts-and-heatmaps.py
1,964
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 6 17:11:44 2020 @author: AJ """ import pandas as pd pd.plotting.register_matplotlib_converters() import matplotlib.pyplot as plt #%matplotlib inline import seaborn as sns print("Setup Complete") # ========================================================================...
ddab4a077cdc786c992947ae569c0b5490d17639
agrawalbansal88/data_structures
/python/link_list/sorted_link_list.py
1,008
3.578125
4
from basic_list import List, Node class IncresingOrderLinkList(List): def bulk_insert(self, values): for value in values: self.insert(value) def insert(self, value): new_node = Node(value) if self.head is None: self.head = new_node;return head = self.hea...
8c887c22c6690af67a6095114593b119735179e2
vegito11/Data_Structure
/Data-Structure-Algorithm-Python3/05-LinkedList/03-Doubly-LinkedList.py
2,052
4.03125
4
class Node: # constructor take name and age as argument and create new Node def __init__(self,name,age): self.name=name self.age=age self.next=None self.prev=None def __str__(self): return f' Name : {self.name} -- Age : {self.age} ' return "" n = Node("omkar",10) # print(n) class Doubly...
3931a878f6cbc591ed67dbed3c4d4041587b7aa3
shortdistance/workdir
/python高级编程code/ch03/p054.py
863
3.5
4
class DistinctError(Exception): pass class distinctdict(dict): def __setitem__(self, key, value): try: value_index = self.values().index(value) # keys() and values() will return # corresponding lists # as long as the dict is not changed # bet...
afa65a27c28ab5710d6fd9fbad02b9f1434e0e28
kanglicheng/CodeBreakersCode
/Graph/210. Course Schedule II.py
1,425
3.765625
4
#[目標][先修] -> 會得到反向的拓樸排序 -> 反轉edges class Solution: def findOrder(self, n: int, prerequisites: List[List[int]]) -> List[int]: def topologicalSort(cur, edges, visited, hasCircle, path): if cur in hasCircle: return hasCircle[cur] if cur...
29c37f8adcb7458daedde03ab4e4b6e385d3d9ea
NareshKumarChava/Leet_Code
/#1651 Hopper Company Queries III.py
6,542
3.578125
4
""" Author: Naresh Chava Date: 05/28/2021 Language: MYSQL ref: https://www.mysqltutorial.org/mysql-recursive-cte/ Table: Drivers +-------------+---------+ | Column Name | Type | +-------------+---------+ | driver_id | int | | join_date | date | +-------------+---------+ driver_id is the primary key f...
dab7bac10b96707a1409eedcf008b7fdb10ccb5c
CS7591/Python-Classes
/2. Python Intermediate/4. Classes/11. OOP part 11.py
1,854
4.21875
4
# Customise sub classes ------------------------------------------------------------------------------------- class Employee: def __init__(self, first, last, salary): self.first_name = first self.last_name = last self.salary = salary # self.email = f'{first.lower()}_{last.lower()}@c...
be51072f6aa1482f5d1376922015770d0951f2c9
ekosaputro09/HackerRank-solutions
/Algorithms/Implementation/Designer PDF Viewer
432
3.984375
4
#!/bin/python3 import sys def get_max_height(word, height_arr) : height = 0 for c in word : height = max(height, height_arr[ord(c) - ord("a")]) return height def get_area(word, height): width = 1 area = len(word) * width * height return area h = list(map(int, input().strip().sp...
44394d56216bb813cf6ffa640d22d974266da714
hargup/bioinformatics
/rosalind/trie.py
1,375
3.703125
4
import networkx as nx from matplotlib import pyplot as plt def create_trie(strings): G = nx.Graph() G.add_node(1) highest_node = 1 for string in strings: root_node = 1 for char in string: adjacent_edges = edge_lables_dict(G, root_node) if char in adjacent_edges.k...
22fd7359d3f9c7c241c496dc26a5fdb6d5e41a76
skimaiyo16/andela-bc-5
/lngntow.py
351
3.953125
4
def num_to_words(n): """ change a number into words using a dictonary to map """ nw = {"0":"Zero", "1":"one", "2":"Two", "3":"Three", "4":"Four", "5":"Five", "6":"six", "7":"Seven", "8":"Eight", "9":"Nine"} words = [] n = str(n) for i in n : words.append(nw[i]) return " ".join(words) pri...
2576a2aa13183f0b632867df72597e1f95125801
Igor-Ferraz7/CursoEmVideo-Python
/Curso/Mundo 3/Desafio077.py
231
3.8125
4
v = ('aprender', 'olhar', 'testar', 'programar') vr = 'a' or 'e' or 'i' or 'o' or 'u' for n in v: print(f'\nNa palavra {n.upper()} temos: ', end='') for l in n: if l.lower() in 'aeiou': print(l, end=' ')
7edeaf592a97069da1578a54c7755c4fdd0a41fb
houxudong1997/Advanced-Artificial-Intelligence
/Breath-First Search.py
694
3.765625
4
graph = { "s": ["a", "b", "c"], "a": ["b","d"], "b": ["a", "f"], "c": ["e"], "d": ["a", "f", "g"], "e": ["c","f","g"], "f": ["b","d","e","g"], "g": [] } def BFS(graph, start): queue = [] visitorder =[] queue.append(start) seen = set() seen.add(start) ...
82d4e81a0722f7ed161cbe11c6aa14c0f852f903
spisladko/py_lab
/lab_04/age.py
1,352
3.515625
4
import datetime as dt from statistics import median from typing import Optional import datetime from api import get_friends from api_models import User user_id = int(input('Enter id: ')) def age_predict(user_id: int) -> Optional[float]: assert isinstance(user_id, int), "user_id must be positive integer" asse...
7b74442a19d0d40ea2eeb0f109b30a892488ff77
Indiana3/python_exercises
/wb_chapter5/exercise120.py
1,421
4.1875
4
## # Read a sequence of items, add them in a list, # format the list, display the result as a string # ## Format a list, separating each item with a comma and # including "and" before the last one # @param t a list # @return a string with all the items of the list formatted # def listFormatter(t): # if t has one ...
36a40bd684b7636e778d800deb57debf45d193c9
digorithm/coding_practice
/hackerrank/diagonal-difference/solution.py
576
3.890625
4
""" You are given a square matrix of size N×N. Calculate the absolute difference of the sums across the two main diagonals. PS: I'm not treating invalid inputs. """ class DiagonalDifference(): def solve(self,mat): return abs(sum([mat[i][i] for i in range(len(mat))]) - sum([ row[-i-1]...
5638767753c1ad3628857c8db45ac63a7b62575e
nikhilmhatre04/FST-M1
/Python/Activities/Activity9.py
240
3.84375
4
numlist1 = [1,2,3,4,5] numlist2 = [6,7,8,9,0] print(numlist1) print(numlist2) numlist3=[] for x in numlist1: if x%2!=0: numlist3.append(x) for j in numlist2: if j%2==0: numlist3.append(j) print(numlist3)
3fc953bf86e3aed5c03133ce5151ef1c8a27c086
novarenv/DataScience
/DSI/Percabangan.py
147
3.703125
4
d = 7 print(1 == 1) if(d == 4): print("Sama dengan 4") elif(d > 4 and d <= 10): print("Antara 5-10") else: print("Lebih kecil dari 4")
b7d80189ef3818e94942ebfa757809412f6b0c47
errorLAD/python
/min-mx.py
219
3.8125
4
student ={ 'biswal':100, 'niraj':200, 'sam':150, 'gokul':50, 'amar':56, } print(min(zip(student.values(),student.keys()))) print(max(zip(student.values(),student.keys())))
e0a66e200edbcf3a1525c9de0535493f42b45c0a
Dinnao/name
/homework5/homework5.3.py
634
3.875
4
def triange(): a = int(input('Enter first side of triangle: ')) b = int(input('Enter first side of triangle: ')) c = int(input('Enter first side of triangle: ')) p = (a + b + c)/3 x = float((p * (p-a) * (p-b) * (p-c))) s1 = (x ** 0.5) print(s1) def square(): a = int(input('Enter first ...
99689a439a1b6cf2b66d379ce6fb5a8e560122f0
ZaynAliShan/3120-Python
/LoShu(4.3).py
4,401
4.21875
4
"""The Lo Shu Magic Square is a grid with 3 rows and 3 columns, shown in Figure 7-8. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. Write a function that accepts a two-dimension...
1e9af257a829bc35ff66ef2c28a5ae447fb6a7e6
akarneliuk/CEX
/10/def.py
1,215
3.75
4
#!/usr/local/bin/python3.8 # Variables ip_addresses = '10.0.0.3-10.0.1.15' # User-defined function def ip_str_int(input_var, operation): if operation == 'get_int': input_var = input_var.split('.') index = len(input_var) - 1 temp_value = 0 while index >= 0: temp_value +...
9402ca0039a3381c3ba7de7ecc0c12603ab09804
saraelan/CodingDojo
/FLASK/checkerboard/server.py
894
3.984375
4
#1.Write a program that generates an HTML page that looks like a checkerboard. should display 8 by 8 checkerboard from flask import Flask, render_template # Import Flask to allow us to create our app, and import # render_template to allow us to render index.html. app = Fl...
f95954fa20a59c9102c938fa3c324870d3f39b15
MestreLion/cs50
/week6 - Python/readability/readability.py
1,551
3.84375
4
import cs50 """ Some assumptions on text input: - It is trimmed: no leading or trailing whitespace. - Word and sentence boundaries are single characters, not multiple runs. (i.e., there are no empty words " " or sentences "..") - Proper syntax: space between sentences and ends with a sentence terminator. """ def ...
20c46afb60b06deccfad9e43861083a7dc54cf92
zakamaldin/algo_and_structures_python
/Lesson_1/8.py
573
4.125
4
# 8. Определить, является ли год, который ввел пользователем, # високосным или не високосным. #Год является високосным в двух случаях: либо он кратен 4, # но при этом не кратен 100, либо кратен 400. x = int(input('Введите год: ')) if (x % 4 == 0 and (x % 100 != 0)) or (x % 400 == 0): print(f'Да, {x} год високосный'...
fd9b4f2254756449af5753826032fc9c8aad3739
Sahilsingh0808/Project-CUOG
/script.py
5,569
3.546875
4
import pandas as pd import re def removeSpaces(str): return str.strip() def StringManipulate(str,master,check): # print(str) if(check==0): #string starts with number c1=master[0:2] c2=master[3:6] c3=str[0:2] c4=str[3:6] c5 = "N/A" c5No=-1...
4364863f349cd2d96638daa03c128b0a9bbb7fd2
aumit210780/Practice-Python
/Fuzz Buzz with if-elif-else.py
246
4.03125
4
n = int(input("Enter a number to play fuzz-buzz: ")) if n%3 == 0 and n%5 == 0: print("Fuzz-Buzz") print() elif n%5 == 0: print("Buzz") print() elif n%3 == 0: print("Fuzz") print() else: print(n) print()