blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f19d6e9e46c6a3265b4625ef98f952e14861a862
artopping/nyu-python
/course1/assignment_5/exercises_test.py
404
4.125
4
x = (raw_input("would you like to convert fahrenheit(f) or celsius(c)? ")) if x == "f": y = (raw_input("what is the fahrenheit?")) f = (int(y) - 32) * 5.0 / 9 print ("and in celsius, that is: "), print (f) elif x == "c": y = (raw_input("what is the celsius?")) f = (int(y) *9) / 5.0 + 32 prin...
false
d3c1a39d1a4f9e21ea569ae1bc0720314ae856e2
artopping/nyu-python
/course1/assignment_5/test.py
284
4.28125
4
#!/usr/bin/env python import sys def convert_f2c(S): """(str): float Converts a Fahrenheit temperature represented as a string to a Celsius temperature. """ fahrenheit = float(S) celsius = (fahrenheit - 32) * 5 / 9 return celsius print (celsius)
false
8ba5229b9bf24c36eec6fc113b1b020064b8ed87
artopping/nyu-python
/course2/session2/classses_session2.py
710
4.4375
4
#!/usr/bin/env python3 #Classes: storage of data and set of functions that define the class # class has a function and data (local to itself) # when you want to use it< instance= MyClass()> class MyClass: pass #obect my_circle as instance of Class circle # think of class as bucket...lot of room, for data storage a...
true
89db7f6519f2542bec43ceecaa3be231b1e429af
vivekgupta8983/python3
/range.py
269
4.21875
4
#!/usr/bin/python3 #range functions returns a sequence for number start from o and ends ta specific number #range(start, stop, step) # for i in range(100): # print(i) # for i in range(2, 10, 2): # print(i) my_range = range(1, 10) print(my_range.index(3))
true
064cb46b734706c23c60ce872fb16fccecee22a4
nikileeyx/learning_python
/2. Dictionary and List/2002_codeReusing.py
842
4.34375
4
#The Code Reusing 1.0 by @codingLYNX ''' Note: In this question, 0 is considered to be neither a positive number nor negative number. You are to implement the following three functions with the following specifications: is_odd(x) returns True if the input parameter x is odd, False otherwise. is_negative(x) returns Tru...
true
dffa406f4b6f6f5d0ee226b49991d5b9f625a711
zeydustaoglu/8.hafta_odevler-Fonksiyonlar
/11. OzgunListe.py
507
4.21875
4
# Verilen bir listenin içindeki özgün elemanları ayırıp yeni bir liste olarak veren bir fonksiyon yazınız. # Örnek Liste : [1,2,3,3,3,3,4,5,5] Özgün Liste : [1, 2, 3, 4, 5] try: newListe = [] def ozgunListe(list): for i in list: if i not in newListe: newListe.append(i) ...
false
690f4504114a972a0c3aa1b2021b820880eff724
kmurphy13/algorithms-hw
/dac_search.py
736
4.1875
4
# Kira Murphy # CS362 HW2 def dac_search(lst: list, key) -> bool: """ Function that searches for an item in an unsorted array by splitting the array into halves and recursively searching for the item in each half :param lst: The unsorted array :param key: The item being searched for :return: Tr...
true
5ceff881fad153efd3b9ce95dfd6b77c7b9f55fa
cheung1/python
/help.py
441
4.15625
4
#1.write the triangle print code # notice: when you just define, it cannot execute #2.define a function def printTriangle(): 'this is the help document ' print ' * ' print ' * * ' print '* * *' #3.invoke the function #notice:only can via the invoke to use the function # invoke the function: write the functio...
true
520ac63216a371940b7c98b2a152bd67b73c1bff
abhisjai/python-snippets
/Exercise Files/Ch2/functions_start.py
1,780
4.78125
5
# # Example file for working with functions # # define a basic function def func1(): print("I am a function") # func1() # Braces means to execute a function # value on console was any print command inside the function # If there was any return value, it was not assigned to any variable # print(func1()) # Execu...
true
4239a7ae04f3adc3b0546b9e18d03d7dbd90946c
abhisjai/python-snippets
/Misc Code/python-tuples.py
1,180
4.28125
4
# Task # # Given an integer n and n space-separated integers as input, create a tuple t, of those n integers. Then compute and print the result of # Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. # Input Format # The first line contains an integer, n, denoting the number of...
true
9b5aae311a253e7f46830efdb6e8bc2c00d67f9e
abhisjai/python-snippets
/Python Essential/Exercise Files/Chap03/sequence.py
603
4.15625
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # x = [ 1, 2, 3, 4, 5 ] # for i in x: # print('i is {}'.format(i)) x = {"one": 1, "two": 2, "three": 3, "four": 4} # for i in x: # print("key {}".format(i)) # for key, value in x.items(): # print("key {0:<5} value {1:<5}".format(key, value)...
false
708d5102fb648b48abd4dd3886f5bb923cf2b856
varunmalik123/Python-Data-Analysis
/write_columns.py
930
4.53125
5
def write_columns(data,fname): """ The purpose of this function is to take a list of numbers and perform two calculations on it. The function will generate a csv file with three columns containing the original data and the result from the first to calculations respectively :param data(list with elements being e...
true
5f6fb8aae1249d25774cf94ddea5c0fb8b9d41a2
Demon520-coder/PythonStudy
/study_08/Dog.py
597
4.40625
4
#创建类: #注意点:1.约定类的首字母大写;2.类的构造函数为:__init__;3.类中的每一个方法都必须传递self形参,因为python在创建实例时会自动传递self; #3.python类没有构造函数重载; class Dog(): def __init__(self,name,age): self.name=name self.age=age def sit(self): print("This dog has beeb sit") def show(self): msg="Dog's name is "+self.name...
false
252bbca8310794f46c6eb24afacc135492508421
Demon520-coder/PythonStudy
/study_01/homework.py
1,427
4.34375
4
#01.输出一段字符串: print('This is my first python program') #02.定义一个变量,并输出大写,小写,首字母大写形式 name='Mr jonh james' print(name.upper()) print(name.lower()) print(name.title()) #03.去除字符串首位空格、末尾空格、首位空格 address=' Beijin ' print('|'+address+'|') print('|'+address.lstrip()+'|') print('|'+address.rstrip()+'|') print('|'+address.strip()+'...
false
d8df82383460b7c1730b7d2af1623a797fb35e5e
ra3738/Latext
/hasConsSpace.py
1,261
4.15625
4
#Checks if current index is a space, returns boolean def isThisASpace(str, index): if (str[index] == " "): return True else: return False #Checks if current index and next index are spaces, returns boolean #If at second last index, returns false def hasConsSpaces(str, index): if (index + 1 < len(str)): if (i...
true
3060d4c3f53a1a2a35e9c41f79cf6c5c8b08402f
JadedCoder712/Character-Distribution
/testing123.py
2,877
4.21875
4
""" distribution.py Author: Kyle Postans Credit: Kyle Postans, Mr. Dennison Assignment: Write and submit a Python program (distribution.py) that computes and displays the distribution of characters in a given sample of text. Output of your program should look like this: Please enter a string of text (the bigger th...
true
0cc275639d9847d73865c59c944c271b99605bb7
RohitPr/PythonProjects
/07. Banker Roulette/7.Banker_Roulette.py
502
4.34375
4
""" You are going to write a program which will select a random name from a list of names. The person selected will have to pay for everybody's food bill. Important: You are not allowed to use the choice() function. """ import random names_string = 'Angela, Ben, Jenny, Michael, Chloe' names = names_string.s...
true
b504f63cabe4ac1ad9f493410378566fda23f66b
CihanKeles/ACM114_Sec2
/Week6/nested_for_exp.py
614
4.1875
4
num_students = int(input('How many students do you have? ')) num_test_scores = int(input('How many test scores per student? ')) for student in range(num_students): total = 0.0 print('Student number', student + 1) print('-----------------') for test_num in range(num_test_scores): print('Te...
true
799fcd9e6c1b9ad2b4f8bd37dcb14989a808bb59
CihanKeles/ACM114_Sec2
/Week14/ACM114_Quiz_Week13_solution.py
864
4.125
4
import random # The main function. def main(): # Initialize an empty dictionary. number_dict = dict() # Repeat 100 times. for i in range(100): # Generate a random number between 1 and 9. random_number = random.randint(1, 9) # Establish or increment the number in ...
true
b0b91399237afcfe69a0b2c78428f139f658950f
tanngo1605/ProblemSet1
/problem5/solution.py
583
4.1875
4
#This is a really cool example of using closures to store data. # We must look at the signature type of cons to retrieve its first and last elements. cons takes in a and b, and returns a new anonymous function, which itself takes in f, and calls f with a and b. So the input to car and cdr is that anonymous function, ...
true
0f9544217d43d0c5ffeb6be1d93d2e33ef345bd0
tutunamayanlar2021/Python
/tuple.py
324
4.21875
4
tuple =(1,"iki",3) list=[1,2,"kader"] print(type(tuple)) print(type(list)) print(len(tuple)) list=["ali","veli"] #güncelleme # tuple=["sena","polo"] list[0]="ahmet" #degitirebiliyoruz #tuple[0]=2 #degiştirilemez print(tuple.count(1)) names=("nobody","who") +tuple #toplma işlemi yapılabiliyor print(list) print(names)
false
24c3d30472fa0fb9cfe9d8f018b4e39dfb3592da
tutunamayanlar2021/Python
/list_methods_Exsample.py
1,086
4.46875
4
names=["Ali","yağmur","hakan","Deniz"] years= [1998,2000,1998,1987] # "cenk"ismini listenin sonuna ekleyin names.append("Cenk") #"sena"ismini listenin basına ekleyin names.insert(0,"Sena") #'deniz'ismini listeden siliniz #names.remove("deniz") # index=names.index("Deniz") # print(index) # names.pop(index) # print(names...
false
5a830eb25ff9411d7390a9e115b36a7c20481e24
tutunamayanlar2021/Python
/referance.py
365
4.15625
4
#value types=>string,number # deger tuttugu için atamadan sonra yapılan degişiklik # sadece yapılanı degiştirir.adresler aynı degil. x=10 y=25 x=y y=30 #print(x,y) #referance =>list,class #Since the addresses are the same, they both change after assignment a=["apple","banana"] b=["apple",...
false
bf772445c70ed744a38609bb35aa045d5d5e29ec
sujanay/python-interview-questions
/tree.py
2,011
4.125
4
from __future__ import print_function # Binary Tree Node class TreeNode: def __init__(self, v, l=None, r=None): self.value = v self.left = l self.right = r # insert data to the tree def tree_insert(root, x): attr = 'left' if x < root.value else 'right' side = getattr(ro...
true
2e615d7d4fc73f1a5540ec12938b87b2f769b5b9
sujanay/python-interview-questions
/python/Algorithms/IsAnagram.py
515
4.4375
4
"""check if the two string are anagrams of each other""" """ Method-1: This method utilizes the fact that the anagram strings, when sorted, will be equal when testing using string equality operator """ def Is_Anagram(str1, str2): if len(str1) != len(str2): return False str1_sorte...
true
8ba114592dbf2cb24b7d441d2bf84cac1b5a3228
chendaye/py100
/基础/练习/栗子-07.py
509
4.25
4
""" 计算点的距离 """ from math import sqrt class distance: def __init__(self, x, y): self.x = x self.y = y def move_to(self, x, y): self.x = x self.y = y def move_by(self, x, y): self.x += x self.y += y def dis(self, x, y): return sqrt((self.x - x)...
false
b3554ace99a9f2df79f386fafd19464937d7d4e6
tapczan666/sql
/homework_03.py
504
4.21875
4
# homework assignment No2 - continued import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() # find all car models in the inventory c.execute("SELECT * FROM inventory") inventory = c.fetchall() for car in inventory: print(car[0], car[1]) print(car[2]) # find all order date...
true
3468722bd044822a7f85464074bc0a6cdae623bb
prydej/WordCount
/Tracker.py
712
4.1875
4
""" Author: Julian Pryde Name: Essay Tracker Purpose: To count the number of words over two letters in a string Dat: 22MAR16 Input: A String Output: An integer containing the number of words over 2 letters in input """ import sys # Read String from file essay_handle = open(sys.argv[1]) essay = essay_handle.read() essa...
true
44473c6405aaa3b116b39c9887e9dd7c53413b1f
Luciano-Grilli/ejercicios-python-del-curso-seguido
/excepciones.py
915
4.125
4
import math try: #acortar decimales num1 = int(input("Ingrese un numero: ")) num2 = int(input("Ingrese otro numero: ")) print("resultado de la division es:","{0:.2f}".format(num1/num2)) except ZeroDivisionError:#al lado se puede poner el tipo de error o no y que respond...
false
6199c577d8e6bef67694d770bded9339a9293ac4
AzwadRafique/Azwad
/Whacky sentences.py
602
4.3125
4
import random adj = input("Insert an adjective ") noun = input("Insert a noun ") verb = input("Insert a verb ending with 'ing' ") if verb.count('ing') == 0: verb = False while verb == False: verb = input("Please insert a verb ending with 'ing' ") sentences = [f"Our house has {adj} furniture and th...
true
d2b105a85201dc8c909dc6c53854c9dfbe04252e
AzwadRafique/Azwad
/Emailsv.py
1,536
4.21875
4
while 1 == 1: number_emails = { 'manha@gmail.com': '12345', 'jack@gmail.com': '124567' } login_or_sign_in = input('login or sign in: ') if login_or_sign_in.upper() == 'LOGIN': email = input('what is your email: ') if email in number_emails: password...
true
4d20a237a1b8b806e5eea64c7c635dff54b4e8c2
dimamik/AGH_Algorithms_and_data_structures
/PRACTISE/FOR EXAM/Wyklady/W2_QUEUE_STACK.py
2,898
4.15625
4
class Node(): def __init__(self,val=None,next=None): self.val=val self.next=next class stack_lists(): def __init__(self,size=0): first=Node() self.first=first self.size=size def pop(self): if self.size==0:return self.size-=1 tmp=self.first.nex...
true
4e9b9da28608efcd69df0f7706a82d16461dd7d2
JulieBoberg/Learn-Python-3-the-Hard-Way
/ex8.py
931
4.3125
4
# declare variable formatter and set it equal to a string with four sets of brackets. formatter = "{} {} {} {}" # prints the string in the variable formatter with the arguments in format in place of the brackets print(formatter.format(1, 2, 3, 4)) # prints the string in the variable formatter with the arguments in ...
true
5d32181fdadd2ab1ca9b672617a612e03216259e
JulieBoberg/Learn-Python-3-the-Hard-Way
/ex20.py
1,617
4.1875
4
from sys import argv script, input_file = argv # define function print_all that accepts parameter f(a file) def print_all(f): # read the file(f) and print it print(f.read()) # define function rewind which accepts parameter f def rewind(f): # find the (0) start of the file(f) f.seek(0) # de...
true
795ba841a724b31cc3f2963b9bd15b9a4f5346fd
natalialovkis/MyFirstPythonProject_Math
/math_project1.py
2,321
4.3125
4
# -*- coding: utf-8 -*- # Math learning program import random import math import turtle print("Hello Dear User!") name = input("Please, enter your name: ") print() print("Hello %s! Let`s learn the Math!" % name) print() num_of_ex = 0 while True: try: num_of_ex = int(input("How many exercises are you goi...
true
30f7e7671a9c003688c80f6433f5a95b266a5a4a
2mohammad/Python_Prac
/11_flip_case/flip_case.py
791
4.28125
4
def flip_case(phrase, to_swap): """Flip [to_swap] case each time it appears in phrase. >>> flip_case('Aaaahhh', 'a') 'aAAAhhh' >>> flip_case('Aaaahhh', 'A') 'aAAAhhh' >>> flip_case('Aaaahhh', 'h') 'AaaaHHH' """ """ split string to list via list c...
false
bb36efd1df3edf317fb9a8ba21309202e4582e33
TrilochanSati/exp
/daysInDob.py
832
4.3125
4
#Program to return days from birth of date. from datetime import date def daysInMonth(month:int,year:int)->int: months=[31,28,31,30,31,30,31,31,30,31,30,31] if(year%4==0 and month==2): return 29 else: month-=1 return months[month] def daysInDob(dobDay,dobMonth,dobYear)->int: ...
true
45971d9756dbb11d7b5c583de74c9c5fcd71fab5
lemonade512/CodeSnippets
/Python/make_args_strings.py
866
4.4375
4
#!/usr/bin/python ''' make_args_strings.py This snippet is an example of a decorator. The decorator in this case takes a functions arguments and turns them into strings. Author: Phillip Lemons Date Modified: 2/16/2014 ''' def _make_arguments_strings(fn): def wrapped(*args, **kwargs): new_args = [str(arg) for ar...
false
c829a7f379119a3e735a4a9b20de160faa4c3776
alzheimeer/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
543
4.40625
4
#!/usr/bin/python3 def say_my_name(first_name, last_name=""): """ Args: first_name (str): the first name last_name (str, optional): the last name Raises: TypeError: if the first_name or last_name are not strings """ if first_name is None or type(first_name) is not str: ...
true
d65d22f6a7e69c886203c873e3870359b74f2eed
chenjiahui1991/LeetCode
/P0225.py
1,053
4.1875
4
class MyStack: def __init__(self): """ Initialize your data structure here. """ self.line = [] def push(self, x): """ Push element x onto stack. :type x: int :rtype: void """ self.line.append(0) for i in range(len(self.li...
true
c8de22cbd9a1535e0ad87b799dc1f604c246c33f
djalma21/maratona
/Treino Atividade 4.py
1,309
4.1875
4
#Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: #"Telefonou para a vítima?" #"Esteve no local do crime?" #"Mora perto da vítima?" #"Devia para a vítima?" #"Já trabalhou com a vítima?" #O programa deve no final emitir uma classificação sobre a participação da pessoa no crime. #Se...
false
e51c78c3e21eb1c6a1624bd113fa1d94ab353293
Abishekthp/Simple_Assignments
/Assigmnet_1/11Factor_and_largest_factor_of_a_Number.py
247
4.25
4
#FIND THE FACTORS OF A NUMBER AND PRINT THE LARGEST FACTOR n=int(input('Enter the number:')) l=0 print('Factors are:') for i in range(1,n): if(n%i==0): print(i) if(i>l): l=i print('largest factor:',l)
true
9db36b88191861353321686f4209406196385ae1
HolyCoffee00/python_books
/python_books/py_crash/chaper_7/greeter.py
267
4.21875
4
name = input("Please tell me your name: ") print("Hello, " + name.title() + "!") prompt = "If you tell us who you are i will personalize the message: " prompt += "\nWhat is your firtst name: " name = input(prompt) print("Hello, " + name.title() + "!")
true
f58ad48501d9a0a3bf2d2fcb239a1e2ca6ad9870
neilkazimierzsheridan/sqlite3
/sq2.py
1,070
4.1875
4
#sqlite part 2 import sqlite3 conn = sqlite3.connect('customer2.db') c = conn.cursor() #create the cursor instance #c.execute(" SELECT rowid, * FROM customers") #rowid to get autogenerated primary key, this is element 0 now ## USING THE WHERE CLAUSE SEARCHING #c.execute(" SELECT rowid, * FROM c...
true
cb7f069f17d3813d4e63840db06f9bb0d08cf929
OSGeoLabBp/tutorials
/hungarian/python/code/circle.py
846
4.15625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import math from point import Point class Circle(Point): """ class for 2D circles """ def __init__(self, x=0, y=0, p=2, r=1): super(Circle, self).__init__(x, y, p) self.r = r def __str__(self): return ("{0:." + str(self.p) + "f}, {1...
false
644335a0226c0b9a54aeb7b689e8452e0705466a
ddib-ccde/pyforneteng2020
/week1/exercise2.py
1,106
4.1875
4
# Print an empty line print(f"") # Ask user for an IP address and store as string ipaddr = input("Please enter an IP address: ") # Split the IP address into four parts and store in a list ipaddr_split = ipaddr.split(".") # Print an empty line print(f"") # Print the header with centered text (^) and width 15 print(f"{...
true
d40e6a0baa4379e0afe1dd8eacf7e2b44ee37ca5
zeuslawl/pau_martin
/Programacio/python/Superior/Estructures_Seqüencials/Estructures_Seqüencials_Ex14.py
759
4.21875
4
#!/usr/bin/python3 # -*-coding: utf8-*- # Pau Martín Arnau # isx46420653 # 11/10/18 # Primera versió # Demanar un nombre de base i convertir els nombres de 3 xifres # d'aquella base a un nombre decimal. # Entrar un numero enter > 0 que sigui la base, també entrar 3 nombres enters > 0 i # que el nombre no sigui maj...
false
1d9174ea48f7685df67ab36c817ab72f1c1f0f7e
GAURAV-GAMBHIR/pythoncode
/3.A2.py
238
4.21875
4
a=(12,14,14,11,87,43,78) print("smallest element is",min(a)) print("largest element is",max(a)) finding product of all element in tuple result=1 for x in a: result=result*x print("product of all element in tuple is: ",result)
true
c6df819a465084cbaf0ad8de72c2e554a3898a37
Bishwajit05/DS-Algos-Python
/Recursion/CoinChangeProblemRecursion.py
1,649
4.25
4
# Implement coin change problem # Author: Pradeep K. Pant, ppant@cpan.org # Given a target amount n and a list (array) of distinct coin values, what's the fewest coins needed to make the # change amount. # 1+1+1+1+1+1+1+1+1+1 # 5 + 1+1+1+1+1 # 5+5 # 10 # With 1 coin being the minimum amount. # Solution strategy: # Thi...
true
cd49cf9074247537a3d29e2ba4d9ad0dea5634c2
Bishwajit05/DS-Algos-Python
/LinkedLists/DoublyLinkedListImple.py
733
4.34375
4
# Doubly Linked List class implementation # Author: Pradeep K. Pant, ppant@cpan.org # Implement basic skeleton for a doubly Linked List # Initialize linked list class class DoublyLinkedListNode(object): def __init__(self,value): self.value = value self.prev_node = None self.next_node = ...
true
a75396b7a5bbd99390cb90c02857f63c0fc99df4
Bishwajit05/DS-Algos-Python
/Sorting/InsertionSortImple.py
938
4.21875
4
# Insertion Sort Implementation # Author: Pradeep K. Pant, https://pradeeppant.com # Insertion sort always maintains a sorted sub list in the lower portion of the list # Each new item is then "inserted" back into the previous sublist such that the # sorted sub list is one item larger # Complexity O(n2) square # Re...
true
4ce6d7ff07ffd9a199d96f8c522a4c043c1e9043
erien/algorithms
/mergeSort/python/main.py
2,430
4.34375
4
"""Example implementation of the merge sort algorithm""" TO_SORT = "../../toSort.txt" SORTED = "../../sorted.txt" def read_table_from_file(path: str) -> list: """Reads table from a file and creates appropriate table... I mean list! Args: path: Path to the file Returns: Read table ...
true
d3d57dbcde978689fb4122a9266b9ea44a4674c7
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
323
4.25
4
#!/usr/bin/python3 def write_file(filename="", text=""): """Writes a string to a text file Args: filename (str): name of the file text (str): string to be input """ with open(filename, 'w', encoding='utf-8') as filie: characters = filie.write(text) return characte...
true
ec92ebb83400693ea92230c152ec34b490eb1703
mapatelian/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
475
4.28125
4
#!/usr/bin/python3 def add_integer(a, b=98): """Function that adds two integers. Args: a (int): first integer b (int): second integer Return: sum of the arguments """ if isinstance(a, int) is False and isinstance(a, float) is False: raise TypeError("a must be an i...
true
acf85c1dae18cff881547f333fd36114a70e6601
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
284
4.125
4
#!/usr/bin/python3 def read_file(filename=""): """Reads a text file in UTF-8, prints to stdout Args: filename (str): name of the file """ with open(filename, 'r', encoding='utf-8') as filie: for linie in filie: print(linie, end='')
true
202bade662bbd859d43c58c1ed371c2c1a0eaf85
mengnan1994/Surrender-to-Reality
/py/0073_set_matrix_zeroes.py
1,615
4.1875
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0]...
true
dbb8650adc7e732575c33a032004fce683831afa
mengnan1994/Surrender-to-Reality
/py/0646_maximum_length_of_pair_chain.py
1,531
4.28125
4
""" You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Given a set of pairs, find the length longest chain which can be formed. You n...
true
6109e08e127c59aa0699d6b7d06e8f65fb1893d7
mengnan1994/Surrender-to-Reality
/py/0151_reverse_words_in_string.py
880
4.375
4
""" Given an input string, reverse the string word by word. Example: Input: "the sky is blue", Output: "blue is sky the". Note: A word is defined as a sequence of non-space characters. Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or trailing spaces. You...
true
40042792515af1f36829f92aaa330ac6cb17555e
mengnan1994/Surrender-to-Reality
/py/0186_reverse_words_in_a_string_ii.py
1,254
4.25
4
""" Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] Note: A word is defined as a sequence of non-space characters. The input string does not contain leading ...
true
2f49b448e55de701569925e9f71c956bd6e1dcdf
mengnan1994/Surrender-to-Reality
/py/0098_valid_binary_search_tree.py
1,395
4.1875
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: 1. The left subtree of a node contains only nodes with keys less than the node's key. 2. The right subtree of a node contains only nodes with keys greater than the node's key. 3. Both the left and right ...
true
250013f9d8f1cb624ca63725487ec54ad7985317
WillHTam/reference
/bubble_sort.py
1,239
4.1875
4
# Bubble Sort # compare consecutive pairs of elements # swap elements in pairs such that smaller is first # at end of list, do so again. stop when no more swaps have been made def bubble_sort(L): """ inner for loop does the comparisons outer while loop is doing multiple passes until no more swaps """ ...
true
912f71e7813de37a3e70d91f41c6b8c57353d45b
Nihiru/Python
/Leetcode/maximum_subarray.py
522
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 4 17:34:37 2020 @author: nick """ def maximum_subarray(array): # setting the maximum sub array similar to max_sum = array[0] current_sum = max_sum for ele in array[1:]: current_sum = max(ele + current_sum, ele) # adding el...
true
00c305f72eb4ca256dd67b8596097b834fb7c910
sandesh-chhetry/basic-python-
/Python Assignment 4/session3_functional.py
2,584
4.25
4
""" ---------------------------------------------------------------------------------------------------------------------------------------------------- """ """ 1. Write a program to display all prime numbers from 1 to """ ##function to find prime number in a range def findPrimeNumber(initial,final): for i i...
true
c29246c37d513184514a1319aec0688b4e3db1f2
sandesh-chhetry/basic-python-
/Python Assignment 1/listGetExample.py
421
4.15625
4
##Exercise 4. Consider a list of any arbitrary elements. Your code should print the length of the list ##and first and fourth element of the list. ##list which contain some element elements = ["1st position", "2nd position", "3rd position", "4th position", "5th position", "6th position"] print("Length of the give...
true
d2a8e97cec6a7e28affd4e0209eae2bb618bcfd5
316060064/Taller-de-herramientas-computacionales
/Clases/Programas/Tarea8/Problema2.py
1,510
4.25
4
'''filas = int(input ("Introduzca el numero de filas de sus matrices: ")) columnas = int(input ("Introduzca el numero de columnas de sus matrices: ")) matriz1 = [] matriz2 = [] matriz3 = [] for i in range (filas): matriz1.append( [0] * columnas) matriz2.append( [0] * columnas) matriz3.append( [0] * columnas) print...
false
302e14a0a325f6763f28b5f2c5d567859717fecf
joescalona/Programacion-Astronomica
/Tarea 1/ejercicio3.py
2,125
4.40625
4
#NUMEROS DE MENOR A MAYOR #PROGRAMA MAS LARGO YA QUE CONSIDERE DIVERSAS OPCIONES INGRESADAS POR EL USUARIO #DISCULPAR POR LA ABUNDANCIA DE CODIGO print('------ NUMEROS DE MENOR A MAYOR (DISTINTOS) ------'+'\n') #SOLICITAR NUMERO Y VERIFICAR QUE SEA ENTERO a=input('Ingresa un numero = ') #SI UN FLOTANTE, TAL COMO ...
false
181b5324ba8239fc341d0304edc0007e2e73fde9
wiselyc/python-hw
/swap.py
352
4.34375
4
def swap_last_item(input_list): """takes in a list and returns a new list that swapped the first and the last element""" input_list[0], input_list[-1] = input_list[-1], input_list[0] # gets the first and last element and makes the first element = the last and the last element = the first return input_l...
true
62482eb26b465185c7301587a6667e2b8fa18603
phttrang/MITx-6.00.1x
/Problem_Sets_3/Problem_2.py
1,834
4.25
4
# Problem 2 - Printing Out the User's Guess # (10/10 points) # Next, implement the function getGuessedWord that takes in two parameters - a string, secretWord, and a list of letters, # lettersGuessed. This function returns a string that is comprised of letters and underscores, based on what letters in # lettersGuessed...
true
2945e387eb1a73bd8610e69bf79b7d0ff0b9462b
qrzhang/Udacity_Data_Structure_Algorithms
/3.Search_Sorting/recursion.py
1,221
4.1875
4
"""Implement a function recursively to get the desired Fibonacci sequence value. Your code should have the same input/output as the iterative code in the instructions.""" def get_fib_seq(position): first = 0 second = 1 third = first + second seq = [first, second, third] if position < 1: r...
true
aa00145cfff0c3d87d1ebc57537143777a49c728
opeoje91/Election_Analysis
/CLASS/PyPoll_Console.py
1,634
4.4375
4
#The data we need to retrieve # Assign a variable for the file to load and the path. #file_to_load = 'Resources/election_results.csv' # Open the election results and read the file #with open(file_to_load) as election_data: # To do: perform analysis. #print(election_data) import csv import os # Assign a varia...
true
dee97b21b9e2b31df218ebf2f75f51155de51650
opeoje91/Election_Analysis
/CLASS/lists.py
1,247
4.625
5
counties = ["Arapahoe","Denver","Jefferson"] #print(counties) #print(counties[0]) #print(counties[2]) ##-to know the second to last item in list, -1 to know the last item #print(counties[-2]) #print(len(counties)) ##slicing to get the first 2 items in counties #print(counties[0 : 2]) ##slice to get the first item in co...
false
418c14a4ae1e95d39e400b389bf6d16c6575559f
ar012/python
/learning/sets.py
948
4.1875
4
num_set = {1, 2, 3, 4, 5} word_set = {"mango", "banana", "orange"} subjects = set(["math", "bangla", "english"]) print(1 in num_set) print("mango" not in word_set) print(subjects) print(set()) # duplicate elements nums = {1, 2, 3, 5, 1, 2, 6, 3, 10} print(nums) # To add a element to a set nums.add(9) print(nums) ...
true
cd5b516a24221e828f5e4b3662057ca52ceba125
arkatsuki/assist
/file/file_rename.py
1,767
4.40625
4
import os """ 改文件的后缀名 rename_to_txt:把文件后缀名改成.txt rename_to_original:与rename_to_txt配套,还原成原来的后缀名 """ def rename_to_txt(dir_path): """ success 把文件后缀名改成.txt :param dir_path: :return: """ for parent, dirnames, filenames in os.walk(dir_path): for filename in filenames: if not...
false
074d2d889a50fda955b37d02d55e64db6f0cd6dc
mvk47/turtle-racing
/main.py
1,252
4.21875
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) bet= screen.textinput(title="Make your bet", prompt= "Which turtle will win the race:\n1.Red\n2.Green\n3.Blue\n4.Yellow\n5.Orange") print(bet) red = Turtle() blue = Turtle() yellow = Tur...
false
84d1c158dd321f99c38ce95c3825a457b21ca9e5
Charles-IV/python-scripts
/recursion/factorial.py
536
4.375
4
no = int(input("Enter number to work out factorial of: ")) def recursive_factorial(n, fact=1): # fact = 1 # number to add to fact *= n # does factorial calculation n -= 1 # prepare for next recursion #print("fact: {}, n = {}".format(fact, n)) - test for debugging if n > 1: # keep repeating unt...
true
9751e43f0580aae99460d521118ac79463027a2c
vapawar/vpz_pycodes
/vpz/vpz_rotate_array.py
316
4.125
4
def rotateL(arr, n): for x in range(n): start=arr[0] for i in range(1,len(arr)): arr[i-1]=arr[i] arr[-1]=start def rotateR(arr,n): for x in range(n): end=arr[-1] for i in range(len(arr)-1,-1,-1): arr[i]=arr[i-1] arr[0]=end x=list(range(1,8)) print(x) rotateL(x,2) print(x) rotateR(x,2) print(x)
false
aab2c535b094205462ac80405250ce17ee993e4e
MorgFost96/School-Projects
/PythonProgramming/3-28/lists.py
1,879
4.5625
5
#List Examples #---------------- #Lists of Numbers #---------------- even_num = [ 2, 4, 6, 8, 10 ] #---------------- #Lists of Strings #---------------- name[ "Molly", "Steven", "Will" ] #------------------------- #Mixed Strings and Numbers #------------------------- info = [ "Alicia", 27, 155 ] #------------ #Prin...
false
d142a70a335d662c1dcc443603f17e2cc3e4996a
MorgFost96/School-Projects
/PythonProgramming/5-16/objects.py
2,685
4.34375
4
#Morgan Foster #1021803 # Intro to Object Oriented Programming ( OOP ) # - OOP enables you to develop large scale software and GUI effectively # - A class defines the properties and behaviors for objects # - Objects are created from classes # Imports import math # --- # OOP # --- # - Use of objects to create programs...
true
a330c68a5d2b531399e1f400f24b56d0c2d6ee4e
MorgFost96/School-Projects
/PythonProgramming/5-9/recursive.py
1,317
4.59375
5
# Recursion # - A function that calls itself # --------- # Iterative # --------- # Main -> a -> b -> c -> d # --------- # Recursive # --------- # Main -> a -> a -> a -> a # ---- # Note # ---- # Whenever possible, use iterave over recusive # Why? Faster and uses less memory # ------- # Example # ------- def main():...
false
16b5ee3084e7b0d7c4bb3db990a45732526dd972
MorgFost96/School-Projects
/PythonProgramming/3-28/sales.py
711
4.15625
4
#This program lists the sales for 5 days def createList(): #Teacher put ndays = 5 and sales = [ 0 ] * ndays sales = [ 0 ] * 5 print( "Enter sales for each day" ) i = 0 while( i < len( sales ) ): print( "Day #", i + 1, ": ", sep = "", end = "" ) sales[ i ] = float( input( ) ) ...
false
51dfa9121db952f837f90310b3970a02a7ae239b
MorgFost96/School-Projects
/PythonProgramming/3-30/insert.py
409
4.5
4
#This program demonstrates the insert method def main(): names = [ "James", "Kathryn", "Bill" ] print( "The list before the insert: " ) print( names ) names.insert( 0, "Joe" ) print( "The list fter the insert: " ) print( names ) main() ##>>> ##The list before the insert: ##['James', 'Kat...
false
97ddb326c2af50e3f61ed34fbe097d61eed12ebd
h4l0anne/PongGame
/Pong.py
2,421
4.28125
4
# Simple Pong Game in Python import turtle wn = turtle.Screen() wn.title("Pong Game") wn.bgcolor("green") wn.setup(width=800, height=600) wn.tracer(0) # Paddle A paddle_left = turtle.Turtle() paddle_left.speed(0) # 0 for maximum possible speed paddle_left.shape("square") paddle_left.color("blue") paddle_left.shap...
true
2aea01ba888855ee4d4d7e024bad881d26d5e9fa
smartpramod/97
/PRo 97.py
449
4.21875
4
import random print("NUMBER GUESSING GAME") number=random.randint(1,9) chances=0 print("GUESS A NUMBER BETWEEN 1 AND 9") while(chances<5): Guess=int(input("Enter your number")) if Guess==number: print("Congrulation, YOU WON") break elif Guess<number: print("Your guess was...
true
bc3e55ea22cd1e7e3aa39a9b020d128df16dfa92
aalhsn/python
/conditions_task.py
1,279
4.3125
4
""" Output message, so the user know what is the code about and some instructions Condition_Task author: Abdullah Alhasan """ print(""" Welcome to Abdullah's Calculator! Please choose vaild numbers and an operator to be calculated... Calculation example: first number [operation] second number = results """...
true
e321759c85fa184f7fdb08811827a36faadc8317
mukesh-jogi/python_repo
/Sem-5/Collections/Set/set1.py
1,960
4.375
4
# Declaring Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} print(set1) # Iterate through Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} for item in set1: print(item) # Add item to set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} set1.add("NewFruit") for item in set1: print(item...
true
a6885c761cbf2d54c530a8a114c7782dabb2631b
Karolina-Wardyla/Practice-Python
/list_less_than_ten/task3.py
400
4.15625
4
# Take a random list, ask the user for a number and return a list that contains only elements from the original list that are smaller than the number given by the user. random_list = [1, 2, 4, 7, 8, 9, 15, 24, 31] filtered_numbers = [] chosen_number = int(input("Please enter a number: ")) for x in random_list: if...
true
3b6824ea991b59ccd05b3d42f872c5e8d1313d4a
Karolina-Wardyla/Practice-Python
/divisors/divisors.py
522
4.34375
4
# Create a program that asks the user for a number and then prints out a list of all the divisors of that number. # Divisor is a number that divides evenly into another number. # (For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) chosen_number = int(input("Please enter a number: ")) possible_diviso...
true
5bf4a3b018d1ec02e5dc007da9e8ad0d7758c02b
HugoPorto/PythonCodes
/CursoPythonUnderLinux/Aula0028ForIn/ForInComLisa.py
578
4.125
4
#!/usr/bin/env python # -*- coding:utf8 -*- cont = 1 lista = [] while cont <= 6: lista.append(input("Digite qualquer coisa: ")) cont = cont + 1 print lista for item in lista: if (type(item) == int): print 'Item inteiro: %d' % item elif (type(item) == str): print 'Item string %s ' % item elif (type(item) ==...
false
0a43c57a016eb641a07c8f0e2ed16080da2866b2
Aaron-Nazareth/Code-of-the-Future-NumPy-beginner-series
/6 - Basic operations on arrays.py
707
4.5
4
# Tutorial 6 # Importing relevant modules import numpy as np # We can create an array between numbers like we can do with lists and the 'range' command. # When using arrays, we use the 'arange' command. a = np.arange(0, 5) # Creates an array from 0 up to 5 - [0 1 2 3 4] print(a) # Basic math operations on arrays b ...
true
b1b17773696b406c5682d1ad6549aad66789e111
Elizabethcase/unitconvert
/unitconvert/temperature.py
1,020
4.25
4
def fahrenheit_to_celsius(temp): ''' Input: temp: (float) - temp in fahrenheit Returns: temp: (float) - temp in celsius ''' celsius = (32.0 - temp)*(5.0/9) return celsius def celsius_to_fahrenheit(temp): ''' Input...
false
9519d25c32ac136ff355e521e4bf36dc80eee71b
meghasundriyal/MCS311_Text_Analytics
/stemming.py
609
4.3125
4
#stemming is the morphological variants of same root word from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer ps = PorterStemmer() #words to be stemmed (list) stem_words = ["eat", "eats", "eating", "eaten", "eater", "received","receiving"] #find stem word for each of the word in the list for ...
true
9937cae75d06147093025d2482225550aace9f9a
Reena-Kumari20/code_war
/Reversed_Words.py
213
4.1875
4
# Complete the solution so that it reverses all of the words within the string passed def reverse_words(s): a=(' '.join(s.split(" ")[-1::-1])) return a string=["hell0 world!"] print(reverse_words(string))
true
8b99f60f51da55d805fcfdd13bf0e34bc71b8386
Reena-Kumari20/code_war
/sum_of_string.py
586
4.1875
4
'''Create a function that takes 2 positive integers in form of a string as an input, and outputs the sum (also as a string): Example: (Input1, Input2 -->Output) "4", "5" --> "9" "34", "5" --> "39" Notes: If either input is an empty string, consider it as zero.''' def sum_str(a, b): if a=="" and b=="": ...
true
301a64567164a85abdef442a8672c985776a87e0
jreichardtaurora/hmwk_2_test
/HW2_Prob_1_JaredReichardt.py
1,398
4.3125
4
''' Created on Sep 13, 2019 @author: jared r CSC1700 section AM The purpose of this problem was to write a calculator that calculates the user's total shipping cost. It handles negative inputs properly, and prompts the user for their package weight, and what type of shipping they used. ''' def main(): print("Sta...
true
88b954e1465b806c15318999a4715c0e6c7d7cc4
renatocrobledo/probable-octo-spork
/codingame/src/norm_calculation.py
1,538
4.65625
5
''' You are given an integer matrix of size N * M (a matrix is a 2D array of numbers). A norm is a positive value meant to quantify the "size/length" of an element. In our case we want to compute the norm of a matrix. There exist several norms, used for different scenarios. Some of the most common matrix norms are : ...
true
88963ec18f118fca69d3e26b3b57db8c5a2736cc
kundan7kumar/Algorithm
/Hashing/basic.py
476
4.1875
4
# Python tuple can be the key but python list cannot a ={1:"USA",2:"UK",3:"INDIA"} print(a) print(a[1]) print(a[2]) print(a[3]) #print(a[4]) # key Error # The functionality of both dictionaries and defualtdict are almost same except for the fact that defualtdict never raises a KeyError. It provides a default value fo...
true
43a8fae76b90437274501bafd949b39995401233
tongyaojun/corepython-tongyao
/chapter02/Test15.py
430
4.125
4
#!/usr/bin/python #sort input numbers userInput1 = int(input('Please input a number:')) userInput2 = int(input('Please input a number:')) userInput3 = int(input('Please input a number:')) def getBiggerNum(num1, num2): if num1 > num2: return num1 else : return num2 biggerNum = getBiggerNum(user...
true
c328f75f3d0278660d4d544563b5d953af5b7041
jjti/euler
/Done/81.py
2,016
4.21875
4
def path_sum_two_ways(test_matrix=None): """ read in the input file, and find the sum of the minimum path from the top left position to the top right position Notes: 1. Looks like a dynamic programming problem. Ie, start bottom right and find the sum of the minimum path from the current...
true
b3cca4d969aa2be4ad517aad8d903ae2826da02d
jjti/euler
/Done/65.py
2,141
4.1875
4
import utils """ The square root of 2 can be written as an infinite continued fraction. The infinite continued fraction can be written, 2**0.5 = [1;(2)], (2) indicates that 2 repeats ad infinitum. In a similar way, 23**0.5 = [4;(1,3,1,8)]. It turns out that the sequence of partial values of continued fractions for squ...
true
d6a3a1abfac543f817434f9b903515db63993c02
jjti/euler
/Done/57.py
1,511
4.125
4
import utils """ It is possible to show that the square root of two can be expressed as an infinite continued fraction. 2 ** 1/2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2) = 7/5 = 1.4 1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = ...
true