blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
39030df71c4efec3896d340a879cd21d049f5c9e
nooraelina/school-work
/Object-oriented-programming/Other-exercises/testi.py
584
4.125
4
class Dices : ''' encapsulates attributes commonly used in dice games (pot and bet) and functions roll and check. Checking is done according to the rules of each game. ''' def __init__(self, number = 1, pot = 100, bet = 1 ) : ''' defines and initializes attributes ''' ...
true
cd654963698ee489af6c17d01f37132e9623d365
afmejia/Python-for-Everybody
/Course1/assignment2_5.py
351
4.1875
4
#Write a program which propmts the user for a Celsius temperature, convert the #temperature to Fahrenheit, and print out the converted temperature # Get input tempCelsius = input('Give a value in Celsius: ') # Convert to Fahrenheit tempFahr = float(tempCelsius) * (9.0 / 5.0) + 32 # Print out result print('In Fahrenh...
true
53a0d35725831abf4ad3e494d28f92705a0c0198
adityaveldi/simplepythonprograms
/venv/tuple.py
439
4.375
4
# tuple is the collection where the elements are ordered and unchangeable tuple=(1,2,3,4,5) print(tuple) print(type(tuple)) for x in tuple: print(x) # we can add two tuples just it concatinates tuple=tuple+tuple print(tuple) # we can know the length using len() print(len(tuple)) # count gives the number times given...
true
cf3f836e652a3def0b78ca18c0e905800e02237a
zorell11/python
/Tic-Tac-Toe/tictactoe-3x3.py
2,989
4.1875
4
BOARD = [['', '', ''], ['', '', ''], ['', '', '']] PLAYER_X = 'X' PLAYER_O = 'O' def print_rules(): print(''' =========================== Welcome to Tic Tac Toe GAME RULES: Each player can place one mark (or stone) per turn on the 3x3 grid The WINNER is who succeeds in placing three of their marks ...
true
11a2088fa30cc5dca79d8eac87fcb891639e79de
kraken19/data_structures_implemetation
/queues.py
677
4.25
4
#python2 cd ~/Documents/Personal/data_structures/data_structures_implementation/ from linked_list import * ##### Defining class queues class queue(singlylinkedlist): ### Initializing the queue def __init__(self): self.head = None self.tail = None ### Add key to the bottom of the queue def...
true
be43c2be6a368de1eb8f5c94bf008d36a3b421c9
satishf889/Data-Structures-Using-Python
/Graph/breadthFirstSearch.py
1,975
4.28125
4
from queue import Queue #Class for creating Adj Node for Graph class AdjNode: #Initialiser for AdjNode def __init__(self,name): self.vertice=name self.neighbour=[] #Class for creating and performing operation on Graph class Graph: #Initialiser for Graph def __init__(self,vertices): ...
true
ef4d79a63698c22601e6df0844674b3b55da7161
67owilliams/Pyhton
/ForBreak.py
237
4.1875
4
Value = input ("Type less than 6 characters: ") LetterNum = 1 for Letter in Value: print ("Letter", LetterNum, " is", Letter) LetterNum += 1 if LetterNum > 6: print ("The string is too long!") break
true
c6d7cb32d5e2d8886921a7544fab2e3fb1fdd968
RahulBantode/Python_Task_-OOPS-
/asgn_1/asgn_1_4.py
350
4.375
4
''' statement :- write a program which display "jay shree mahakal" string 5 times on screen''' def main(): #here we explicitly pass starting and ending point to the range function #last point is excluded so we want 5 times printing so we pass end point as 6 for i in range(1,6): print("{} . Jay Shree Mahaka...
true
f29171e06226a468ae191fc952003aa8c3a7fa03
RahulBantode/Python_Task_-OOPS-
/Inheritance/oop_2.py
1,191
4.1875
4
'''Demonstration static method,class method,instance method ''' class Student: School = "Lokmanya Vidyalay" #class variable def __init__(self,no1,no2,no3): #init method which works like constructor self.m1 = no1 #instance variable self.m2 = no2 self.m3 = no3 def InstanceTotal(self): #instan...
true
a506ef3ee2d7802cfb5e11a910a2814149609a15
RahulBantode/Python_Task_-OOPS-
/asgn_7/asgn_7_2.py
2,355
4.15625
4
'''Problem Statment : WAP which has one class with named as BankAccount. BankAccount class contains two instance variables as Name and Amount. That class contains one classs variable as ROI which initalise to 10.5 Inside the init method initialise all name and amount variables by accepting the values from user. The...
true
07359ed205861899464be2fb4ee9802748d31a7e
RahulBantode/Python_Task_-OOPS-
/general_assignments/asgn_string9.py
452
4.3125
4
'''People often forget closing parentheses when entering formulas. Write a program that asks the user to enter a formula and prints out whether the formula has the same number of opening and closing parentheses.''' string=input("Enter the Formula=") for ch in range(len(string)): if string[ch]!=')': print(s...
true
5f2e832361c1af996173fab0ab064ecd67ceeb89
RahulBantode/Python_Task_-OOPS-
/string/asgn_string12.py
336
4.28125
4
'''Write a program that asks the user to enter a string s and then converts s to lowercase, removes all the periods and commas from s, and prints the resulting string.''' string=input('Enter the String = ') print(string.lower(),end="\n") for ch in range(len(string)): if string[ch]!=',': print(string[ch...
true
ffb2d8ad2cae2c00edb82c7d5c9f08313d35b059
RahulBantode/Python_Task_-OOPS-
/general_assignments/SET_4/asgn8.py
539
4.5625
5
#set1 =10. Write a Python Program to print ASCII Value of a character #to find the ascii value of character #python gives built in function 'ord()' character=input("Enter the character =") print("The ASCII value of character",character,"=",ord(character)) #to find the character from ascii value #...
true
18d03ff1bbd790276f509ba63fa726f687b5d991
RahulBantode/Python_Task_-OOPS-
/dictonary/asgn_dict1.py
1,051
4.15625
4
'''Write a program that repeatedly asks the user to enter product names and prices. Store all of these in a dictionary whose keys are the product names and whose values are the prices. When the user is done entering products and prices, allow them to repeatedly enter a product name and print the corresponding price ...
true
14c2293922da338ada1ea64d74d1ad8e69fc0be1
BaptPicxDev/monte-carlo-pi
/main.py
1,512
4.53125
5
# -*- coding: utf-8 -*- ## Librairies import math import random from datetime import datetime ## Environment SQUARE_SIDE_LENGTH = 1 CIRCLE_DIAMETER = 1 CONFIGURATION = """ --------------------------------- This script, developped in python3, will try to aproximate the value of pi. In this example...
true
e24fed87a9a9f15056f8dd2e2d57f9d0709bda52
CodersInSeattle/InterviewProblems
/problems/graphs/reconstruct_itinerary.py
1,467
4.5
4
""" Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK. Note: If there are multiple valid itineraries, you should return the itinerary tha...
true
1bdc2f86719334f08d7afa6c4345cecb0c0d406f
CodersInSeattle/InterviewProblems
/problems/sorting/pancake_sort.py
815
4.25
4
""" Given an unsorted array, sort the given array using only a flip() operation: flip(arr, i): Reverse arr from 0 to i """ def flip(arr, i): # Implemented only for testing low, high = 0, i while low < high: arr[low], arr[high] = arr[high], arr[low] low += 1 high -= 1 def pancak...
true
745fb1cf3e31d9463900f36237f07496b3a04f4f
nareshkr22/gtu_python
/largest_odd.py
304
4.21875
4
#Print largest odd number from 10 entered numbers num_list = list() for i in range(1,11): num = int(input("Enter a number ")) num_list.append(num) largest = 0 for number in num_list: if number % 2 != 0 and number > largest: largest = number print largest
true
e1bd339f0cfac6ceb94894c9e704cb0c7645b7b1
nareshkr22/gtu_python
/tuple_info.py
1,069
4.125
4
#An interactive program which first asks user to enter basic information of at least 10 students and returns required information from information repository def add_data(): info_repo = list() for i in range(2): data = list() print("=======Student {0}=======".format(i+1)) enroll ...
true
56db54431ee8097d82ccb158495253d3546378dd
joses90/freecodecamp
/find-the-longest-word-in-a-string/find-the-longest word-in-a-string.py
378
4.25
4
def findLongestWordLength(string): leng = 0 word = '' lis = string.split() for w in lis: if len(w) > leng: leng = len(w) word = w return word, leng text = 'What is the average airspeed velocity of an unladen swallow' w,c = findLongestWordLength(text) print('\nThe lon...
true
48dbf75969c53561d8dd69744393411242a6f907
joses90/freecodecamp
/factorialize-a-number/factorialize-a-number.py
629
4.5625
5
def factorialize(num): if type(num) == int: # If number is 0 or 1, return 1 if (num == 0 or num == 1): sol = 1 # Else, the result should be the number times the number-1 # This function is recursive and calls itself for the previous number else: s...
true
a821a36e54df4c81ea71420a90b803144c557e8a
sasquatchchicken/get_prime
/prime_num.py
442
4.25
4
#!/usr/bin/env python3 import math import sys num = int(input("---/\/\ enter a number & check if it's prime: ")) def prime_check(b): if (b==2): return True elif ((b<2) or ((b%2)==0)): return False elif (b>2): for i in range(2,b): if not(b%i): return False return True check_num = prime_check(num) while...
true
57e379b5d04e796544eaf71797629b0c3485cdd6
willcodefortea/ProjectEuler
/pe/problems/026.py
1,115
4.21875
4
#!/usr/bin/python from pe.toolbox import is_prime def longest_cycle(n): ''' We only need to test primes as any other composite will have the same cycle length. We're searching for a Full Reptend Prime http://mathworld.wolfram.com/FullReptendPrime.html So we want to find the larges...
true
31878326ecf52d8541159768ccbdc366aeb379a1
Xaaris/Hauptprojekt
/src/utils/timer.py
1,262
4.25
4
"""Functions used to measure the execution time of a wrapped function""" from collections import Counter from functools import wraps from time import time from tabulate import tabulate number_of_calls = Counter() total_time_per_function = Counter() def timing(function_to_time): """ Annotation which can be u...
true
40c8db8bafa7ce8ff6198305c153f34ee545a3ad
PythonProgrammingPracticals/Prac05
/word_count.py
545
4.3125
4
#Exercise 3 - Counting occurences of words in a string def main (): word_dict = {} user_sentence = str(input("Enter a string of text here:")) user_words = user_sentence.split() for word in user_words: number_of_words = word_dict.get(word, 0) word_dict[word] = number_of_words + 1 ...
true
c110e3e32effa8ce69603879199cbfdcd2805c3f
sikander27/Techgig-python
/30 Days Coding Challenge/day9_narcissistic.py
1,034
4.28125
4
""" For this challenge, you will take an integer input and store it in a variable and checks whether the input number is a Narcissistic number or not. If it is, then print 'True' else print 'False'. ######################################################### Explanation First of all, what is a Narcissistic Number? An ...
true
b29dcbd8141cb5323c5aded6f5a7a7134d92adef
tospolkaw/CloanGit_PythonHealthcare
/py_files/0009_random_numbers_and_sequences.py
2,005
4.5
4
# coding: utf-8 # Here we look at the standard Python random number generator. It uses a <em>Mersenne Twister</em>, one of the mostly commonly-used random number generators. The generator can generate random integers, random sequences, and random numbers according to a number of different distributions. # ## Import...
true
fa22296dea94ca0eba0aa64975a12a10647c6919
tospolkaw/CloanGit_PythonHealthcare
/py_files/0058_chi_square.py
1,897
4.53125
5
# coding: utf-8 # # Chi-squared test # # See https://en.wikipedia.org/wiki/Chi-squared_test # # Without other qualification, 'chi-squared test' often is used as short for Pearson's chi-squared test. The chi-squared test is used to determine whether there is a significant difference between the expected frequencies ...
true
5db10b1c6fecc6c7feac65cd375c1d4708c7d0ce
tospolkaw/CloanGit_PythonHealthcare
/py_files/0011_loops.py
1,689
4.75
5
# coding: utf-8 # # Loops and iterating # <em>for</em> loops can be used to step through lists, tuples, and other 'iterable' objects. # # Iterating through a list: # In[2]: for item in [10,25,50,75,100]: print (item, item**2) # A for loop may be used to generate and loop through a sequence of numbers (not...
true
7c10b52d8911a0b7d33d79a391bc5641e5eae379
tospolkaw/CloanGit_PythonHealthcare
/py_files/0112_use_pandas_for_training_test_split.py
1,635
4.125
4
#!/usr/bin/env python # coding: utf-8 # # Splitting data set into training and test sets using Pandas DataFrames methods # # Note: this may also be performed using SciKit-Learn train_test_split method, but here we will use native Pandas methods. # # ## Create a DataFrame # In[1]: # Create pandas data frame impo...
true
6800f3d89dd11497814cdc5667704f728eb5367a
denizaral/Python-Calculate-Prime-Number
/CalculatePrimeNumber.py
251
4.21875
4
// Calculate Prime Number Example number = int(input("Enter number : ")) primeNumber = True for x in range(2,number): if (number % x) == 0: primeNumber = False break if primeNumber: print("PRIME") else: print("NOT PRIME")
true
0e8a944a020fc5bfb4a9c7671c994e62976547d0
cs-richardson/greedy-albs1010
/greedy.py
1,249
4.1875
4
#Albert ''' This function takes no parameters. It asks the user "how much change is owed" and retuns the minimum amount of coins needed. The function will re-prompt the user if a number less than 0 is entered ''' def calculate(change=None): #Asks for input(change that is owed) rounds the float to two decimal places....
true
59eb1b3fd44773bcaa5d969851fffdc59afec8bf
Anastasia-code/Summer-projects
/guessWord.py
1,786
4.3125
4
import random # A list of random words to guess later potential_words = ["computer", "program", "frame", "python", "programmer"] word = random.choice(potential_words) #random word chosen # Use to test your code: print(word) # Converts the word to lowercase word = word.lower() # Make it a list of lette...
true
e01ad1213de9ba42986455311b268223232ee957
dheerajk7/flask-app-practice
/using_sqlite/sqlite.py
626
4.125
4
import sqlite3 from sqlite3.dbapi2 import connect connection = sqlite3.connect('data.db') cursor = connection.cursor() create_table = "CREATE TABLE users(id int, username text, password text)" cursor.execute(create_table) # To insert one user user = (1, 'jose', '1234') insert_query = "INSERT INTO users VALUES(?, ?,...
true
3720505e6111323799ceecd0fbbaf6fe25b35361
lcx94/python_daily
/data_structure/2020-07/20200719/relative_sort_array.py
1,012
4.34375
4
# -*- coding:utf-8 _*- ''' @author: lcx @file: relative_sort_array.py @time: 2020/7/20 9:50 @desc: Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements th...
true
f2a1e93def6334331862ec9918464cfd338f8972
lcx94/python_daily
/data_structure/2020-04/20200418/reverse_vowels_of_string.py
1,269
4.625
5
# -*- coding: utf-8 -*- """ --------------------------------- File Name: reverse_vowels_of_string Description: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Author: Liu Changxin date: 2020/4/20 --------------------------------- Change A...
true
7967c95697e40aade020cd5378ea83e3c51ff20b
mostafaelmasry163/sprints-homework
/Python/S_PY_09.py
699
4.5625
5
# Ask the user to enter the radius of a circle in order to alert its calculated area and circumference. import math import tkinter from tkinter import messagebox # This code is to hide the main tkinter window root = tkinter.Tk() root.withdraw() def find_Circumference(radius): return 2 * math.pi * radius def ...
true
4a0f44c52784d0b9b864b416d6851f85aa3d8b4d
mhaythornthwaite/Python-Zero-to-Mastery-Course
/9_Error_Handling.py
2,322
4.4375
4
print(f'\n\n') print(' ---------------- START ---------------- ') # ----------------------------- ERROR HANDLING -------------------------------- #N.B./ ERRORS ARE CALLED EXCEPTIONS #allows us to handle the error within the programme so if one line of code is out in the thousands we dont get an error message as the ...
true
bef8047fc41a4c05cfac70cac4d9a6da2de0a72d
CodeTheCity/codethecity.github.io
/database_driver.py
1,456
4.125
4
import sqlite3 from sqlite3 import Error class database: def __init__(self, db_file): self.db_file = db_file def create_connection(self): """ create a database connection to a SQLite database """ self.conn = None try: self.conn = sqlite3.connect(self.db_file) ...
true
83556837349ff6f4d3c517f67b817e12550c5b3e
Sukanya-R-ITS/Practice_LC
/Valid Mountain Array.py
1,220
4.25
4
Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < A[i] arr[i] > arr[i + 1] > ... > arr[arr....
true
952c3fe73d47621b4da57a7cfd1a61ea3dc8ad5b
Ranadib/language_python
/factorial.py
246
4.34375
4
number = int(input("enter the number: ")) factorial = 1 if number < 0 : print("please enter a number positive:") else: for i in range(1,number+1): factorial = factorial * i print (f"the factorial of number: {factorial}")
true
8b63040584d4b961e8f5f7ab542092d7dfca6990
cnvallefuoco/Python_Lab3
/fortune.py
2,886
4.3125
4
# Describe the program to the user print ("Welcome!") print("") print ("\t This program is designed as a game that will tell you your fortune!") print("") # Prompt user for input data user_name = input ("Please enter your name: ") user_age_str = input ("Please enter your age: ") fav_color = input ("Please enter your f...
true
e1f4a4f0d80fb6cb22f932644a84398d247e73e3
SarikaRathi/NPTEL-Joy-of-Computing-Week-8-Solution
/week_8_programming_ass3.py
879
4.34375
4
# Week 8 Programming assignment 3 # Given an English sentence, check whether it is a pangram or not. A pangram is a sentence containing all 26 letters in the English alphabet # Input Format: # A single line of the input contains a string # Output Format: # Print Yes or No def checkPangram(s): List = [] # creat...
true
cc7546a878fffa2578f3986496620abb5c06f01e
hiteng/python_workspace
/practice_modules/divisor_num.py
454
4.15625
4
def divisor_check(): out_list = list() num = input("Enter the number : ") if num == 0: return "The number cannot be divisible by 0." else: for i in range(1, num+1): try: if num % i == 0: out_list.append(i) except ZeroDivis...
true
b4e0517a5a43b8c2c2d219f8c2274dd72cfebc14
ramsha275/PIAIC_Sir_Inam
/function.py
1,396
4.25
4
# def greet(): #function definition # print("Good morning") # greet() #function calling # print("I am outside the function ") # greet() # print("Completed") # # def my_pet(owner , pet , city = "Karachi"): # print(owner ," is an owner of ", pet , ".They are from ",city) # my_pet(pet = "Cat" , owner =...
true
5e9bda6e63d2cd250c14c17d33885cc7c25e8e79
gamezober/dsp
/python/q8_parsing.py
1,009
4.3125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to r...
true
2071b002242a3d744ed9554b7fc6639d07d029a1
MATTALUI/cs101
/w04-budget-inputs.py
837
4.1875
4
class BudgetItem: def __init__(self, name, monthly): self._name = name self._monthly = monthly def display(self): yearly_cost = self._monthly * 12 print(f"%s\t\t$%.2f\t\t$%.2f" % (self._name, self._monthly, yearly_cost)) expenses = [] collecting_expenses = True while collecting...
true
3f6c64e3d0856d3a3476c1a40a148089c1b69baa
MuberraKocak/data-structure-python
/CrashCourse/dfs.py
2,111
4.25
4
def dfs(root, target): if root is None: return None if root.val == target: return root # return non-null return value from the recursive calls left = dfs(root.left, target) if left is not None: return left # at this point, we know left is null, and right could be null o...
true
01d3e2cb9656fc04d0b9c89b4e1dbf9789ed6c72
MuberraKocak/data-structure-python
/ModifiedBinarySearch/binary_search.py
1,028
4.1875
4
def binary_search(arr,key): start,end = 0, len(arr) - 1 isAscending = arr[start] < arr[end] while start <= end: # calculate the middle of the current range mid = start + (end-start) // 2 if key == arr[mid]: return mid if isAscending: # ascending order ...
true
dfa726144335015702e98da8d074df949683de43
krototype/machine-learning-algorithms
/simple-reg/simple.py
2,440
4.3125
4
# -*- coding: utf-8 -*- """ IMPLEMENTATION OF SIMPLE LINEAR REGRESSION USING GRADIENT DESCENT this code is created by Abhinav Srivastava, just for the purpose of learning """ import pandas as pd import matplotlib.pyplot as plt import numpy as np #global variable alpha=0.01 #it computes the total error using any regr...
true
8f47721ede4ad5931e3c632bf44e858710ad6ec9
nouranali/Techy-CAT-Shops-
/np.py
1,382
4.21875
4
import numpy as np #Numpy is the core library for scientific computing in Python. # It provides a high-performance multidimensional array object, and tools for working with these arrays #The most popular data structure in numpy is ndarrays #unlike python lists # elements in ndarrays are of the same type, indexed by ...
true
c37313689c250945e6f4a587bab44bde96c747d7
partha123-byte/placement-practice-codes
/segmented array.py
796
4.1875
4
# Sort an array of 0s, 1s and 2s # Difficulty Level : Medium # Last Updated : 09 Apr, 2021 # Given an array A[] consisting 0s, 1s and 2s. The task is to write a function that sorts the given array. The functions should put all 0s first, then all 1s and all 2s in last. # Examples: # Input: {0, 1, 2, 0, 1, 2} # Outpu...
true
0fdb8acb328a7bd8e088b3bce12cf3b3d65b97f2
sumonkhan79/DataScience-Random
/numpy_exercise.py
1,059
4.4375
4
### GRADED ### Build a function called 'first_starting_vowel' ### ACCEPT a list of strings as input ### RETURN the first string that starts with a lowercase vowel ("a","e","i","o",or "u") ### HOWEVER if no string starts with vowel, RETURN the empty string ("") ### YOUR ANSWER BELOW def first_starting_vowel(string_li...
true
ff27da0b309062899dff59e621e60e32cac2ee44
RobbieJennings/Software-Engineering-LCA--Python
/BinaryTree.py
2,683
4.28125
4
from collections import OrderedDict class Node(): """A node used for populating a Binary Tree""" def __init__(self, key): """Form a Node Keyword arguments: Key -- the key attached to the Node""" self.key = key self.left = None self.right = None self.pa...
true
0a7ae7889c33c1efe2bd95d5564349987c92bd8b
jerodj15/SmallPythonProjects
/studentOb.py
976
4.21875
4
""" Intiail tutorial class student: def details(self,name,age): self.age = age self.name = name print("the name is {} and the age is {}".format(name,age)) def __init__(self): balance = 20.00 print("You are welcome") print("Balance is {}".format(balance)...
true
8db818f2b3f593301f6866cb0b2d1272cefb109c
ajitluhach/algorithms
/set_operations.py
592
4.15625
4
from collections import MutableSet class Set: def __lt__(self, other): """Return True if this set is a subset of other.""" if len(self) >= len(other): return False for e in other: if e not in self: return False return True def __or__(self, o...
true
8e11895ced804ac3994dc80cfcd45a046e2eddd6
mindful-ai/oracle
/amstar-03/day_04/argparse_ex/arg_02.py
788
4.25
4
import argparse parser = argparse.ArgumentParser() ''' The option is now more of a flag than something that requires a value. We even changed the name of the option to match that idea. Note that we now specify a new keyword, action, and give it the value "store_true". This means that, if the option is specified, ...
true
e8b4de7fc40fd5de1799d08db9650646056fbb4c
mindful-ai/oracle
/amstar-01/day03/examples/oop/special_methods.py
2,188
4.15625
4
from functools import total_ordering @total_ordering class Account: """A simple account class""" def __init__(self, owner, amount=0): """ This is the constructor that lets us create objects from this class """ self.owner = owner self.amount = amount ...
true
928ebcc69ba0ed5464547efc9f694dc375458516
mindful-ai/oracle
/amstar-01/day01/examples/sum_of_numbers.py
210
4.125
4
# Program to add two numbers # Input a = int(input('Enter a number: ')) b = int(input('Enter another number: ')) # Process # s = int(a) + int(b) s = a + b # Output print('The sum is: ', s)
true
4e654739c471ece5cecec80a763a26b49d217e6b
mindful-ai/oracle
/amstar-03/day_04/transcipts/trans_format.py
2,011
4.3125
4
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> a = 10 >>> s = "python" >>> f = 1.45 >>> print('Value: ', f) Value: 1.45 >>> print("The measurement was", f, " units") The measurement was 1....
true
bd6139b20c0e49f38719f9e209e2e14c1bd5716c
Tanuj-tj/Python
/HangMan_Game/main.py
1,408
4.15625
4
import random import hangman_words import hangman_art # Hangman Shapes imported from hangman_art.py file stages = hangman_art.stages # Word List imported from hangman_words.py file word_list = hangman_words.word_list # Hangman Logo imported from hangman_art.py file print(hangman_art.logo) choose_word =...
true
8b1f577c22b9a9587ab9053dc64b06d09af8042e
wenxuefeng3930/python_practice
/interview/program/program_str/test_include_char2.py
861
4.15625
4
#!/usr/bin/env python # encoding: utf-8 """ @author: cbr """ def is_all_char_included(l1, l2): l1 = sorted(l1) l2 = sorted(l2) a = 0 for b in range(0, len(l2)): while (a < len(l1)) and l1[a] < l2[b]: # 注意这两个表达式的顺序 a += 1 if a >= len(l1) or l1[a] > l2[b]: retur...
true
3f7dd821dbea3727b7d4a9585b05815d3fe1cfc7
leonardef/py_exercises
/q2.py
424
4.21875
4
# Write a program which can compute the factorial of a given numbers. # The results should be printed in a comma-separated sequence on a single line. # Suppose the following input is supplied to the program: 8 # Then, the output should be:40320 n = 8 i = 1 fat = 1 while i <= n: fat = fat * i i = i + 1 print(...
true
9ba984176696d7740c37b350c3dc49da3f737641
JohnJTrump/Python_Projects
/polymorphism.py
1,577
4.375
4
# # # Python: 3.9 # # Author: John Trump # # # Purpose: Create two clases that inherit from another class # 1. Each child will have two attributes # 2. Parent will have one method # 3. Both children will use polymorphism of parent # class Fruit: # Define ...
true
c5991d1c4015f0fa4a20c567b14f364155aeb750
VivekJadeja/CBCode
/0. Crash Course/StringCrashCourse.py
1,015
4.375
4
a = [[]] * 3 # "a" actually just has one inner list but referenced 3 times print(a) a[0].append("value") print(a) n = [[] for _ in range (3)] n[0].append("value") print(n) a = [1] print(a) n = a print(n) n[0] = 2 print(n) random_list = ["Joe", "Steve", "Ann", "Bnn"] sorted_list = sorted(random_list) # [1,2,3,4,5] p...
true
adc13f7ee53e97f8860fe77e35052b634ad9b7b7
FireAndYce/99proj
/pi.py
308
4.125
4
### Pi to the Nth digit import math while True: try: i = int(input("How many digits of pi would you like to see?")) except ValueError: print("that is not an integer") continue else: break print(str(math.pi)[0:(i+2)])
true
880e77500423299024072387afeec6eee528b17f
CatherineTrevor/api-practice
/api.py
2,267
4.1875
4
#Currency Converter - www.101computing.net/currency-converter/ import json, urllib.request #Request an API Key from https://free.currencyconverterapi.com/free-api-key API_Key = "api_key" #When requesting an API key, you will also be asked to verify your email. Please do so by following the instructions on the email yo...
true
3e39c4b6be9ca04215a01e46e3a85c60b636dea0
benhall847/Python-Exercises
/tipCalculator.py
970
4.125
4
def tipCalculator(): start = True try: bill = float(input("Total bill? : ")) except: print("Invalid input! Try again.") return tipCalculator() while start: service = str(input("Was the service good, fair, or bad? : ")).lower() if service == 'good': tip...
true
066b4961fec27beafd8f60a65f21a8022ed28fd7
digitalgroovy/py-loops
/nested_ex_2.py
263
4.1875
4
x = float (input('Enter a number for x: ')) y = float (input('Enter a number for y: ')) if x == y: print ('x and y are equal') if y != 0: print ('therefore, x/y is', x/y) elif x < y: print ('x is smaller') else: print ('y is smaller') print ("Thanks")
true
88af69ab5bfa3bbc56cc2e9f228db0c9b74eeec4
jaxtonw/Sp21-Julia-Demonstration
/src/bisection.py
1,733
4.15625
4
import math # Constants PI = math.pi def absErr(value, valueApprox): ''' The following code will compute the absolute error between value and valueApprox ''' val = value - valueApprox return abs(val) def bisectionMethod(function, lowerbound, upperbound, maxIter=100, tol=10e-10, returnIter=False):...
true
c708ad0b9f524bc757ac205bd9b4e7233011f76a
saurbhc/k-nearest_neighbors_algorithm
/calculate_k_nearest_neighbors.py
2,710
4.21875
4
import pandas as pd from calculate_euclidean_distance import EuclideanDistance def get_input(): help_text = """ Find Euclidean Distance between multiple n-dimension cartesian-coordinate(s) with given same-dimension cartesian-coordinate (note) Send your suggestion on Saurabh.Chopra.2021@live.rhul.ac.uk f...
true
8ae04d18ade6242e8a7a13a77559dbc6276c5c73
saad-abu-sami/Learn-Python-Programming
/basic learning py/string_0.py
1,257
4.21875
4
a = ' data science ' print(a[1]) #strings in Python are arrays of bytes representing unicode characters. print(a[2:5]) #font 0,1=d,a then t,a,space print(a[-7:-4]) #from end e,c,n,e, -4 then sci -7 print(len(a)) print(a.strip()) #no space on terminal [data science].The strip() method removes any whitespace from th...
true
476af194a68f4acf371a0ff19460e7f72bf0bfa8
grayjac/Test_Project
/cylinder.py
328
4.25
4
#!/usr/bin/env python # ME499-S20 Python Lab 0 Problem 2 # Programmer: Jacob Gray # Last Edit: 4/1/2020 from math import pi # Import pi from math library # Calculating the volume of a cylinder with radius r, height h r = 3 # Radius of cylinder h = 5 # Height of cylinder print((pi * r ** 2) * h) # Print volume ...
true
3271292dc297f49f56840ba11b21f19b3339986e
7blink/ProjectEuler
/Euler009.py
566
4.3125
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ import math def compute(): max = 1000 #create a loop within a loop within...
true
3f3c8f8d8abf68ace5139f9b0b8371bcde099ada
pieper-chris/practice
/Fundamentals/Searching/searching.py
1,569
4.25
4
# Basic search algorithms and their complexities # Linear search (ints) # pass in the element (int) to be found and an int list to search in (can be unsorted) # returns index of 1st-found element to match 'elt', returns -1 if DNE def linear_search(elt, lst): idx = 0 lst_size = len(lst) while((idx<lst_size)...
true
0f1d674a1e08bde99451aa919f2cbbb5a31d2c97
haoyuF996/AL-cs-homework-June-17-Monday-2019
/word count.py
2,273
4.15625
4
def extract_words_from_file(filename): '''Extract all words(split by space) in a .txt file and return a list of the words''' file = open(filename,'r') file_content = file.read() file.close() words = file_content.split() return words def find_element_binary(alist,item): '''Binary sear...
true
9deb690821b549cf6b02e82f603299dea1c68cee
ashishk123cliste/Text_to_speech
/Text_to_speech.py
2,644
4.15625
4
#03/02/2021 #wednesday #Following 3 modules you have to import in your system. from tkinter import * from gtts import gTTS from playsound import playsound window = Tk() #above line initiate the window. #window is the name of the window created in this project. #further all the happpening goingto occur in...
true
329cb31ee6423a0c2a5f20577381d51739f0b831
CannonStealth/Notes
/Python/start/operators.py
1,803
4.625
5
#There are different types of operators print (10 + 8) #Sum print (10 - 8) #Substraction print (10 * 8) #Multiplication print (10 / 8) #Division print (10 % 5) #Modulus print (10 ** 5) #Exponentation print (10 // 8) #Floor divisions """ == Equal x == y != Not equal x != y > Greater than x > y < Less than x < y >...
true
b8d9a96f3a3c15e81486e3d370ef16a746d964b3
CannonStealth/Notes
/Python/loops/break.py
303
4.28125
4
# we use break to stop a loop for item in ["balloons", "flowers", "sugar", "watermelons"]: if item != "sugar": print("We want sugar not " + item) else: print("Found the sugar") break # Output: """ We want sugar not balloons We want sugar not flowers Found the sugar """
true
45d2b0f7c5d741a5829d4885d9b214380da2b945
Daniel-Benson-Poe/Intro-Python-I
/src/02_datatypes.py
836
4.5
4
""" Python is a strongly-typed language under the hood, which means that the types of values matter, especially when we're trying to perform operations on them. Note that if you try running the following code without making any changes, you'll get a TypeError saying you can't perform an operation on a string and an in...
true
8d74ec5f1fad7bbdc02eb49747872d77fce4077c
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 01 - Basics/All answers.py
1,943
4.15625
4
#001 print name name = input("What is your name? ") print("Hello", name) #002 print first and last name firstname = input("What is your first name? ") surname = input("What is your surname? ") print("Hello", firstname, surname) #003 print joke using 1 line of code print("What do you call a bear with no teeth?\nA Gumm...
true
6a7b622bf3465e20f9dd6a9f24771eb83ad1e3cf
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 01 - Basics/008 Restaurant bill.py
212
4.21875
4
#008 Restaurant Bill price = int(input("What is the total value of the bill? ")) diners = int(input("How many diners are there? ")) print("Each person should pay ", price/diners, " towards the cost of the meal")
true
1d38b65285304de02dc281d027cc7ab2bd052fb3
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 09 - Tuples, Lists and Dictionaries/079 List of numbers.py
498
4.125
4
#079 List of numbers nums = [] for i in range(0,3): nums.append(int(input("Please enter a number to add to the list: "))) print(nums) while input("Would you like to add another number to the list? Yes/No: ").lower() != "no": nums.append(int(input("Please enter a number to add to the list: "))) print(n...
true
235cf883da3dd773918be64db29e2f79d77a50d9
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 03 - Strings/023 print section of string.py
383
4.125
4
#023 Print section of string rhyme = input("Please enter the first line of a nursery rhyme: ") rhymeLength = len(rhyme) print("You've entered", rhymeLength, "characters") num1 = int(input("Please enter a number that is less than " + str(rhymeLength) + ": ")) num2 = int(input("Please enter a number between " + str(num1...
true
51442e7366f8a3e71b1983cd41b609ad5593f26e
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 05 - For loops/038 Display each letter on separate line, repeat X times.py
253
4.125
4
#038 Display each letter on separate line, repeat X times name = input("What is your name? ") num = int(input("How many times shall I display the name? ")) for i in range(0, num): for k in range(0, len(name)): print(name[k])
true
233d21b66d4870ee3ed065fd9a69a0c40ac0be42
gerrycfchang/leetcode-python
/tree/level/largest_value_in_tree_row.py
1,446
4.21875
4
# 515. Find Largest Value in Each Tree Row # # You need to find the largest value in each row of a binary tree. # # Example: # Input: # # 1 # / \ # 3 2 # / \ \ # 5 3 9 # # Output: [1, 3, 9] # Definition for a binary tree node. import collections class TreeNode(o...
true
585e8eba9850d99ff0dff2df5da7baa31a253625
gerrycfchang/leetcode-python
/sum/sum_of_two_integers.py
607
4.15625
4
""" Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. """ class Solution(object): def getSum(self, a, b): """ :type a: int :type b: int :rtype: int """ while b != 0: ...
true
c40e914dabb1cff875817ba5d819831fdf862d6c
gerrycfchang/leetcode-python
/medium/rotate_image.py
1,050
4.1875
4
# 48. Rotate Image # # You are given an n x n 2D matrix representing an image. # # Rotate the image by 90 degrees (clockwise). # # Note: # You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. # DO NOT allocate another 2D matrix and do the rotation. # # Example 1: # #...
true
2fe371ea4c2ae4dfeba268e20d36d9b2ed8c30c7
gerrycfchang/leetcode-python
/easy/string_compression.py
2,168
4.15625
4
# 443. String Compression # # Given an array of characters, compress it in-place. # The length after compression must always be smaller than or equal to the original array. # Every element of the array should be a character (not int) of length 1. # After you are done modifying the input array in-place, return the new ...
true
532f8b61ef92562c5bcad102076c46f3935b7a6a
gerrycfchang/leetcode-python
/tree/min_abs_diff_in_binarytree.py
1,679
4.1875
4
# 530. Minimum Absolute Difference in BST # # refer to 783. Minimum Distance Between BST Nodes # Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. # # Example: # # Input: # # 1 # \ # 3 # / # 2 # # Output: # 1 # # Explanati...
true
eb620786f5bd650b45825c5e4ed3d7b5575527bb
gerrycfchang/leetcode-python
/google/power_of_three.py
1,010
4.25
4
""" Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? """ ### log3n = log10n / log103 class Solution(object): def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ if n == 0: ...
true
2808c0f2504c5c21ac8fb6abe7d7fa3c1cb71dba
laviniaclare/Toy-Problems
/num_to_string.py
949
4.34375
4
"""Write a function, num_to_string, which takes in an integer and returns a string representation of that integer with ',' at the appropriate groupings to indicate thousands places. >>> num_to_string(1234) '1,234' >>> num_to_string(10) '10' >>> num_to_string(999999) '999,999' """ def num_to_string(num): ou...
true
8a9cc6d7880b2803c12ea70bbefa5cdfc08640b6
vicsho997/NumpyPractice
/numpy_arrayDatatype.py
2,817
4.15625
4
import numpy as np """Data Types in Python strings - used to represent text data, the text is given under quote marks. eg. "ABCD" integer - used to represent integer numbers. eg. -1, -2, -3 float - used to represent real numbers. eg. 1.2, 42.42 boolean - used to represent True or False. complex - used to represen...
true
24af815b1d1288521ffe0eab3afff314a4084785
vicsho997/NumpyPractice
/numpy_arraySearchingSorted.py
1,586
4.65625
5
import numpy as np """Searching Sorted Arrays There is a method called searchsorted() which performs a binary search in the array, and returns the index where the specified value would be inserted to maintain the search order. The searchsorted() method is assumed to be used on sorted arrays. """ #Find the indexes...
true
c95fac35c392b4b6b07124916a0a0b1020c6adc9
Schachte/Python-Development-Projects
/functions_area_temperature_conversion_python.py
1,121
4.15625
4
#Compute area of a triangle def triangle_area(base, height): area = .5 * base * height return area base = raw_input("What is the base?") base = int(base) height = raw_input("What is the height?") height = int(height) a = triangle_area(base, height) print 'Area is ' + str(a) #Convert F to C #F = c * 9/5 + 32 #C...
true
0eb3b4286a4ae9bdcf87ab4000e1f61adfd54d79
tian142/P1.PaySplit
/main.py
1,403
4.25
4
# this script takes the user's inputs of meal price, tip paid, and the number of people splitting the meal to calculate the cost each individual has to pay # for commit 2nd commit # for 3rd commit # prompts the user to enter meal price: meal_price = int(input('Please enter the price of your meal: ')) # tax variable s...
true
8204d50fffdca9754d45867a0a7290771a1c1ef4
radovanbacovic/leetcode.test
/python_recursion/06_03/binary_tree_traversal.py
1,561
4.53125
5
""" Python Recursion Video Course Robin Andrews - https://compucademy.net/ """ class Node(object): def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def preorder_print(root, path=""): """Root->Left->Right""" if root: pat...
true
fa1e4fee51443d2e0fe6c76522fc372095b671b7
Crmille/Python-Projects
/guessNumber.py
1,294
4.28125
4
# -*- coding: utf-8 -*- """ GUESS THE NUMBER """ import random def main(intro=True): if intro == True: print(""" Welcome to Guess the Number! Here are the rules: 1. A number is randomly generated. 2. You guess the number. 3. If your guess is correct, ...
true
bf82def1b0a4bd29216a4b5b49cddd9d08216cde
chai1323/Data-Structures-and-Algorithms
/InterviewBit/Linked List/List Cycle.py
1,778
4.3125
4
# Node class class Node: # Function to initialise the node object def __init__(self, data): self.data = data # Assign data self.next = None # Initialize next as null # Linked List class contains a Node object class LinkedList: # Function to initialize head ...
true
18dc87341247a30b5877c972116d80ae2122986b
chai1323/Data-Structures-and-Algorithms
/LeetCode/String/Valid Parentheses.py
1,434
4.125
4
''' Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Example 1: Input: s = "()" Output: true Exa...
true