blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c48773934e07b51e8d8f85cd16281ade4e76e463
Wisetorsk/INF200-assignement-work
/EX05/myrand.py
1,592
4.125
4
# -*- coding: utf-8 -*- """ Two types of Number generators. """ __author__ = 'Marius Kristiansen' __email__ = 'mariukri@nmbu.no' class LCGRand(object): """ Pseudo-Random Number Generator (Prng) using LCG-algorithm to generate numbers """ def __init__(self, seed): """ Constructor...
true
29482cff7662538ddd879abfd864d4013dc9895d
nishantml/100-days-of-code
/matrix/diagonalSum.py
907
4.375
4
""" Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. Example 1: Input: mat = [[1,2,3], [4,5,6], [7,8,9]] Output:...
true
395760099db3a558c470193286eea5c35f79c8e3
RMarc96/OSU-Classes
/CS160/buoyancy2.py
1,744
4.40625
4
#"Buoyancy Program" lab 6 edit by Ronald Salinas CS160 def main(): end = False while not end: while True: try: r = float(input("What is the radius of your sphere? ")) except ValueError: print("Invalid input. Try again.") continue if r < 0: print("Cannot be negative. Try again.") continu...
true
41932ea10cbcbdcd7e29823fa5e99d59d53168de
Nikita-lys/Codewars
/6 kyu. Stop gninnipS My sdroW!.py
878
4.125
4
# https://www.codewars.com/kata/stop-gninnips-my-sdrow/ def spin_words(sentence): """ Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only let...
true
3d31be42090cc0a425ad11f791ff07328431066c
Nikita-lys/Codewars
/6 kyu. Valid Braces.py
1,810
4.65625
5
# https://www.codewars.com/kata/valid-braces/ def validBraces(string): """ Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if the string is valid, and false if it's invalid. This Kata is similar to the Valid Parentheses Kata, b...
true
8ef8127a7ae4ae8d2e8e965d76648d52397b2c29
supvenka/pythonSamples
/ExceptionHandlingSample.py
1,608
4.25
4
""" Exception Handling We must have a try followed by an except block or finally block Valid Try -except-else-finally Try-else-finally Try-except-else Try -else only (not valid) Try only else is optional """ def writeToFile(data): try: #fp = open("FileDoesNotExist.txt") fp = open("Py...
true
22226ff819c2ca0f2bb27d742241ed5cb2ae9c2d
supvenka/pythonSamples
/CommandLineArgsSample.py
1,023
4.5
4
""" Command Line Args: Where we are executing a script to which the command line arguments are passed. sys.args is a list that would retrieve the user provided inputs in the command line """ import sys import os print "No of arguments :", len(sys.argv) print " Arguments passed = ", sys.argv # Read file and...
true
e811d99b020b07743bb698f2dc70b0aa59d7c6de
supvenka/pythonSamples
/RaiseExceptionSample.py
461
4.28125
4
""" Raising an Exception : We can raise only inbuilt exception or user defined exception """ def add(a,b): if type(a) is int and type(b) is int: pass elif type(a) is str and type(b) is str: pass else: raise TypeError ("Either int and str") c = a + b print "Result...
true
0b183c651de84332ab008828bd92ad69be7f27b1
supvenka/pythonSamples
/caseStudy_loops_efficient.py
608
4.21875
4
print " --- More efficient when using not ----" for number in range (2,21): print "Number = " , number # flag = False remove this we donot need ths for divisor in range (2, number): if not number % divisor : #flag = True break else: print "number is...
true
a2b4c0a091b297aae652eba39798c08a7b9ef294
Timothy-py/100-PythonChallenges
/Q77.py
1,896
4.34375
4
# Given a sorted array of distinct integers and a target value, return the index if the target is found. # If not, return the index where it would be if it were inserted in order. # You must write an algorithm with O(log n) runtime complexity. def search_insert(nums, target): left, right = 0, len(nums) - 1 whi...
true
1288ad716174a36fd57068f8e720eece5ffb6e4c
Timothy-py/100-PythonChallenges
/Q32.py
358
4.25
4
from functools import lru_cache # Create a function to print the nth term of a fibonacci sequence using recursion, and # also use lru_cache to cache the result. @lru_cache(258) def fib(n): if n == 0: return 0 elif n == 1: return 1 elif n >= 2: return fib(n-1) + fib(n-2) for i in ...
true
66070ebc990552beab756c3b63b60d80747687e0
Timothy-py/100-PythonChallenges
/Q74.py
1,160
4.15625
4
from math import factorial # You are climbing a staircase. It takes n steps to reach the top. # Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? def climbStairs(n): res = 0 two = n//2 for i in range(two+1): t = i # number of twos ...
true
523f36c9083c1b70b2b207107a1c10e788c42d97
Timothy-py/100-PythonChallenges
/Q75.py
1,215
4.40625
4
# Given an integer numRows, return the first numRows of Pascal's triangle. # In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: # This solution first initializes an empty list called triangle to store the rows of the triangle. It then iterates through the rows, starting from th...
true
aa77447b51290270009cb4b25d7d490536feabaf
KaranPuro/File-Finder
/main.py
834
4.1875
4
import os # opening statement print("put file here") #inputs user input into program path = os.path.abspath(input()) size = 0 # folder path input print("Enter folder path") path = os.path.abspath('C:\Program Files\Common Files') # for storing size of each file size = 0 # for storing the size of the large...
true
fc266a0d009c775bd8e681ab0095052f1459ed29
31062/algerhythms
/stack_in_python.py
1,150
4.34375
4
class Stack: """a stack create as a class""" #constructor def __init__(self,max_size): # set attributes starting values self._items = 0 self._max_size = max_size self._stack_pointer = 0 self._stack_list = [] def is_empty(self): #find out it t...
true
18dd8fd607ee1ff5a261abca092703f460215757
viktor40/pi_leibniz
/calculate_pi.py
1,397
4.46875
4
# calculate_pi.py # MIT License # github.com/viktor40/HammerBotPython """ Calculate the value of π using the Leibniz formula for pi: https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80. This is a rather slow way to calculate π since the series converges slowly. This was mostly a personal exercise. ITERATIONS wil...
true
33e930b370dd07d9957a4946a3d32db1782ef39c
ErikPerez312/CS2-Tweet-Generator
/rearrange.py
791
4.25
4
"""Script will rearrange a list of words.""" import sys import random def rearrange(words): """Will rearrange and return list of WORDS.""" scrambled_list = list(words) words_length = len(words) # Code below taken from StackOverflow. Link below # https://stackoverflow.com/questions/17489477/shuffl...
true
251a8ad7fd7b4f6d295da1ba61e3ee6010fd17ab
venusdoom/py_tests
/test4/guess_game_hard.py
1,034
4.125
4
# Guess game, hard mode import random print("Hello, my dear friend. Lets try to play my game.") print("Try to guess randomly generated number in range of 1 to 100.") print("The game will tell you if the guessed number is correct, or") print("if the number is greater or lower than yours.") print("You have only 7 tries...
true
82dbd26192b4833d36bfcefad3b3b110ab783c99
venusdoom/py_tests
/test5/skill_points.py
2,801
4.28125
4
# skill points test print("You have 10 skill points.") print("You can assign and unassign them into 4 characteristics: strength, health, wisdom and agility.") skill_points = 10 characteristics = {"Strength": 0, "Health": 0, "Wisdom": 0, "Agility": 0} user_choice = None char_choice = None MENU_MAIN = """\nMain menu: -...
true
4040a45890925afb7370d53d05ab7af537ae2bb5
hejiang2/HackerRank
/10 Days of Statistics/Day 4 - Geometric Distribution I.py
962
4.125
4
# Negative Binomial Experiment # A negative binomial experiment is a statistical experiment that has the following properties: # 1. The experiment consists of n repeated trials. # 2. The trials are independent. # 3. The outcome of each trial is either success (s) or failure (f). # 4. P(s) is the same for every trial. #...
true
ce6af2b3d098ca6490f0d70a6eb44b0651b1dbef
hejiang2/HackerRank
/10 Days of Statistics/Day 7 - Pearson Correlation Coefficient I.py
1,024
4.125
4
# We use the following formula to calculate the Pearson correlation coefficient: # rho_{X,Y} = sum(xi - mu_x)(yi - mu_y)/(n*sigma_x*sigma_y) # list comprehension # [thing for thing in list_of_things] # List comprehension is an elegant way to define and create list in Python. # input().split(separator, maxsplit) n = ...
true
d4afee956c3992976c71bbe839a9410c5145bdab
Brooks-Willis/softdes
/chap04/polygon.py
1,483
4.3125
4
"""Created as a solution to an excersize in thinkpython by Allen Downey Written by Brooks Willis Creates a polygon with any number of sides of any length or an arc of set set radius and sweep angle """ from swampy.TurtleWorld import * from math import pi world = TurtleWorld() bob = Turtle() bob.delay = 0.01 def l...
true
a2e8ffb47a29f5750209bea1accdfa83a90cc3da
ashasatya/PyProject
/CodeclubProject/TurtleRace.py
1,494
4.1875
4
from turtle import * from random import randint import time # Speed the turtle module to draw faster from co-ordinates at (-140,140) speed(10) penup() goto(-140, 140) # Draw the vertical lines to create a track for step in range(15): write(step, align='center') right(90) for num in range(8): penu...
true
f2b61798ffe3030f6d56bc70616841965e85b44d
bhushankelkar/machinelearning-resources-ieee-apsit
/linear_regression/simple_linear_regression.py
1,846
4.25
4
# Simple Linear Regression # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd import math # Importing the dataset dataset = pd.read_csv('Salary_Data.csv')#has only 2 columns experience and salary(index 0 and 1) X = dataset.iloc[:, :-1].values #takes all column except la...
true
6fab4f412d8902ee23a9b9861bb0abdb3f418d32
gongqiong/CS61a
/Week1/hw01/hw01.py
1,849
4.1875
4
from operator import add, sub def a_plus_abs_b(a, b): """Return a+abs(b), but without calling abs. >>> a_plus_abs_b(2, 3) 5 >>> a_plus_abs_b(2, -3) 5 """ if b < 0: f = sub else: f = add return f(a, b) def two_of_three(a, b, c): """Return x*x + y*y, where x and y are the two largest members of the po...
true
a262d461814b9ae877f366dabaf2df9c552c8901
Anmolagarwal123/ROCK-PAPER-AND-SCISSOR-GAME
/rock,paper and scissor.py
1,107
4.34375
4
#ROCK PAPER AND SCISSOR GAME #WE HAVE TO IMPORT THE RANDOM FUNCTION BECAUSE COMPUTER IS CHOOSING A RANDOM NUMBER print("Let's play a rock,paper and scissor game with the computer!") import random player_action = input("Enter a choice (rock,paper,scissor):") possible_outcomes = ["Rock","Paper","Scissor"] compu...
true
17a9cf4ce05694b380120fe7d4d08547d2489df2
CiaranMoran27/Programming
/Week02/lab2.3.3-div.py
515
4.28125
4
# Program that read in two numbers and outputs the integer answer and the remainder # Author: Ciaran Moran #input read in a string which is converting to type(int) to allow a mathematical operation x = int(input('Enter First Number: ')) y = int(input('Enter Number you want to divide by: ')) # // operator performs di...
true
23671e8aa7b2722bd6ff7455df960b6ddad76900
CiaranMoran27/Programming
/Week04-flow/lab4.2.4-extra.py
591
4.1875
4
# This Program continues to prompts the user to guess a random number between 0 to 100, until the guess is correct # Author: Ciaran Moran import random # assign random number between 1 to 100 to the variable numberToGuess = random.randint(0,100) guess = int(input("Please guess the number:")) #use of Sentinal control...
true
c52de2172dcf16bf4a9979f74a3226a440f933cd
CiaranMoran27/Programming
/Week04-flow/Week_04_Weekly_Task/collatz.py
1,729
4.3125
4
# collatz.py # The program asks the user for a positive integer and outputs successive values # based on if the input number is odd or even. The progam ends if 1 is entered. # Author: Ciaran Moran number = input("Enter a number: ") while True: try: numberInt = int(number) # try convert number variable t...
true
cef587964cd0a2d34830de2b3301b9afc2e48c65
brendanreardon/hackerrank
/tutorials/30 days of code/03-conditional_statements.py
750
4.5625
5
""" Objective In this challenge, we're getting started with conditional statements. Check out the Tutorial tab for learning materials and an instructional video! Task Given an integer, , perform the following conditional actions: - If is odd, print Weird - If is even and in the inclusive range of to , print Not We...
true
1ce1846cfb90d600c65e5dc2e9e8bdf6a69eacdd
Xuan4dream/Leetcode
/381-H. Insert Delete GetRandom O(1) - Duplicates allowed.py
1,712
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: # 04132021 First try referring to the solution import random class RandomizedCollection(object): def __init__(self): """ Initialize your data structure here. """ self.lst = [] self.idx = defaultdict(set) def inse...
true
f77b16db04e13946397132016099278fb205b7b3
Pranavi-Duvva/Stanford-University-Code-in-place-2021
/NIMIM_extension.py
1,695
4.40625
4
def main(): """" AI Game of NIMM Python program that reads in a number from the user and then displays the Hailstone sequence for that number. Task: Ask the user input for a positive integer and call it number. If number is even, divide it by two. If number i...
true
54b11bc405303af84e25b85cc1134b7ee9ebce4e
chandu17297/python3
/practice3.py
908
4.21875
4
#print english alphabets import string for letter in string.ascii_uppercase: print(letter) #print 1 to 10 numbers for i in range (1,11): print(i) #Create a function that calculates acceleration given initial velocity v1, #final velocity v2, start time t1, and end time t2. #The formula for accel...
true
8813a23f076a67cd64b9e2c90358952775f395fb
chandu17297/python3
/wordcharcount.py
276
4.1875
4
name="my name is chandra shekar" words=name.split() #split function returns the words from string name print(name.split()) noofwords=len(words) print("No of words in a string:",noofwords) for i in range(noofwords): print("no of char in word",[i+1],"is :",len(words[i]))
true
bd59edf68ea466ba4b66696330983b4d9a845804
samscislowicz/holbertonschool-higher_level_programming
/0x06-python-test_driven_development/3-say_my_name.py
518
4.5
4
#!/usr/bin/python3 """ This is the say_my_name module. This is to print out the first and last names that is typed in. """ def say_my_name(first_name, last_name=""): """ Prints 2 strings as first and last name. first_name and last_name must be strings. """ if isinstance(first_name) != str: ra...
true
e17fddbfd3df3950cd2545d6d96879fc88ada946
philipcraig/Scratchpad
/Hwk1/Hwk1/Hwk1.py
1,132
4.25
4
import time # we need this for the sleep statement below # input the limit and convert it to an integer limit = int(input("What number shall I square up until? ")) # loop from 1 until limit, including limit itself for i in range(1, limit+1): print(i, "squared is", i * i) # input the number of the times-table ...
true
732603e491f551a6d5c9a36165adc6eec7d66441
ajonzy/text_game
/rooms/cabin.py
527
4.15625
4
def cabin(): print("You are in a small cabin. There is a fire going in the fireplace, and a staircase in the corner.\n\nDo you stoke the fire? (f)\nDo you go up the stairs? (u)\nDo you go outside? (o)\n") choice = input().lower() while True: if choice == "f": return "fire" elif c...
true
6e713950b64d834621429de4612e17ad9d3b2026
anbet/99-Prolog-Problems
/ex25.py
856
4.25
4
def break_words(stuff): """This function will break words for us""" words= stuff.split(' ') return words def sort_words(words): """sorts words for us""" return sorted(words) def print_first_word(words): """Prints the first word""" word = words.pop(0) print word def print_last_word(words): """prints the las...
true
2950c57a1c308bdde3a761b22cce7df73a648f2e
Sujankhyaju/IW_PythonAssignment1
/datatype/30.py
285
4.3125
4
# Write a Python script to check whether a given key already exists in a dictionary. sample_dict = { x:x**2 for x in range(1,5)} print(sample_dict) input_key = int(input("Enter any key")) if input_key in sample_dict.keys(): print("Already present") else: print("Key Missing")
true
8866d97a5d7528dd23ff51b82f3fe1d66fbe0b8c
Sujankhyaju/IW_PythonAssignment1
/datatype/3.py
377
4.40625
4
# 3. Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself. input_string = input("Enter a string::") input_string = input_string.lower() first_character = input_string[0] output_string = first_character + input_string[...
true
b2fca18ac479c27157d99eff5f535df3b15ea2ef
Sujankhyaju/IW_PythonAssignment1
/datatype/11.py
283
4.125
4
# 11. Write a Python program to count the occurrences of each word in a given # sentence. input_string = input("Enter a sentence") input_string = input_string.split() output = {} for i in input_string: count = input_string.count(i) output.update({i:count}) print(output)
true
045616b479f10e67fceb96a4f5040273980bfa25
Sujankhyaju/IW_PythonAssignment1
/datatype/2.py
457
4.28125
4
# 2. Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string. input_string = input("Enter a string") # output_string ="" if len(input_string)>=2: output_string= input_string[:2] + input_string[-2:...
true
f66310c068aa7d42ec06b5b38c88cce5f5b7a52d
kzh980999074/my_leetcode
/src/Array/89. Gray Code.py
686
4.25
4
''' The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. Example 1: Input: 2 Output: [0,1,3,2] Explanation: 00 - 0 01 - 1 11...
true
7ca1ebb8584befd1bdd48fe125aa2640f32e5347
kzh980999074/my_leetcode
/src/string/20. Valid Parentheses.py
884
4.15625
4
''' Given a string 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. Note that an empty string is also considered valid...
true
b9ce04729fb8e7e09d209c4dbc20768051c7cd52
inampaki/python-teaching-lists-practice
/comparision operators.py
310
4.125
4
name = input("Entyer the name") gender = input("Entyer the gender") age = int(input("Enter the age")) if(age < 20 and gender == 'Male'): print(name," Please sit in first 2 rwos ") elif(age >= 20 and gender == 'Male'): print(name," Seat in the middle 3 rows") else: print("Please sit in last rows!")
true
ccb7dff1c7e4129d490e707db52afc74271ae5a7
PirateHunterZoro/Assignment1
/Assignment1/5.py
207
4.4375
4
""" To swap value of two variables without using third variable """ x,y=int(input()),int(input()) print("Before swap x, y are {}, {}".format(x,y)) x,y=y,x print("Before swap x, y are {}, {}".format(x,y))
true
a98528b07f50ec7a82196dd1ad1aeaa46cdc8509
D4YonSoundcloud/python-basics
/basics/dictonaries.py
852
4.15625
4
# A dictionary is a collection which is unordered # changeable and indexed. # no Duplicate members # Create dict person = { 'first_name': 'John', 'last_name': 'Doe', 'age': 47, } # constructor # person2 = dict(first_name='Sara', last_name="Williams") # get a value print(person['first_name']) print(person...
true
6ea70f1ef20d5e9d51ea24a59ff16b07109028d5
candytale55/A_day_in_the_supermarket_Py_2
/1_03_Control_Flow_n_Looping.py
355
4.3125
4
# Python 2 # loop through each item in the list called a, if the number is even, print it out. If the item % 2 == 0. a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] for item in a: if item % 2 == 0: print item # Prints: """ 0 2 4 6 8 10 12 """ # REF: https://discuss.codecademy.com/t/why-does-my-code-not-...
true
3301e874719ab8faee9220d1be198e4fd86de1fe
AnilPokuri/Python---Assignment1
/Eg12.py
368
4.28125
4
""" 12. Write a program find all even number from the given input list and display output as a list format. """ Input_List = [] Output_List = [] for val in range(10): val = int(raw_input("Enter an Integer: ")) Input_List.append(val) print Input_List for num in Input_List: if num%2 == 0: ...
true
14d98922488d790d96c0c42a1212fd99188ccdb1
gayathrimahalingam/interview_code
/check_if_btree_is_balanced.py
1,506
4.21875
4
# implement a function to check if a binary tree is balanced. # a tree is balanced if the heights of the two subtrees of any node never differ by more than one # Solution recursively compute the heights of subtrees of each node import os import sys from binary_tree import BTree, createMinimalBST # not so efficient ...
true
54f445aa7e296c81a4648c52114c70986af6248e
gayathrimahalingam/interview_code
/linked_list_of_nodes_at_each_level_of_binary_tree.py
1,860
4.1875
4
# Given a binary tree, design an algorithm which creates a linked list of all nodes at each depth # solution: a modified pre-order traversal passing depth information # also a modified breadt first search works # add root to linked list, then traverse each element in this linked list and create a new list # write a ...
true
917164247d1571fd8976dda5c5f9d0bf19df5073
gayathrimahalingam/interview_code
/sort_an_array_so_that_anagrams_are_together.py
809
4.25
4
### Write a method to sort an array of strings so that the anagrams are together import os # Time Complexity: Let there be N words and each word has maximum M characters. # The upper bound is O(NMLogM + MNLogN). def sortForAnagrams(arr): hashmap = {} for i in range(len(arr)): # convert to char arr...
true
7b824309bcd3d0dd3702a2a350d641d8eb6fc960
mueller14003/CS241
/TA07.py
2,079
4.125
4
from abc import ABC, abstractmethod class Employee(ABC): def __init__(self, name=""): self.name = name self.type = "" self.amount = 0 super().__init__() @abstractmethod def get_paycheck(self): pass # More intuitive... I like this better than how the assignmen...
true
14304dbd223ed3afade421723e1098d658fee5e3
mpande98/Artificial-Intelligence
/Project #3/problem1.py
1,880
4.125
4
# Implement PLA foir linearly separable dataset # Takes a csv of input data and location of output # Run code as python3 problem1 input1.csv output1.csv # Weights in last line of output csv define decision boundary for given dataset # Weights are the slope of the decision boundary from visualize import * import pa...
true
22f5e407e2c04e24755d12e83c0052f8b2fbd3a3
Komal01/coderbyte-solutions
/time_convert.py
368
4.1875
4
#Have the function TimeConvert(num) take the num parameter being passed #and return the number of hours and minutes the parameter converts to #(ie. if num = 63 then the output should be 1:3). Separate the number #of hours and minutes with a colon." def TimeConvert(num): x= num/60 y= num%60 return "{}:{}"....
true
7a7dc1b49f682e3a1bce9c936bd7b4f63d3388d1
mochisoft/Assignments
/StandardDeviation.py
2,169
4.125
4
import random import math import numpy as np import matplotlib from matplotlib import pyplot as plt """ Class Assignment 2: 1. Generate Temperature values for a year 2. Calculate the standard deviation. 3. Generate scatter plots showing standards deviation for each month """ def get_month_days(x): max_days= {'Jan...
true
2f22f73e3629756c66866bc8c8a245bf1705da7f
alishagoyal01/NumberGuessing
/numberguessing.py
1,418
4.21875
4
import random player_name=input("Please enter your name") rnum=random.randint(1,10); count=0 flag=0 score=0 while count<3: gnum=int(input("Hello! "+ player_name+ " Please enter the number you guessed between 1 to 10\n")) print(rnum) if rnum==gnum: count=count+1; flag=1; if c...
true
914efc96d06808df0755c5baf550f60935aae4f7
TheCornelius/SQL-Insert-Statement-Converter
/SQL-Insert-Statement-Converter/SQL_InsertValue.py
2,420
4.125
4
# This program was written during Lab 6 of Database Fundamentals - to convert the records of different tables inside the tutorial document to SQL INSERT commands # Variables in this program are in the global scope, which will be accessed from the different functions that are defined # These lists uses these indexes to...
true
256073e816f91bcd37993c68dcc6dc7bbcfe53c5
gagangulyani/ProjectEulerChallenge
/Problem 1/solution_optimized.py
944
4.375
4
""" This program calculates and displays the sum of the multiples of 3 or 5 below 1000. """ def SumOfMultiples(number, range_=1000): """ This function takes in number and range_ and returns sum of multiples of the number below range_ using Finite Arithmetic Progression D...
true
b3418cbda482b1cb017a85cff5d330d148271de4
Mat4wrk/Regular-Expressions-in-Python-Datacamp
/4.Advanced Regular Expression Concepts/Reeepeated characters.py
487
4.125
4
# Complete the regex to match an elongated word regex_elongated = r"\w*(\w)\1\w*" for tweet in sentiment_analysis: # Find if there is a match in each tweet match_elongated = re.search(regex_elongated, tweet) if match_elongated: # Assign the captured group zero elongated_word = match_elongated.group(0) ...
true
07023d509ba4d910652b06d2914cb2adeb942dfd
ms0695861/Hey
/tmp_convert.py
238
4.28125
4
#Temperature Conversion #Let user enter the "Celsius" #And print to "Fahrenheit" temp_c = input('Please enter the Celsius: ') temp_c = float(temp_c) #str convert to float temp_f = (9 / 5 * temp_c) + 32 print('Fahrenheit is: ', temp_f)
true
73a231f0073720d4496ecfc1efc879597c693f8b
takafumihoriuchi/hydla_project
/simulation_python/references/intro-python-code/turtle_functions.py
1,457
4.65625
5
# KidsCanCode - Intro to Programming # Functions example using turtles - draw random shapes import turtle import random fred = turtle.Pen() colors = ["red", "green", "blue"] fred.speed(20) # Define how to draw a square def square(length): for i in range(4): fred.forward(length) fred.left(90) # De...
true
620ba4a4ee64aae200627a8b4a560ca5a4e94646
CodeWithDhruva/mywebsite.github.io
/main.py
1,321
4.25
4
print("Welcome to Multi- Purpose Python projects") print("If you Want to Calculate enter 1, If you Want to Check if you are eligible for for driving and voting enter 2,:\n") opt = input("Please enter your options:\n") opt = int(opt) if opt == 1: print("Welcome TO the calculator. Please Enter the numbers") num...
true
21d8a304d7ace7f6e1d9d23a05ca5b306bc7967b
Artifishul/LPTHW
/ex6.py
960
4.5
4
# craetes a variable and uses formatters to insert the number 10 x = "There are %d types of people." % 10 # assigns a string to a variable binary = "binary" # assigns a s tring to a variable do_not = "don't" # assigns a string to a variable that has two formatters referencing two variables y = "Those who know %s and t...
true
2a45b871e4b5b51f3db084096abcdcb9c6ac6c73
wiserdor/ExchangeRates
/ExchangeRates/ert.py
1,980
4.1875
4
""" Name: Dor Wiser program get date input from user and prints the exchange rates for that date in a tabular form """ import exrates as ex import sys # There are some currencies that give an encoding error (ie. São Tomé and Príncipe Dobra), i used this function to prevent errors def uprint(*objects, sep=' '...
true
ba36a053c579187e1669e8b1568ce000ea75704b
linabiel/day_2_lab
/start_point/exercise_a_stops.py
978
4.375
4
stops = ["Croy", "Cumbernauld", "Falkirk High", "Linlithgow", "Livingston", "Haymarket"] # 1. Add "Edinburgh Waverley" to the end of the list # 2. Add "Glasgow Queen St" to the start of the list # 3. Add "Polmont" at the appropriate point (between "Falkirk High" and "Linlithgow") # 4. Print out the index posi...
true
d0adbb8f72a11aeda2534272f3a375dfd413481b
gautamgitspace/iGeek
/Python Advanced Topics/map.py
933
4.4375
4
#!/usr/bin/env python """ using map and reduce: map and reduce both take an function and iterable function will operate on elements of the iterable """ from functools import reduce def pow_of_two(n): return 2**n nums = [0,1,2,3,4,5] res = map(pow_of_two, nums) print res # same stuff can be done using lambdas r...
true
2fb2782ea3470028476aa5d2cea97c021af04545
chris510/Coding-Problems
/python/linked_lists/876_middlelinkedlist.py
1,068
4.125
4
# Given a non-empty, singly linked list with head node head, return a middle node of linked list. # If there are two middle nodes, return the second middle node. # Example 1: # Input: [1,2,3,4,5] # Output: Node 3 from this list (Serialization: [3,4,5]) # The returned node has value 3. (The judge's serialization ...
true
0e6ca2f71bc4d9255055e4f1a95c402b525dff77
chris510/Coding-Problems
/python/trees/226_invertbinarytree.py
1,193
4.1875
4
# Invert a binary tree. # Example: # Input: # 4 # / \ # 2 7 # / \ / \ # 1 3 6 9 # Output: # 4 # / \ # 7 2 # / \ / \ # 9 6 3 1 # Trivia: # This problem was inspired by this original tweet by Max Howell: # Google: 90% of our engineers use the software you wrote (Homebrew...
true
448351c94069d6f9b6e60bdc53d3d6d84daf715e
chris510/Coding-Problems
/python/linked_lists/206_reverselinkedlist.py
757
4.3125
4
# Reverse a singly linked list. # Example: # Input: 1->2->3->4->5->NULL # Output: 5->4->3->2->1->NULL # Follow up: # A linked list can be reversed either iteratively or recursively. Could you implement both? # class Solution: # def reverseList(self, head: ListNode) -> ListNode: # if head is None or head.n...
true
869c6e8911f85a42a9897ac5e068c749c84ca963
humayun-rashid/python-problems
/Assignment-1/extra.py
732
4.4375
4
""" Program generates three random numbers and stores them into three variables, n1, n2 and n3. Finish the program by outputting the middle one of the numbers. For example, if the values are 11, 22 an 7, you should output 11. Do not not output anything else but the number! """ # Import random library import random ...
true
c36150cfd63ea71345deba9744afef00ccc7bc09
humayun-rashid/python-problems
/Assignment-1/task-3.py
1,189
4.3125
4
""" Task 3. Write a program that queries the user for three numbers and outputs the smallest of them. Example run: Give the first number: 11 Give the second number: 4 Give the last number: 7 Smallest number is: 4 Make sure it works with all the following numbers (given in this order, one line per program run): 1,2,3 3,...
true
c99516cc1fb9c119806629d5de7783aa90f05ff3
humayun-rashid/python-problems
/Assignment-1/task-6.py
2,124
4.1875
4
""" Task 6. (Double points!) Write a program that queries a number. The problem is that you don’t know what kind of number it is. User might enter any of the following: 123 # a valid Integer 156.23 # a valid float 5.22.3 # invalid float (too many points) abcd # not a number Your task is to: 1. Check if the value is a v...
true
c48afa801b4b179374ca9bcacdfdc66eabb520d6
kushagra-18/codewayy_python_series
/Python-Task2/sets.py
663
4.1875
4
s#Sets #intialising sets panSet = {"COVID-19", "Spanish FLu", "Ebola"} print(panSet) #Accesing sets through loops for x in panSet: print(x) #Adding item using add fucntion panSet.add("Polio") print(panSet) #Adding multiple items using update fucntion panSet.update(["Polio","AIDS"]) print(panSe...
true
b51981567dcae3e073fb3a3e1bd579bf520754d9
imiekus/python-training
/Boolean and conditional logic/driving_license.py
327
4.28125
4
age = input("How old are you: ") if age: age = int(age) if age >= 16 and age < 18: print("You can have driving license but need to drive with your parent") elif age >= 18: print("You can drive") else: print("You can't drive, you're too young!") else: print("Please enter your...
true
a115e9397aa05edc813416ccabd91f92ff74718f
Juma13701/Homework1python
/main.py
2,876
4.1875
4
# Author: Juma Al-Maskari jpa5637@psu.edu course1 = input("Enter your course 1 letter grade:") credit1 = float(input(" Enter your course 1 credit:")) gradepoint1=0.0 if course1 == "A": print(F" Grade point for course 1 is: 4.0") gradepoint1+=4 elif course1 == "A-": print(f" Grade point for course 1 is: 3.67") g...
true
520067f210d74005e2806d1419cac2c537be18b4
JeffLawrence1/Python-Basics
/dictbasics.py
1,023
4.65625
5
# Assignment: Making and Reading from Dictionaries # Create a dictionary containing some information about yourself. The keys should include name, age, country of birth, favorite language. # Write a function that will print something like the following as it executes: # My name is Anna # My age is 101 # My country of...
true
71393d4c249398fb4cd8e4b1d135192ab6b2e425
mpHarm88/lambdata
/lambdata_mpharm88/date.py
1,267
4.15625
4
""" This is a function for taking a date column and using pandas to transform it into 5 new columns: pandas date time column including day, month, and year dedicated day column dedicated month column dedicated year column dedicated season column - {3,4,5:spring, 6,7,8:summer, 9,10,11:autumn, 12,1,...
true
4de0a12a4b34a460417f20ee03c651fe21f81431
Sanyam07/AutoML
/Pipeline/Learner/Models/Callbacks/abstractCallback.py
1,187
4.1875
4
from ..abstractModel import AbstractModel from abc import abstractmethod, ABC class AbstractCallback(ABC): """ Defines how a callback should behave like. A callback has a model and a frequency of calling. """ def __init__(self, lambda_function=None): """ Initializes an...
true
c66522ce34f4d510ac9d17297d0977fc17af680a
tong-gong/ICS3U-Unit4-07-Python
/homework.py
401
4.15625
4
#!/usr/bin/env python3 # Created by Tong Gong # Created time December 2020 # This is a Nested Loops program. def main(): # This is the function to run Nested Loops. counter = 0 # Process & output for counter in range(1000, 2001): print(counter, end = " ") counter + 1 if coun...
true
a2c75d9524871377be9d409b6c83fdc957b1de94
aj-romero/python_exercites
/reverse_full_name.py
232
4.5625
5
name = input('Please, set the name: ') lastname = input('Please, set the last name: ') fullname = name + ' ' + lastname reverse_name = fullname[::-1] print('The fullname is: ',fullname) print('the reverse name is:', reverse_name)
true
70de2b7b6414c424e6f2f219bfa6d5200b1b63db
alimmolov13/Pobinhood_Project
/K_Nearest.py
1,898
4.34375
4
import math def classifyAPoint(points, p, k=3): ''' This function finds the classification of p using k nearest neighbor algorithm. It assumes only two groups and returns 0 if p belongs to group 0, else 1 (belongs to group 1). Parameters - points: Dictionary of training point...
true
91a66cbc144c5ed60bf7c23ac5c68817fa8f02e5
Keerti-Gautam/PythonLearning
/Collection-Of-Useful-Datatypes/Sets.py
1,573
4.46875
4
# Sets store sets (which are like lists but can contain no duplicates) empty_set = set() # Initialize a "set()" with a bunch of values some_set = set([1, 2, 2, 3, 4]) # some_set is now set([1, 2, 3, 4]) print some_set print "Set cannot have duplicates!!" # order is not guaranteed, even though it may sometimes look s...
true
873c42eadb33240d80871af80658c02c5635b35c
Keerti-Gautam/PythonLearning
/Classes/Methods/UsageOfPropertyMethod.py
2,530
4.4375
4
# We subclass from object to get a class. class Human(object): # A class attribute. It is shared by all instances of this class species = "H. sapiens" # Basic initializer, this is called when this class is instantiated. # Note that the double leading and trailing underscores denote objects # or att...
true
e7911ecb4e04e4728018acc5b7f7c1e5a7b9c3ca
iftiaj/AssignmentOneCalculator
/assignment part 1 calculator.py
1,674
4.40625
4
print("-----------------------------\n" "------assignment part 1------\n" "-----------------------------\n") print("A simple calculator that perform arithmatic operations regardless of their index position.") option=input("Enter an arithmetic operation:") # step 1 : Ask user to enter input print(option) o...
true
a674e901382b4a49182b3b992e81f066ee0eead2
tanaydin/stuff
/prime.py
382
4.1875
4
from math import sqrt primes = [2] def is_prime(n): if n in primes: return True i = 2 sqrt_n = round(sqrt(n)) while i <= sqrt_n: if is_prime(i) and n % i == 0: return False i += 1 primes.append(n) return True a = is_prime(int(input("Enter Number To Check...
true
b400d54b3d869a594a798129493a32ba1cffe1e3
LHB6540/Python_programming_from_entry_to_practice_code_demo
/part1_7th_while_input/demo.py
790
4.125
4
# input message = input('Please input your information:') print(message) prompt = 'Please input your name:' name = input(prompt) print(name) number = input('Enter a number,this code will tell you if it\'s even or odd:') number = int(number) if number%2 == 0: print('It\'s even') else: print('It\'s odd') # whil...
true
7de397e7ba7486e2676310602ae51037d6669f50
hurrymaplelad/ctci
/leetcode/380-set-insert-delete-random.py
1,430
4.125
4
import random; class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.values = []; self.indicies = {}; def insert(self, val): """ Inserts a value to the set. Returns true if the set did not already contain th...
true
8448462087f5fac4878a71818b568cbef5580618
GhostOsipen/pyRep
/leetcode/PalindromeNumber.py
697
4.15625
4
# Given an integer x, return true if x is palindrome integer. # An integer is a palindrome when it reads the same backward as forward. # For example, 121 is palindrome while 123 is not. def isPalindrome(x: int) -> bool: if x >= 0: nums = [] s = "" for i in str(x): nums.append(i...
true
cea4a29987d9fedc3742e0412a7d05d6e02e2727
sathyainfotech/Single-Inheritance
/Single Inheritance.py
571
4.1875
4
""" Inheritance ----------- 1)Single Inheritance 2)Multiple Inheritance 3)Multi Level Inheritance 4)Hybrid Inheritance 5)Hierarchical Inheritance """ class Addition: def add(self): a=int(input("Enter The A Value:")) b=int(input("Enter The B Value:")) c=a+b ...
true
8ce599cf4af10072646f0b07dfcf257ca56329ca
MattRooke/CP1404_Pracs
/prac_05/count_words.py
434
4.3125
4
""""Test String this is a test string to test the number of words counted is the to a a {num: word for num, word in enumerate(input_text)} """ input_text = input("String:") word_in_string = input_text.split(" ") print(word_in_string) word_count = {} for word in word_in_string: count = word_in_string.count(word) ...
true
8041daf0d77d84bb58b7c78bbc76481e050ead57
AsuwathamanRC/Python-Programs
/Working with CSV/NATO Alphabet/main.py
574
4.3125
4
import pandas as p CSV_PATH = r"Working with CSV\NATO Alphabet\nato_phonetic_alphabet.csv" data = p.read_csv(CSV_PATH) alphabetsDict = {row.letter:row.code for (index,row) in data.iterrows()} # wordList = [w for w in word] # solution = [alphabetsDict[word] for word in wordList] def generatePhonetic(): word = in...
true
adcf7a779f2d63d83443d63f8c3ea62f666f27ba
Skee123/Skee123.github.io
/Python/grocery.py
502
4.34375
4
#build a basic grocery list groceries = [] print (groceries) groceries = ["milk", "eggs", "bread", "bacon", "airheads"] print (groceries) #play around with the list groceries.append("spinach") print (groceries) groceries.remove ("bacon") print (groceries) print (groceries [0]) print (groceries [2]) groceries.del(0...
true
1d902626a5dbf7b4295d8daba1b99ec5fe8ea13f
LuckyGitHub777/Python-Foundations
/bmi-calculator.py
543
4.3125
4
#!/usr/bin/python def calculate_bmi(height, weight): BMI = (weight * 703 / (height *height)) if BMI < 18.5: return 'Your BMI is ' + str(BMI) +'. Thats Under-weight.' if BMI >= 18.5 and BMI < 25 : return 'Your BMI is ' + str(BMI) +'. Thats a Normal Weight.' if BMI > 25: return ...
true
39512067960416245632272b6b434dd79985e759
dlingerfelt/DSC510Summer2020
/SIMEK_DSC510/DSC510_2.1_Simek.py
1,104
4.3125
4
# Katie Simek # DSC510-T303 # Assignment 2.1 # 12/6/2020 """ This program asks the user for their company name, length of cable to be installed and computes the cost at $.87 per foot. The program prints a receipt for the user. """ print('Hello, welcome to the fiber optic cable installation ' ...
true
cead6a1e6812e4151d53b22f6c7e6abe15e897f3
dlingerfelt/DSC510Summer2020
/HOLDMAN_DSC510/Assignment 2.1.py
968
4.46875
4
#DSC 510 #Week 2 #Programming Assignment 2.1 #Sarah Holdman #06/12/20 #This program will do the following: #Display a welcome message #Retrieve the company name #Retrieve the number of feet of cable needed #Calculate the cost of installation #Print a receipt #Welcome user and retrieve company name company = input('We...
true
9e08c21569f0d89f82aa9eb037fe883fbc3e7e6f
dlingerfelt/DSC510Summer2020
/TESORO_DSC510/Tiffany Tesoro - Assignment Week 7.py
2,103
4.1875
4
#DSC 510 #Week 7 #Programming Assignment Week 7 #Author Tiffany Tesoro #07/19/2020 #NOTE: ADDED EXTRA COMMENTS FOR REMINDER IN FUTURE USE #TO HELP REMOVE PUNCTUATION import string print() #DEFINE ADD_WORD FUNCTION #ADD WORD TO DICTIONARY #REFERENCE TEXTBOOK ADVANCED TEXT PARSING PG 114 def add_word(counts, file_...
true
94e3ed9324fa1b6f9ac04ed71ff6b45674fa5da8
Jared-Hinkle/Jared-Hinkle
/School Projects/Intro to Python/6.12.py
423
4.125
4
#Jared Hinkle #jah87410 #6.12 #This program will display a given number of characters per line using a function def printChars(ch1, ch2, numberPerLine): num = ord(ch1) num2 = ord(ch2) lineNum = 0 while(num < num2 + 1): print(chr(num), end = " ") lineNum = lineNum + 1 if lineNum =...
true
d8ed3ef1c5ef541149c8dd32ae7df0d09ef36fab
saminsakur/tkinterpy
/helloworld.py
243
4.34375
4
from tkinter import * window = Tk() # the class for the window # create a label widget text1 = Label(window, text="Hello world!") # Shoving it onto the window text1.pack() # main loop to show the window repeatedly maybe window.mainloop()
true
fbead6714a132e87f81cc1b8d11f039ef44d2cb8
dipeshbabu/python-labs-codio
/objects/objects_exercise3.py
1,201
4.40625
4
""" Exercise 3 Define the class SuperHero. The class should have a constructor that accepts the following parameters (in this order): name- String with the name of the super hero, e.g. "Spider-Man" secret_identity - String with the true name of the hero, e.g. "Peter Parker" powers - A list of strings with each element ...
true