blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5e4ebbcc9a0da90a2d5be7a5e2ab181d22598512
jingzli/study
/python/googlePythonClass/D1_file.py
1,238
3.625
4
import sys import os def Cat(filename): # read the file line by line, use less RAM than read in whole file f = open(filename, 'rU') for line in f: # print line # line string include new line at the end print line, # ',' at the end, prohibits the new line at the end f.close() # close file ...
d132b39aab49dbd3ed14ef9eefa8eec92ba63f72
SimonLundell/Udacity
/Intro to Self-Driving Cars/Introduction/2_car_turning.py
504
3.6875
4
# CODE CELL # # This is the code you should edit and run to control the car. from Car import Car import time # TODO: Make changes to the steering and gas values and see how they affect the car's motion def circle(car): car.steer(4.5) car.gas(0.50) car = Car() circle(car) # Observations: Increasing the ...
4a5a794c8e9604f09e64d570eefa26173085a45c
ap1729/ML_Project1
/implementations.py
19,821
3.8125
4
# -*- coding: utf-8 -*- """some helper functions for project 1.""" import csv import numpy as np def standardize(x): """ Standardize the original data set with standard deviation. Arguments: x (array to be standardized) """ std_x = np.std(x) if std_x == 0: std_x = 1 mean_x = np...
198403d68bf29faddf7d4098ac93c6f97bcc8ac7
friessm/math-puzzles
/p0006.py
872
4.09375
4
""" Solution to Project Euler problem 6 https://projecteuler.net/problem=6 """ def sum_of_squares(number): """ Cubic function. 1**2 + 2**2 + ... + n**2 can be expressed as a cubic function. a*n**3 + b*n**2 + c*n + d where d = 0 because 0, for n = 0. Solve 3 unknowns and voila 1/3*n*3 + 1/2*n**2...
51bcee4b0342d18462144f80e360f2082c6a1bf0
mithun2k5/Python-Code
/Python-Projects/Flatten Nested List Iterator.txt
304
3.8125
4
#Flatten Nested List Iterator: lst = [[1,2],2,[1,1]] new_lst = [] for i in range(len(lst)): if type(lst[i]) == list: temp = lst[i] for j in range(len(temp)): new_lst.append(temp[j]) else: new_lst.append(lst[i]) new_lst Output: [1, 2, 2, 1, 1]
bdfd26506d21d238f55e5679e34930c852a99c86
MariusDL/Python-Steganography
/steganography.py
2,182
3.921875
4
from PIL import Image import stepic import easygui import base64 # show options to the user print("Choose an option:\n1. Encode text in image\n2. Extract text from image\n") # loop until the user enters a correct choice choice = "" while(not(choice == "1" or choice == "2")): choice = input("Enter your cho...
c40f2d082ce47b2047bc9cdaff881a76e27397fb
franciszxlin/Practice-Problems
/count_and_say.py
1,282
4.125
4
# -*- coding: utf-8 -*- """ Created on Fri May 22 23:52:06 2020 @author: Francis Lin """ """ The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 6. 312211 1 is read off as "one 1" or 11. 11 is read off as "two 1s" o...
70be452441f85c74ed4205e63086486e0b85909b
Sale3054/SwiftRepo3308
/docs/movie_data.py
1,081
3.875
4
#!/usr/bin/python3 from urllib.request import urlopen import json from random import shuffle def api(title): """ The function takes a tile pull info via api then return a json data of the ginve movie """ title = title.replace(" ", "+") response = urlopen("http://www.omdbapi.com/?apikey=cc47980e&t={}".format(t...
9a3071b077f666ffde246e0f72e0cb0b88c450bf
gar-kai/com404
/Notes/bot.py
1,220
3.921875
4
== If the values of two operands are equal, then the condition becomes true. (a == b) is not true. != If values of two operands are not equal, then condition becomes true. (a != b) is true. <> If values of two operands are not equal, then condition becomes true. (a <> b) is true. This is similar to != operator. > If th...
4e560b35fb492beb9aa7e358abfc6ebe8e717196
ay701/Coding_Challenges
/number/findMaxAfterMin.py
475
3.640625
4
# [10,1,15,2,3,5,1,3] def find_max_after_min(l): if len(l) <= 1: return None prev = l[0] min_ = prev max_ = None for cur in l[1:]: if prev < min_: min_ = prev max_ = cur if cur > prev else None elif cur == min_: if max_ is None or cur...
87e166b85733264dcab02b51435b2cced4764008
pretolindao/prova-douglas
/10 LISTA.py
171
3.59375
4
list = [] for i in range(10): word=input(f"ESCREVE QUALQUER COISA) {i+1} de 10)\n") list.append( word + '\n') text = open("list.text", "w+") text.writelines(list)
dd37ae44ec9541992069adec175f379bf1e84740
daniel-reich/turbo-robot
/fNQEi9Y2adsERgn98_16.py
1,586
4.21875
4
""" Write a function that takes the coordinates of three points in the form of a 2d array and returns the perimeter of the triangle. The given points are the vertices of a triangle on a two-dimensional plane. ### Examples perimeter( [ [15, 7], [5, 22], [11, 1] ] ) ➞ 47.08 perimeter( [ [0, 0], [0, 1], ...
39296d73450775bf150d55f89f1884705cb676bb
ch3n-github/Leetcode
/_20_isValid.py
263
3.671875
4
class Solution: def isValid(self, s: str) -> bool: valdic=['{}','()','[]'] s0='' for i in s: s0+=i if s0[-2:]in valdic: s0=s0[:-2] if s0=='':return True else:return False
d6a40e0f05b1040bfea89d08d869a124cd863bdc
pinological/pythonClass4th
/pythonlist1/qn8.py
202
4.1875
4
import array number = input("Enter the number :") temp = number[::-1] if(number == temp): print("The number "+number+" is a palindrome") else: print("The number "+number+" is not a palindrome")
3fe0f513c8b7a35f2f232bc6114d6a47fee13644
rjcrter11/leetChallenges
/arrays/matrix_elements_sum.py
776
3.984375
4
''' Given matrix, a rectangular matrix of integers, where each value represents the cost of the room, your task is to return the total sum of all rooms that are suitable for the CodeBots (ie: add up all the values that don't appear below a 0). Example -For matrix = [[0, 1, 1, 2], [0, 5, 0, 0], ...
d18c10b9adc6cceb4091e3f99ba7c0e584f2bdb8
Srihitha2782/BestEnlist
/task21.py
747
3.859375
4
#1Q def listofTuples(11, 12): return list(map(lambda x, y:(x,y), 11, 12)) list1 = [1,2,3] list2 = ['a', 'b', 'c'] print(listofTuples(list1, list2)) def merge(list1, list2): merged_list = list(zip(list1, list2)) return merged_list list1 = [1,2,3] list2 = ['a', 'b', 'c'] print(merge(list1, list2)...
89a92dc31166267184d089faa36c0f9699de175b
IlyaMosiychuk/python_language
/students/km63/Mosijchuk_Illya/homework_7.py
5,678
3.6875
4
#task1----------------------------------------------- """ Найдите индексы первого вхождения максимального элемента. Выведите два числа: номер строки и номер столбца, в которых стоит наибольший элемент в двумерном массиве. Если таких элементов несколько, то выводится тот, у которого меньше номер строки, а если ном...
e209c8ebcc4a19c0b93982b9497175b6ef587624
candytale55/Bitwise_Operations_Py_2
/11_The_Man_Behind_the_Bit_Mask.py
936
4.53125
5
""" A bit mask is just a variable that aids you with bitwise operations. A bit mask can help you turn specific bits on, turn others off, or just collect data from an integer about which bits are on or off. """ # we want to see if the third bit from the right is on: num = 0b1100 mask = 0b0100 desired = num & mask i...
6891eaaaa7e7136afd12bc737ef3ac5f4e71255c
GitDruidHub/lessons-1
/lesson-06/classwork-01.py
305
3.53125
4
dict_eng_to_rus = { "apple": "яблоко", "house": "дом" } dict_rus_to_eng = { value: key for key, value in dict_eng_to_rus.items() } def from_eng_to_rus(eng): rus = dict_eng_to_rus[eng] return rus def from_rus_to_eng(rus): eng = dict_rus_to_eng[rus] return eng
004f2809837913d7b1cfb949743bd4ce3edde9c0
suchak1/leetcode
/e/univalued-bst.py
544
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def unival(self, root, val): if not root: return True else: return root.val == val and self.univa...
18be90e99417955daeebd2b304f8790b754a2792
evicente71/evicente_pyton
/cadenas.py
1,005
4.28125
4
# Ejemplo de cadenas s1 = "Parte 1" s2 = "Parte 2" print(s1 + " " + s2) #Parte 1 Parte 2 s = "curso de Python" print(type(s)) #Formateo de cadenas x = 5 s = "El número es: " + str(x) print(s) s = "Los números son %d y %d." % (5, 10) print(s) #uso de format cadenas s = "Los números son {} y {}".format(5, 10) prin...
95808b861c32248f3557a3957e39cbe06211f87b
Yifei-Deng/myPython-foundational-level-practice-code
/Woniu ATM version3.0.py
3,691
3.5625
4
''' WoniuATM a. 在前面项目的基础上进一步改进,要求使用一个二位列表来保存用户名和密码 b. 添加如下操作主菜单,用户选择对应的菜单选项进行操作,每次操作完成后继续进入主菜单,用户输入3之后可以结束并退出应用 *****************Welcome to Woniu ATM***************** ******Please Choose One of The Following Options****** **************1.Sign Up 2.Log In 3.Exit*************** ''' users = [ ['Rey','5P1...
46c3d5a31541a82d027ae7a16075716ba603494b
jewells07/Python
/divisible7&5.py
174
3.796875
4
#Find numbers which are divisible by 7 and multiple of 5 between a range n1=[] for x in range(1,200): if(x%7==0) and (x%5==0): n1.append(str(x)) print(",".join(n1))
06fa4009cec4a6db92cce8ae8e8a9bcd24bb5bbe
george39/hackpython
/entrada.py
176
4.15625
4
#!/usr/bin/env python #_*_ coding: utf8 _*_ nombre = input("digite su nombre") edad = int(input("digite la edad")) print('tu nombre es: ' + nombre) print('tu edad es ', edad)
c61eb10372fca1bc295758c20137fd53eaffe7f6
northcott-j/film-revenue-model
/src/data_collection/QueueConsumer.py
1,225
4.0625
4
""" Abstract class to handle taking an item, doing something, and adding it to an output Queue """ from abc import ABCMeta, abstractmethod from threading import Thread class QueueConsumer: __metaclass__ = ABCMeta def __init__(self, ins, outs): self.input_q = ins self.output_q = outs s...
e9e91310537c8efb5f082271da1653d76b94e62b
gurbuxanink/Python-Companion-to-ISLR
/code/chap2/incomeEdPlot.py
1,137
4.15625
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np income_ed = pd.read_csv('data/Income1.csv', index_col=0) # The book does not provide the true function of Income versus Education # This function is similar to the plot shown in the book def edIncome(ed, a, b, c, d): return d + c * np.exp(a ...
854eb1c70addcefc8ce71c70e91795aef40d8fcc
TeoMoisi/LFTC
/Scanner/Scanner.py
3,986
3.53125
4
from LanguageSpecification import operators, lexic, separators, codificationTable import re class Scanner: def __init__(self, pif, symbolTable, fileManipulator): self.pif = pif self.symbolTable = symbolTable self.fileManipulator = fileManipulator def stringWithoutQuotes(self, line, in...
e5e189f6821e116aea1ee15a89c144a6a0ba9344
Winnie1003/python
/dongChui.py
476
3.828125
4
#coding=utf-8 import random #1.获取用户输入 player = int(input("please input a number:0:剪刀,1:石头,2:布...")) #2.获取电脑输入 computer = random.randint(0,2) #3.将玩家的输入和电脑的输入作比较 #玩家盈 if (player == 0 and computer == 1) or (player == 1 and computer == 2) or (player == 2 and computer == 0): print("Congradulation!You win!") #平局 elif pla...
f55a862e6e398f8c8696bffc2777db3bc1cfc6a6
Indiana3/python_exercises
/wb_chapter5/exercise113.py
439
4.28125
4
## # Read a collection of words and display each word only once # # Start with an empty list words = [] # Read a word from user and add it to the list till a blank line is entered word = input("Please, enter a word: ") while word != "": words.append(word) word = input("Please, enter another word: ") # Displa...
2430a171a815debe7d24712c04dad8db852c1d15
TMcMac/holbertonschool-higher_level_programming
/0x03-python-data_structures/10-divisible_by_2.py
265
3.9375
4
#!/usr/bin/python3 def divisible_by_2(my_list=[]): if len(my_list) == 0: return None results = [] for num in my_list: if num % 2 == 0: results.append(True) else: results.append(False) return results
26f4ab2068f8db50d1c58577de51b5d2f943acc0
keerow/python-Q2
/Ex3 - Sequences & Lists/firstlastnameSearch.py
655
4.03125
4
#Prend en entrée le nom des étudiants et renvoie une liste d'étudiants n'ayant pas été cités firstname = ['Anne', 'Bastien', 'Cécile', 'Didier', 'Bastien','Cécile'] lastname = ['Smal','Bodart','Pirotte','Valentin','Boldart','Poireau'] search = [] #Simulation d'un DO WHILE sur python inputname = input("Nom de l'élève...
51a3929965fa81e23638ca2907e017e0ee4e3d38
mitchellflax/lps_grading
/ps6/jorge.py
977
3.953125
4
class Player(object): def __init__(self, name, age, goals): self.name = name self.age = age self.goals = goals def getStats(self): summary = "The players name is " + self.name + "." + "\n" summary = summary + "The players age is " + str(self.age) + "." + "\n" summary = summary + "The players final goals are...
940b5d0055ee9eb938abd40e1c7d624c1d95ddc8
jashby360/Python-Playground
/PythonEx/ch2.26.py
379
3.84375
4
import turtle c = int(input("Enter the radius: ")) turtle.down() turtle.circle(c) turtle.penup() turtle.setposition(-(c * 2), 0) turtle.pendown() turtle.circle(c) turtle.penup() turtle.setposition(0, -(c * 2)) turtle.pendown() turtle.circle(c) turtle.penup() turtle.setposition(-(c * 2), -(c * 2))...
9036b8bbac167a941a4ed09195cd32ef2730d805
pvanh80/intro-to-programming
/round01/study_benefits.py
437
3.875
4
amount_study_benefit = float(input('Enter the amount of the study benefits: ')) index_raise = 0.0117 after_raise = amount_study_benefit*index_raise+amount_study_benefit print ('If the index raise is 1.17 percent, the study benefit,' '\n' 'after a raise, would be', after_raise, 'euros') print ('and if there was another ...
db8402bb7f364388c40a6628a38fa268bd3bd05d
CalicheCas/IS211_Assignment6
/conversions_refactored.py
2,256
3.75
4
def convertThat(self, fromUnit, toUnit, value): # Distance Conversions while fromUnit.lower() == 'miles': if toUnit.lower() == 'meters': return round(value * 1609.344, 2) elif toUnit.lower() == 'yards': return round(value * 1760, 2) elif toUnit.lower() == 'miles...
4d14544d41079e18bba67fad0f72063784f69931
Zoom30/a115_repo
/challenge.py
294
3.859375
4
def tuple_added(nums, target): if type(nums) != list: raise TypeError("You are expected to insert a list") else: for i in range(0, len(nums)): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: return i, j
2016bd3ee79cbee4d4c565cd92d62fc4be2acd17
standardgalactic/bond
/pybond/tutorials/heat_watcher/heat_watcher.py
3,650
3.5625
4
# # A simple demonstration of using Bond for spying and mocking # an application for monitoring temperature and sending alerts # # See a full explanation of this example at # http://necula01.github.io/bond/example_heat.html # # rst_Start import time import re import urllib, urllib2 from bond import bond class HeatWat...
e8f4b54c644f0380cb3fcc83696147f948aac196
GangaJathin/Ganga-Jathin
/NEXUS.py
6,872
4
4
def title(): print("THE.......") print("MYSTERY.....") print("press p to play, q to exit....") print("P.S......press enter to advance to next message") title() print("you are in a cold dark room with an old man with a scar on his eye beside you") print("All you remember is that few minute...
98993ed9b9b69074dc3624a14646e117b5d74f40
aquatiger/LaunchCode
/word count.py
1,841
3.890625
4
# Write a program called alice_words.py # that creates a text file named alice_words.txt # containing an alphabetical listing of all the words and # the number of times each wrod occurs import string file_name = 'oxford.txt' wordset = {} with open(file_name, 'r') as f: for line in f: word_list = line.spl...
bcca74def9958fb37810d2894143e0ceb85e0321
benquick123/code-profiling
/code/batch-2/vse-naloge-brez-testov/DN12-M-001.py
1,788
3.5
4
from collections import * def preberi(ime_datoteke): file = open(ime_datoteke) dictionary = defaultdict(list) line_counter = 1 for line in file: line = line.replace("\n", "") clean_line = map(int, line.split(" ")) dictionary[line_counter] += clean_line line_count...
44f10e8de70cb01b12913be72836374e53b2e2cc
lilharry/rc-data
/utils/hours.py
13,747
3.859375
4
import sqlite3 import os import csv import random def addKcidsToDb(): #connect to db db = sqlite3.connect("data/database.db") c = db.cursor() #open csvs f1314 = open("data/csv/hours_kc-13-14.csv") f1415 = open("data/csv/hours_kc-14-15.csv") f1516 = open("data/csv/hours_kc-15-16.csv") f...
404f9d0498bf7bf466ac1333152ffc988061dbe6
shafirpl/InterView_Prep
/Basics/Colt_Data_structure/DynamicPrograming/fibonaci.py
793
4.1875
4
def fibonaci_recursive(n): if n == 1: return 1 if n == 2: return 1 return (fibonaci_recursive(n-1)+ fibonaci_recursive(n-2)) def fibonaci_memo(n, memo = {}): if memo.get(n) is not None: return memo[n] if n <= 2: return 1 memo[n] = fibonaci_memo(n-1, m...
41056ebd735b836a3b3cc2a3ce38bfc485ef9fcd
pqnguyen/CompetitiveProgramming
/platforms/interviewbit/MaxDepthofBinaryTree.py
455
3.703125
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param A : root node of tree # @return an integer def maxDepth(self, A): return self.maxDepthHelper(A) def maxDepthHel...
bcaf58fbba375c2fbc89e55a4115b25f1a7d588d
vasujain/Pythonify
/lib108.py
231
3.65625
4
#!/usr/bin/env python """Produces a christmas tree pattern of stars.""" ch = "*" bl = " " for i in range(10): print bl*(9-i), print ch*(2*i -1), print bl*(9-1) #9 bl 1 star 9 bl #8 bl 3 star 8 bl #7 bl 5 star 7 bl
986af6784b1e35b488c1e9273e87c4566755cb03
platinum2015/python2015
/cas/python_module/v07_braking_distance.py
343
3.890625
4
def get_braking_distance(v0): ''' Calculates braking distance [m] with mu = 0.3 and v0 [km/h] ''' mu = 0.3 #Coefficient of friction g = 9.81 # gravitational acceleration return 0.5*v0**2 / (mu*g) velocity = 100 #km/h print "The braking distance for v0=",velocity,"is",get_braking_d...
7ffdf8aa753b4eb6eb2ae72a04aaa3d22f073f9f
syurskyi/Python_Topics
/021_module_collection/counter/_exercises/templates/counter_005_Updating from another Iterable or Counter_template.py
1,135
4.3125
4
# f.. c... _______ d..d.., C.. # # # Updating from another Iterable or Counter # # Lastly let's see how we can update a Counter object using another Counter object. # # When both objects have the same key, we have a choice - do we add the count of one to the count of the other, # # or do we subtract them? # # We can do...
16c1d2822646823aa5f5f0c5567ab17db67d62cf
andystanier/andystanier.github.io
/projects/Yahtzee/yahtzee.py
4,146
4.0625
4
#!/usr/bin/python ############################################################## ## ## Yahtzee.py ## Andy Stanier ## 29-30 August 2016 ## ## The purpose is to simulate throwing a Yahtzee ## (Five of a kind with 5 dice) and counting how ## many goes it takes before it occurs. ## ## The process is repeated many t...
462d132fc58a8f29bc642d2b55d56714831bb30e
upon120/pythonAlgorithm
/code/第一章/1-6(p24).py
350
4.0625
4
num1 = int(input("Enter the dividend:")) num2 = int(input("Enter the divider:")) if num2 != 0: #如果输入的除数不是0 result = num1/num2 if result == int(num1/num2): #如果result的值与两数相除取整后的值相等 print(int(result),"integer") else: print(result,"decimal") else: print("The divider can’t be 0.Error.")
0b130db7ae27c0a89c40d7b9e680d0bb5a302cd8
menglf1203/python
/课堂/list.py
2,885
3.90625
4
# /usr/bin/env python # -*- coding:utf-8 -*- #列表list # a=[1,'dfgh',3,4,5] # print(a[1]) #支持索引 # print(a[:]) #中括号里加:是显示全部的 # print(a[-2]) #也支持反索引 # print(a[2:9]) #支持切片 # print(a[:2]) # a=[123,'sad',213,['fgh','ytr',87],5,56] # #列表中有:数字,字符串,列表,元组等 # print(a[1][0]) #支持嵌套索引 # print(a[1][2]) #前提是提取的元素是支持索引(也就是字符串)...
153b9506f70150871f135fb9cc002e757a5ba8db
Aeres-u99/tsurusetto
/tsurusetto.py
646
4.5
4
#!/bin/env python3 # 2 Enter space betweeen similar functions/conversives of each other # 4 Enter space betweeen 2 different functions # A comment line to specify what it does. def character_to_ascii(character_series): '''Converts a characterstring to ascii numbers''' ascii_series = [" ".join(str(ord(characte...
dd1417c7ca8a59ab9434afe61b0c9f6409c7d6e4
tnakaicode/jburkardt-python
/polpak/omega.py
6,345
4.03125
4
#! /usr/bin/env python # def omega(n): # *****************************************************************************80 # # OMEGA returns OMEGA(N), the number of distinct prime divisors of N. # # First values: # # N OMEGA(N) # # 1 1 # 2 1 # 3 1 ...
e20fabfeb57512caa024f152e85c902d51d91ceb
komalahire/Test-questioin
/prime.py
202
4.125
4
user_input = input("enter your number") i = 2 while i < (user_input): if user_input % i == 0: print ("not prime number") break i = i + 1 else: print ("prime number")
eb05fed186593ad09d834d19d4af40fe957eb506
DenisPower1/NOS
/tests/teste.py
134
3.828125
4
while True: n=0 n=input("Informe o número a ser multiplicado ") for x in [1,2,3,4,5,6,7,8,9,10,11,12] : print(n,"X",x,"=",n*x)
c5d3b8afbe27965f5d360b7536128d07fb0202d9
cnyy7/LeetCode_EY
/leetcode-algorithms/242. Valid Anagram/242.valid-anagram.py
1,318
3.984375
4
# # @lc app=leetcode id=242 lang=python3 # # [242] Valid Anagram # # https://leetcode.com/problems/valid-anagram/description/ # # algorithms # Easy (52.42%) # Likes: 747 # Dislikes: 111 # Total Accepted: 356.2K # Total Submissions: 676.9K # Testcase Example: '"anagram"\n"nagaram"' # # Given two st...
3bb0dd7e18654592917a9d5b37db4042eabdf32f
milw0rmch/SPSE
/Module2/inputParser.py
545
3.9375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sun Feb 5 11:39:00 2017 @author: root """ def input_Parser(portRange): plist = portRange.split("-") # print plist[0] # print plist[1] portList = range(int(plist[0]),int(plist[1])+1) return portList # print portList[2] ...
fc29352ab6004121baad2b6d3f44092fce02b6e0
nweston/sort-visualizations
/sort.py
4,695
3.734375
4
import hypothesis.strategies as st def selection_sort(data): """Sort contents of data in place. This is a generator which yields each algorithm step (comparison or swap), allow for visualization or instrumentation. The caller is responsible for performing swaps. """ for dest in range(len(data) - 1): y...
620a60aa84f44480ccc5843d259509d0304b5c0c
oyxhm/Leetcode
/Leetcode-Python/FlattenBinaryTreeToLinkedList.py
1,051
4.25
4
""" Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 """ from TreeNode impo...
3bcad3924bf0c413103c9d522a16f052937969be
runalb/Python-Problem-Statement
/PS-1/ps04.py
270
4.375
4
# PS-04 WAP to accept radius of circle and calculate area and circumference of circle r = float(input("Enter radius of circle: ")) #Aera of circle area = 3.14 * r * r #Circumference of circle circum = 2 * 3.14 * r print("Area:",area) print("Circumference:",circum)
e34370dea04d81a7746edda98242fab660f8d81e
joonkyu4220/LeetCode
/Remove Nth Node From End of List.py
1,528
3.65625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode "...
8ab1b9300d8fa05c260086882736e11037756f97
eshaanmandal/morse_shu
/morshu.py
4,677
3.6875
4
class Morse: '''the default dictionary used for encoding and decoding ''' morse_codes = { 't':'-', 'e':'.', 'm':'--', 'n':'-.', 'a':'.-', 'i':'..', 'o':'---', 'g':'--.', 'k':'-.-', 'd':'-..', 'w':'.--', 'r':'.-.', 'u':'..-', 's':'...', '?':'----', '.':'---.', 'q':'--.-', 'z':...
a099f9a99aa4b730d4843044b06272759b21b997
akimitsu1025/kadai-04
/for_study.py
8,043
3.953125
4
import pandas as pd ### 商品クラス class Item: def __init__(self,item_code,item_name,price): self.item_code=item_code self.item_name=item_name self.price=price def get_price(self): return self.price ### オーダークラス class Order: def __init__(self,item_master): self.item...
f74ce7c37ba366e011194db3eae095451e8f6278
c2eien/python
/hardway/ex13.py
524
4.1875
4
from sys import argv # argv is a MODULE that allows you to pass variables through the command line # so you run this file from the command line like this: "python ex13.py 1st 2nd 3rd" # where 1st 2nd 3rd are the variables after the script name print(argv) script, first, second, third = argv # this unpacks/maps the g...
ca21032f32fd02073167d1e781539137012f8ecb
janissuonpera/school_work
/Python/round1/checkers.py
372
3.65625
4
r = int(input()) c = int(input()) h = int(input()) w = int(input()) for z in range(1, r+1): for x in range(1, h+1): for c in range(1, c+1): for v in range(1, w+1): if(z%2 != 0): if(c%2 != 0): print(" ", end="") else: print("#", end="") else: if(c%2 == 0): print(" ", end...
576cc092ec8a0d19d7e27bc917202efd95810dcf
HusanYariyev/Python_darslari
/57-masala.py
265
3.671875
4
ism = input("Ismingizni kiriting ") son = int(input("Necha martta takrorlasin ")) def takror(ism): if ism[len(ism)-1] != " " : ism = ism + " " else: ism = ism return lambda n : n * ism x = takror(ism) print(x(son))
b9d0113abc4f9ca6ca4e62aeb38d03fdbc61d5f5
amithimself/rbac
/rbac_app/models/resources.py
824
3.515625
4
class Resources: def __init__(self): self.resourcesList = {} def add_resource(self, resources_name, required_persmission): """Add a resource in the system :param name: name of resource and permission associated for the resource """ self.resourcesList[resources_name] = ...
3f6cfdbc4eaa1f85fbeac72e60dce722773ce0a9
antho1810/CursoPython
/Tareas/ActividadFor.py
175
3.671875
4
def main(): V1 = int(input("Ingrese el primer valor: ")) V2 = int(input("Ingrese el segundo valor: ")) for i in range(V1, V2): if i % 2 != 0: print(i) main()
67c5028a12b5d04e84b2360091d3628624bfb06f
santoshtbhosale/Python-String
/Python_Interview_program.py
3,267
4.125
4
""" Write a program to demonstrate different number data types in Python. a = 34 b = 34.7 c = 3 + 4j print(type(a)) print(type(b)) print(type(c)) ______________________________________________________________________________________ Write a program to create, concatenate and print a string and accessing sub-...
ea447e7bda484358b280cea02f588fd17b9df919
Sattik-Tarafder/PYHTON
/noob_kuhu.py
451
4.28125
4
# Program to sort alphabetically the words form a string provided by the user # Define sentence word = "Hello this Is an Example With cased letters" # Split string by space, then sort the splitted string, and then put the string back together word = ' '.join( sorted( word.split() ) ) # word.split() - Splits stri...
b4d80daa0ad92a2456dd871443eb482a643698a9
letsudo/learn_python
/09_python_loop_statements.py
2,094
4
4
# coding=utf-8 # 循环类型 描述 # while 循环 在给定的判断条件为 true 时执行循环体,否则退出循环体。 # for 循环 重复执行语句 # 嵌套循环 你可以在while循环体中嵌套for循环 # break 语句 在语句块执行过程中终止循环,并且跳出整个循环 # continue 语句 在语句块执行过程中终止当前循环,跳出该次循环,执行下一次循环。 # pass 语句 pass是空语句,是为了保持程序结构的完整性。 count = 0 while (count < 9): print 'The count is:', count count = count + 1 print "G...
3b6c491307c8238f836eb109e14ada90ef1655ad
mryanivtal/dual_svm_project
/src/svm/helpers/data_helpers.py
3,031
3.5625
4
import pandas as pd import numpy as np def convert_class_to_int(df: pd.DataFrame, target_column: str, DEBUG=False) -> dict: """Converts DataFrame Target object column from string to integer in {-1, 1}, updates the dataframe in-place. Gets: df - dataframe target_column - Target column name re...
3f69d04480d7db06f88251162f4f5f32ad86b752
alixhami/palindrome_check_python
/palindrome_check.py
191
3.796875
4
# A function to check if the input string is a palindrome. # Return True if the string is a palindrome, otherwise return False. def palindrome_check(my_phrase): raise NotImplementedError
94353813b9f04451ec8b7489d4deda5710dfcaeb
Neminem1203/Puzzles
/DailyCodingProblem/30-rainWall.py
2,061
4.03125
4
''' You are given an array of non-negative integers that represents a two-dimensional elevation map where each element is unit-width wall and the integer is the height. Suppose it will rain and all spots between two walls get filled up. Compute how many units of water remain trapped on the map in O(N) time and O(1) sp...
4d17776eb2dd0857e8b30a7267d9cd943f819365
mehdirezaie/f2py
/ex2/hw_python.py
330
3.5
4
#!/usr/bin/python """ Pure Python module to do matrix multiplication (c) Mehdi Rezaie """ import math, sys,numpy def mul(x,y): t = numpy.shape(x) z = numpy.zeros((t[0],t[0])) for i in range(t[0]): for j in range(t[0]): for k in range(t[0]): z[i][j] += x[i][k]*y[k][...
ab5e25eb1fb40bfd794ebff06b3fb86f8da83113
HagenGaryP/lpthw
/ex14.py
998
4.3125
4
# Exercise 14: Prompting and Passing # In this exercise we'll use input slightly different by having it print # a simple > prompt. This is similar to games like Zork or Adventure. from sys import argv script, user_name = argv # command line arg - "python ex14.py Name" prompt = '> ' print(f"Hi {user_name}, I'm...
f114fd5b958f06c7642c914113b7de5b22f6634f
Lisolo/ACM
/leap_year.py
369
3.546875
4
# coding=utf-8 import datetime year = '2014' def isLeapYear(y): y = int(y) if (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0): print 366 else: print 365 def isLeapYear2(y): y = int(y) y1 = datetime.datetime(y, 1, 1) y2 = datetime.datetime(y+1, 1, 1) print str(y2 - y1).spl...
67cfc04ef7569fed8c48d5a04ad7d443fb15bf16
kylegarrettwilson/Python-Madlib
/Intro to Python/main.py
1,728
4.09375
4
print "Hello World" # one line comments ''' this is multiple lines (doc strings) ''' first_name = "Kermit" last_name = "The Frog" response = raw_input("Enter your name ") print "Hello there, ", response #expressions birth_year = 1989 current_year = 2016 age = current_year - birth_year print "You are " + ...
5e44053edbc76774efae6a7736c6fbefa2fa1779
kedgarnguyen298/nguyenquockhanh-fundamental-c4e24
/session2/homework/serious_ex2.py
121
4.15625
4
n = int(input("Enter a number: ")) fac = 1 for i in range(1, n+1): fac *= i print("Factorial of", n, "is: ", fac)
1b3f99fcae5d9049d6323706819d4ef2a356e90d
CelesteRCodes/whiteboardingpractice
/sum-counts/count.py
1,231
4.46875
4
"""Count words in a sentence, and print in ascending order. For example:: >>> word_count("berry cherry cherry cherry berry apple") apple: 1 berry: 2 cherry: 3 If there is a tie for a count, make sure the words are printed in ascending order within the tie:: >>> word_count("hey hi hello") hel...
598dea25a327a5b4388d395da60f1d72ff764862
mwarne97/Meme_Generator
/src/QuoteEngine/models.py
633
3.609375
4
"""QuoteModel defines the structure of a meme's quote.""" class QuoteModel: """A quote model. A quote model comprises a body of text and an author, both of which are required. """ def __init__(self, body: str, author: str): """Create a new 'QuoteModel'.""" self.body = body se...
88b75bed128ab946873296ab7fe9894729f8b96c
jocelinoFG017/IntroducaoAoPython
/01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex26.py
295
3.625
4
""" Leia um valor de área em metros quadrados m² e apresente-o em hectares. A fórmula de conversão é: H = M * 0.0001, sendo M a área em m² e H a área em hectares. """ area = float(input("Valor da área (M²): ")) convert = area * 0.0001 print("Em Hectares fica: {:.4f}".format(convert))
e1d7e436ff1ad01ff4490dc2de4a61b2a3e739c1
shlesh/Python
/car_game.py
959
4.125
4
print('''Welcome to the Car Game Start Stop Quit''') var = input("what would you like to do? ").upper() status = False while len(var) >= 0: if var == "START": if status == False: status = True print("Car has started") status = True var = input("What would you ...
2a2c92eac65a47807f7d9e8441ce6c879d48d828
eriksnc/CYPErikNC
/libro/Problemas_resueltos/capitulo2/problema2_1.py
91
3.515625
4
n=int(input("Dame un valor:")) if (n>0): t=n/4+40 print("La temperatura es de,",t)
934ca2bca3540fca06c3c3f363fb6281253a7199
harryhk/ProgrammingCompetition
/rpi_UPE/PC2012-spring2/prac/years.py
565
3.609375
4
#!/usr/bin/env python from __future__ import print_function import sys , pdb def travel(l,time): diff = [ y-x for (x, y) in zip( l, l[1:] )] diff.sort() jump = len(diff) for i in diff: time = time -i if time <= 0: if time == 0 : jump=jump-1 break else: jump = jump -1 return jump ...
69e582f8cab2743ea65e3b89bc795fd719a11a53
awzsse/Keep_Learning_ML
/PythonDataStructure/DataStructure/single_cycle_link_list.py
5,562
3.90625
4
# 首先定义一个节点类 class Node(object): def __init__(self, elem): self.elem = elem self.next = None class SingleLinkList(object): # 单向循环链表 # 定义构造函数,默认参数node为None,即一个Node类的对象 def __init__(self,node=None): # 设置私有属性,头节点先指向None self.__head = node # 如果不是空链表,让第一个节点的next指向自己 if node: node.next = node # 判断链表是否为空...
6aa189c5418517066d8a22ebb13047bc6b9e7cc3
asihacker/python3_bookmark
/python笔记/aaa基础内置/python内置模块/signal信号模块/timeout-decorator模块实现超时机制.py
725
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/15 20:09 # @Author : AsiHacker # @File : timeout-decorator模块实现超时机制.py # @Software: PyCharm # @notice : True masters always have the heart of an apprentice. import time import traceback import stopit # https://www.cnblogs.com/haoxr/p/8757985.html ...
5daea9573ee2764a78cd8cf6074fc4428ac64621
zTaverna/Logica-de-Programacao
/Unidade 01/Aula 04 ex 04.py
439
4.15625
4
print("Digite os lados de um triângulo:") a=float(input("Lado 1: ")) b=float(input("Lado 2: ")) c=float(input("Lado 3: ")) if a<(b+c) and b<(a+c) and c<(a+b): if a==b and b==c: print("O triângulo é equilátero!") else: if a==b or a==c or b==c: print("O triângulo é isósceles...
50103f6538f1b1ac23c34d3ccad29d72336d4677
rsaravia/PythonBairesDevBootcamp
/Level2/ejercicio1.py
408
4.09375
4
# 1. Write a Python program to scan a specified directory and identify the sub directories and files. import os #get all the elements of current working directory l = os.listdir(os.getcwd()) print("elementos en ",os.getcwd(),": ", l) for elemento in l: if os.path.isfile(os.path.join(os.getcwd(),elemento)): ...
aecce113728843f51a52f13535c79f4951a68eee
BrennoBernardoDeAraujo/ALGORITMOS-2019.2
/A2.Q4.py
526
4.0625
4
n1 = float(input("digite um numero: ")) n2 = float(input("digite outro numero: ")) n3 = float(input("digite mais outro numero: ")) if n1 <= n2 and n2 <= n3: print(n3,n2,n1) if n2 < n1: aux = n1 n1 = n2 n3 = aux if n3 < n2: aux = n3 n3 = n2 n2 = a...
fe49c869128cf2d704aa1cc08c17c28170181e03
S-Vel/day-4-
/Question 03.py
81
3.515625
4
a=50 b=50.74 print("Int to float a: ",float(a)) print("Float to int b: ",int(b))
fe51bbf21a1cb9188e4cbc6a147bfe4d2dd3fecf
emildoychinov/Talus
/loader/maths.py
3,298
3.90625
4
import re class grammarError(Exception) : pass #the tokenizer for the parser class Tokenizer: def __init__(self, expr): #we split the expression into different tokens with a regular expression self.tokens = re.findall(r'[\d\.]+|[+-\/*\(\)\^]', expr) #if lettets (a-Z) are in the expression it...
161b04446c18397bec71c78b670e0c20d79bf37d
XMK233/Leetcode-Journey
/py/231.py
822
3.609375
4
class Solution: def isPowerOfTwo(self, n: int) -> bool: ## 大佬的思路:n和n-1按位与,得0,则为幂。 ## 要注意,边界条件如果是0,1之类,属于特殊情况,需要另行对待。 if n == 0: return False if n == 1: return True return (n & (n - 1) == 0) ## 我的思路:反正就是1打头后面皆是0的数字就对了。 ## 那就酱紫:这个数右移一位,再左...
203cb1e2b2dfb59ada4faac11d2d30e63466df2f
a307/Pong-Game
/Pong_Game.py
4,351
3.96875
4
# simple pong game # 2020-08-16 Sean B # name of file ---> Pong_Game.py import turtle # creating window for GUI wn = turtle.Screen() # window title, colour, and demenions wn.title("Pong by Sean") wn.bgcolor("black") wn.setup(width=800, height=600) # updates window faster wn.tracer(0) # Score score_...
7f4fbe710728db649fbc3164cd7658d6bc984e94
suchi-dev/python-practice
/data_structures.py
548
3.609375
4
our_list = [ 27, 46, -1, 17, 99] print(our_list) print(type(our_list)) jackson = ["A", "B", "C", 1,2,3, "Do", "Rey", "Mi", True, False] print(jackson[4]) print(jackson[7]) print(jackson[-2]) x = jackson[6] print(x) print(jackson[0:3]) my_list=[1,2, [3,4,5],6,7, 8] print(my_list[2]) print(my_list[2][0]) print(my_list[...
bbac63f6f91fae88d6e43656ec0f3a51af8d1f89
jimbrunop/brunoperotti
/Exercicios-Python/DecisaoExercicio26.py
2,175
3.734375
4
# Um posto está vendendo combustíveis com a seguinte tabela de descontos: # # Álcool: # até 20 litros, desconto de 3% por litro # acima de 20 litros, desconto de 5% por litro # Gasolina: # até 20 litros, desconto de 4% por litro # acima de 20 litros, desconto de 6% por litro Escreva um algoritmo...
1d93b7a51dc4979a8de22e1ad02c5a886bf77d98
jegiraldp/python
/calculadora/inicio.py
1,532
3.765625
4
from suma import suma from resta import resta from producto import producto from division import division import sys class inicio: def inicio(): inicio.menu() def menu(): print("\n-----------------------") print("Calculator T2000\n") print("1. Sumar") print("...
eb0c5d436ca162983688852debbb31b9e63db828
JulianKemmerer/Drexel-CS260
/PA2/group4-assignment2/tries.py
1,266
4.21875
4
#!/usr/bin/env python from array import * from list_array import * def makeTrie(): allWords = [] f = open("AliceInWonderland.txt","r"); lines = f.readlines(); for i in lines: thisline = i.split(" "); for j in thisline: if j!="": allWords.append(j.strip()) x=ListArray() for word in allWords: for ...
9224e40d1f4b6309099dcdb1d214b0947f3e83c5
kumaranshu8092/Python_tut
/Day-3/treasure_island.py
1,248
4.5
4
#day-3 project print("Welcome to treasure Island \nYour mission is to cross through the door alive") direction=input("You are at cross road.Where you want to go? Type 'left' or 'right'\n") if(direction=='left' or direction=='Left'): print("You come to a lake.\nThere is an island in the middle of the lake....
d61ca312823933744e122218ded8d5ef056ccaf6
Mondiegus/Python_learning
/Basics/euclidean_distance2.py
833
3.84375
4
from math import sqrt def euclidean_distance(A, B): """ >>> A = (0,1,0,1) >>> B = (1,1,0,0) >>> euclidean_distance(A, B) 1.4142135623730951 >>> euclidean_distance((0,0,0), (0,0,0)) 0.0 >>> euclidean_distance((0,0,0), (1,1,1)) 1.7320508075688772 >>> euclidean_di...
f13f8e376f008d27bb4233044864b8632423ace3
gabriellaec/desoft-analise-exercicios
/backup/user_348/ch40_2020_06_21_22_25_41_499277.py
385
3.78125
4
#Com for def soma_valores (valores): s = 0 for i in range(len(valores)): s = s + valores[i] return s #Com while def soma_valores (valores): # Determina uma variável com o valor inicial da soma s = 0 i = 0 while i< len(valores): # Atualiza o valor da soma para cada elemento d...
10f2ad8bc33b8d4dd3907927e7910cddae826c95
riley-csp-2019-20/1-2-3-apple-avalanche-pickles9
/123adamschmok.py
4,522
3.578125
4
# a123_apple_1.py import turtle as trtl import random apple_image = "apple.gif" # Store the file name of your shape wn = trtl.Screen() wn.addshape(apple_image) # Make the screen aware of the new file wn.setup(width=1.0, height=1.0) wn.bgpic("tree.gif") #apple = trtl.Turtle() #drawer = trtl.Turtle() nu...