blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1da282a3db3a9b690c69d8b9a7261d8685ad6d5a
piyushPathak309/100-Days-of-Python-Coding
/Challenge Solve Quadratic Equations.py
1,300
4.375
4
# Write a Python program that prints the positive and negative solutions (roots) for a quadratic equation. # # If the equation only has one solution, print the solution as the output. # # If it has two solutions, print the negative one first and the positive one second on the same line. # # If the equation has no...
true
4e56f040e15f71067bf725fa1c6368fe9600ef62
piyushPathak309/100-Days-of-Python-Coding
/Check String Contain Numbers or not.py
217
4.21875
4
# Write a Python program that check if a string only contains numbers. # # If it does, print True. Else, print False. text = input("Enter a text: ") if (text.isdigit()): print(True) else: print(False)
true
5b646ffd8354cebd9e929ecf336550b31792e52d
amiskov/real-python
/part1/02. Fundamentals: Working with Strings/notes.py
1,390
4.5625
5
""" Fundamentals: Working with Strings """ # "Addition" and "multiplication" of strings print('hello' * 3) print('hello' + 'world') # Convert strings to numbers print(int('22') + float(1.35)) # We can't convert floating point strings to integers # int('22.3') # error # Convert numbers to strings print(str(22.3) + '...
true
5997e47a7d55ef99daf50d986493eeca7a7245a4
zecookiez/CanadianComputingCompetition
/2018/Senior/sunflowers.py
1,424
4.15625
4
"""Barbara plants N different sunflowers, each with a unique height, ordered from smallest to largest, and records their heights for N consecutive days. Each day, all of her flowers grow taller than they were the day before. She records each of these measurements in a table, with one row for each plant, with the first...
true
abd86de13f0ee03be189915181c1bb753ef1d88c
UnknownAbyss/CTF-Write-ups
/HSCTF 7/Miscellaneous/My First Calculator/calculator.py
805
4.21875
4
#!/usr/bin/env python2.7 try: print("Welcome to my calculator!") print("You can add, subtract, multiply and divide some numbers") print("") first = int(input("First number: ")) second = int(input("Second number: ")) operation = str(raw_input("Operation (+ - * /): ")) if first != 1 or se...
true
899c8b3843aef975c187c0eee14bd7fbf333c0b8
dingning8768/aaa
/raw_input
299
4.21875
4
#!/usr/bin/env python this_year = 2013 name = raw_input("please input your name:") #age = raw_input("how old are you?") #age = input("how old are you?") age = int(raw_input("how old are you?")) print "hello",name,'\n' print "you are",age,'years old!' print "so you were born in: ",this_year - age
false
87bc943b81db33c06442b07dfc3a342473670801
gbrs/EGE_files
/strings.py
1,683
4.25
4
string1 = ' абраКАДАБРА' string2 = 'АБРАкадабра ' string3 = '13579' string4 = '02468' print('конкатенация:') print(string1 + string2) print(string3 + string4) print('-=-'.join([string1, string3, string2, string4])) print() print('методы строк:') print(string1) print(string1.strip()) print(string1.lower() + '<->' + st...
false
aaeb75bbd4423f7c148e61da5bef5232589ab5a7
skybrim/practice_leetcode_python
/everyday/349.py
576
4.125
4
""" 349. 两个数组的交集 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入:nums1 = [1,2,2,1], nums2 = [2,2] 输出:[2] 示例 2: 输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出:[9,4] 说明: 输出结果中的每个元素一定是唯一的。 我们可以不考虑输出结果的顺序。 """ def intersection(nums1, nums2): set1 = set(nums1) set2 = set(nums2) if len(set1) < len(set2): return [num fo...
false
14d781f18c86c4e48e0237da097831651a6b49c3
skybrim/practice_leetcode_python
/everyday/941.py
1,003
4.15625
4
""" 941. 有效的山脉数组 给定一个整数数组 A,如果它是有效的山脉数组就返回 true,否则返回 false。 让我们回顾一下,如果 A 满足下述条件,那么它是一个山脉数组: A.length >= 3 在 0 < i < A.length - 1 条件下,存在 i 使得: A[0] < A[1] < ... A[i-1] < A[i] A[i] > A[i+1] > ... > A[A.length - 1] 提示: 0 <= A.length <= 10000 0 <= A[i] <= 10000 示例 1: 输入:[2,1] 输出:false 示例 2: 输入:[...
false
9f709bddfc95ddef6e0b1e4c074924cc2fe8278f
mikesorsibin/PythonHero
/Generators/Example_three.py
285
4.15625
4
def myfunc(): for x in range(3): yield x x = myfunc() #using next to call the values of x one by one print(next(x)) #iter keyword s="hello" for x in s: print(x) #here we cannot directly call next method, we need to iter s. iter_s = iter(s) print(next(iter_s))
true
89cd5390e210dda72dc45ea5bf2f0f81e8ffa4b8
mikesorsibin/PythonHero
/Inbuilt and Third Party Modules/datetime.py
833
4.1875
4
>>> import datetime >>> t = datetime.time(5,34,5) >>> t datetime.time(5, 34, 5) >>> t.min datetime.time(0, 0) >>> datetime.time <class 'datetime.time'> >>> datetime.time.min datetime.time(0, 0) >>> print(datetime.time.min) 00:00:00 >>> today = datetime.date.today() >>> today datetime.date(2020, 4, 7) >>> print(today) 2...
false
3f7235eccddf88ef10b556af01ffbe1a8c0cf44f
mikesorsibin/PythonHero
/Inbuilt and Third Party Modules/re_one.py
585
4.1875
4
import re # List of patterns to search for patterns = ['term1', 'term2'] # Text to parse text = 'This is a string with term1, but it does not have the other term.' for pattern in patterns: print('Searching for "%s" in:\n "%s"\n' %(pattern,text)) #Check for match if re.search(pattern,text): p...
true
550001146f8a243c64d6d3649d907af7b715730b
Hafsa25/Assignment
/marksheet.py
1,145
4.21875
4
print(" ******* 9TH MARKSHEET*******") print("CODED BY HAFSA BHATTI") print("Enter your Roll number") roll_no=int(input()) print("What did you chose in 9th? Biology or Computer?") choice=input() if choice=="Biology": final=choice elif choice=="Chemistry": final=choice print("Enter your Sindhi marks ou...
false
0906f368808b375ed77eb7fd946b3c2ea78d073f
danrihe/Fractals
/TriangleFractal.py
2,413
4.40625
4
import turtle #input the turtle module wn = turtle.Screen() #create the screen wn.bgcolor("black") hippo = turtle.Turtle() #create 4 turtles fishy = turtle.Turtle() horse = turtle.Turtle() sheeha = turtle.Turtle() print("What color would you like **hippo** to be? (Not black)") #allows user to define t...
true
7c6a81e88ffb8eb0dc9c3b67fe9552bdbfcaa2af
momentum-cohort-2019-09/examples
/w5d2--word-frequency/word_frequency.py
2,753
4.125
4
import string STOP_WORDS = [ 'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'has', 'he', 'i', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the', 'to', 'were', 'will', 'with' ] def remove_stop_words(words): """Given a list of words, remove all words found in STOP_WORDS.""" filter...
true
14c0855e08dca33dedd9b2a619b6aad79373f892
harkbot/beginners_python
/whos_yo_daddy.py
1,898
4.34375
4
#Who's yo daddy? #Self-coded #create dictionary of sons and fathers #key = son, value = father #make options to exit, enter name of son to get father, add, replace, and delete son-father pairs daddy = {"Bill": "Tedd", "Jack": "Jill?", "Rory": "Kyle", "Kevin": "Adam", "Dylan": "Jeremy"} choice = None print() while ...
true
ffb8b75b6d47da30a53c358148b0e64012a95495
khaloodi/graphs_codecademy
/graph_search/bfs.py
1,282
4.28125
4
''' Breadth-First Search: Take My Breadth Away Unlike DFS, BFS is primarily concerned with the shortest path that exists between two points, so that’s what we’ll be thinking about as we build out our breadth-first search function. Using a queue will help us keep track of the current vertex and its corresponding path. ...
true
0ed42ee0ca150237661494c4ceadc36d4db9c4af
toeysp130/Lab-Py
/lab3-2.py
338
4.21875
4
#watcharakorn# num1 = int( input("Enter value number 1 :")) num2 = int( input("Enter value number 2 :")) num3 = int( input("Enter value number 3 :")) MinValue = min(num1, num2, num3) MaxValue = max(num1, num2, num3) print() print("Your Enter Number :",num1, num2, num3) print("maxvalue : " , MaxValue) print("minvalu...
false
7530c19e94561d02d5f4f26a0d3a6a3d25018949
nahTiQ/poker_bot
/table.py
2,815
4.15625
4
'''Table object''' from random import randint from players import Player import console as c class Table: def __init__(self): self.players = 0 self.cards = [] self.pot_round = 0 self.pot = 0 def ask_for_players(self): '''Ask for a number, convert to int, then return that number to pass t...
true
4d819770c12674b97b385227107fb104c15f975f
Queru78/programacion1
/practica2/probandoH.py
213
4.1875
4
#!/usr/bin/python numero =input("ingrese numero ") el6= numero % 6 if (el6==0): print("el numero %s es divisible por 6"% (numero)) else: print("el numero %s no es divisible por 6" % (numero))
false
91b6c2dbe6ff6c2d2c4ff492c6a4e872a5da5d22
pwatson1/python
/exampleCode/inheritance_ex1.py
896
4.125
4
# Object oriented programing based around classes and # instances of those classes (aka Objects) # How do classes interact and Directly effect one another? # Inheritence - when one class gains all the attributes of # another class # BaseClass is the parent class # Must use object so the child class can refer ...
true
db3d42f5b60b5478fe2081a5f564f48bca96c71c
pwatson1/python
/exampleCode/nesting_functions_decorators.py
2,138
4.625
5
# what are nesting functions? Functions that are # declared within other Functions ''' def outside(): def printHam(): print "ham" return printHam myFunc = outside() myFunc() ''' ''' # why nest a function within a function? def outside(): # this acts like a class for the subfunctions...
true
c97bb7b63b95d8e4004876c4fcc9ec45afdacb85
pwatson1/python
/exampleCode/singletonMetaClass.py
1,215
4.375
4
# Chapter 17 class Singleton(type): # _instance is just a container name for the dictionary # but it makes it easier to foloow what's happening _instances = {} # this function uses cls instead of self . Unlike self which refers # to the parent class, cls refers to any class def __call__(cls, *args, **kwa...
true
5d5adcde16694ecb2dcf02af9af1264f972c823a
crazcalm/PyTN_talk_proposal
/recipies/recipe1/recipe1.py
701
4.3125
4
""" Source: Python Cookbook, 3rd edition, number 4.14 Problem: -------- You have a nested sequence that you want to flatten into a single list of values Solution: --------- This is easily solved by writing a recursive generator function involving a yield from statement Notes: ------ 1. Python 2 does not have ...
true
89dfe9e4aef4b838180e5e36928a4bb1bfde8b19
nnanchari/CodingBat
/Warmup-1/front3.py
313
4.15625
4
#Given a string, we'll say that the front is the first 3 chars of the string. If the string length is less than 3, #the front is whatever is there. Return a new string which is 3 copies of the front. def front3(str): front=str[:3] if len(str)<3: return str+str+str else: return front+front+front
true
ef733ebbf670d6d41b80406a57c09b261e029856
pcolonna/coding-exercises
/Chapter_2/2.3_delete_mid_node.py
1,226
4.34375
4
# Question 2.3: delete_middle_node. """ Algo to delete a node in the middle of a singly linked list. Not necessarily the middle, just any node that is not the first or last one. """ from LinkedList import LinkedList """ To delete a node in a linked list, you can just skip it. Jump or ignore it. So if...
true
c1e9d0096130246882886fecb3dd52106bb4f657
pcolonna/coding-exercises
/Chapter_3/3.5_Sort_Stack.py
1,182
4.125
4
# Question 3.5: Sort Stack # # Sort a stack such as the smallest item is on top. # Use only one additional temporary stack. from random import randrange class Stack(list): def peak(self): return self[-1] def push(self, item): self.append(item) def empty(self): return len(self...
true
a50dac74db197f2e63675b1bf0bbcaaa53c3eaa1
heenashree/pyTutorialsforAnalytics
/Lists/listOperations.py
2,292
4.34375
4
#!/bin/python import sys mega_list = [2,3,4,5.5,6,'hi'] list1 = ["hi", "1", 1, 3.4, "there", True] def add_an_item(item): print("Your list before append", list1) print("Adding/appending an item at the end of the list\n") list1.append(item) print("Item is appended\n") print(list1) def update_to_list...
true
cea53adb50f9ccf3498e4ff272e45ed0186e4536
AhmedZahid098/tests_and_side_projects
/Book learning python/sqlite_python/mydatabase.py
1,178
4.15625
4
import sqlite3 from database import Employee conn = sqlite3.connect(':memory:') c = conn.cursor() c.execute("""create table employees( first text, last text, pay integer )""") def insert_emp(emp): with conn: c.execute("insert into employees values (:first, :last, :pay...
false
b01ea9552782249f526040b1621b4218adb68a7a
jaewon4067/Codes_with_Python
/Object-oriented programming/Creating a simple blog.py
1,576
4.5
4
""" As I'm learning OOP, I'm going to make a mini blog where people can post with me. I'm going to create a 'Post' class and a BlogUser' class to print out the full contents of the blog. """ class Post: def __init__(self, date, content): # The post class has date and content as attributes. self....
true
08208fe3612826d96129e5fcf3e87131e11f3a24
namaslay33/Python
/Day1.py
1,368
4.375
4
# Write a Python program to print the following string in a specific format (see the output). Go to the editor # Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" # Output : # Twink...
true
c945a40c704f1620193151da431a184542c957ad
namaslay33/Python
/FunctionExercises/FunctionExercise4.py
435
4.15625
4
# 4. Odd or Even # Write a function f(x) that returns 1 if x is odd and -1 if x is even. Plot it for x values of -5 to 5 in increments of 1. This time, instead of using plot.plot, use plot.bar instead to make a bar graph. import matplotlib.pyplot as plot def f(x): if x % 2 != 0: return 1 else: ...
true
3f020df6813f72453e9ee31b3cf272b0ecb93c8b
MintuKrishnan/subrahmanyam-batch
/python_lectures/22. Merge Sort/merge_sort.py
893
4.15625
4
def merge(A, start1, end1, start2, end2): p1 = start1 p2 = start2 temp = list() while p1 <= end1 and p2 <= end2: if A[p1] < A[p2]: temp.append(A[p1]) p1 += 1 else: temp.append(A[p2]) p2 += 1 while p1 <= end1: temp.append(A[p1]) ...
false
e09253f9a7610a88e51bb69920829a69ad5fb3a1
spettigrew/cs2-guided-project-ram-basics
/src/lower_case_demo1.py
1,660
4.59375
5
""" Given a string, implement a function that returns the string with all lowercase characters. Example 1: Input: "LambdaSchool" Output: "lambdaschool" Example 2: Input: "austen" Output: "austen" Example 3: Input: "LLAMA" Output: "llama" *Note: You must implement the function without using the built-in method on...
true
fa9f821dd75ab2d98c2f8fdc7a62b275f905d5c7
Gcriste/Python
/listAppendInsertExtend.py
1,579
4.3125
4
# Create a list called instructors instructors = [] # Add the following strings to the instructors list # "Colt" # "Blue" # "Lisa" instructors.append("Colt") instructors.append("Blue") instructors.append("Lisa") # Create a list called instructors instructors = [] # Add the following str...
true
1d89205fbd188befd987f7be0bb108c3559d66ad
yandryvilla06/python
/funciones/var_global.py
1,367
4.28125
4
""" Un ámbito define los límites de un programa en los que un espacio de nombres puede ser accedido sin utilizar un prefijo. Como te he mostrado en el apartado anterior, en principio existen, como mínimo, tres ámbitos. Uno por cada espacio de nombres: Ámbito de la función actual, que tiene los nombres locales a la fu...
false
bc91aa916a3de2e1347840f80d4348dc06e706b6
sat5297/AlgoExperts.io
/Easy/InsertionSort.py
295
4.1875
4
def insertionSort(array): for i in range(1, len(array)): j = i while j>0 and array[j] < array[j-1]: swap(j, j-1, array) j-=1 return array def swap(m, n, arr): arr[m], arr[n] = arr[n], arr[m] #Time Complexity: O(n^2) #Space Complexity: O(1)
false
f525573e903ced3083429eab40cb5e20af07ea70
Ivaylo-Atanasov93/The-Learning-Process
/Python Advanced/Lists_as_Stacks_and_Queues-Exercise/Balanced Paretheses.py
874
4.125
4
sequence = input() open_brackets = ['(', '{', '['] closing_brackets = [')', '}', ']'] def balanced(sequence): stack = [] for bracket in sequence: if bracket in open_brackets: stack.append(bracket) elif bracket in closing_brackets: index = closing_brackets.index(bracket) ...
true
d79154371342cce5e8aa5986ab62d94f01d9ce78
Ivaylo-Atanasov93/The-Learning-Process
/Python Advanced/Functions_Advanced-Exercise/Odd or Even.py
346
4.28125
4
def odd(numbers): return sum([num for num in numbers if num % 2 != 0]) def even(numbers): return sum([num for num in numbers if num % 2 == 0]) command = input() numbers = [int(num) for num in input().split()] if command == 'Odd': print(odd(numbers) * len(numbers)) elif command == 'Even': print(even...
false
376a1185f116eebf1b94ecaa5669cfc799a7dacb
santhosh790/competitions
/DailyCodingProblem/D130a_MaxProfitStockList.py
1,447
4.1875
4
''' The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the gi...
true
9172b5f15b2faef2f93a79417f72647832ebdaf9
mr-vaibh/python-payroll
/PRACTICAL-FILES/string/string2.py
371
4.34375
4
# This function prints a pyramid def make_pyramid(n): k = n - 1 # for spaces # loop for number of rows for i in range(0, n): # loop for number spaces for j in range(0, k): print(end=" ") k -= 1 # loop for number of columns for j in range(0, i+1): print("* ", end="") print("\r") n = int(input(...
true
4d32a642c347bed483aa859d9b499485e2818265
mr-vaibh/python-payroll
/PRACTICAL-FILES/string/string1.py
293
4.25
4
# this program simply prints a string in vertical reverse order string = str(input("Enter a string: ")) length = len(string) initial = 0 # the range in the loop below basically deals with length for i in range(-1, -(length + 1), -1): print(string[initial] + "\t" + string[i]) initial += 1
true
ba973167bfcc7d3842194a2e1d190c276ec5b74e
mr-vaibh/python-payroll
/PRACTICAL-FILES/others/3-stack.py
609
4.28125
4
# implementation of stack using list stack = [] choice = 'y' print('1. Push\n2. Pop\n3. Display elements of stack') while True: choice = int(input("Enter your choice: ")) if choice == 1: elem = input("Enter your element which you want to push: ") stack.append(elem) elif choice == 2: ...
true
8fef69e5d705f817e78315d18611a2c3a77f09b4
love-adela/algorithm-ps
/acmicpc/4504/4504.py
215
4.15625
4
n = int(input()) number = int(input()) while number: if number % n == 0: print(f'{number} is a multiple of {n}.') else: print(f'{number} is NOT a multiple of {n}.') number = int(input())
true
3785c2340cc205f09c94f5d1753ff221f53aa041
wmichalak/algorithms_and_datastructures
/Session 1/week3_greedy_algorithms/2_maximum_value_of_the_loot/fractional_knapsack.py
1,337
4.125
4
# Uses python3 import sys def get_optimal_value(capacity, weights, values): """Find the maximal value of items that fit into the backpack :param capacity: :param weights: :param values: :return maximum price of items that fit into the backpack of given capacity""" # Get price per weight list s...
true
44cb4188e6949960326659bdd6ee4db10f9d8046
cesarramos95/Algotitmo-Shannon-Fano
/encode.py
1,043
4.15625
4
#!/usr/bin/env python3 from calculations import calculate_codes def encode(symbol_sequence, codes): encoded = [] codes_dict = dict(codes) for symbol in symbol_sequence: code = codes_dict.get(symbol) if code is None: raise Exception(f"Invalid symbol: {symbol}") encoded...
true
367216a1c5906e1f53f70f5425f533800f52222d
rubaalibrahim/100DaysOfCode
/week 02.py
2,226
4.25
4
>>> # Day 6 >>> x = int(4) >>> y = int(6.2) >>> z = int('9') >>> print(x) 4 >>> print(y) 6 >>> print(z) 9 >>> x = float(4) >>> y = float(6.2) >>> z = float('9') >>> print(x) 4.0 >>> print(y) 6.2 >>> print(z) 9.0 >>> x = str('r3') >>> y = str(66) >>> z = str(7.3) >>> print(x) r3 >>> print(y) 66 >>> print(z) 7.3 >>>...
false
f115ae3b67a11c1b83b04bc014190f4716a04516
rubaalibrahim/100DaysOfCode
/week 05 (part 2).py
1,703
4.15625
4
>>> # Day 29 >>> numbers = ['1','2','3'] >>> for x in numbers: print(x) 1 2 3 >>> for x in'python': print(x) p y t h o n >>> fruits = ['apple','strawberry','orange'] >>> for x in fruits: print(x) if x == 'strawberry': break apple strawberry >>> for x in fruits: if x == 'strawberry': break print(x) ...
false
515e1f803403b0da28345dab126a0c43ee26c855
EshSubP/Advent-of-code2020
/Day 5/Solution/Day5_1.py
274
4.125
4
fname = input("Enter file name: ") fh = open(fname) s = "" largest = 0 for line in fh: s = line.replace('F','0').replace('B','1').replace('L','0').replace('R','1') decimal = int(s,2) if decimal>largest: largest = decimal print(largest)
true
74496e40f3712ea5a0a66e12f6bc8379319be36a
ag220502/Python
/Programs/ForLoops/nDiffInputsSumAndAverage.py
297
4.15625
4
#Take N different inputs and print their sum and average n = int(input("Enter the Number Of Values : ")) sum1 = 0 for i in range(1,n+1): inp = int(input("Enter Value",i," : ")) sum1 = sum1 + inp print("The Sum Of Inputs are : ",sum1) avg = sum1/n print("The Average Of Inputs are : ",avg)
true
e5f3ee04a995d38082ce69037f2093b8732110f8
ag220502/Python
/Programs/Swapping/25.SwappingUsingSecMethod.py
257
4.21875
4
#Swap Variables Using First Method a = int(input("Enter Value Of A : ")) b = int(input("Enter Value Of B : ")) print("Valus Of A :",a) print("Valus Of B :",b) a,b=b,a print("Values after Swapping are : ") print("Valus Of A :",a) print("Valus Of B :",b)
false
3d51fc9dc33632d4b7716a77322f25c4c60087d4
ag220502/Python
/PythonWorbook/IntroductionToProgramming/ex1.py
602
4.5625
5
''' Exercise 1: Mailing Address Create a program that displays your name and complete mailing address. The address should be printed in the format that is normally used in the area where you live.Your program does not need to read any input from the user. ''' name = "Narendra Aliani" comp = "Pragati Computers" street =...
true
536ee6d0932a23527435bf198a2ad25b7a67b846
hwulfmeyer/NaiveBayesClassifier
/filehandling.py
2,133
4.15625
4
""" This file is for the methods concerning everything from file reading to file writing """ import re import random def read_data_names(filepath: str): """ function to read class names & attributes :param filepath: the relative path to the file containing the specifications of the attribute_values :...
true
1c6666ec14512ddee9fc74a1c5c5384e3a0865ec
cleversongoulart/fatec_20211_ids_introducao_calculadora
/calculadora.py
517
4.125
4
a=int(input("Digite o primeiro inteiro: ")) b=int(input("Digite o segundo inteiro: ")) operacao=input("Escolha a operação:\n (+) soma\n (-) subtração\n (*) multiplicação\n (/) divisão\n (**) exponenciação \n Digite o símbolo da operação escolhida: ") if(operacao=='+'): resultado=a+b elif(operacao=='-'): result...
false
40d611aa7b3363cc767033f6b75ccec10c449c07
Lem0049/less0n3
/Lesson4/mnozhestvo.py
464
4.125
4
mnozhestvo1 = {'red','green','blue','yellow'} mnozhestvo2 = {'green', 'blue', 'brown'} mnozhestvo1.add('orange') print(mnozhestvo1) mnozhestvo2.remove('blue') print(mnozhestvo2) a = 5 mnozhestvo3 = mnozhestvo1.copy() mnozhestvo3.add('cyan') print(mnozhestvo3) print(mnozhestvo1 | mnozhestvo3) #объединение множеств pr...
false
902324145120c755d622786b53aac55ecd666314
medvedodesa/Lesson_Python_Hillel
/My_algorithms/Fibonacci_Nums/fibonacci_recursion_ method.py
582
4.28125
4
# ЧИСЛА ФИБОНАЧЧИ С ПОМОШЬЮ РЕКУРСИИ # Последовательность: 1, 1, 2, 3, 5, 8, 13, 21, 34, 34, 55, 89, ... def fibonacci_1(number): if 0 <= number <= 1: return number else: return fibonacci_1(number - 1) + fibonacci_1(number - 2) def fibonacci_2(number): return number if 0 <= number <= 1 els...
false
1e477ac3ab739fbb9c3459473a9546f6629ce711
medvedodesa/Lesson_Python_Hillel
/Lesson_1/task_lesson_1/task_1.py
1,380
4.59375
5
# Задача №1 ("Hello World") """ - Скачать и установить Python (Не забываем про установку галочки "Add python to PATH") - Проверить правильность установки и доступность python.Для этого в консоли (терминале) вводим комманду: python -V (в ответ должны увидеть соббщение Python 3.x.x - где х.х будут цифры указывающие...
false
ccd2ad36f3775d3697aa5b95913cb371047aa272
vaishalicooner/Practice-Linked-list
/practice_linkedlist/llist_palindrome.py
484
4.15625
4
# Implement a function to check if a linked list is a palindrome. def is_palindrome(self): head = self prev = None while self.next: self.prev = prev prev = self self= self.next tail = self tail.prev = prev while head is not tail and head.data == tail.data: head...
true
1bf5b7b938d506f0b446fa6b37d74ae6f2d0fbb3
Maruthees/Python-learning
/For-elif-break-enumerate.py
965
4.1875
4
#break is for for-loop where it comes out of loop immediately x="Dhoni is captain" for i in x: if i=='i': print("Sucess") break else: print("Fail") #To check more conditions use elif for i in x: if i=='i': print("Success we got i") elif i=='a': ...
false
8ec1024e7c5c2eb0cce0f7eeef0c8c0fdc572b12
caitp222/algorithms
/circular_moves.py
1,022
4.15625
4
# http://www.techiedelight.com/check-given-set-moves-circular-not/ # check if a given set of moves is circular or not def is_circular(str): possible_directions = ["north", "east", "south", "west"] current_direction = "north" co_ords = { "x": 0, "y": 0 } for char in str: if char == "M": ...
false
d2637b319939be641a6c2a7c41e65e4aa0c09087
caitp222/algorithms
/quicksort.py
396
4.125
4
def quicksort(lst): if len(lst) <= 1: return lst else: pivot = lst[-1] less = [] more = [] for x in lst: if x < pivot: less.append(x) elif x > pivot: more.append(x) return quicksort(less) + [pivot] + quicksor...
true
125983d80ed08e174a0b4fa12298dea058c6dbff
tiagoColli/tcc
/oam/preprocess/__init__.py
1,066
4.28125
4
import pandas as pd def normalize(df: pd.DataFrame, min: int, max: int, weights: dict = None) -> pd.DataFrame: ''' A min-max normalization to all the columns in the dataframe. If desired you can change the scale of a given column using the 'weights' param. The weight will be multiplied by every value in t...
true
81907a9c79fd38a1eaf3f0f3ca3bcfad2822eed7
Environmental-Informatics/building-more-complex-programs-with-python-walcekhannah
/program_6.5.py
553
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Due January 31, 2020 Created on Tue Jan 28 14:49:13 2020 by Hannah Walcek ThinkPython Exercise 6.5 This program creates the function gcd which finds the greatest common divisor between two values, a and b. """ def gcd(a,b): """ This function takes two integers...
true
db80e754a496e9bbfe46e4bc6221f88db2881867
nimesh-p/python
/Programs/prime.py
368
4.25
4
def check_prime_number(): num = int(input("Enter the number to check prime or not: ")) if (num == 1): return "1 is neither prime nor composite" elif (num <= 0): return "Enter valid number" else: for number in range(2, num): if(num % number == 0): return "Number is not prime" br...
true
dde3119b0326f82c7fc6a841a65c743996761905
EmilyM1/IteratorAndGenerator
/iterateGenerate.py
2,325
4.21875
4
#!/usr/bin/python 3 #counts letters in words words = """When we speak we are afraid our words will not be heard or welcomed. But when we are silent, we are still afraid. So it is better to speak.""".split() print(words) numberoflettersineachword = [len(word) for word in words] print(numberoflettersineachword) #FOR ...
true
5f4bbef7e4d835b91cd01c0b40820d3ce2b33fb1
masonbot/Wave-1
/volumeofcylinder.py
223
4.125
4
import math pi = math.pi Height = input("Height of cylinder in metres: ") Radius = input("Radius of cylinder in metres: ") r2 = float(Radius) * float(Radius) area = float(pi) * (r2) * float(Height) print(round(area,1))
true
93aecb1e3e72c0bf869e318fc8bd42a087f4df2f
MTGTsunami/LeetPython
/src/leetcode/graph/union_find/1202. Smallest String With Swaps.py
1,848
4.25
4
""" You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. You can swap the characters at any pair of indices in the given pairs any number of times. Return the lexicographically smallest string that s can be changed to afte...
true
722ce61e45de006519ae80918965d818eb1a749a
MTGTsunami/LeetPython
/src/leetcode/graph/union_find/547. Friend Circles.py
1,882
4.25
4
""" There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a friend circle is a group of students who are direct or indirect frien...
true
60d9cea1e813483eb57a4383766a61fc3b8d85d8
selivanovzhukov/Homework1
/lesson_7/les7_task2.py
863
4.25
4
temp_value = int(float(input('Please enter the value:\n'))) temp_unit = input('Please enter the type:\n') def temp_calc(temp_value, temp_unit): if temp_unit == 'K': k = temp_value c = temp_value + 273.15 f = int(float((temp_value + 459.67) / 1.8)) print(f'The temperature in Kelvins...
false
29c910f3e2c4c5f71d547c819d2b52cf33c1d6fb
TamishaRutledge/LearningPython
/learning_strings.py
554
4.59375
5
#Learning about strings and string manipulation strings = "The language of 'Python' is named for Monty Python" print(strings) """ The title method changes each word to title case Where each word begins with a capital letter The upper method converts the string to all uppercase The lower method converts the string to ...
true
b69b7875b640001a743e3d51961b81e6ccf64299
Whit3bear/yogurt
/katas/5kky_The_Clockwise_Spiral.py
1,031
4.8125
5
""" Do you know how to make a spiral? Let's test it! Classic definition: A spiral is a curve which emanates from a central point, getting progressively farther away as it revolves around the point. Your objective is to complete a function createSpiral(N) that receives an integer N and returns an NxN two-dimensional a...
true
e4719f01ead333588f33677263df9745019bbc4c
Whit3bear/yogurt
/katas/6kky_Build_Tower.py
989
4.1875
4
""" Build Tower Build Tower by the following given argument: number of floors (integer and always greater than 0). Tower block is represented as * Python: return a list; JavaScript: returns an Array; C#: returns a string[]; PHP: returns an array; C++: returns a vector<string>; Haskell: return...
true
9c04455fc47972869896529685f7887bb5f79458
Lcarpio69/Interactive-Python-Temperature-Converter
/myController.py
1,623
4.34375
4
import tkinter import myView # the VIEW import myModel # the MODEL # this is controller class that binds the View and Model classes class Controller: """ The Controller for an app that follows the Model/View/Controller architecture. When the user presses a Button on the View, this Controller call...
true
f905cfcc20b56b5c3e5c089e878869aa4422b80a
AngelVasquez20/APCSP
/Angel Vasquez - Magic 8 Ball.py
982
4.125
4
import time import random answers = ["maybe", "not sure", "could be", "positive", "ask again", "Yes", "no", "Possibly", "Ask later", "I'm tired", "I don't know", "YESSS", "I think you are"] name = input("What is your name:") print("Welcome to Magic 8 Ball %s where you ask a question and the magic ball will...
true
ead07a51b9790967e90c5cd0e81dffeddd863046
AngelVasquez20/APCSP
/Challenge 5.py
212
4.15625
4
def rectangle(): length = int(input("Please enter the following length of a rectangle: ")) width = int(input("Please enter the following width of the rectangle: ")) print(length * width) rectangle()
true
ea4e20dda65d32fdadcdcaa8035abf5eb452e4b2
Vakicherla-Sudheethi/Python-practice
/count.py
215
4.21875
4
o=input('Enter a string as input:') p={}#{} are used to define a dictionary. for i in set(o): p[i]=o.count(i)#count() function returns the number of occurrences of a substring in the given string. print(p)
true
00a987fc4606e2298bc57b2286f28353e75e0c0d
Vakicherla-Sudheethi/Python-practice
/lists2.py
341
4.4375
4
colleges=["aec","jntuk","iit",1,2,3,"kkd","surampalem","kharagpur"] print(colleges) #data type of colleges print("data type of colleges",type(colleges)) #modification or change the list name is possible colleges[1]="pragathi" print(colleges) #access list elements by element by using for loop for i in colleges: ...
false
879aa63a51fa2cc436e14df1ecd21f94bd8c3faf
FaDrYL/From0ToPython
/src/Fundamental/Variables_Data_Types/Variables_Data_Types_sample.py
1,034
4.25
4
""" Author: FaDr_YL (_YL_) """ print("---int---") a_int = 10 print(type(a_int)) print("---string---") a_string = "string" print(type(a_string)) print(a_string.upper()) print(a_string.index("s")) # you can try other functions by your own. print("---format string---") string_2 = "price: {0}, desc: {1}" print(strin...
false
186e12c1d208a7637635ef204bdccf4bd79d0a8b
Iandavidk/Web-development-2021
/Numerical_grade_to_letter_grade.py
333
4.3125
4
#get user input of a numerical grade grade = input("Enter your grade: ") #cast to an int grade = int(grade) #test the range of the number and print the appropriate letter grade if grade >= 90: print('A') elif grade >= 80: print('B') elif grade >= 70: print('C') elif grade >= 60: print('D') else: ...
true
ccf306f58c97d71600d74907fe1552c2d23aedbb
Iandavidk/Web-development-2021
/Iterate_over_name.py
210
4.1875
4
name = input("What is your first name?") letter_count = 0 print(name, "is spelled:") for x in name: print(x, end = '') letter_count += 1 print("") print(letter_count, "letters in the name", name)
true
6af7c1099fabb4e8f14d29224113a35fd252f95d
vivek-x-jha/practiceML
/LogisticRegression/LogisticRegression.py
1,497
4.15625
4
# Implement Logistic Regression from scratch # Performs Linear Regression (from scratch) using randomized data # Optimizes weights by using Gradient Descent Algorithm import numpy as np import pandas as pd import matplotlib.pyplot as plt np.random.seed(0) features = 3 trainingSize = 10 ** 1 trainingSteps = 10 ** 3 ...
true
9b1d5204cb8a3a1b5aa66d58323feda831bef1da
jackson097/Exam_Calculator
/functions.py
2,121
4.34375
4
""" Determines if the number is a floating point number or not Parameters: number - the value entered by the user """ def is_float(number): try: float(number) return True except: return False """ Determines if the number provided is a valid float Parameters: number - the value entered by t...
true
2ac0e3f7d5bab58c67a46c92d533bd298f1b73e0
geshkocker/python_hw
/hw5_task1.py
203
4.375
4
for x in range(1,10): if x % 2 == 0: print(f'{x} is even') elif x % 3 == 0: print(f'{x} is odd') elif x % 2 != 0 or x % 3 != 0: print(f'{x} in not divisible')
false
2152125ba808c6e177a2dbaf26ed313490f4809b
BrianArb/CodeJam
/Qualification_Round_Africa_2010/t9_spelling.py
2,859
4.1875
4
#!/usr/bin/env python """ Problem The Latin alphabet contains 26 characters and telephones only have ten digits on the keypad. We would like to make it easier to write a message to your friend using a sequence of keypresses to indicate the desired characters. The letters are mapped onto the digits as shown below. To i...
true
1aab08b258a9cf37d22bcbd707142377720b906c
mosestembula/andela-day4
/find_missing.py
661
4.21875
4
# ============================================================================ # missing number function implementation # ============================================================================ def find_missing(list_one, list_two): """find_missing function find the missing number between two lists ""...
true
501d3a53838105543f4e3ca884061d84096045cb
kkarczewski/Private-Secure-Shell
/tools/fibo/fibo.py
541
4.125
4
#! /usr/bin/env python3.5 # Fibonacci numbers module def fib(n): # write Fibonacci series up to n a=0 b=1 while b < n: print(b) a,b=b,a+b def fib2(n): # return Fibonacci series up to n result = [] a, b = 0, 1 while b < n: result.append(b) a, b = b, a+b re...
false
c2f4ea87cbf17bb311b550b701f52e3292e8d910
MadeleineNyhagen-zz/coursework
/Python/Lynda-Python-Courses/Python GUI Development with tkinter/Ch06_01_pack.py
1,918
4.15625
4
#!/usr/bin/python3 # template.py by Barron Stone # This is an exercise file from Python GUI Development with Tkinter on lynda.com from tkinter import * from tkinter import ttk root = Tk() ### Using fill and expand properties: ##ttk.Label(root, text = 'Hello, Tkinter!', ## background = 'yellow')....
true
0a987c5193de317a08bd3e0092c28a8129085cef
MadeleineNyhagen-zz/coursework
/Python/Lynda-Python-Courses/Python GUI Development with tkinter/Ch05_05_scrollbar.py
1,386
4.3125
4
#!/usr/bin/python3 # scrollbar.py by Barron Stone # This is an exercise file from Python GUI Development with Tkinter on lynda.com from tkinter import * from tkinter import ttk root = Tk() ### text with scrollbar: ##text = Text(root, width = 40, height = 10, wrap = 'word') ##text.grid(row = 0, column = 0...
true
94cfee2114c031675bad9a6c4a598268c8b65f4a
MadeleineNyhagen-zz/coursework
/Python/Python-in-a-Day/simple_script9.py
1,943
4.34375
4
epic_programmer_dict = {'ada lovelace' : ['lordbyronsdaughter@gmail.com', 111], 'margaret hamilton' : ['asynchronous.apollo@mit.edu', 222], 'grace hopper' : ['commodore.debug@vassar.edu', 333], 'jean jennings bartik' : ['bartik@eniac.mil', 444], ...
true
fa8119fbd9a657952ef79880744cdcfad6a0f758
HugoSantiago/Quickest-Way-Up
/Dijkstra/dijkstra.py
2,313
4.1875
4
# Python3 implementation to find the # shortest path in a directed # graph from source vertex to # the destination vertex infi = 1000000000 # Function to find the distance of # the node from the given source # vertex to the destination vertex def dijkstraDist(g, s, path): # Stores distance of ea...
true
b9b20a0d8fb550b18852a1b063e8e006f6c50833
jpragasa/Learn_Python
/Basics/3_Variables.py
385
4.28125
4
greeting = "This is stored in greeting" #Basic data types #Integer: numbers with no decimals #Float: numbers with decimals a = 5 b = 4 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) #The 2 slashes mean the number is returned as an integer print(a % b) for i in range(1, a // b): ...
true
c5f658bb8e497c1563f0bbaf249c2f978c2d33ab
micaswyers/Advent
/Advent2015/16/day16.py
2,311
4.15625
4
from collections import defaultdict TARGET_SUE = { 'children': 3, 'cats': 7, 'samoyeds': 2, 'pomeranians': 3, 'akitas': 0, 'vizslas': 0, 'goldfish': 5, 'trees': 3, 'cars': 2, 'perfumes': 1, } # Part 1 def parse_input(): """Returns...
false
c0e7ca6c23d2cfd041c3e1d5663ef9724bd3af54
SharmaSwapnil/Py_Stats_Scripts
/HR_StringUpdate.py
375
4.15625
4
def count_substring(string, sub_string): counter = [] for i in range(len(string)): ss = string.count(sub_string,i,i+len(sub_string)) counter.append(ss) return sum(counter) if __name__ == '__main__': string = input("Enter string ").strip() sub_string = input("Enter substring ").strip() count...
true
032f6f4b8860955361d854b7134fd13ca3670691
inbalalo/Python
/hw1_question1.py
541
4.25
4
def trifeca(word): """ Checks whether word contains three consecutive double-letter pairs. word: string returns: bool """ for i in range(0, len(word)): if (len(word)-i) >= 6: if word[i] == word[i+1] and word[i+2] == word[i+3] and word[i+4] == word[i+5]: ...
true
cb1688a038336a2725b06870130b2d5d5754fc10
Shopzilla-Ops/python-coding-challenge
/calculator/mjones/calculator.py
1,477
4.25
4
#!/usr/bin/python2.7 '''A simple interactive calculator''' import sys def add(num1, num2): '''Add two numbers''' res = num1 + num2 return res def sub(num1, num2): '''Subtract one number from another''' res = num1 - num2 return res def mult(num1, num2): '''Multiply two numbers''' r...
false
0b2f4e73efe111b9e87707f5c9a81c62f6f8db20
lipanlp/Python-crawler-learning
/class learning.py
1,791
4.25
4
class student(): def speak(self): print('%s 说我是一个%s岁的%s生' % (self.name,self.age,self.gender)) lipan=student() lipan.name="帅哥" lipan.age="15" lipan.gender="男" lipan.speak() #>>>帅哥 说我是一个15岁的男生 #学习类(class)相关实践 #2020年2月18日15:16:19 class teacher(): def __init__(self,name,age,height): ...
false
e458a1e97a36eb70d0d602bc920f58d16cca0b9a
Dsgra/python_examples
/ExamplesWordCount.py
945
4.125
4
#!/usr/bin/python #The code used below will return the content of a file from the directory # in fact it will do with any file. f = open("example.txt", "r") data = f.read() f.close() print(data) # Another example below will show a more complex data readed structure f = open("New_File_Reading.txt", "r") data ...
true
47b16887879d2f6631c7e47b10f4ba87a02606d8
practicerkim/lpthw
/ex33a.py
940
4.4375
4
# -*- coding: utf-8 -*- def make_array(array_length, incre): i = 0 numbers = [] print '\nfunction using while statement' while i < array_length: numbers.append(i) i = i + incre print numbers print "\n" def make_array_using_for(array_length, incre): i = ...
false
b0ad65d0f6dfc06546385afa9a7f69bfe3cc017d
vineeta786/geeksForGeeks_python
/String/Stng functions - II.py
315
4.3125
4
#User function Template for python3 # Function to check if string # starts and ends with 'gfg' def gfg(a): b = a.lower() if((b.startswith('gfg') or b.startswith('GFG')) and b.endswith('gfg') or b.endswith('GFG')): # use b.startswith() and b.endswith() print ("Yes") else: print ("No")
true
fcdae2fbe26fdc25a813d3e14e72d358903c78aa
super-aardvark/project-euler
/problem-001-100/problem-011-020/problem-015.py
951
4.1875
4
''' Created on Jan 10, 2017 @author: jfinn ''' def paths_through_lattice(grid_size): # Problem defines the grid size as the number of squares. Add one to get the number of intersections. grid_size += 1 # We'll track the number of different paths that may be taken to get to each node nodes = [ [...
true