blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
79960d1a3ebf7da0418dba9ac144e1d0d3992ce1
vishrutkmr7/DailyPracticeProblemsDIP
/2019/10 October/dp10012019.py
1,687
4.125
4
# This problem was recently asked by Apple: # You are given the root of a binary tree. You need to implement 2 functions: # 1. serialize(root) which serializes the tree into a string representation # 2. deserialize(s) which deserializes the string back to the original tree that it represents # For this problem, oft...
true
f335d44d04a36aaf9f627a675d9941a58ad6de3f
vishrutkmr7/DailyPracticeProblemsDIP
/2022/10 October/db10132022.py
1,334
4.15625
4
""" This question is asked by Google. Email addresses are made up of local and domain names. For example in kevin@dailybyte.com, kevin is the local name and dailybyte.com is the domain name. Email addresses may also contain '+' or '.' characters besides lowercase letters. If there is a '.' in the local name of the emai...
true
aaa2e4edb6f221f9f90f27ff289b3ee5fb018864
vishrutkmr7/DailyPracticeProblemsDIP
/2022/09 September/db09122022.py
1,936
4.21875
4
""" This question is asked by Amazon. Given two trees s and t return whether or not t is a subtree of s. Note: For t to be a subtree of s not only must each node’s value in t match its corresponding node’s value in s, but t must also exhibit the exact same structure as s. You may assume both trees s and t exist. Ex: G...
true
30dc7180449eb258c5de44e7106895438c3e785c
vishrutkmr7/DailyPracticeProblemsDIP
/2022/07 July/db07102022.py
1,679
4.15625
4
""" Given a binary tree and a target, return whether or not there exists a root to leaf path such that all values along the path sum to the target. Ex: Given the following tree… 1 / \ 5 2 / / \ 1 12 29 and a target of 15, return true as the path 1->2->12 sums to 15. Ex: Given the following...
true
46f7bb7b353e09d13ce403a544108e3d8d90164d
vishrutkmr7/DailyPracticeProblemsDIP
/2023/04 April/db04252023.py
1,227
4.1875
4
""" You are given a list of words and asked to find the longest chain. Two words (or more) form a chain if a single letter can be added anywhere in a word, s, to form a word, t (where s and t are both words within the list of words you’re given). Return the length of the longest chain you can form. Ex: Given the follo...
true
b49cf638dff419467641a03f58133200a95d7c3e
vishrutkmr7/DailyPracticeProblemsDIP
/2022/06 June/db06282022.py
1,852
4.15625
4
""" Given two binary trees, return whether or not the two trees are identical. Note: identical meaning they exhibit the same structure and the same values at each node. Ex: Given the following trees... 2 / \ 1 3 2 / \ 1 3 return true. Ex: Given the following trees... 1 ...
true
d83eb7cee5a0dfab8c148dedd8a69174cfa2ce31
vishrutkmr7/DailyPracticeProblemsDIP
/2022/09 September/db09052022.py
822
4.15625
4
""" This question is asked by Google. Given an N-ary tree, return its maximum depth. Note: An N-ary tree is a tree in which any node may have at most N children. Ex: Given the following tree… 4 / | \ 3 9 2 / \ 7 2 return 3. """ class Node: def __init...
true
4df7f30c188fb54435b61a0a1d93549a9f311bc1
vishrutkmr7/DailyPracticeProblemsDIP
/2022/10 October/db10272022.py
494
4.1875
4
""" Given an integer n, return whether or not it is a power of three. Ex: Given the following value for n... n = 9, return true Ex: Given the following value for n... n = 50, return false """ class Solution: def isPowerOfThree(self, n: int) -> bool: return n >= 1 and 3**20 % n == 0 # Test Cases if _...
true
429daad59e7b7eb5ad43b37f716f5aa5d6a59433
vishrutkmr7/DailyPracticeProblemsDIP
/2019/09 September/dp09202019.py
561
4.21875
4
# This problem was recently asked by Uber: # You are given a string of parenthesis. Return the minimum number of parenthesis that would need to be removed # in order to make the string valid. "Valid" means that each open parenthesis has a matching closed parenthesis. def count_invalid_parenthesis(string): # Fil...
true
6367a951c70d858dfe49ea57b0630303e549da65
Gutwack/simpleCalculator
/simpleCalculator.py
1,090
4.375
4
>>> while True: print("Options: ") print("Enter 'add' to add two numbers") print("Enter 'subtract' to subtract two numbers") print("Enter 'multiply' to mulitply two numbers") print("Enter 'divide' to divide two numbers") print("Enter 'quit' to end the program") userInput = input(": ") if userInput == "quit": ...
true
a34e501d74db21eb2f079ac4e6679331cf5daf2f
venkataganeshkona/geeksforgeeks
/class1.py
652
4.1875
4
#This code explains the concept of class in python class square(): pass x=square() x.side=14 print x.side #another example of class class square(): def perimeter(self,side): return side*4 a=square() print a.perimeter(14) #another example class student(): def __init__(self,name): self...
true
69ea34bdd57ac0035b6fb7597cd7b631aef1fb11
jeffhow/learnpython3thehardway
/ex30.py
563
4.21875
4
people, cars, trucks = 30, 40, 15 if cars > people: # 40 > 30 ? True print("We should take cars.") # This one elif cars < people: print("we should not take cars.") else: print("We can't decide.") if trucks > cars: # 15 > 40 ? False print("Too many trucks.") elif trucks < cars: # 15 < 40 ? True ...
true
3943323a85018f274504022d1a2651da244ff4e9
fossabot/IdeaBag2-Solutions
/Numbers/Factorial Finder/factorial_finder.py
1,076
4.28125
4
#!/usr/bin/env python3 """A program that finds the factorial to any given number. Title: Factorial Finder Description: The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1. Also the factorial of zero, 0, is defined as being 1. Develop a program that solves the factorial ...
true
07ad1dd6d9295824de99da2f9ebc5bdc10725998
fossabot/IdeaBag2-Solutions
/Text/Scooby Doo/scooby_doo.py
1,536
4.59375
5
#!/usr/bin/env python3 """Replace all characters in each word with "r" until a vowel appears in it. Title: Scooby Doo Description In the popular kids show "Scooby-Doo", the main character had a speech impediment that makes him replace all consonants at the start of a word until it runs into a vowel with an "r". For e...
true
b757e0c47e233797bd0348c7940df3e3fd964980
fossabot/IdeaBag2-Solutions
/Text/CD Key Generator/cd_key_generator.py
2,540
4.4375
4
#!/usr/bin/env python3 """Generates random keys. Title: CD Key Generator Description: Develop a program which generates keys for an application that you may put on a CD. A great example would be the keys you use for installation of a major software product from companies like Microsoft or Adobe. Have the user specify...
true
ec632663179ba0a556bd9ff93d9f178e185c699c
fossabot/IdeaBag2-Solutions
/Text/Password Generator/password_generator.py
2,651
4.65625
5
#!/usr/bin/env python3 """A password generator and manager. Title: Password Generator Description: Create a program that allows a user to enter a password name eg: "Facebook Account Password" and length eg: '24'. Your program should then proceed to generate a strong password. This strong password should be generated ...
true
1fb0c1fbe42512cfecc20b198e0c9bfd6ca6eefa
fossabot/IdeaBag2-Solutions
/Text/Count Words in a String/tests.py
779
4.15625
4
#!/usr/bin/env python3 import unittest from count_words_in_a_string import count_lines, count_paragraphs, count_words class Test(unittest.TestCase): def test_count_words(self): self.assertEqual(count_words("This sentence has five words"), 5) def test_count_lines(self): self.assertEqual(coun...
true
92dcc850a73611b33f3fb675deac74f38386eef8
Aditya3049/Python
/Tony'sPizza.py
652
4.1875
4
print("Welcome to Tony's Pizza") name=input("What is your name?: ") phone=input(f"{name} what is your contact number? : ") item=input("What is your favourite item from our menu? : ") add=input("What would you like to add to our menu? : ") quantity=int(input("Rate the food quantity on the scale of 1 to 5 : ")) qua...
true
31af2e6a5727452b067efde383cdb364054fcc3c
Mustafatalib/Python-Crash-Course-Exercises
/4.11-My pizzas, Your pizzas.py
592
4.125
4
pizza = ['cheese pizza', 'olive pizza', 'pepperoni pizza'] for i in pizza: print(i.title() + " is my favourite pizza.") print("I really lieke to eat pizzas when im hungry and these are my favourite pizzas. ") print("I really love pizzas.") frnd_pizza = ['cheese pizza', 'olive pizza', 'pepperoni pizza'] frnd_pizza.a...
true
d7d3bce4c8eebcdd66598f625a84943bcb59ebb2
jeremiah-hodges/learning.py
/basics/lists.py
889
4.34375
4
friends = ["tom", "lisa", "albert" , "oscar" , "toby"] # print list print(friends) # access index print(friends[1]) # specify a range print(friends[2:]) print(friends[1:3]) # modify list friends[1] = "mike" print(friends[1]) # combine lists nums = [1, 2, 3, 4, 5, 5] new_friends = friends.copy() new_friends.extend...
true
cc698833fae3ff418f0d2beafb25d338f6ca1ce9
tarheel-achiu/TheSelfTaughtProgrammer
/Chapter_6.2.py
367
4.1875
4
# 2. Write a program that collects two strings from a user, inserts them into a string # "Yesterday I wrote a [response_one]. I sent it to [response_two]!" and prints a new string response_one = input("Enter an object: ") response_two = input("Enter a person: ") output = "Yesterday I wrote a {}. I sent it to {}!".for...
true
828680f24b76630da6f9df6c0803c8720d633b3b
tarheel-achiu/TheSelfTaughtProgrammer
/Chapter_7_Notes.py
2,664
4.53125
5
#For Loop for [variable_name] in [iterable_name]: [instructions] #where [variable_name] is a variable name of your choosing assigned to the value of each item in the iterable, #and [instructions] is the code to be executed each time through the loop. #For loop through iterable string name = "Ted" for character ...
true
f3d068adcbc50a324282d4e8db62aed00a5ba9da
edwinachan/python-katas
/codewars-kata14-first-non-repeating-character.py
2,330
4.125
4
#First non-repeating character #Write a function named firstNonRepeatingLetter† that takes a string input, and returns the first character that is not repeated anywhere in the string. #For example, if given the input 'stress', the function should return 't', since the letter t only occurs once in the string, and occu...
true
449d12616b80db3dda16f4f45b4b34ca8d366eea
edwinachan/python-katas
/code-club-projects/racing-turtles.py
1,448
4.34375
4
#https://codeclubprojects.org/en-GB/python/turtle-race/# from turtle import * from random import randint #Start drawing from the top left corner speed(10) penup() goto(-140,140) #Create vertical tracks numbered 0-5. Use write function to achieve this #right(90) makes the turtle turn right 90 degrees #forward(10) ...
true
750565af03d945fbdc32e26347b28977b203e9dc
AndreeaMihaelaP/Python
/Lab_1/Ex_8.py
456
4.4375
4
# Give a string that represents a polynomial (Ex: "3x ^ 3 + 5x ^ 2 - 2x - 5") and # a number (whole or float). Evaluate the polynomial for the given value. #Horner method def horner( poly, x): result = poly[0] for i in range(1 , len(poly)): result = result*x + poly[i] return result # Let us evalua...
true
f892acb48e95d59b664e2dabe528f00208da542e
ashinsukumaran/pythonprograms
/flow_of_controls/looping/factprg.py
261
4.21875
4
print("factorial program") num = int(input("enter a number")) if(num>0): fact = 1 for i in range(1,num+1): fact=fact*i print(fact) elif num==0: print("factorial of 0 is 1") else: print("factorial for -ve numbers is no exists")
true
abda0bd5eacb723675c6595d3a60eec3b2f42c23
ashinsukumaran/pythonprograms
/Data_collections/list/list_elemets_adding.py
217
4.1875
4
print("list program to enter elements and store it in a list") l=[] n=int(input("enter the size of the list")) for i in range(n): e=int(input("enter the elements")) l.append(e) print("elements in list are",l)
true
74a0cb608c9738d730db7a27fef96fbdc09ae8ee
JackMullane1/IntroProgramming-Labs
/lab03/pi.py
572
4.40625
4
# A program to compute pi based on a math sequence, takes user's input. import math def main(): num = int(input("Enter the nth term of the pi sequence: ")) result = (pi(num)) print("Sum: ", result) print("Accuracy: ", (math.pi - result)) def pi(num): if num <= 0: print("The number has to...
true
05b550c1b66e6d130bc80dca0e5dc2b057f00da7
JackMullane1/IntroProgramming-Labs
/lab07/tx3.py
2,000
4.1875
4
# CMPT 120 - Intro to Programming # Lab 6 - Lists, Functions, and Error Handling. # Author: Jack Mullane # Created: 10-24-2019 def printRow(row): output = "|" for square in row: if square == 0: output += (" |") elif square == 1: output += (" x |") elif square ...
true
bab914ce254d1e3a004f862dd91a605d893ef38b
ninankkim/git101
/day_of_week.py
613
4.25
4
day_of_week = int(input( "Please enter number 0 through 6: ")) if day_of_week == 0: print('Sunday') elif day_of_week == 1: print('Monday') elif day_of_week == 2: print('Tuesday') elif day_of_week == 3: print ('Wednesday') elif day_of_week == 4: print ('Thursday') elif day_of_week == 5: print ('F...
true
8c79faf726a377d02349f6855a9457caeb75b0a9
zois-tasoulas/algoExpert
/medium/threeNumberSort.py
1,442
4.1875
4
def three_number_sort_a(array, order): last_a = -1 last_b = -1 for index, number in enumerate(array): if number == order[0]: last_a += 1 swap(array, last_a, index) last_b += 1 if last_b != last_a: swap(array, last_b, index) elif...
true
850a016fd0de8ce74889c747ff90dfcd26aca401
sociopath00/PythonBasics
/14_for_loop.py
512
4.1875
4
""" @author: Akshay Nevrekar @created_on: 4th November,2019 @last_updated_on: 4th November,2019 """ # print 1 to 5 numbers for i in range(1, 6): print(i) # print elements in the list prog_lang = ["python", "java", "c++", "r langauge", "php"] for i in prog_lang: print(i) # print each character fro...
true
9be6420ad9784618e5870f57d0b2a4de1293adcd
AshleyNMarti/PythonCode
/average-height/soln/average_height.py
697
4.1875
4
# Morning Problem 2 # average_height.py # 1616898 # the floor() function might be useful # for a floating point number x, floor(x) is the greatest integer <= x import math #(I changed this because the original wasn't seeming to work...???) # read in the input numbers = list(map(int, input().split())) # now "numb...
true
085be95c099ba84e8ee27369d7930f35e531ac5f
nreavell/Pracs
/prac_09/cleanup_files.py
2,586
4.1875
4
""" CP1404/CP5632 Practical File renaming and os examples """ import shutil import os def main(): dir_names = {} """Demo file renaming with the os module.""" print("Current directory is", os.getcwd()) # change to desired directory os.chdir('FilesToSort') # print a list of all files (test) ...
true
d250ace4bea36183925833c3307c96edf399f482
MaggieChege/Python-Practice
/even_odd.py
433
4.1875
4
#practise2: #asks user to enter 2 numbers check if numder is even or odd #also check if number is a divisible by 4 num1 = input("Enter your first number") check = input("Enter your second number") if int(num1%2 == 0): print (num1,"hello pretty one, your number is Even") elif num1%2 != 0: print("Get over it, Your Num...
true
3f6eee9b00534fb5e00d33daa0cef4ee78e2d8e8
LiuFang816/SALSTM_py_data
/python/coala_coala/coala-master/coalib/misc/DictUtilities.py
1,360
4.40625
4
from collections import Iterable, OrderedDict def inverse_dicts(*dicts): """ Inverts the dicts, e.g. {1: 2, 3: 4} and {2: 3, 4: 4} will be inverted {2: [1], 3: [2], 4: [3, 4]}. This also handles dictionaries with Iterable items as values e.g. {1: [1, 2, 3], 2: [3, 4, 5]} and {2: [1], 3: [2], 4: [3...
true
4245079f9adee2d28f6c330f423af62301baa947
Pratiknarola/PyTricks
/conditionalassignment.py
476
4.1875
4
#! /usr/bin/env python3 """Python has two ways to do conditional assignments The first is a fairly standard teranary style; <value if true> if <conditional> else <value if false> The second method takes advantage of the fact that python's or is lazy. When an assignment is made if the first value is falsy (None is fal...
true
5831b4c7388287260ad2941c843a9e36f0cc528f
atul27-git/YouTube-Video-Downloader
/YouTubeDownloader.py
1,619
4.125
4
''' Initially we have to download the pytube Library which will enable you to download videos from YouTube. ''' #pip install pytube import tkinter as tk from pytube import YouTube '''Creating the root window''' root = tk.Tk() '''Setting the dimension and the title for the root window''' root.geometry('800x500') roo...
true
667f8e937a71fb55e104e58caf3ac77815d196dd
HGalchar/Image-Encryption-using-AES-with-Python
/geeksimgenc1.py
2,517
4.3125
4
def encryption(): print("Encryption Start.........") try: # take path of image as a input path = input(r'Enter path of Image : ') # taking encryption key as input key = int(input('Enter Key for encryption of Image : ')) # print path of image file and encryption key that...
true
b2dec3befe79e0e93393151347aec3a716b5526e
shengjie-min/python-tutorial
/inheritance/init_vs_new.py
728
4.25
4
''' Created on Jun 10, 2013 @author: shengjiemin __new__ is the first step of instance creation. It's called first, and is responsible for returning a new instance of your class. In contrast, __init__ doesn't return anything; it's only responsible for initializing the instance after it's been created. ''' class Age...
true
c783fc3eb8cfbb0462ba839f4ccd1b575380e973
julienemo/exo_headfirst
/pyramide.py
2,167
4.15625
4
# wanted the user to choose between two stuffs # given there are only two choices I thought of boolean # for ex like this # choice = bool(input('Would you wand a whole or half pyramid ?')) # but it didn't work out coz True == having and answer and False == no answer import sys def get_choice(): valid = {"WHOLE"...
true
f7c7ea66b87e517cbebd6c3f66d725c89be2847b
think-chao/interview
/动态规划/Unique Paths.py
1,762
4.28125
4
#coding=utf-8 """ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths ar...
true
7b1a06e2df5c44520c0c5b0f356bd3dcd3fcb3f8
lalithkumart-corp/python-workaround
/src/basics/iterations.py
1,494
4.15625
4
class Iterations: def handle(self): myData = {'name': 'lalith', 'age': 25} for i in myData: print(myData[i]) ## Wotking with Lists # Syntax: ''' list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b", ...
true
146ef17053e62f84c1a20c3f2c7a103d0ac46e49
dlatney/Python
/rollercoaster_ticket.py
554
4.125
4
print("Welcome to the rollercoaster!") height = int(input("What is your height: ")) bill = 0 if height >= 48: age = int(input("How old are you? ")) if age < 12: bill = 5 print("Your ticket is $5") elif age >= 18: bill = 12 print("Your ticket is $12") else: bill = ...
true
4ead0fa086ff686656a8281734fd074729d6fee6
hasanahmvd/CS1026B
/Labs/Lab3/task3/Lab 3 Assignment 2.py
618
4.375
4
month = (raw_input("Please enter the current month: ")) if month == "January" or month == "December" or month =="February" : print("In {}, it is winter, I suggest you go snowboarding".format(month)) elif month == "March" or month == "April" or month =="May" : print("In {}, it is spring, I suggest you go hiking...
true
72ec784c7f94b7a50b17bdda187656a11ecf328d
hasanahmvd/CS1026B
/Labs/Lab4/task4/Lab 4 Assignment.py
559
4.25
4
num = int(input("How many numbers do you want to use today? ")) x = 1 value = int(input("Enter the number: ")) max = value min = value total = value while x < num: value = int(input("Enter the number: ")) if value > max: max = value if value < min: min = value total = total + value ...
true
431ac01c8801c6ef87b9b9ce46a651db73cc0a39
dilanmorar/python_basics
/python_basics/dictionairies.py
240
4.15625
4
# dictionary # it has key(word) and values(definition) pairs # syntax # dictionary = {'key':'value'} my_dictionary = {'tissue':'', '':''} print(my_dictionary['']) # accessing or re-assigning is with the key inside the []
true
c9a8c7a4a55b8b4105fd45026ecf65cb9820c1e7
dilanmorar/python_basics
/python_basics/if_functions.py
679
4.15625
4
# if functions # control flow # while loops also part of the control flow # syntax # if <condition>: # block of code # elif <condition>: # block of code # else: # block of code age = int(input('what is your age? ')) if age < 21 and age >= 18: print('you can drive, vote, but not drink in the US') elif...
true
ca0f682b8fb7c139bc080b85bf36fb7b08af43a1
GauravSahani1417/Python-Practice-Codes
/List Programs/Sum of elements in a list.py
410
4.21875
4
#Python program to find sum of elements in list #Input: [12, 15, 3, 10] #Output: 40 # Python program to find sum of elements in list x = 0 # creating a list list1 = [11, 5, 17, 18, 23] # Iterate each element in list # and add them in variale total for y in range(0, len(list1)): x = x + list...
true
35800dd4fea785c577649250e21fe27f9d6afa36
EzechukwuJI/switchng_python
/polynomial by James.py
1,917
4.5625
5
def evaluate_poly(poly, x): """ Computes the polynomial function for a given value x. Returns that value. Example: >>> poly = (0.0, 0.0, 5.0, 9.3, 7.0) # f(x) = 7x^4 + 9.3x^3 + 5x^2 >>> x = -13 >>> print evaluate_poly(poly, x) # f(-13) = 7(-13)^4 + 9.3(-13)^3 + 5(-13)^2 180339.9 poly...
true
5ef1f243d1c591debfbb63ea48168090339ee4fc
SandraLeikanger/Flask-Project
/TapsWeek5/Tap.23.py
910
4.28125
4
def infinite_numbers(start=0): #Generators are great because the code is simpler, but it will give you the same output as complex class functions, and also saves memory space since it uses iterators. while True: yield start #Generators use the keyword "yield" instead of "return", which will itera...
true
028acb994a65749fdbcdc9176d42fa20416a7bbd
shoeless0x80/100_Python_Exerciese
/79.py
811
4.3125
4
#Create a script that lets the user submit a password until they have satisfied three conditions: #1. Password contails at least one number #2. Contains one uppercase letter #3. It is at least 5 chars long #Print out a message "Password is not fine" if the user didn't conreate a correct password password = input("Ente...
true
1d00629bf194aef5c076782f0e67acde133e0fa2
wilsoncgj/A-Beginners-Guide-To-Python
/A Beginners Guide To Python/python_strings/replacing_strings.py
209
4.5
4
#One string can replace a substring in another string. # This is done using the replace() method on a string. For example: welcome_message = 'Hello World!' print(welcome_message.replace("Hello", "Goodbye"))
true
629f73d4033301e9521a34804fb992b9cc0ce86f
shellyhanda/Python
/loop.py
322
4.125
4
LetterNum=1 for Letter in "Howdy!!": print("Letter",LetterNum," is ",Letter) LetterNum+=1 value=input("Enter the Sting with less than 6 Character") count=1 for Letter in value: print("Letter",count," is ",Letter) count+=1 if(count>6): print("The String is too long") break ...
true
b8159c802f3f0db0402adda18460f6fd8e4e96dd
metal32/Algorithm
/PythonApplication1.py
1,600
4.5
4
"""CREATING A NEW CLASS""" class Employee: raise_amount=1.04 def __init__(self, first, last, pay): self.first=first self.last=last self.pay=pay self.email=first+last+"@gmail.com" def fullname(self): return "{} {}".format(self.first,self.last) def apply_raise(self)...
true
d2614f794c9bb22987354983a7f8db954f38eea1
metal32/Algorithm
/PythonApplication2.py
2,040
4.25
4
"""CREATING A NEW CLASS""" class Employee: raise_amount=1.04 def __init__(self, first, last, pay): self.first=first self.last=last self.pay=pay self.email=first+last+"@gmail.com" def fullname(self): return "{} {}".format(self.first,self.last) def apply_raise(self)...
true
4fc0ba8ce7c2643ad64528bc696a54f06e0672c7
PeterKoppelman/Python-INFO1-CE9990
/intersect.py
2,510
4.25
4
""" intersect.py Print the intersection and difference of two sets. Use two csv files to start. One lists the names of the companies in the DOW 30. The second lists companuies in the NASDAQ 100 Peter Koppelman July 30, 2017 """ import sys import itertools import csv # Read in the two files from the harddrive filena...
true
6e3e897c23f886a13c1acc1ef66df00aba85f82e
eepgwde/godel-program-converter
/src/godel_utils/godel_utils.py
1,340
4.15625
4
from typing import Generator, Tuple from src.primes import prime_generator def sequence_to_godel_number(sequence: Generator[int, None, None]) -> int: """ Converts a sequence of numbers into a Gödel number Gödel(a_1, ..., a_n) = p_1 ^ a_1 * ... * p_n ^ a_n where p_i is the ith prime number and a_i is the ith el...
true
f44881172e8050b8e0941f960d7767f81135b5ba
eepgwde/godel-program-converter
/src/code_to_godel.py
1,000
4.375
4
import sys import os from .encode_program import encode_program_as_number def read_program() -> str: """ Check for the input code. If the argument is not a file, then it will be treated as input code. If no argument is given, then the user will be prompted to enter the code. """ # check if an argument was pass...
true
f6ed7d2d772b2c228ddc3e8665375c38ea5fbc00
wbennett84/Python-Projects
/Encapsulation project.py
1,137
4.375
4
#here we are defining our class and setting up some variables with initial values. # These are private and protected variables, respectively. #Next we are setting up some print and value-setting functions for use # later on when we call them. class Private: def __init__(self): self.__private = 30 ...
true
9fd1b71222ea162bf0ea627494e7184f93f2ad98
rcortezk9/Python
/Conditional/age_checker.py
273
4.125
4
# Age Checker your_age = input("How old are you? ") friend_age = input("How old is your friend? ") if int(your_age) >= 18 or int(friend_age) >= 18: print("Congrates, one of you is old enough to vote!") else: print("Sorry, one of you are to young to vote.")
true
60fbc8c837a282dfcede64d621d120b2f8f03c89
rcortezk9/Python
/Lists/looping_through_a_slicing.py
238
4.5
4
# Looping through a list # Looping through a slice with a for Loop names = ['rene', 'stephanie', 'mariah', 'victoria', 'sophia'] print("Here are the names of the the last 3 registrations.") for name in names[2:]: print(name.title())
true
99d29f194634b6b617ce5d7858295bbb3a44f536
tdefriess/cs-module-project-algorithms
/moving_zeroes/moving_zeroes.py
1,393
4.1875
4
''' Input: a List of integers Returns: a List of integers ''' def moving_zeroes(arr): first_zero_index = -1 second_zero_index = -1 i = 0 while i < len(arr): if arr[i] == 0 and second_zero_index == -1 and first_zero_index != -1: second_zero_index = i i += 1 # if a ...
true
04f1a59ec73e0f5bed71e7ec8a45616a0e836bcb
RajlaxmiSen/python_course
/fizzbizz.py
446
4.21875
4
# Print out numbers from 1 to 100 (including 100). # But, instead of printing multiples of 3, print "Fizz" # Instead of printing multiples of 5, print "Buzz" # Instead of printing multiples of both 3 and 5, print "FizzBuzz". for index in range(1,101): if (index % 3 == 0 and index % 5 ==0): print("FizzBuzz"...
true
916dd26b8143011ca7e74562fc6ba49b9c06b2ff
MunaV/MunaPythonRepo
/JokeGenerator.py
1,936
4.34375
4
## JOKE GENERATOR IN PYTHON ## Write a program that asks a user for ## their favourite number and then tells ## them a joke. The program will call a ## joke printing function with the users ## favourite number. ## The function will accept one numeric ## parameter and use it to choose the ## joke to tell. You wi...
true
adc253a420be7c9dba91727c140fc97ee751b180
lorena-ang/Practice-Python-Exercises
/01-Character-Input.py
705
4.21875
4
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. # Add on to the previous program by asking the user for another number and printing out that many copies of the previous message.Print out that many...
true
e8106c6a5b0b81acda75ae5371344f3b44e2dab6
dtekluva/cohort3b8wd
/lami/assignment_1.py
222
4.34375
4
# write a program that takes a string value and print the reverse input_value = input('Please enter a word: ') rev_input_value = input_value[::-1] print(f'{input_value.title()} is reversed as: {rev_input_value.title()}')
true
5d0cb63a278454ff5a977d8436e8c25187439310
dtekluva/cohort3b8wd
/lami/function_assignment.py
2,309
4.3125
4
# Write a Python program that accepts a hyphen-separated sequence of words as input and prints the words in a hyphen-separated sequence after sorting them alphabetically. # Sample Items : green-red-yellow-black-white # Expected Result : black-green-red-white-yellow # Write a Python function to create and print a list ...
true
187f8b5ff279ced93e37f781a009795e0c4159db
dtekluva/cohort3b8wd
/devjoseph/week 6/dictt.ass.py
1,113
4.25
4
# Write a small program that takes in any sentence or speech and breaks down all the word into a dictionary containing the word as key and a list/dictionary of the length of the word, and number of vowels in the word # example: # input : "statistics and probabilty have made for discoveries" # output: # { # ...
true
2658791275fe8008a1343ed3e3c7bb25c756746e
karolkocemba/week2
/solution_5.py
953
4.4375
4
#This script checks if a number entered by the user is a prime number import math def prime(n): if type(n) != int: print ("That is not an integer /n") elif n <= 2: print ("Make sure your integer is positive and greater than 2:") else: is_prime = True for i in range(2,n): # although the definition of 'prim...
true
6b4984530bb72919eab34d65b6c287c5b0f03687
samilarinc/CSLabs
/CS115 Lab03/lab-03-3.py
681
4.15625
4
import random def throwUntil(n, summ): dice = 0 counter = 0 while dice != summ: dice = 0 counter += 1 for i in range(n): a = random.randint(1,6) print(a, end=' ') dice += a print() return counter n = int(input("Enter nu...
true
9073e43254f24087ae4aa68299ba84f0ac9d1cef
belgort-clark/ctec-121-lab-5-2020
/lab5.py
2,282
4.125
4
''' CTEC 121 - Lab No. 5 Overview: This lab will have students work with the TextBlob library TextBlob library documentation - https://textblob.readthedocs.io/en/dev/ ================================================================================ PLEASE CAREFULLY READ THROUGH ALL OF THE INSTRUCTIONS PRIOR TO STARTIN...
true
43d411f1a25d5b8972bfc9d3116529860f91dc53
naseemkhan7021/Python_A_Z_Tutorial
/python_nupy_jupyter_all file/python_npy.py
911
4.28125
4
import numpy as np #single dimensional array create #array() inbuilt function of numpy library [] ==> array([]) a=np.array([3,4,5,8]) # here a is a user defined array object print(a) print(type(a)) # to display type of array object then use typ() nd means no. of dimensional print(a.ndim) ...
true
89ff1df282a06c11a004b77adde66881308e81fb
mnicasio/Math-4330-Quiz-03
/dotProd.py
1,320
4.28125
4
def dotProd(vector, vector2): """[This function takes two vectors as its parameters and returns the dot product] Arguments: vector {[list]} -- [this will be a list of numbers ] vector2 {[list]} -- [this will be a list of numbers] Returns: [ans] -- [this is the new vector that was created after ...
true
847de8ab135a44ca13d14d5f709f3250b4542663
mscott97/PRG105
/PenniesPay.py
413
4.125
4
numberOfDaysWorked = int(input("Please enter how many days you worked ?")) totalNumberOfPennies = 0 print() print("day\tSalary\n----\t----") for currentDay in range(numberOfDaysWorked ): PenniesForTheDay = 2 ** currentDay totalNumberOfPennies += PenniesForTheDay print(currentDay + 1,"\t",Pennies...
true
7fdf19e85feb777822ab41255d52600fc99fd25c
petercrackthecode/LeetcodePractice
/diameter_of_binary_tree/my_solution.py
2,113
4.1875
4
# https://leetcode.com/problems/diameter-of-binary-tree/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right from typing import Optional class Solution: def __init__(self): ...
true
c04739cbb7ac1f335b71608a6b0c10fa2e4049a6
petercrackthecode/LeetcodePractice
/invertTree/my_solution.py
741
4.1875
4
from typing import Optional # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: ...
true
b295f3ca3e931fbfc178c842876ce1c88480a895
gaetanoantonicchio/algorithms_and_data_structures
/Sorting /merge_sort.py
2,079
4.375
4
####################### # MERGE SORT # ####################### def merge_sort(A): if len(A) <= 1: return A midpoint = len(A) // 2 # split arrays recursively - divide step left, right = merge_sort(A[:midpoint]), merge_sort(A[midpoint:]) return merge_1(A, left, right) # merge step...
true
342cd09dfcc4896dfdbcf05e63603a8c6a734ff6
tristanbriseno/CS-Calculator
/custom-calculator.py
334
4.375
4
height = float(input("Input your height in meters: ")) weight = float(input("Input your weight in kilogram: ")) #this is where the code is requesting an input in the form of a float. print("Your body mass index is: ", round(weight / (height * height), 2)) #Here is where the code is printing the text and the result of t...
true
5386949c177062199e743e067f73fb520dffe507
rahultiwari56/weekday2019_08_06
/Assignments/Ashok/AssignExtra1-Input,TypeConversion.py
2,602
4.25
4
#1. Input temperature in Fahrenheit in print in Celsius. fahrenheit = input("Enter the value: ") celsius = (fahrenheit-32)/1.8 print(celsius) #2. Write a program to input a number and print its square and cube. num = input("Enter a number: ") square = num*num print(square) cube = num*num*num print(cube) #3. WAP to in...
true
1c2f5cc8fee5e010633b9eae92065c2789416e4f
tielushko/The-Modern-Python-3-Bootcamp
/Section 14 - Dictionaries/dictionary_comprehension.py
517
4.5625
5
#the syntax: {____:____for___in____} -iterates over keys by default -to iterate over keys and values using .items() numbers = dict(first=1, second=2, third=3) squared_numbers = {key: value ** 2 for key, value in numbers.items()} print(numbers) print(squared_numbers) print({num: num**2 for num in [1,2,3,4,5]}) str1...
true
b620df414155dff5bf81ddc55cd8943951a7e41c
tielushko/The-Modern-Python-3-Bootcamp
/Section 15 - Dictionary Exercises/state_abbreviation.py
672
4.4375
4
# Given two lists ["CA", "NJ", "RI"] and ["California", "New Jersey", "Rhode Island"] create a # dictionary that looks like this {'CA': 'California', 'NJ': 'New Jersey', 'RI': 'Rhode Island'} . # Save it to a variable called answer. I expect you to do this with a dictionary comprehension, but you can also use a bu...
true
32493f76438394793b9c63604808d7e0a6370ab1
tielushko/The-Modern-Python-3-Bootcamp
/Section 15 - Dictionary Exercises/ASCII_codes_dict.py
292
4.1875
4
# Your task is to create dictionary that maps ASCII keys to their corresponding letters. Use a # dictionary comprehension and chr() . Save the result to the answer variable. You only need to care # about capital letters (65-90). ASCII = {key:chr(key) for key in range(65,91)} print(ASCII)
true
841748f4bb30a295965c8b64832d79c0b2a9f731
agarces1/folLoopsPython
/forLoopspython3/forLoopspython3/forLoopspython3.py
723
4.59375
5
#the idea for the while loop is to iterate through something, most of the times the while loop is used for finite tasks that have predetermined lenght, while and for loops are interchangable. exampleList = [1,5,6,6,2,1,5,2,1,4] for numbers in exampleList: print(numbers) #this code will print out each item in that...
true
46c5f63250f90e52c707307aa2ec8b7585d2c700
jon1123/python_udemy
/dacorators.py
1,606
4.21875
4
'''Decorators''' def func(): print(1) #return 1 func() s = 'This is a golbal variable' def func(): print(locals()) print(globals()) print(globals()['s']) func() def hello(name = 'Jose'): print( 'Hello ' + name) hello() greet=hello #del hello() // dose not work??? greet() ######## video ...
true
96b472bc9bbb644ea518376aa29ddbf84d9133f4
swankong/LeetcodeSolutions
/Merge_Sorted_Array.py
1,039
4.3125
4
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. # Note: # The number of elements initialized in nums1 and nums2 are m and n respectively. # You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. # Exa...
true
720042bbc00b3e6807ac1bf97a3024d59fa0680c
Saradalakshmi87/Practice-Problems
/Binary_exponentiation.py
972
4.15625
4
''' USING RECURSION ''' def exp(a,n): #defining a function to calculate the power i.e., a^n if n == 0: # anything power 0, results in 1. So, if n value equals to 0, then return 1 return 1 subprob = exp(a,n//2) # Dividing the problem into s...
true
a2ee7e2d8937eb967b3a7f9a0299074ef1d3574b
sartajroshan/aptitude-problem
/array, List/prob8.py
552
4.1875
4
''''# Function to reverse words of string def rev_sentence(sentence): # first split the string into words words = sentence.split(' ') # then reverse the split string list and join using space reverse_sentence = ' '.join(reversed(words)) # finally return the joined string return reverse_sentence if...
true
a2b16f0854dd7b1c75b40c86110d4987e22215fe
Danyshman/Leetcode
/FlattenNestedListIterator.py
1,418
4.125
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ # class NestedInteger: # def isInteger(self) -> bool: # """ # @return True if this NestedInteger holds a single integer, rather than a nested list. # ""...
true
4a2f04af9c686deab5bb016a8fccc8319a2809d9
pmheintz/PythonTutorials
/control_flow/range_demo.py
506
4.40625
4
""" Range creates a sequence of numbers, but doesn't save them in memory Useful for generating numbers """ # list() casts the range() to a list. Range generates numbers between 1st arg and 2nd arg print(list(range(0, 10))) a = range(5, 21) print(a) print(type(a)) print(list(a)) print("*" * 20) b = range(10) # Prints...
true
bc09ca232735437c3d4010e2a6300eb0c206a420
pmheintz/PythonTutorials
/basicsyntax/string_slice_indexing.py
305
4.34375
4
a = "This is a string" # Print from 1st index to end print(a[1:]) # Print from start to index 6 (not including 6) print(a[:6]) # Print from start to finish every 2 print(a[::2]) # Use negative to start from the end print(a[:-2]) print(a[::-2]) # Easily reverse a string print(a[::-1]) b = a[::-1] print(b)
true
a8c603f73111fb705e824e8e0e167a19dcabd03c
dionnewest/DojoAssignments
/Python/scores.py
678
4.125
4
import random print "Scores and Grades" for n in range (0,10): random_num = random.randint(60,100) if random_num >= 90: print "Score: "+str(random_num)+"; Your grade is A" elif random_num >= 80 and random_num <90: print "Score: "+str(random_num)+"; Your grade is B" elif random_num >= 70 and random_num <80: pr...
true
b313d0561840a1e4aaefd9ecf1723cb55d92a6ad
curiousTauseef/Algorithms_and_solutions
/LeetCode/9_palindrome-number.py
1,527
4.34375
4
""" Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Examp...
true
5437ea2223174c26d763beabd0ce1edcc8ae9166
HAMZAH7K/HackerrankPython
/division.py
486
4.28125
4
# Task # Read two integers and print two lines. The first line should contain integer division, a // b. The second line should contain float # division, a / b. # You don't need to perform any rounding or formatting operations. # Input Format # The first line contains the first integer, a. The second line con...
true
f81972838850b2cc7153786bc45915439ef8e20c
JoNowakowska/CodeChallenges
/SimpleFunReverseLetters.py
1,051
4.5
4
""" Given a string str, reverse it omitting all non-alphabetic characters. Example For str = "krishan", the output should be "nahsirk". For str = "ultr53o?n", the output should be "nortlu". Input/Output [input] string str A string consists of lowercase latin letters, digits and symbols. [output] a stri...
true
6ba82d6865debd93c3f36eb94a43e78161c50bac
JoNowakowska/CodeChallenges
/all_star_code_challenge.py
1,335
4.71875
5
""" This Kata is intended as a small challenge for my students Your family runs a shop and have just brought a Scrolling Text Machine (http://3.imimg.com/data3/RP/IP/MY-2369478/l-e-d-multicolour-text-board-250x250.jpg) to help get some more business. The scroller works by replacing the current text string with a simi...
true
f479715cb13228e0a0a3f68da5d39e613794efa9
Elonet/python3_formation_1
/square.py
664
4.3125
4
import argparse # From https://docs.python.org/fr/3/howto/argparse.html # Définition des arguments parser = argparse.ArgumentParser() parser.add_argument("square", type=int, help="display a square of a given number") parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2], help="increase output verbosit...
true
b687d5dcfa96c7d45d0e84b026a8f545ea119230
jerryzhu1/python_rice_coursera
/intro_pyrhon_1/1_Rock-paper-scissors-lizard-Spock.py
1,414
4.125
4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # by jerry_zhu #convert name to number def name_to_number(name): if name == "rock": number = 0 elif name == "Spock": number = 1 elif name == "paper": number = 2 elif name == "lizard": number = 3 elif name == "scissors...
true
695184a2034176dabc2c2936d94f7378ee8ec524
stefanlnt23/AE1-Time-Constrained-Assessment
/Block _1_Mini Assessment.py
1,845
4.21875
4
# TASK 1: # Requirements: # [1] The function should be named happy_thought and should have no parameters. # [2] The function should then display the message "What is your happy thought?" # [3] The function should then read in the user's response. # [4] The function should then display the message "Think about {t...
true
68b62e8ebe0121307cdb83a5151acb345a3b8c3b
sedje/100DaysOfPython
/day-26-nato_alphabet/main.py
491
4.1875
4
import pandas def main(): # Create a dictionary in this format {"A": "Alfa", "B": "Bravo", etc... } nato = pandas.read_csv("nato_phonetic_alphabet.csv") alphabet = {row.letter: row.code for (index, row) in nato.iterrows()} # Create a list of the phonetic code words from a word that the user inputs. ...
true