blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
23dac488a3aafd80fdef2c6a58aa3c74f2df51f3
Keremk98/Module-7
/Problem2CheckRange.py
750
4.40625
4
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> #Kerem Kok >>> #2/26/2021 >>> #Problem 2. Writing a Python function to check whether a number is in a given range. >>> def test_range(x): if ...
true
74df03e81ff8b1c939163798919b91bbc2bd3642
basketdump/ProjectEuler
/Problem_1.py
1,021
4.34375
4
''' Problem 1 of Project Euler -------------------------- If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' def get_multiples_below(factors, max_value): '''returns a list of ...
true
fb2cdf654204a59c02a34692dc8b4533c0259082
StanleyPangaruy/assignment_5
/Life_stages.py
642
4.25
4
# Program 3: Life stages # Create a program that ask for an age of a person # Display the life stage of the person. # Rules: # 0 - 12 : Kid # 13 - 17 : Teen # 18 : Debut # 19 above : Adult def lifeStage(): while True: try: age = int(input("Age: ")) except ValueError: print("...
true
67dea5ef3a999c1b27c8605c1ee126f56a34c103
arwagh/saudidevorg
/week6Challenge.py
466
4.34375
4
#Question 1: write a recursion to calculate 5^3 def my_func(n, a): if(a>0): result = n * my_func(n,a-1) print("result: {}".format(result)) else: result = 1 return result my_func(5,3) #Quesion 2: write a list that contains: -4, -6, -5, -1, 2, 3, 7, 9, 88. #Then write a lambda that...
true
d216f5f6742af8c11a6ad024e956eb38d10a0387
csraxll/wu-exercises
/ladder/util.py
671
4.28125
4
class LadderCalculator: """Utility class to make calculations about ladders""" @classmethod def calculate(cls, n): """Returns all possible combinations when climbing a ladder making 1 or 2 steps at time. Parameters: n (int):The number of steps that the ladder has. Returns: x(int):The...
true
fb99fa2f5b43c74e68d2bab6b2e22f2173ec93c9
kamuc2012/Session_6_to_12
/Session8/ProblemStatement3.py
597
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Write a python module script that contains fib2() method to calculate the Fibonacci series till 1000 and save it as fibo.py. Note : The module created as fibo.py has to be placed in lib folder For linux/ubuntu path = /home/anaconda/lib/python3 For Windows path = C:/U...
true
65c3c879c09670d21cdb38ea62de7fff5e03b9ab
kikeobayemi/MyCodioActivities
/conditionals exercise 5.py
420
4.40625
4
#Problem #Use the variable x as you write this program. x will represent a string. #Write a program that determines if x is a vowel (a, e, i, o, and u ). #If yes, print _ is a vowel, where the blank is the value of x. #If no, print _ is not a vowel, where the blank is the value of x. x = "e" if x == "a" or x == "e"...
true
98ec3b53dc71b018622afdf339bf5b31a02245fb
kikeobayemi/MyCodioActivities
/while loop exercise.py
405
4.1875
4
#Using while True:, create a loop that prints the sum of all the numbers between 0 and 100. #Note: the sum should include the number 100. #mycode #sum1 = 0 #counter = 1 #while True: # sum1 = sum1 + counter #counter = counter + 1 #print(sum1) #if counter == 100: # break total = 0 count = 0 while True: if...
true
06e103f674ef31d40a29f20a6441e608f7b03754
alejandrolgarcia/bases-python
/basic/tuples.py
1,044
4.46875
4
# Python Tuple # create a tuple tuple1 = ("Batman", "Superman", "WonderWoman", "Flash", "Aquaman", "Cybord", "Green Lantern") print(tuple1) # access tuple items print(tuple1[1]) # Superman # negative indexing print(tuple1[-1]) # Green Lantern # range of indexes print(tuple1[2:5]) # ('WonderWoman', 'Flash', 'A...
true
28d09f409689b7fc8943f443aaed84f7748773b8
sourabhjoshi220/Python-Basic-Programs
/Even_Odd0to100.py
246
4.15625
4
num1=int(input("Enter your choice to start")) num2=int(input("Enter the Ending Number")) for i in range(num1, num2+1): if(i%2==0): print("The number is Even Number:",i) else: print("Number is Odd:",i)
true
55a9b147082648de5eaba0f34a53045c62422dee
connormullett/week_2_challenge_solutions
/challenge_8.py
1,073
4.1875
4
# - Open the file below, and parse the document into a list of each item. # - Create a class that the data above could be further parsed into, and create a list of the class instances. (first name, last name, age, hobby) # The class should have an introduction method that returns the string below. # "(NAME) is (AGE) y...
true
b5da30eca7667a733d0fca714823864abbdf280b
gauravssnl/interview-preparation
/python/Elements of Programming Interviews in Python/primitive_types/parity_bruteforce.py
542
4.1875
4
# Computing the parity of the word. # The parity of a binary word is 1 if the number of 1s in the word is odd; # otherwise, it is 0 # Time Complexity : O(n) def parity(x): result = 0 # store count of 1's in the number while x: result ^= x & 1 x >>= 1 return result if __name__ == "__main__...
true
03ee14dd5dcecab01afcef6b21fa05dd9876f9ce
abdullahmehboob20s/Python-learning
/chapter-11-inheritance/6-class-methods.py
782
4.125
4
import os os.system("cls") class Employee: company = "Google" salary = 100 location = "Karachi" # it will not change the actual "salary" attribute above "location" # instead, it will make another instance attribute of "salary" and change that def changeSalary0(self, sal): self.salary...
true
6fcea48ab2531aca15c2749387bf1eea034036c8
kikunij/datastructureshomework
/Joachim Kikuni.Lab01/JoachimKikuni_Reading files.py
429
4.1875
4
#Joachim Kikuni #Write a python program that asks the user to enter the name of a text file, then produces a text file with the same content but line numbers added to the beginning of each line. def main(): file = open(input("enter the name of a text file:")) text = file.readlines() lineNumber = 1 ...
true
d65f5636102df239befc22484d41ef23b940b95e
arsamigullin/problem_solving_python
/leet/microsoft/strings_and_arrays/missing_number.py
2,113
4.21875
4
import typing List = typing.List class Solution: ''' NOTE: this recursion def find(n): if n==0: return 0 return n+find(n-1) is the same as len(nums)*(len(nums)+1)//2 - this is Gaussian formula ''' def missingNumber(self, nums: List[int]...
true
a2a414a9c1cbc9b4b43768a6e936e4282d174a3f
arsamigullin/problem_solving_python
/leet/Combinatorics/828_Count_Unique_Characters_of_All_Substrings_of_a_Given_String.py
991
4.15625
4
import string ''' The idea is to count substrings where a particular char is unique for examples, XAXXAXBAZ let's count how many substrings exists where char A is unique We can put ) somewhere between first and the second A and then somewhere between the second A and third A. The total substrings count is (i-j)*(j-k) ...
true
9de0fbf2020936526c62b5f9df51840b3c0aad39
arsamigullin/problem_solving_python
/leet/graphs/flower_planting_with_no_adjacent.py
1,312
4.1875
4
#https://leetcode.com/problems/flower-planting-with-no-adjacent/ # Important conditions: # paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y. # each flower connected no more that with 3 flowers # we have only 4 types of flowers # Algo: # 1. convert the input in adjacency-list r...
true
a3fed6bf11a7280b246e8065b0a9795872113580
arsamigullin/problem_solving_python
/leet/microsoft/strings_and_arrays/single_element_sorted_array.py
1,154
4.125
4
import typing List = typing.List # Observation # once the single is met all the pairs the pairs are starting from odd index # all pairs of numbers till 3 are starting from even indexes # starting from 4 the pairs are starting from odd (5) # [ 1, 1, 2, 2, 3, 4, 4, 8, 8] - nums # [ 0, 1, 2, 3, 4, 5, 6, 7, 8] - indexes ...
true
d6675374eaf8b12f0b43a6116932e490a009cb72
arsamigullin/problem_solving_python
/learning_material/GraphAlgorithms/TopologicalSort/TarjanAlgorithm.py
2,908
4.34375
4
# TOPOLOGICAL-SORT.G/ # 1 call DFS.G/ to compute finishing times u.f for each vertex u # 2 as each vertex is finished, insert it onto the front of a linked list # 3 return the linked list of vertices # NOTE: this algo does not detect the cycle # Python program to print topological sorting of a DAG import collections f...
true
da4d939605bfd8f9b57b1ffe32491b0ca4ad4a31
niel-Da/Practice-Python
/Practice_Python/exercise9.py
862
4.125
4
#Exercise9 #import the randint submodule from random from random import randint #assign random number to a variable called number number = randint(1,9) #initialze the variable guess and count to 0 guess = 0 count = 0 #check for while loop condition while guess != number and guess != "exit": #assign user input ...
true
7ffd3afe47c1752ad8205faa1a6ee76b191eeff6
niel-Da/Practice-Python
/Practice_Python/exercise15.py
615
4.4375
4
# Write a function that asks the user for a string containing multiple words. Print ## back to the user the same string, except with the words in backwards order. #ask user for long string a = input('Enter a long string or sentence: ') #define your function def reverse_String(a): #split long sting by whitesp...
true
d7294a5e645da9e6e45f9d5dc3db55fd91bff4a1
artembigdata/home_work_7.12.2020
/home_work_7.12.2020_6_athlete running.py
217
4.1875
4
a = float(2) max = 0 num = float(a) day = int(1) while num <= 3: num = num * 1.1 day = day + 1 print(day,"-й день:","{:.2f}".format(num)) print("will be more 3 kilometers in", day, "days")
true
2be317901fda76ef15c89bd9135dbeda8a86db99
FoothillCSClub/PythonWorkshop
/cheatsheet.py
2,750
4.46875
4
# Python cheet sheet for Samuel and Kishan's python workshop # Don't try to run this file; you'll just get a lot of undefined # variable errors # define variable a to be 5 a = 5 # define variable b to be the string: Hello World! b = "Hello World!" # print(...) prints whatever is inside the parenthesis to the consol...
true
fb26d5f7563c26ab8447365a72a8540885b06f7e
paschok/nltk
/supervised_classification.py
1,243
4.15625
4
import nltk import random from nltk.corpus import names from nltk.classify import apply_features # We start by just looking at the final letter of a given name. # The following feature extractor function builds a dictionary containing relevant information about a given name: def gender_features(word): return {'la...
true
3d22b208435a4b6ed5fd33885596d2331505ca6d
abimohaninibm/sdet
/python/Activity10.py
263
4.21875
4
#Given a tuple of numbers, iterate through it and print only those numbers which are divisible by 5 tup=tuple(input("Enter the items in tuple : ").split(",")) print("Numbers divisible by 5 are : ") for i in tup: if (int(i) % 5 == 0): print(i)
true
d054904bd73b6603ead64e6f78d5a56cc577ea8f
abimohaninibm/sdet
/python/Activity13.py
221
4.15625
4
def sum(numbers): sum=0 for num in numbers: sum+=int(num) return sum numbers=input("Enter the numbers delimitted with , : ").split(",") print("The sum of list of elements are :",sum(numbers))
true
54876490087c812d4adfc55f8448c2469033402d
zhangjoshua/DateCalculator
/DateCalculator.py
1,796
4.21875
4
# Given your birthday and the current date, calculate your age # in days. Compensate for leap days. Assume that the birthday # and current date are correct dates (and no time travel). # Simply put, if you were born 1 Jan 2012 and todays date is # 2 Jan 2012 you are 1 day old. # IMPORTANT: You don't need to solve t...
true
55287af726f4dadc0f33f797cd1bd8d899579a7b
Love-Kush-Tak/Automating-boring-stuff-with-python
/isPhoneNumber check phone number.py
1,238
4.125
4
def isPhoneNumber(text): if len(text)!= 12: return False for i in range(3): if not text[i].isdecimal(): return False if text[3] != '-': return False for i in range(4,7): if not text[i].isdecimal(): return False if text[7] != '-': ...
true
de73671c1d38278744d65af0435f28cc0e595fd3
Anancha/Hands-on-Supervised-Learning-With-Python
/Chapter01/Code_Files/fibbonacci.py
412
4.15625
4
num_terms = input("Enter the number of terms") n = int(num_terms) a = 0 #First Term b = 1 #Second Term i = 0 if(n <= 0): print("Please enter a valid number of terms") if(n==1): print("Fibonacci series",a) else: print("Fibonacci sequence upto",n,":") while i < n: print(a,end=' ') nex...
true
09a214f8c13e2e6b8747ff074c53cfe35124d9b5
anonimato404/hacker-rank-python
/easy/08_find_maximum_depth_xml.py
667
4.28125
4
""" You are given a valid XML document, and you have to print the maximum level of nesting in it. Take the depth of the root as 0. Input Format The first line contains N, the number of lines in the XML document. The next N lines follow containing the XML document. """ import xml.etree.ElementTree as etree def dept...
true
adaef1c5fa52ff511685b6041c063eb863768e03
anonimato404/hacker-rank-python
/easy/04_arithmetic.py
443
4.375
4
""" The provided code stub reads two integers from STDIN,"a" and "b". Add code to print three lines where: The first line contains the sum of the two numbers. The second line contains the difference of the two numbers (first - second). The third line contains the product of the two numbers. """ def format_arithmetic...
true
7067269d642682d4a1ae321042991028726294fa
anonimato404/hacker-rank-python
/exams/03_string_representation_of_objects.py
666
4.1875
4
""" Implement two vehicle classes: - Car and Boat """ class Car: def __init__(self, maximum_speed, notation_units): self.maximum_speed = maximum_speed self.notation_units = notation_units def __str__(self): return ( f"Car with the maximum speed of {self.maximum_speed} ...
true
6448b728ae0162089b2c851fc76f6167f6d13a1c
darkmark1991/DailyCodingProblem
/2019/02/09/CarCdr.py
722
4.5
4
# Basically what cons does is return a function (pair) # that takes an argument function (f) and returns f(a, b) def cons(a, b): def pair(f): return f(a, b) return pair # In order to get the first element # we define function that takes two arguments and returns the first one # and pass it to the p...
true
dad7ecd7aae26a83d4639db569dd29360804319d
fran96/LearnPythonTheHardWay
/ex8.py
787
4.625
5
formatter = "{} {} {} {}" '''formatter.format --> Tells python to: 1. Take the formatter string defined above, 2. Call its format function 3. Pass to format 4 args which match up with the 4 {} in the formatter variable. (like passing args to the format func) 4. The result of...
true
3f540ff23584b5c00953d4a5d2cf7bd97ecb89a8
gr1d99/samplecodes
/SampleLists/MyList.py
2,180
4.5
4
class MyList: """ a simple class that allows you to manipulate lists. Usage: l = MyList() l.add_items(1,2,3) all functions defined in this class are self explanatory. """ def __init__(self): self.items = [] def add_items(self, *items): """ items are added ...
true
6460a0a7d91e352a50cabb159c837c5162d03f33
eshulok/8.-Conditional-Code
/main.py
1,060
4.46875
4
#We can use "if statements" to run code based on specific conditions temperature = 80 #The print statement will only print if the temperature value is greater than 75 if temperature > 75: print ('It is time to go to the beach!') #When we use an if statement, we put a colon at the end, and then all of the lines that ...
true
d90c750f96918fc71afde1d628c1b4a0f6d87406
Parneetkaur2000/100DaysOfCode
/day27.py
902
4.46875
4
Given a string s. Return all the words vertically in the same order in which they appear in s. Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed). Each word would be put on only one column and that in one column there will be only one word. Example 1: Inpu...
true
e37483fda88a858c2727eb7618bee653c057e50d
Rudra30/NUmber-Guessing-Game
/guess.py
609
4.25
4
import random print("Number Guessing Game") Number = random.randint(1,9) chances = 0 print("Guess a Number between 1 and 9: ") while chances < 5 : guess = int(input("Enter Your Guess: ")) if guess == Number: print("COnGraTuLaTioNS! You Won") break elif guess < Number: ...
true
ca21406a39999e5e34d727ef05aef0892ec6b4d6
kaskaczmarczyk/python
/simple_calculator_ver2.py
891
4.1875
4
import sys signs = ('+', '-', '*', '/') def calculate(): a = input("Enter a number (or a letter to exit): ") if a.isdigit(): a = int(a) elif a.isalpha(): sys.exit() sign = input("Enter an operation: ") while sign not in signs: break b = input("Enter ano...
true
f8bda8b100b9472e7178dbecf2b8e0a9496beb56
Stephen-Kamau/july_work
/form_entry_GUI_app/temp_analyser.py
759
4.1875
4
#It takes temperature recording for a particular period of time and draw a line graph for it #inputs of temp from the user are stored in list #lets start import matplotlib.pyplot as pt import numpy as np def get_Input(): temp=[] try: x=int(input("Enter the number of days you wish to entee\n \ their te...
true
f143af6c7d58609ccc917bb484a6e3ea6e784b3f
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202012/20201222_balanced_binary_tree/balanced_binary_tree.py
1,476
4.125
4
""" Title: Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the left and right subtrees of every node differ in height by no more than 1. Example 1: Input: root = [3,9,20,null,null,15,7] Output:...
true
cd4d0331b8c0a7b2cd0d6eb99ab5b3c89b49be78
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202009/20200917_robot_bounded_in_circle/robot_bounded_in_circle.py
2,137
4.15625
4
""" Title: Robot Bounded In Circle On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 degress to the right. The robot performs the instructions given in order, and repeats t...
true
e2bda42be4f1f5788d93d46c08f0eb9e430065fe
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202011/20201104_minimum_height_trees/minimum_height_trees.py
2,206
4.125
4
""" Title: Minimum Height Trees A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes labelled from 0 to n - 1, and an array of n - 1 edges where edges[i] = [ai, bi] indicates that there ...
true
7163afd8bf16fe3fd75b4adbf3f08d3ad6df6c18
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202008/20200827_find_right_interval/find_right_interval.py
2,712
4.125
4
""" Title: Find Right Interval Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on the "right" of i. For any interval i, you need to store the minimum interval j's inde...
true
9ea2e5d649ab443a72b86b877d792c13b02f2505
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202012/20201210_valid_mountain_array/valid_mountain_array_solution_1.py
2,393
4.21875
4
""" Title: Valid Mountain Array 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: 1) arr.length >= 3 2) There exists some i with 0 < i < arr.length - 1 such that: a) arr[0] < arr[1] < ... < arr[i - 1] < A[i] b) arr[i]...
true
a09e824e88171b59740c7fff85f20be8e66c2d89
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202012/20201206_populating_next_right_pointers_in_each_node_ii/populating_next_right_pointers_in_each_node_ii.py
2,543
4.125
4
""" Title: Populating Next Right Pointers in Each Node II Given a binary tree struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all next pointers are s...
true
405a237a269058b320fec68bc0c44f655639f69d
arivolispark/datastructuresandalgorithms
/leetcode/30_day_leetcoding_challenge/202006/20200628_reconstruct_itinerary/reconstruct_itenarary.py
2,914
4.375
4
""" Title: Reconstruct Itinerary 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: 1) If there are multiple valid itineraries, ...
true
90a527a53b2138c1d7b6113efaf1f973909e10aa
harithaasheesh/mypythonrepo
/work/min_max_even.py
283
4.125
4
min=int(input("enter a minimum range value")) max=int(input("enter a maximum range value")) # for i in range(min,max+1,2): # print(i) # for i in range(min,max+1): # if i%2==0: # print(i) #using while loop while min<=max: if min%2==0: print(min) min+=1
true
7257b92cc80d7e3fcc9b1874337313d4c7ecff8e
harithaasheesh/mypythonrepo
/fuction/sumof_n_fucn.py
524
4.1875
4
# fuction with argument # def sum(num): # i=0 # add=0 # for i in range(1,num+1): # add=add+i # print("sum=",add) # sum(3) #fuction without argument # def sum(): # num=int(input("enter a number")) # i=0 # add=0 # for i in range(1,num+1): # add=add+i # print("sum=",ad...
true
10c984956e18145217e12dcac6a93223ad606cd3
tochukwuokafor/my_chapter_7_solution_gaddis_book_python
/file_line_viewer.py
837
4.40625
4
# use the file_line_viewer.txt to practise this piece of code def main(): try: enter_file_name = input('Please enter the file name: ') except IOError: print('The filename cannot be found or opened.') opened_file = open(enter_file_name, 'r') read_into_list = [] for line in opened_fil...
true
eea087550c04c4d2745300780445d511c7957430
icidicf/python
/online_coding/string/reverseOrderingOfWords.py
521
4.125
4
#!/usr/bin/python import sys import re if (len(sys.argv) < 2): print "please enter input test string"; sys.exit(0); inputStr=sys.argv[1]; #version 1 #tempStr=inputStr.split(" "); tempStr=re.split('\s+',inputStr); tempResult=[]; outStr=""; for i in tempStr: part=i[::-1]; tempResult.append(part); outStr=" ".join(...
true
cae465e39bdd88ae3b3c5f5199285c115e5ac3b5
zbfjk/pytorch_learn
/optim.py
1,871
4.28125
4
import torch import math from torch.nn.modules import linear #create tensors to hold input and outputs x = torch.linspace(-math.pi,math.pi,2000) y=torch.sin(x) #prepare the input tensor (x,x^2,x^3) p=torch.tensor([1,2,3]) xx=x.unsqueeze(-1).pow(p) #use the nn package to define our model and loss functi...
true
c350da846d84f414a480859cde63b0017c462bf8
thitimon171143/MyPython
/midterm 2562-1/boolean-ex.py
447
4.1875
4
test = input('Enter a string: ') print('This is what I found about that string:') if test.isalnum() : print('The string is alphanumeric.') if test.isalpha() : print('The string contains only alphabetic characters.') if test.islower() : print('The letter in the string are all lowercase.') if test.isnumeric(...
true
4f0c3bc10011d1ace9d38be471cfaaca237126c1
nibukdk/PyProjects
/Python Proejcts/SImple Problems/CalculatorInvalidChecker.py
2,174
4.21875
4
import math def main(): print('Calculator'); calculation(); def inputCheck(): canContinue = True; while canContinue: inpt1 = input('Give a number:') num = 0; try: num = int(inpt1); '''try: inpt2=input('Give a number:') n...
true
f473bf030f2c53141a105eeb5b4ee0f7b7c5f971
TechSoc-MSIT/DS-ALGO-REPO-HACKTOBER
/python/stack.py
875
4.125
4
class Queue: def __init__(self): self.list = [] def push(self,item): self.list.append(item) print(item+" pushed to Stack") def pop(self): print(len(self.list)) if(len(self.list)==0): print("Stack is Empty") else: print(self.list[len(self.list)-1]+" popped from Stack") self.list.pop() def ...
true
99ba2b479617f8b3820977a3493e6354f16dd5ad
akozyreva/python-learning
/6-methods-functions/6.4-pick-evens.py
303
4.40625
4
# Define a function that takes in an arbitrary number of arguments, and returns a # containing only those arguments that are even. def even_func(*args): mylist = [] for i in args: print(i) if not(i%2): mylist.append(i) return mylist print(even_func(1,2,4,5,6))
true
2972338cf1f4e5d150440fd6cb99940785e8344c
akozyreva/python-learning
/14-capstone-proj/classical-algorithms/bubble-sort.py
887
4.15625
4
import random # let's create generator for list sorting def create_random_list(low, high): len = high - low for x in range(len): yield random.randint(low, high * low) alist = list(create_random_list(2, 7)) def bubbleSort(alist): for passnum in range(len(alist)-1, 0, -1): print("Begin o...
true
2e2b9495a47c50319a65062def8436fcd0be0e02
akozyreva/python-learning
/3-basics/3.5-sets.py
338
4.21875
4
# sets - it's unordered collection of the unique items you want mySet = set() mySet.add(1) mySet.add(2) print(mySet) # it doesn't make sense, because we still have {1, 2}, so it will be ignored mySet.add(2) mylist = [1,1,1,1,1,2,2,2] # shows only unique values! print(set(mylist)) # it also works with strings print(se...
true
090ed27d2ac8961286d329679d94898e753e8056
akozyreva/python-learning
/6-methods-functions/6.9-function-assessment2.py
2,506
4.1875
4
import math import string # Write a function that computes the volume of a sphere given its radius. def vol(rad): return rad ** 3 * math.pi * 4 / 3 print(vol(2)) # Write a function that checks whether # a number is in a given range (inclusive of high and low) def ran_check(num,low,high): return low < num < hi...
true
e2365a8f66459779d401b4e5dcc80c1cbdaa8622
AlexanderIvanofff/Python-Fundamentals
/regular expressions/HTML_parser.py
1,306
4.375
4
""" Write a program that extracts a title of a HTML file and all the content in its body. When you do that print the result in the following format: "Title: {extracted title}" "Content: {extracted content}" The content should be a single string. There might be different tags inside of the body, which you must ignore. Y...
true
d0e00d1b05fca93d3153210a907b5e01c18b6552
elmspace/PracticeQuestions
/Permutations_of_a_String.py
1,961
4.1875
4
""" In this problem, we want to write a function which will take a string and will pring all possible permutations of it. Example: String = abc Output: abc, bac, bca, cba, cab, acb. The number of permutation is N!, where N is the number of characters in the string. """ """ This class contains the method, which wi...
true
0a3e36299c1dfad6202e051e9854c72fa7238123
elmspace/PracticeQuestions
/Doubly_Linked_List_Implementation.py
1,576
4.25
4
""" In this code, we will be implementing a doubly link list. It will going to have a head and tail pointer. This problem is meant to simply play around with doubly linked-lists. """ class DNode: def __init__(self, input_Data): self.Data = input_Data; self.Next = None; self.Prev = None; class DLinkedList:...
true
f25c694a61676d21f05c1064d1599b098f702ad4
weesiau/exam
/sort.py
1,055
4.21875
4
unsorted = [4,1,6,8,3,5,2,7] def bubblesort(array): swapped = True while swapped: swapped = False for i in range(len(array)-1): if array[i] > array[i+1]: array[i],array[i+1] = array[i+1],array[i] swapped = True return array def insert...
true
bcf3a309a22d0a0fef69874d3985f6a5b44744b0
standroidbeta/Intro-Python-I
/src/14_cal.py
1,546
4.5
4
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py month [year]` and does the following: - If the user doesn't specify any input, your program should ...
true
4cd96e7d9ecfe6917d715f6b221707417aa5c813
Gayathri547/Day1
/Basics/fn&ln_reverse_list.py
265
4.1875
4
fn=input("enter your first name\n") cfn=list(fn) print(cfn) ln=input("enter your last name\n") cln=list(ln) print(cln) ''' for i in cfn: cln.append(i) print("your name is ",cln) ''' for j in cfn: cln.append(j) print("your name in reverse order is",cln)
true
70f484cc8fd9504bb6e6e8788de69baa8b60927b
Vedvyas-Kalupnath/Python-projects
/ASCII.py
217
4.28125
4
print("Find Value of a specific character in ASCII") print("") a = str(input("Enter a single character: ")) # print the ASCII value of assigned character in c print("The ASCII value of '" + a + "' is", ord(a))
true
f1a8f132bb5e06405c4a1087f785e5a707ad1375
Vedvyas-Kalupnath/Python-projects
/Question5.py
683
4.125
4
# function definition for hcf def hcf(num1, num2): # comparison num1 with num2 if num1 > num2: # if num 1 > num 2, smaller is assigned value of num 2 smaller = num2 #if num 1 not > num 2, smaller is assigned value of num 1 else: smaller = num1 #range check: # if num modulo i =0...
true
b2f3da4aae47fa4cdc6b6206283a619ebbb620e9
wgalbreath/wgalbreath.github.io
/week_02/notes_monday_sec2.py
2,500
4.375
4
''' this is a triple quote (everything after should get ignored) # anything that begins with a # is a comment # comments are code that doesn't get executed print('hello world') print('goodbye world') var1 = 'hello' var2 = 'world' var3 = var1 + ' ' + var2 print (var3) # for integers, python is always going to give y...
true
c172b1a8b75a4371f216e5418c45eb89e183df99
jamestiotio/pns
/extras/gauss.py
1,533
4.28125
4
# Naive Implementation of SUTD ISTD 2021 50.034 Introduction to Probability and Statistics Midterm Exam Final Question # Created by James Raphael Tiovalen (2021) import numpy as np import matplotlib.pyplot as plt rng = np.random.default_rng() LAMBDA = rng.uniform(0, 1) N = 1_000_000 DATA_POINTS = 1_000_000 BINS = 20...
true
ab357bf50ce31a8f1b1551dc519c73ca97aabf3d
GarbyX/Python-Projects
/Rolling the dices.py
388
4.125
4
import random min = 1 max = 6 roll_again = "yes" while not (roll_again != "yes" and not (roll_again == "y")): print("Rolling the dices...") print("The values are....") print(random.randint(min, max)) print(random.randint(min, max)) roll_again = input("Roll the dices again?") myInst...
true
c742980c7fd10f9ce239660d0c42d4a767a88291
picardcharlie/python-201
/02_more-datatypes/02_20_stay_positive.py
263
4.3125
4
# Use a list comprehension to create a list called `positive` from the list # `numbers` that contains only the positive numbers from the provided list. numbers = [5, -8, 3, 10, -19, -22, 44, 2, -1, 4, 42] positive = [y for y in numbers if y > 0] print(positive)
true
527de3699ba2d8466431a86aaaca353f06f24c7a
picardcharlie/python-201
/02_more-datatypes/02_18_advanced_sorting.py
734
4.625
5
# CHALLENGE: Write a script that sorts a dictionary into a # list of tuples based on the dictionary's values. For example: # input_dict = {"item1": 5, "item2": 6, "item3": 1} # result_list = [("item3", 1), ("item1", 5), ("item2", 6)] # Check out the Python docs and see whether you can come up with a solution, # even ...
true
40a0d27f2f34cea04c04845b36e1383c3a884753
sarahlevins/automate-the-boring-python
/chapter-seven/question21.py
905
4.53125
5
# How would you write a regex that matches the full name of someone whose last name is Watanabe? You can assume that the first name that comes before it will always be one word that begins with a capital letter. The regex must match the following: # 'Haruto Watanabe' # 'Alice Watanabe' # 'RoboCop Watanabe' # but not th...
true
66d85ced36843b84ba370c44c0a5f4844a4ea28b
renishb10/ds_algorithm_python
/DS_Python/linkedlist/linkedlist.py
2,011
4.3125
4
class Node(object): #constructor in python def __init__(self, data): self.data = data self.nextNode = None class LinkedList(object): def __init__(self): self.head = None self.size = 0 # Complexity O(1) def insertAtStart(self, data): self.size = self.size +...
true
44e4d1f0ee53230a2551d17d3c45a6c93a36c922
ebarbs/p4e
/Course 3/Course3_Week6.py
2,138
4.34375
4
# Welcome Eric Barbieri from Using Python to Access Web Data # # Extracting Data from JSON # # In this assignment you will write a Python program somewhat similar to # http://www.py4e.com/code3/json2.py. The program will prompt for a URL, # read the JSON data from that URL using urllib and then parse and extract # the ...
true
b0def32576b1f24441388739b2e1a5d5a4e75358
Griffinw15/cs-module-project-algorithms
/inclass/single_number.py
1,681
4.125
4
''' Input: a List of integers where every int except one shows up twice Returns: an integer ''' def single_number(arr): # O(n^2) runtime # is this the best we can do? # how do we get rid of one of the for loops? # when looping through the elements, let's count how many times # they occur # ...
true
783bbe331002fe135ac7975b2cf617859853cf30
Rohanvasista/Coding-activities
/JUNE-11/program1.py
523
4.15625
4
problem statement: Python program to check whether the given number is fibonacci or not solution: def fib(n): if(n == 0): return 0 elif(n == 1): return 1 else: return (fib(n - 2) + fib(n - 1)) n = 20 a = [fib(i) for i in range(n)] z = int(input("Enter the number\n")) if z ...
true
0128fad9d8282f0537327259d15b17d85eac180b
Rohanvasista/Coding-activities
/JUNE-10/p2.py
364
4.34375
4
problem statement: Python program to find number of even and odd numbers solution: tuple = (1,2,3,4,5,6,7) c,c1=0,0 for i in tuple: if(i%2==0): c = c+1 else: c1 = c1+1 print("The count of even numbers is : ",c) print("The count of odd numbers is : ",c1) Output: The count of even numbers...
true
73c607da94c719efb97716cc67e473d5de61fcf4
XianYX/Python-
/2013-10-9/三角2.py
2,720
4.34375
4
# -*- coding: utf-8 -*- """ Spyder Editor python 2.7 This program is for computing the angle of the triangle It's made by Duan Yi. Student number:1130310226 E-mail:yumendy@163.com version:1.1 date:2013年10月11日 21:22:04 """ #import the necessary function from math import sqrt from math import acos from math import degree...
true
7b3c0736ad7f9acbe84ef1fe2ea766514479698d
Holgermueller/python_sandbox-master
/python_sandbox_starter/strings.py
515
4.3125
4
# Strings in python are surrounded by either single or double quotation marks. Let's look at string formatting and some string methods name = 'Holger' age = 43 # Concatenate #print('Hello, my name is ' + name + ' and I am ' + str(age)) # String Formatting # Arg by position #print('My name is {name} and I am {age}'....
true
ab6b89783607954a8397ec99dd7562a955d4b7d7
ravikiransharvirala/coding-problems
/test_sep09_pb3.py
986
4.28125
4
''' Example 1: Input: "the sky is blue" Output: "blue is sky the" Example 2: Input: " hello world! " Output: "world! hello" Explanation: Your reversed string should not contain leading or trailing spaces. Example 3: Input: "a good example" Output: "example good a" Explanation: You need to reduce multiple spaces ...
true
5e1f9fbccc2804ea37e62fe94c9860c77de96f9a
meghasawant/Python-programming
/list/fibonacci_list.py
601
4.28125
4
#********** Program to return list of number which appeared in fibonacci series. def fibonacci(data): result = [] upper_bound = max(data) f1,f2,f3 = 0,1,1 result.append(f1) for i in range(0,upper_bound): while(f3 <= upper_bound): result.append(f3) f3 = f1 + f2 f1,f2 = f2,f3 i=0 result1 = [] whil...
true
23fccc7e26a37814a22b5fd8a21c279d35faf7c7
lj020326/project-euler
/problem4.py
514
4.21875
4
''' A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' def is_palindrome(number): return str(number) == str(number)[::-1] largest_palindrome = 0 fo...
true
e59dec05265a57e074a6129283faa6fd41e318ac
hadahash/projecteuler
/problem1/prob1.py
401
4.1875
4
#!/usr/bin/python # author: hadahash # Project Euler Problem 1 # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. # hadahash@ubuntu:~$ python prob1.py sumof = 0 for i in range(0,...
true
19554d915c5ae4ec00388af76e63510be586e952
Ruchir-Verma/PythonPractice
/UserInput.py
647
4.125
4
''' To get the input from the user , we have to use input() function . ''' x = input('Enter 1st number') y = input('Enter 2nd Number') z = x+y print(z) # It will print xy(in the form of string) ''' To get the sum , we have to provide the data type with input function as follows : ''' x = int(input('Enter 1st n...
true
68b3929b408607bac596471239b9622e0d830b8f
Ruchir-Verma/PythonPractice
/Multithreading.py
1,807
4.59375
5
''' A process can be divide into smaller units called Threads,which is an independent part of execution. Multitasking : At one point we can run multiple apps(E.g MS Word, VLC ,etc at the same time).They do not actually run simultaneously, but CPU schedule the time in such a way that it seems that they are running tog...
true
3292e746d2b8174a26a0c1be2cbc0c25709d00ec
gaebar/python-by-example-exercises
/exercises/intro/maths/challenge_034.py
535
4.125
4
# Challenge 034 print(""" 1) Square 2) Triangle """) num = (int(input("Enter a number: "))) if num == 1: square = int(input("Provide the length of one of the square sides: ")) area = square * square print("The area of your square is", area) elif num == 2: base = int(input("Provide the base of the trian...
true
641cfd9181383d86ce4c1fdf50b2ca4d75dc3d69
gaebar/python-by-example-exercises
/exercises/tuples_lists_dictionaries/challenge_070.py
1,342
4.34375
4
# TUPLES, LISTS AND DICTIONARIES # Challenge 070 """ 70: Add to program 069 to ask the user a number and display the country in that position. """ country_names = ( "England", "Italy", "Spain", "France", "Portugal", "Germany", "Ukraine", "USA", "Norway", "Sweden", "Austria"...
true
04e6cfee502dfe25e56375f39a01f75556b17ac1
gaebar/python-by-example-exercises
/exercises/intro/maths/challenge_032.py
223
4.1875
4
# Challenge 032 import math radius = int(input("Enter the radius of a circle: ")) depth = int(input("Enter the depth of a cylinder: ")) area = math.pi * (radius**2) total_volume = area * depth print(round(total_volume, 3))
true
c458cbd715269dfdc13f1a21f6e93764e4577336
gaebar/python-by-example-exercises
/exercises/subprograms/challenge_118.py
491
4.21875
4
""" Define a subprogram that will ask the user to enter a number and save it as the variable “num”. Define another subprogram that will use “num” and count from 1 to that number. """ def ask_for_number(): num = int(input("Please, give me a number: ")) return num def count_number(num): for count in...
true
0cfd500187e8c8e241baf9efa5292172a47ea60c
gaebar/python-by-example-exercises
/exercises/reading_and_writing_from_a_text_file/challenge_109.py
1,343
4.75
5
""" Display the following menu to the user: 1) Create a new life 2) Display the file 3) Add a new item to the file. Make a selection 1, 2 or 3: Ask the user to enter 1, 2 or 3. If they select anything other than 1, 2 or 3 it should display a suitable error message. If they select 1, ask the user to enter a scho...
true
594dd2353a6b6108aedcfc2663d066fcf0993874
l-Chris-l/Exercism
/high_scores.py
541
4.21875
4
highScores = [] addingScores = '' while addingScores.lower() != 'no': scores = input('Please enter a high score: ') highScores.append(scores) addingScores = input('Would you like to add another? ') def highestScore(): highest = max(highScores) print('The highest score is ' + highest) def lastAdde...
true
1f1e852c5be2b1e8673d345e0eaa879dea66478e
hemalatha-20/test
/pyramid4.py
322
4.28125
4
rows = int(input("Enter the number of rows: ")) k = 2 * rows - 2 # Outer loop in reverse order for i in range(rows, -2, -2): # Inner loop will print the number of space. for j in range(k, 0, -1): print(end=" ") k = k + 1 for j in range(0, i + 1): print("*", end=" ") print("...
true
14c585fc3314373ead9b227a190d10678a8e9111
rsingh2020/Rahul_Singh_Consultadd_Training_Task1
/read_csv.py
749
4.1875
4
""" As a Developer, You need to write a python program file “read_csv.py” in which you need to write a function that reads the given CSV file “Task_Training_Data.csv”, fetch the data and only return the Name and Email of all the entries. """ # Step 1: import csv with open('/Users/rahul/PycharmProjects/practice/Task_Tr...
true
50af0d849eda032ac141611ce462d217f9a9e746
Anvitha-15/Virtual-Coffee-Machine
/main.py
2,846
4.40625
4
from data import MENU from logo import logo resources = { "water": 300, "milk": 200, "coffee": 100, } # TODO: 1 Ask user, what would they like to have or current report of resources in a repeated manner! is_machine_on = True profit = 0 def is_resource_sufficient(order_ingredients): # argu...
true
030a529e60a72d1fee946f8cb89e1fbca09b7011
zenvin/PythonCrashCourse
/PART 1/chapter_6/user.py
1,093
4.84375
5
#Looping through a dictionary #python lets you loop through a dictionary. Dictionaries can be used to loop #through information in a variety of ways; therefore, several ways to loop through #them. You can loop through all of a dictionary's key value pairs, through its keys, #or through its value. #Looping through all...
true
80be6475813925146234c836a670fa3cf812238f
zenvin/PythonCrashCourse
/PART 1/chapter_6/polling.py
537
4.1875
4
favorite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } #make a list of people who should have take the favorite language poll: taken_poll = ['jen', 'ryeker', 'kevin', 'phil'] #loop through the list. Print a thank you to people that have taken the poll #and tell those that ha...
true
09acc6f9e700d41555778661825b39d00ce2f488
zenvin/PythonCrashCourse
/PART 1/chapter_1/hello_world.py
1,085
4.15625
4
{ "cmd": ["python3", "-u" "$file"], } #creating a variable message = "Hello Python World!" print(message) #creating the variable again to see what will be printed message = "Hello Python Crash Course world!" print(message) #the message variable is updated and will print the second message. #You can change the value...
true
8741449845604838331fbb00531d700db5d4a934
zenvin/PythonCrashCourse
/PART 1/chapter_4/pizzas.py
629
4.71875
5
#think of at least three kinds of pizzas. Store them into a list and then use a for loop to print the name of each pizza pizzas = ["pepperoni", "chesse", "Meatza"] for pizza in pizzas: print(pizza) #modify the for loop to print a sentence using the name of the pizza. pizzas = ["pepperoni", "chesse", "Meatza"] for pi...
true
5309fe57b40c5eeff48558a041ca0d5c703c4a2b
zenvin/PythonCrashCourse
/PART 1/chapter_5/hello_admin.py
1,232
4.1875
4
#make a list of five or more usernames. loop through the list and print a #greeting to each user. usernames = ['admin', 'ken', 'ryu', 'bison', 'chun-li', 'sagat'] for user in usernames: if 'admin' in user: print(f"Hello {user.title()}, would you like to see a status report?") else: print(f"Hello {user.title()},...
true