blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
af8f6a301de6b7bcf12dce96898944ec99928b6d
vickylee745/Learn-Python-3-the-hard-way
/ex30.py
925
4.46875
4
people = 30 cars = 40 trucks = 15 if cars > people: print("We should take the cars.") elif cars < people: print("We should not take the cars.") else: print("We can't decide.") if trucks > cars: print("That's too many trucks.") elif trucks < cars: print("Maybe we could take the trucks.") else: ...
true
33dffd72dbc71e9bf6d0669e3570557c5102418d
Chyi341152/pyConPaper
/Concurrency/codeSample/Part4_Thread_Synchronuzation_Primitives/sema_signal.py
1,236
4.65625
5
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # sema_signal.py # # An example of using a semaphore for signaling between threads import threading import time done = threading.Semaphore(0) # Resource control. item = None def producer(): global item print("I'm the producer and I produce data.") ...
true
3df062d10ddff464e32ed814ddd2012dc97d326d
DataKind-DUB/PII_Scanner
/namelist.py
1,231
4.25
4
#!/usr/bin/python3 -i """This file contain functions to transform a list of names text file to a set """ def txt_to_set(filename): """(str) -> set() Convert a text file containing a list of names into a set""" res = set() with open(filename,'r') as f: for line in f: l = line.strip().split() for item in l:...
true
9a049b0cd58d5c48f564591f9edb5ff6b19e1ae9
Ishita46/PRO-C97-NUMBER-GUESSING-GAME
/gg.py
551
4.25
4
import random print("Number Guessing Game") Number = random.randint(1,9) chances = 0 print("Guess a number between 1-9") while chances < 5: guess = int(input("Enter your guess")) if guess == Number: print("Congratulations you won!") break elif guess < Number: print("Yo...
true
36a5612ef360eeb868da742bc9f29f535cb3fb84
saparia-data/data_structure
/geeksforgeeks/maths/2_celcius_to_fahrenheit.py
852
4.5
4
""" Given a temperature in celsius C. You need to convert the given temperature to Fahrenheit. Input Format: The first line of input contains T, denoting number of testcases. Each testcase contains single integer C denoting the temperature in celsius. Output Format: For each testcase, in a new line, output the temper...
true
795bc9954ddcd5e52ad3477bf197c5bedd9a9650
saparia-data/data_structure
/geeksforgeeks/linked_list/segregate_even_and_odd_nodes_in_linked_list_difficullt.py
2,808
4.15625
4
''' Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list. Also, keep the order of even and odd numbers same. https://www.geeksforgeeks.org/segregate-even-and-odd-elements-in-a-linked-list/ ''' class Node: ...
true
17d7ca663bf8697b79bd7824a49e561839818cf3
saparia-data/data_structure
/pepcoding/dynamic_programming/4_climb_stairs_with_minimum_moves.py
1,375
4.15625
4
''' 1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0th step and are required to climb to the top. 3. You are given n numbers, where ith element's value represents - till how far from the step you could jump to in a single move. You can of-course fewer number of ste...
true
fea46e295115747dfcc38e182eb865603b501e74
saparia-data/data_structure
/pepcoding/recursion/1_tower_of_hanoi.py
961
4.15625
4
''' 1. There are 3 towers. Tower 1 has n disks, where n is a positive number. Tower 2 and 3 are empty. 2. The disks are increasingly placed in terms of size such that the smallest disk is on top and largest disk is at bottom. 3. You are required to 3.1. Print the instructions to move the disks. 3.2. from tower...
true
60937f08311c74e6773fa09eaec056097efb9496
saparia-data/data_structure
/pepcoding/generic_tree/17_is_generic_tree_symmetric.py
1,776
4.1875
4
''' The function is expected to check if the tree is symmetric, if so return true otherwise return false. For knowing symmetricity think of face and hand. Face is symmetric while palm is not. Note: Symmetric trees are mirror image of itself. Sample Input: 20 10 20 50 -1 60 -1 -1 30 70 -1 80 -1 90 -1 -1 40 100 -1 1...
true
008b19ff7efc7fc9be540903c086a792aed6c0d2
saparia-data/data_structure
/geeksforgeeks/maths/7_prime_or_not.py
1,297
4.34375
4
''' For a given number N check if it is prime or not. A prime number is a number which is only divisible by 1 and itself. Input: First line contains an integer, the number of test cases 'T'. T testcases follow. Each test case should contain a positive integer N. Output: For each testcase, in a new line, print "Yes" i...
true
3fb0fefa594130bd865c342d60d0f7ff34127f7f
saparia-data/data_structure
/geeksforgeeks/linked_list/4_Insert_in_Middle_of_Linked_List.py
1,343
4.15625
4
''' Given a linked list of size N and a key. The task is to insert the key in the middle of the linked list. Input: The first line of input contains the number of test cases T. For each test case, the first line contains the length of linked list N and the next line contains N elements to be inserted into the linked...
true
296acd0cb1655e3fd6d57e80b9bd72529ffb4ecc
saparia-data/data_structure
/geeksforgeeks/matrix/8_Boundary_traversal_matrix.py
2,384
4.34375
4
''' You are given a matrix A of dimensions n1 x m1. The task is to perform boundary traversal on the matrix in clockwise manner. Input: The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase two lines of input. The first line contains dimensions of the matrix A, n1 and...
true
789288e7c8987df76436b463f7e8fa6f2d9b1a8a
saparia-data/data_structure
/geeksforgeeks/tree/6_height_of_binary_tree.py
698
4.125
4
''' Hint: 1. If tree is empty then return 0 2. Else (a) Get the max depth of left subtree recursively i.e., call maxDepth( tree->left-subtree) (a) Get the max depth of right subtree recursively i.e., call maxDepth( tree->right-subtree) (c) Get the max of max depths of left and ri...
true
770ac8812cac09b77d0990edacc7fed78c612480
saparia-data/data_structure
/geeksforgeeks/maths/1_absolute_value_solved.py
1,062
4.375
4
''' You are given an interger I. You need to print the absolute value of the interger I. Input Format: The first line of input contains T, denoting number of testcases. Each testcase contains single integer I which may be positive or negative. Output Format: For each testcase, in a new line, output the absolute value...
true
35030f181df15a7fb1ad550279aadc98a6baf954
saparia-data/data_structure
/geeksforgeeks/sorting/11_Counting_Sort.py
1,265
4.25
4
''' Given a string S consisting of lowercase latin letters, arrange all its letters in lexographical order using Counting Sort. Input: The first line of the input contains T denoting number of testcases.Then T test cases follow. Each testcase contains positive integer N denoting the length of string.The last line of i...
true
d476ee8753b489e9a160984ca1a71e49eed86f2d
saparia-data/data_structure
/geeksforgeeks/array/3_majority_in_array_solved.py
2,439
4.40625
4
''' We hope you are familiar with using counter variables. Counting allows us to find how may times a certain element appears in an array or list. You are given an array arr[] of size N. You are also given two elements x and y. Now, you need to tell which element (x or y) appears most in the array. In other words, pri...
true
8f2e60355dfe700cfde7b30b569d431ce959b7e5
saparia-data/data_structure
/geeksforgeeks/strings/6_check_if_string_is_rotated_by_two_places.py
1,986
4.21875
4
''' Given two strings a and b. The task is to find if the string 'b' can be obtained by rotating another string 'a' by exactly 2 places. Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. In the next two lines are two string a and b respectively. Output: ...
true
b6bf8024d4250adafec321751f4317591391a1c9
saparia-data/data_structure
/geeksforgeeks/tree/26_Foldable_Binary_Tree.py
1,007
4.4375
4
''' Given a binary tree, find out if the tree can be folded or not. -A tree can be folded if left and right subtrees of the tree are structure wise mirror image of each other. -An empty tree is considered as foldable. Consider the below tree: It is foldable 10 / \ 7 15 \ / 9 1...
true
b05134767f55b443af849edfa92df6ae5937491b
saparia-data/data_structure
/geeksforgeeks/matrix/11_Reversing_the _columns_Matrix.py
1,919
4.40625
4
''' You are given a matrix A of dimensions n1 x m1. The task is to reverse the columns(first column exchanged with last column and so on). Input: The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase two lines of input. The first line contains dimensions of the matrix...
true
e76d09cc97d9d6d8677ae32ba52425ec5fa34a0f
cginiel/si507
/lecture/week3/2020.01.21.py
2,638
4.46875
4
# # import datetime # # date_now = datetime.datetime.now() # # print(date_now.year) # # print(date_now.month) # # print(date_now.day) # # print(type(date_now)) # # class is a type of thing, object is a particular instance of that class!!!!! # # BEGIN CLASS DEFINITION # """ # class Dog: # def __init__(self, nm, ...
true
1d07ee37723cc22548908a0a75b02facb6664100
alexbenko/pythonPractice
/classes/magic.py
787
4.125
4
#how to use built in python methods like print on custom objects class Car(): speed = 0 def __init__(this,color,make,model): this.color = color this.make = make this.model = model def __str__(this): return f'Your {this.make},{this.model} is {this.color} and is currently going {this.speed} mph' ...
true
b821bd68661a42ae46870bd01178d181656149e6
xenron/sandbox-github-clone
/qiwsir/algorithm/divide.py
2,005
4.125
4
#! /usr/bin/env python #coding:utf-8 def divide(numerator, denominator, detect_repetition=True, digit_limit=None): # 如果是无限小数,必须输入限制的返回小数位数:digit_limit # digit_limit = 5,表示小数位数5位,注意这里的小数位数是截取,不是四舍五入. if not detect_repetition and digit_limit == None: return None decimal_found = False ...
true
465074ef23a66b649ac36eb6a259c9ace2732cb3
YYYYMao/LeetCode
/374. Guess Number Higher or Lower/374.py
1,424
4.15625
4
374. Guess Number Higher or Lower We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I ll tell you whether the number is higher or lower. You call a pre-defined API guess(int num) which returns 3 possible results (-1...
true
b7cfe79cf0003bdb6d174d1471fbb672b0700b7f
codeAligned/interview_challenges
/sort_and_search/binary_search.py
442
4.25
4
def binary_search(iterable, target): """Determine if target value is in sorted iterable containing numbers""" sorted_iterable = sorted(iterable) low = 0 high = len(sorted_iterable) - 1 while low <= high: midpoint = (high + low) // 2 if sorted_iterable[midpoint] == target: return True elif sorted_iterable[...
true
c92ba78a30f78a134befad3de91f7572a201b1ef
szk0139/python_tutorial_FALL21
/mysciW4/readdata.py
1,018
4.1875
4
def read_data(columns, types = {}, filename= "data/wxobs20170821.txt"): """ Read data from CU Boulder Weather Stattion data file Parameters: colums: A dictonary of column names mapping to column indices types: A dictonary of column names mapping to the types to which to convert each colum...
true
9b34c6cc778d0a45f819a5667308a2e4f5f7f1f8
Stepancherro/Algorithm
/stack.py
1,879
4.1875
4
# -*- encoding: utf-8 -*- # Stack() creates a new stack that is empty. # It needs no parameters and returns an empty stack. # push(item) adds a new item to the top of the stack. # It needs the item and returns nothing. # pop() removes the top item from the stack. # It needs no parameters and returns the item....
true
5b7ad9bbd58b59d7e7319bad5d970b5dbba1a529
moha0825/Personal-Projects
/Resistance.py
1,018
4.375
4
# This code is designed to have multiple items inputted, such as the length, radius, and # viscosity, and then while using an equation, returns the resistance. import math def poiseuille(length, radius, viscosity): Resistance = (int(8)*viscosity*length)/(math.pi*radius**(4)) return Resistance def main(): ...
true
d0a53a4ca42e65bb86f1e4453bdfe747ea8227ee
AmineNeifer/holbertonschool-interview
/0x19-making_change/0-making_change.py
578
4.25
4
#!/usr/bin/python3 """ Contains makeChange function""" def makeChange(coins, total): """ Returns: fewest number of coins needed to meet total If total is 0 or less, return 0 If total cannot be met by any number of coins you have, return -1 """ if not coins or coins is None: re...
true
3b2c0d8d806dcc4b73a80bf0564a77f77b906b67
laurenhesterman/novTryPy
/TryPy/trypy.py
1,832
4.5625
5
#STRINGS # to capitalize each first letter in the word use .capitalize() method, with the string before .capitalize characters = "rick" print characters.capitalize() #returns Rick #returns a copy of the whole string in uppercase print characters.upper() #returns RICK #.lower() returns a copy of the string converted ...
true
017ccb38921399323ccb3c169a50063b3057a118
Alex-Reitz/Python_SB
/02_weekday_name/weekday_name.py
566
4.25
4
def weekday_name(day_of_week): """Return name of weekday. >>> weekday_name(1) 'Sunday' >>> weekday_name(7) 'Saturday' For days not between 1 and 7, return None >>> weekday_name(9) >>> weekday_name(0) """ i = 0 weekdays = ["Sunday", "Monday", "Tuesd...
true
5c39c42c7787b07e51728b67855c4f58fa98fd0f
leios/OIST.CSC
/hello_world/python/hello_world.py
788
4.15625
4
#-------------hello_world.py---------------------------------------------------# # # In most traditional coding courses, they start with a simple program that # outputs "Hello World!" to the terminal. Luckily, in python... this is pretty # simple. In fact, it's only one line (the line that follows this long comment).#...
true
4508866832b2578a43788e47e00c3e9781bb6b44
cesarmarroquin/blackjack
/blackjack_outline.py
2,089
4.1875
4
""" I need to create a blackjack Game. In blackjack, the player plays against the dealer. A player can win in three different ways. The three ways are, the player gets 21 on his first two cards, the dealer gets a score higher than 21, and if the player's score is higher than the dealer without going over 21. The deale...
true
3883f41652fa43d96be453f5d5434aead2cf3ead
mohit131/python
/project_euler/14__Longest_Collatz_sequence.py
1,095
4.21875
4
'''The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 It can be seen that this sequence (starting at 13 and finishing ...
true
df01dc415a7750095dcd99b64690469a7c41b983
Chittadeepan/P342
/lab5_q2.py
1,328
4.1875
4
#importing everything from math module from math import * #importing all functions from library from library import * #poly_f(x) function def poly_f(x,coeff,n): sum=0 for i in range(1,n+1): sum=sum+coeff[i-1]*x**(n-i) return sum #main program def main(): #initialising fi...
true
e537efac5d4877eb9b8516a4b02cee19f7985323
PratheekH/Python_sample
/comp.py
201
4.28125
4
name=input("Enter your name ") size=len(name) if size<3: print("Name should be more than 3") elif size>50: print("Name should not be more than 50") else: print("Name looks fine")
true
2a8ea1f95001015fba07fc2130024b5c6a8375c7
aashishah/LocalHackDay-Challenges
/EncryptPassword.py
702
4.28125
4
#Using Vignere Cipher to encrpt password of a user using a key that is private to the user. def encrypt(password, key): n = len(password) #Generate key if len(key) > n: key = key[0:n] else: key = list(key) for i in range(n - len(key)): key.append(key[i % len(key)...
true
15c76b453894e5eb09fcaa195a0a8a66351b1048
Karlo5o/rosalind_problems
/RNA.py
700
4.1875
4
""" An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'. Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing all occurrences of 'T' in t with 'U' in u. Given: A DNA string t having length at most 1000 nt. Return: The transcribed RNA...
true
d516d08d9c1af9bce8e845f69552a45377b6696b
marcusiq/w_python
/greeting.py
1,570
4.4375
4
""" Generally. There is no method overloading in python. Overloading in other languages occurs when two methods have the same name, but different numbers of arguments. In python, if you give more than one definition using the same name, the last one entered rules, and any previous definitions are ignored. """ # Her...
true
0db7eaa487bf54eb30f885b7baf11d93dfd6eabd
adamelliott1982/1359_Python_Benavides
/lab_04/1359-lab_04/drop_grade.py
1,549
4.34375
4
# Program: drop_grade.py # Programmer: Adam Elliott # Date: 02/26/2021 # Description: lab 4 - lists and for statements ######################################################## # create list of 5 grades and initialize grades = [100, 80, 70, 60, 90] # print report name – DROP LOWEST GRADE PROGRAM print('DRO...
true
37ac60fa04dbaed484d77e43317c6069a26ad777
marc-p-greenfield/tutor_sessions
/payment_system.py
602
4.21875
4
number_of_employees = int(input("How many employees do you want to enter:")) total_payment = 0 for i in range(number_of_employees): name = input('Please enter name: ') hours = float(input('How many hours did you work this week? ')) rate = float(input('What is your hourly rate?')) payment = 0 overt...
true
f26e9e6bc1103c6c72fbe0fc72ed2435b62281ad
KishoreMayank/CodingChallenges
/Cracking the Coding Interview/Arrays and Strings/StringRotation.py
349
4.1875
4
''' String Rotation: Check if s2 is a rotation of s1 using only one call to isSubstring ''' def is_substring(string, sub): return string.find(sub) != -1 def string_rotation(s1, s2): if len(s1) == len(s2) and len(s1) != 0: return is_substring(s1 + s1, s2) # adds the two strings together and calls ...
true
b5d3beb20cc86479f91f35db74f4f4a87bd54dc4
KishoreMayank/CodingChallenges
/Interview Cake/Stacks and Queues/MaxStack.py
821
4.3125
4
''' Max Stack: Use your Stack class to implement a new class MaxStack with a method get_max() that returns the largest element in the stack. ''' class MaxStack(object): def __init__(self): self.stack = [] self.max = [] def push(self, item): """Add a new item to the top o...
true
047638de234a37c895d55b1aa6f571f72d2c9f4c
stellakaniaru/practice_solutions
/learn-python-the-hard-way/ex16.py
877
4.3125
4
'''Reading and writing files''' from sys import argv script, filename = argv print "We're going to erase %r."%filename print "If you don't want that, hit CTRL-C(^C)." print "If you don't want that, hit RETURN." raw_input("?") print "Opening the file..." target = open(filename, 'w') #when you open the file in writ...
true
b1025eb52f8c374fecd1458fe6e151f38eb8ec1a
stellakaniaru/practice_solutions
/overlapping.py
500
4.1875
4
''' Define a function that takes in two lists and returns True if they have one member in common.False if otherwise. Use two nested for loops. ''' #function definition def overlapping(list1, list2): #loop through items in first list for i in list1: #loop through items in second list for j in list2: #check...
true
5b49cf35ea8a0c178691c729f4275a93519be37c
stellakaniaru/practice_solutions
/learn-python-the-hard-way/ex7.py
849
4.40625
4
'''more printing''' #prints out a statement print 'Mary had a little lamb.' #prints out a statement with a string print 'Its fleece was as white as %s.'%'snow' #prints out a statement print 'And everywhere that Mary went.' print '.' * 10 #prints a line of ten dots to form a break #assigns variables with a characte...
true
053d3a417ab0f05a201f9999917babd870869561
stellakaniaru/practice_solutions
/years.py
664
4.25
4
''' Create a program that asks the user to enter their name and age. Print out a message addressed to them that tells them the year they will turn 100 years old. ''' from datetime import date #ask for user input on name and age name = input('Enter your name: ') age = int(input('Enter your age: ')) num = int(input('...
true
1f42e53223e2ec4d0ce3f185cf5e4919985e0f0c
stellakaniaru/practice_solutions
/max_three.py
364
4.3125
4
''' Define a function that takes in three numbers as arguments and returns the largest of them. ''' #function definition def max_of_three(x,y,z): #check if x if the largest if x > y and x > z: return x #check if y is the largest elif y > x and y > z: return y #if the first two conditions arent met,z becom...
true
d3b3b842686d62d102ef89dfdffb0fefdc834343
prabhatpal77/Adv-python-oops
/refvar.py
475
4.1875
4
# Through the reference variable we can put the data into the object, we can get the data from the object # and we can call the methods on the object. # We can creste a number of objects for a class. Two different object of a same class or different classes # does not contain same address. class Test: """sample cla...
true
69996ed2547992a8a7b8eb86e554740f0ac3647b
IrinaVladimirTkachenko/Python_IdeaProjects_Course_EDU
/Python3/TryExcept/else_finaly.py
855
4.34375
4
# If we have an error - except block fires and else block doesn't fire # If we haven't an error - else block fires and except block doesn't fire # Finally block fires anyway #while True: # try: # number = int(input('Enter some number')) # print(number / 2) #except: # print('You have to ent...
true
b7c8c1f93678be20578422e02e01adeba36041f9
Ballan9/CP1404-pracs
/Prac01/asciiTable.py
420
4.25
4
LOWER = 33 UPPER = 127 print("Enter a character:") character = input() print("The ASCII code for g is", ord(character)) number = int(input("Enter a number between {} and {}:".format(LOWER,UPPER))) if number < LOWER or number > UPPER: print("Invalid number entered") else: print("The Character for {} is ".format...
true
82b1b76a67d899523d77c2ee9d6fdea0812cbd67
catherinelee274/Girls-Who-Code-2016
/Python Projects/fahrenheittocelsius.py
356
4.28125
4
degree = input("Convert to Fahrenheit or celsius? For fahrenheit type 'f', for celsius type 'c'") value = input("Insert temperature value: ") value =int(value) if degree == "c": value = value-32 value = value/1.8 print(value) elif degree == "f": value = value*1.8 + 32 print(value) else:...
true
3775cb6c2e02e1b142b14ef88f2cadd57fd47d3e
blakerbuchanan/algos_and_data_structures
/datastructures/datastructures/queues.py
697
4.1875
4
# Impelement a queue in Python # Makes use of the list data structure inherent to Python class Queue: def __init__(self): self.Q = [] def remove(self): try: self.Q.pop(0) except: print("Error: queue is empty.") def add(self, item): self.Q.append(ite...
true
54785e654145533309b1197a6f17aea09a8d7b28
go1227/PythonLinkedLists
/DoubleLinkedList.py
1,655
4.1875
4
__author__ = "Gil Ortiz" __version__ = "1.0" __date_last_modification__ = "4/7/2019" __python_version__ = "3" #Double Linked List class Node: def __init__(self, data, prev, next): self.data = data self.prev = prev self.next = next class DoubleList: head = None tail = None d...
true
56bfaaa56ffb54a986b9d7ea862cb670405b785e
carloslorenzovilla/21NumberGame
/main.py
2,291
4.34375
4
""" Created on Sun Jul 14 10:17:48 2019 @author: Carlos Villa """ import numpy as np # This game is a take on a 21 Card Trick. 21 numbers are randomly placed # in a 7x3 matrix. The player thinks of a number and enters the column that # the number is in. This step is repeated three times. Finally, the number # that t...
true
f7e6ef2007bcea37aa7aa2d7ba71a125b0bde471
yulyzulu/holbertonschool-web_back_end
/0x00-python_variable_annotations/7-to_kv.py
442
4.15625
4
#!/usr/bin/env python3 """Complex types""" from typing import Tuple, Union def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]: """ type-annotated function to_kv that takes a string k and an int OR float v as arguments and returns a tuple. The first element of the tuple is the string k. ...
true
d4d47e92f11fbac4d36867562b0616dd8fad565e
je-castelan/Algorithms_Python
/Python_50_questions/10 LinkedList/merge_sorted_list.py
1,009
4.1875
4
""" Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. """ from single_list import Node def mergeTwoLists(l1, l2): newList = Node(0,None) pos = newList while (l1 and l2): if l1.value < l2.value: ...
true
42ea8bfbfab0cda471b19eb65d3981a235888341
je-castelan/Algorithms_Python
/Python_50_questions/19 Tree Graphs/max_path_sum.py
1,457
4.125
4
""" A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum of a path is the sum of the node's values in the path. Given th...
true
6c8974807d165228b8465c8fbf0f469b7d6ac8c6
dmoncada/python-playground
/stack.py
1,359
4.1875
4
class Stack: '''A simple, generic stack data structure.''' class StackNode: def __init__(self, item, next_node): self.item = item self.next = next_node class EmptyStackException(Exception): pass def __init__(self): '''Initializes self.''' self....
true
c122d2a776f88be7797cfbd7768db9be8e54e8a3
murthyadivi/python-scripts
/Prime number check.py
864
4.1875
4
# returns the number input by user def input_number(prompt): return int(input(prompt)) # Checks if the given number is a primer or not def check_prime(number): #Default primes if number == 1: prime = False elif number == 2: prime = True #Test for all all ...
true
3e8715e64fe0540e8b00d7c28567773c3a8b178c
Krishan00007/Python_practicals
/AI_ML_visulizations/ML_linear_regression.py
1,873
4.15625
4
import warnings warnings.filterwarnings(action="ignore") # Practical implementation of Linear Regression # ----------------------------------------------- import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression def get_data(filename): dataframe = pd.read_csv(fil...
true
61c414f192b860ad7fd4f392ce611b22d58d0f98
Krishan00007/Python_practicals
/practical_6(2).py
2,141
4.28125
4
""" Write a GUI-based program that allows the user to convert temperature values between degrees Fahrenheit and degrees Celsius. The interface should have labeled entry fields for these two values. These components should be arranged in a grid where the labels occupy the first row and the corresponding fields occu...
true
d8c97706c79eaeff2111524b111e3a25753176b7
Krishan00007/Python_practicals
/AI_ML_visulizations/value_fill.py
1,035
4.34375
4
# Filling a null values using interpolate() method #using interpolate() functon to fill missing values using Linear method import pandas as pd # Creating the dataframe df = pd.DataFrame( { "A": [12, 4, 5, None, 1], "B": [None, 2, 54, 3, None], ...
true
23c50555c6cf85b3157b30c463e390d4b374d50c
Krishan00007/Python_practicals
/practical_3(1).py
2,229
4.78125
5
""" A bit shift is a procedure whereby the bits in a bit string are moved to the left or to the right. For example, we can shift the bits in the string 1011 two places to the left to produce the string 1110. Note that the leftmost two bits are wrapped around to the right side of the string in this operation. Def...
true
14c47f156cf416431864448d62d3f27918d5226b
PNai07/Python_1st_homework
/02_datatypes.py
1,888
4.5625
5
# Data Types # Computers are stupid #They doi not understand context, and we need to be specific with data types. #Strings # List of Characters bundled together in a specific order #Using Index print('hello') print(type('hello')) #Concatenation of Strings - joining of two strings string_a = 'hello there' name_perso...
true
9908be12de460b5cb7a690eae3b9030e8422e8a2
PNai07/Python_1st_homework
/06_datatypes_booleans.py
1,426
4.5625
5
# Booleans # Booleans are a data type that is either TRUE or FALSE var_true = True var_false = False #Syntax is capital letter print(type(var_true)) print(type(var_false)) # When we equate/ evaluate something we get a boolean as a response. # Logical operator return boolean # == / ! / <> / >= / <= weather = 'Rain...
true
53e2fc8c6c8ba4b78ad525d40a369a082611cb30
Parth731/Python-Tutorial
/Quiz/4_Quiz.py
264
4.125
4
# break and continue satement use in one loop while (True): print("Enter Integer number") num = int(input()) if num < 100: print("Print try again\n") continue else: print("congrautlation you input is 100\n") break
true
9641bd85b9168ca13ea4e70c287dd703d3f7c19c
Parth731/Python-Tutorial
/Exercise/2_Faulty_Calculator.py
920
4.1875
4
#Exercise 2 - Faulty Calculator # 45*3 = 555, 56+9 = 77 , 56/6 = 4 # Design a caluclator which will correctly solve all the problems except # the following ones: # Your program should take operator and the two numbers as input from the user and then return the result print("+ Addition") print("- Subtraction") print("...
true
0a5b0d751a1fcbfa086452b6076527668aa4fcbc
shrobinson/python-problems-and-solutions
/series (2,11).py
365
4.28125
4
#Given two integers A and B. Print all numbers from A to B inclusively, in ascending order, if A < B, or in descending order, if A ≥ B. #Recommendation. Use for loops. #For example, on input #4 #2 #output must be #4 3 2 A = int(input()) B = int(input()) if A < B: for i in range(A, B+1): print(i) else: for i...
true
bb4b6083ef0eca3abca1627acfab5a77dd0bc485
shrobinson/python-problems-and-solutions
/length_of_sequence (2,4).py
394
4.1875
4
#Given a sequence of non-negative integers, where each number is written in a separate line. Determine the length of the sequence, where the sequence ends when the integer is equal to 0. Print the length of the sequence (not counting the integer 0). #For example, on input #3 #2 #7 #0 #output should be #3 n = int(inp...
true
608a587c0123d50950fb43f3321572f01a2450e2
shrobinson/python-problems-and-solutions
/countries_and_cities (3,18).py
855
4.28125
4
#First line of the input is a number, which indicates how many pairs of words will follow (each pair in a separate line). The pairs are of the form COUNTRY CITY specifying in which country a city is located. The last line is the name of a city. Print the number of cities that are located in the same country as this cit...
true
28150f1848962980561507ee3bf9a41804f3e564
shrobinson/python-problems-and-solutions
/leap_year (1,13).py
508
4.15625
4
#Given the year number. You need to check if this year is a leap year. If it is, print LEAP, otherwise print COMMON. #The rules in Gregorian calendar are as follows: #a year is a leap year if its number is exactly divisible by 4 and is not exactly divisible by 100 #a year is always a leap year if its number is exactly...
true
a7a8ba21ad69cd68dc8ab7d57faf2cd40681524f
Get2dacode/python_projects
/quickSort.py
1,180
4.15625
4
def quicksort(arr,left,right): if left < right: #splitting our array partition_pos = partition(arr,left,right) quicksort(arr,left, partition_pos - 1) quicksort(arr,partition_pos+1,right) def partition(arr,left,right): i = left j = right -1 pivot = arr[right] while i < j: ...
true
7b145f2578ad8e7a8b78b3230f38631bdc1f76c7
aadilkadiwal/Guess_game
/user_guess.py
651
4.15625
4
# Number guess by User import random def user_guess(number): random_number = random.randint(1, number) guess = 0 guess_count = 0 while guess != random_number: guess = int(input(f'Guess the number between 1 and {number}: ')) guess_count += 1 if guess > random_number: ...
true
b4f271e3a902188ce99905547ebcf43d52261f50
niloy-biswas/OOP-Data-structure-Algorithm
/oop.py
2,673
4.15625
4
class Person: def __init__(self, name: str, age: int, birth_year: int, gender=None): self.name = name # Person has a name // has a relation with instance self.__age = age self.__birth_year = birth_year # Private variable / Data encapsulation self.gender = gender def get_name(s...
true
2c758cd5b6825ae199112690ac55dc7e229f782d
ritopa08/Data-Structure
/array_rev.py
867
4.375
4
'''-----Arrays - DS: An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), that can be referenced as (you may also see it written as ). Given an array, , of integers, print each ele...
true
a87621ac4cb9c506b514ee5c6f69796330c92237
pratibashan/Day4_Assignments
/factorial.py
261
4.25
4
#Finding a factorial of a given no. user_number =int(input("Enter a number to find the factorial value: ")) factorial = 1 for index in range(1,(user_number+1)): factorial *= index print (f"The factorial value of a given number is {factorial}")
true
6671ca404f704cf143d719c60f030eddf9a48b8d
vasudhanapa/Assignment-2
/assignment 2.py
750
4.40625
4
#!/usr/bin/env python # coding: utf-8 # 1. Write a program which accepts a sequence of comma-separated numbers from console and generate a list. # 1. Create the below pattern using nested for loop in Python. # * # * * # * * * # * * * * # * * * * * # * * * * # * * * # * * # * # # In[1]: num1 = 1 num2 = ...
true
9709680af1eeef88c1b8472142c5f85b9003114c
AmitAps/advance-python
/generators/generator7.py
860
4.5
4
""" Understanding the Python Yield Statement. """ def multi_yield(): yield_str = "This will print the first string" yield yield_str yield_str = "This will print the second string" yield yield_str multi_obj = iter(multi_yield()) while True: try: prt = next(multi_obj) print(prt) ...
true
9f311f33adbc0a2fb31ffc1adb014bb66de0fb2b
AmitAps/advance-python
/oop/class2.py
337
4.15625
4
class Dog: #class attribute species = 'Canis familiaris' def __init__(self, name, age): self.name = name self.age = age """ Use class attributes to define properties that should have the same value for every class instance. Use instance attributes for properties that vary from one instance...
true
42f8e41488f1de16d53ced9f76053374fe5ce4a3
AmitAps/advance-python
/instance_class_and_static_method/fourth_class.py
1,073
4.15625
4
import math class Pizza: def __init__(self, radius, ingredients): self.radius = radius self.ingredients = ingredients def __repr__(self): return (f'Pizza({self.radius!r}, ' f'{self.ingredients!r})') def area(self): return self.circle_area(self.radius) ...
true
a4a9466ca29261aff4264cd4d2c565df7c19a0fa
AmitAps/advance-python
/dog-park-example.py
703
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 22 09:25:55 2020 @author: aps """ class Dog: species = "Canis familiaris" def __init__(self, name, age, breed): self.name = name self.age = age self.breed = breed # Another instance method def speak(se...
true
c977f10079c4c36333dfc1b33635945b2e469c29
Ayselin/python
/candy_store.py
1,014
4.125
4
candies = { 'gummy worms': 30, 'gum': 40, 'chocolate bars': 50, 'licorice': 60, 'lollipops': 20, } message = input("Enter the number of the option you want to check?: \n1. To check the stock. \n2. How many candies have you sold? \n3. Shipment of new stock.") if message == '1': for candy, ...
true
1788d7fb0349eebc05ab37f91754b18e6ce66b3f
SeshaSusmitha/Data-Structures-and-Algorithms-in-Python
/SelectionSort/selection-sort.py
423
4.3125
4
def insertionSort(array1,length): for i in range(0, length ): min_pos = i; for j in range(i+1, length): if array1[j] < array1[min_pos]: min_pos = j; temp = array1[i]; array1[i] = array1[min_pos]; array1[min_pos] = temp; array1 = [2, 7, 4, 1, 5, 3]; print "Array before Selection sort" print(array1);...
true
4b414735cbd1563ac59a6598279f7a4863723828
zaidITpro/PythonPrograms
/inseritonanddeletionlinklist.py
1,106
4.15625
4
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def insert(self,data): if(self.head==None): self.head=Node(data) else: current=self.head while(current.next!=None): current=current.next current.next=Node(data) d...
true
e2c32f8e48cb84d2c52db49f4559746ac7a56eae
petr-tik/lpthw
/ex30.py
779
4.15625
4
#-*- coding=utf-8 -*- people = 30 cars = 40 trucks = 15 if cars > people: print "We should take the cars." elif cars < people: print "We should not take the cars." else: print "we cannot decide" if trucks > cars: print "That's too many trucks" elif trucks < cars: print "maybe we could take the trucks" else: p...
true
92fee0692d9bfd860c4235c13ca639065c0bb7ee
petr-tik/lpthw
/ex4.py
1,281
4.25
4
# assign the variable 'cars' a value of 100 cars = 100 # assign the variable 'space_in_a_car' a floating point value of 4.0 space_in_a_car = 4 # assign the variable 'drivers' a value of 30 drivers = 30 # assign the variable 'passengers' a value of 90 passengers = 90 # assign the variable 'cars_not_driven' a value equal...
true
7e4d07ccaffd2671193f8d011a8c209e15a02552
plooney81/python-functions
/madlib_function.py
887
4.46875
4
# create a function that accepts two arguments: a name and a subject # the function should return a string with the name and subject inerpolated in # the function should have default arguments in case the user has ommitted inputs # define our function with default arguments of Pete and computer science for name and su...
true
b41ce62b8a50afdc1fb0fecb58bfe7de4c59d9cd
psukalka/morning_blues
/random_prob/spiral_matrix.py
2,073
4.4375
4
""" Date: 27/06/19 Program to fill (and optionally print) a matrix with numbers from 1 to n^2 in spiral form. Time taken: 24min Time complexity: O(n^2) *) Matrix formed with [[0]*n]*n will result in n copies of same list. Fill matrix elements individually instead. """ from utils.matrix import print_matrix def fill_s...
true
26a29fa5956b9ef81041c2d0496c26fd4eb0ad08
psukalka/morning_blues
/random_prob/matrix_transpose.py
1,037
4.4375
4
""" Given a matrix, rotate it right by 90 degrees in-place (ie with O(1) extra space) Date: 28/06/19 Time Complexity: O(n^2) Time taken: 30 min """ from utils.matrix import create_seq_matrix, print_matrix def transpose_matrix(mat): """ Rotate a matrix by 90 degrees to right. Ex: Original: 1 2...
true
54053e477ab116aa59c4a4e52bb3744d28fe56b8
storans/as91896-virtual-pet-ajvl2002
/exercise_pet.py
2,167
4.25
4
# checks if the number entered is between 1-5 or 1,3 or whatever has been stated # check int function def check_int(question, error, low, high): valid = False # while loop while valid == False: number = input("{}".format(question)) try: number = int(number) if low <=...
true
0dba230b503ad68b4fa1c6185a947637633ba7a6
SimonLundell/Udacity
/Intro to Self-Driving Cars/Bayes rule/numpy_examples.py
638
4.375
4
# but how would you print COLUMN 0? In numpy, this is easy import numpy as np np_grid = np.array([ [0, 1, 5], [1, 2, 6], [2, 3, 7], [3, 4, 8] ]) # The ':' usually means "*all values* print(np_grid[:,0]) # What if you wanted to change the shape of the array? # For example, we can turn the 2D grid fr...
true
2c55e90b57860b41171344fcc2d3d1a7e69968b1
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/NumberRelated/DivisbleBy3And5.py
522
4.3125
4
# Divisible by 3 and 5 # The problem # For a given number, find all the numbers smaller than the number. # Numbers should be divisible by 3 and also by 5. try: num = int(input("Enter a number : ")) counter = 0 for i in range(num): if i % 15 == 0: print(f"{i} is divisible by 3 and 5.") ...
true
66af1aa9f857197a90b5a52d0d7e83a5a56f1d35
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/Reverse/ReverseNumber.py
376
4.3125
4
# Reverse a number # The problem # Reverse a number. def reverse_number(num: int) -> int: reverse_num = 0 while num > 0: reverse_num = reverse_num * 10 + num % 10 num //= 10 return reverse_num try: n = int(input("Enter a number : ")) print(f"Reverse of {n} is {reverse_number(n)}")...
true
4a31afea4a442fef55f57d261d0f93298e056efd
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/PrimeNumber/AllPrimes.py
530
4.1875
4
# All Prime Numbers # the problem # Ask the user to enter a number. Then find all the primes up to that number. try: n, p = int(input("Enter a number : ")), 2 all_primes = [False, False] all_primes.extend([True] * (n - 1)) while p ** 2 <= n: if all_primes[p]: for i in range(p * 2, n...
true
e2f84b0a47c1b9c39d804cd95e53820c1e99c47e
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/EasyOnes/TemporaryVariables.py
745
4.5
4
# Swap two variables # The problem # Swap two variables. # # To swap two variables: the value of the first variable will become the value of the second variable. # On the other hand, the value of the second variable will become the value of the first variable. # # Hints # To swap two variables, you can use a temp varia...
true
bc0cdadda198a60507364154b43e3a9088605e08
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/LoopRelated/SecondSmallest.py
848
4.25
4
# Second smallest element # The problem # For a list, find the second smallest element in the list try: size = int(input("Enter the size of the array : ")) user_list = [] unique_ordered = [] if size <= 0: raise ValueError("Size of array must be a non-zero positive integer") if size > 1: ...
true
0bf8f3f1388fc54ef3956e91899841438aca7482
kanuos/solving-https-github.com-ProgrammingHero1-100-plus-python-coding-problems-with-solutions
/PrimeNumber/SmallestPrimeFactor.py
770
4.1875
4
# Smallest prime factor [premium] # The problem # Find the smallest prime factor for the given number. def is_prime(number): number = abs(number) if number == 0 or number == 1: return False for i in range(2, number): if number % i == 0: return False return True def all_fac...
true
7bcb73db98b3c593be479799b1c548e8d83bbfed
ParkerCS/ch18-19-exceptions-and-recursions-elizafischer
/recursion_problem_set.py
2,681
4.125
4
''' - Personal investment Create a single recursive function (or more if you wish), which can answer the first three questions below. For each question, make an appropriate call to the function. (5pts each) ''' #1. You have $10000 on a high interest credit card with an APR of 20.0% (calculated MONTHLY, so MPR is APR...
true
41b46b0cbd0b3b8e5a8be106469a82bcfa096b60
koakekuna/pyp-w1-gw-language-detector
/language_detector/main.py
933
4.34375
4
# -*- coding: utf-8 -*- """This is the entry point of the program.""" from languages import LANGUAGES def detect_language(text, languages=LANGUAGES): """Returns the detected language of given text.""" # create dictionary to store counters of words in a language # example --> counters = {"spanish": 29...
true
f70add96e7e82cf95f9f6a8df4f00a25b2a8f17d
ankity09/learn
/Python_The_Hard_Way_Codes/ex32.py
596
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 8 18:40:47 2019 @author: ankityadav """ the_count = [1,2,3,4,5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters' ] for number in the_count: print("This is count {}".format(number)) for fru...
true