blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5f111a2967558285ab96d83966b029eebe29a3d2
saisrikar8/C1-Dictionary
/main.py
1,797
4.125
4
''' 03/08/2021 Review List: mutable, [] List functions LIST.insert(INDEX, ELEMENT) LIST.append(ELEMENT) LIST.remove(ELEMENT) LIST.pop(INDEX) LIST[INDEX] = ELEMENT Tuple immutable, () ___________________________________________________ Dictionary Another type of list, stores data/values inside the curly...
true
a010b033f58c902cfcf9979e4ab456c78795f2d7
chernish2/py-ml
/01_linear_regression_straight_line.py
2,976
4.3125
4
# This is my Python effort on studying the Machine Learning course by Andrew Ng at Coursera # https://www.coursera.org/learn/machine-learning # # Part 1. Linear regression for the straight line y = ax + b import pandas as pd import numpy as np from plotly import express as px import plotly.graph_objects as go # Hypo...
true
21f96178fa5517739532612710192bcb8edb93c4
akankshashetty/python_ws
/Q5.py
341
4.34375
4
"""5. Write a program to print the Fibonacci series up to the number 34. (Example: 0,1,1,2,3,5,8,13,… The Fibonacci Series always starts with 0 and 1, the numbers that follow are arrived at by adding the 2 previous numbers.)""" a = 0 b = 1 c = 0 print(a,b,end=" ") while not c==34: c=a+b print(c,end=" ") ...
true
3a6d4b45c0dc2a0e77274788d52aac17fc3c987e
deepakrkris/py-algorithms
/dcp/dcp-8.py
2,014
4.28125
4
# A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. # # Given the root to a binary tree, count the number of unival subtrees. # # For example, the following tree has 5 unival subtrees: # # 0 # / \ # 1 0 # / \ # 1 0 # / \ # 1 1 class Node: ...
true
b026172df9da07b51d08f93cb970c1053f1f7901
VSVR19/DAA_Python
/StacksQueuesDeques/QueueUsingTwoStacks.py
1,489
4.15625
4
# Inspiration- https://stackoverflow.com/questions/69192/how-to-implement-a-queue-using-two-stacks class Queue2Stacks(object): def __init__(self): # Two Stacks self.stack1 = [] self.stack2 = [] def enqueue(self, element): # Add elements to Stack 1 having element as the range. ...
true
5dfc5b0e7de1e49ecd4155d698ca05c5cd2692ef
VSVR19/DAA_Python
/LinkedLists/DoublyLinkedListImplementation.py
915
4.375
4
# This class implements a Singly Doubly List. class Node: # This constructor assigns values to nodes and # temporarily makes the nextnode and previousnode as 'None'. def __init__(self, value): self.value = value self.nextnode = None self.previousnode = None # Setting up nodes and t...
true
719e956d0b6b79da3f485580157c0cf8cc51c05b
remsanjiv/Machine_Learning
/Machine Learning A-Z New/Part 2 - Regression/Section 9 - Random Forest Regression/random_forest_regression.py
2,239
4.21875
4
# Random Forest Regression # Lecture 77 https://www.udemy.com/machinelearning/learn/lecture/5855120 # basic idea of random forest is you use multiple Decisions Trees make up # a forest. This is also called Ensemble. Each decision tree provides a prediction # of the dependent variables.The prediction is the average of...
true
5268874f85dcf7dbcc8dacda9de2813ad88f9e69
sadika22/py4e
/ch11/ch11ex01.py
759
4.15625
4
# Exercise 1: Write a simple program to simulate the operation of the grep com- # mand on Unix. Ask the user to enter a regular expression and count the number # of lines that matched the regular expression: # $ python grep.py # Enter a regular expression: ^Author # mbox.txt had 1798 lines that matched ^Author # $ pyth...
true
0d466471f22138a6b079a50f06bc76c3b4e400a5
srikarporeddy/project
/udemy/lcm.py
337
4.125
4
def lcm(x,y): """ this functions takes two integers and return L>C>M""" if x>y: greater = x else: greater = y while(True): if((greater %x==0) and (greater %y==0)): lcm = greater break greater += 1 return lcm num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) print...
true
709eb2afb2fe89532b6f95c35a4d3b416ff088f6
KartikShrikantHegde/Core-Algorithms-Implementation
/Selection_Sort.py
1,126
4.125
4
''' Selection_Sort Implementation Let the first element in the array be the least. Scan through rest of the array and if a value less than least is found, make it the new least And swap with old least Selection_Sort running time needs N-1 + N-2 + ..... Comparisons and N exchanges which is a quadratic time. Thus the ...
true
98f4d8b4a54003c0f0591c6b68cb8bd3c769f3c8
jtrieudang/Python-Udemy
/Day1.0.py
1,142
4.46875
4
# Write your code below this line 👇 print("hello world!") print('Day 1 - Python Print Function') print('The function is declared like this:') print("print('what to print')") # Return to the front print("Hello world!\nHello World!\n Hello Dude!") # concatenate, taking seperate strings print("Hello" + "Jimmy") ...
true
faa46dec270c2a7b3cf438fa338ad65027f8ee64
Aunik97/variables
/practice exercise 3.py
352
4.21875
4
#Aunik Hussain #15-09-2014 #Practice Exercise 3 print("this programme will divide two numbers and show the remainder") number1 = int(input("please enter the first number")) number2 = int(input("please enter the second number")) answer = number1 / number2 print("The answer of this calculation is {0} / {1} is ...
true
d5d120d1d5cf585b27ced7859623ce562a1a85a8
StRobertCHSCS/fabroa-Andawu100
/Practice/2_8_1.py
233
4.25
4
#Find the value of number number = int(input("Enter a number: ")) #initialize the total total = 0 #compute the total from 1 to number for i in range(1,number+1): #print(i) total = total + i #total output print(total)
true
dbe390db8a59f54378cdeeec195e3fc81cef6c56
PatrickChow0803/Sorting
/src/recursive_sorting/recursive_sorting.py
1,700
4.21875
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge( arrA, arrB ): elements = len( arrA ) + len( arrB ) merged_arr = [0] * elements # [] are used to create array literals. This gives me multiple [0] to work with. # TO-DO i = 0 # Cursor for left array j = 0 # Cursor for rig...
true
12d26fbb29fbe19013f91cd792a36e1a9a27a299
ChengChenUIUC/Data-Structure-Design-and-Implementation
/GetRandom.py
1,526
4.15625
4
class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.d = dict() self.arr = [] self.n = 0 def insert(self, val): """ Inserts a value to the set. Returns true if the set did not al...
true
40783e2766d62c324b30d7b79386a4540a46b585
zexhan17/Problem-Solving
/python/a1.py
984
4.4375
4
""" There are two main tasks to complete. (a) Write a function with the exact name get_area which takes the radius of a circle as input and calculates the area. (You might want to import the value of pi from the math module for this calculation.) (b) Write another function named output_parameter . This should, again, t...
true
556ad2319af38b153209f918a202c793a646ed55
XBOOS/leetcode-solutions
/binary_tree_preorder_traversal.py
2,500
4.375
4
#!/usr/bin/env python # encoding: utf-8 """ Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively?""" """ Method 1 using recursion. adding anothe...
true
f58f1448011d7be58f03493652af3da8451f8152
XBOOS/leetcode-solutions
/odd_even_linked_list.py
1,581
4.25
4
#!/usr/bin/env python # encoding: utf-8 # Method 1 # Must loop the walk with stepsize of 2 # could also make dummy starting node then start with head not head.next.next # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class S...
true
1bdf52e8770eb8dc1061e74a9c53672ddf0c2a48
XBOOS/leetcode-solutions
/first_bad_version.py
1,315
4.1875
4
#!/usr/bin/env python # encoding: utf-8 """ You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Supp...
true
3d0375292722763c19960095b2c270e3fe20620d
christianhv/python_exercises
/ex18.py
595
4.34375
4
#!/usr/bin/env python # This one is like the scripts with argv def print_two(*args): arg1, arg2 = args print "arg1 = %r, arg2 = %r" % (arg1, arg2) #Ok, that *args is actually pointless, we can do just this def print_two_again(arg1, arg2): print "arg1 = %r, arg2 = %r" % (arg1, arg2) #This just print on...
true
c448adeef80d1c158d1ed8ead495a9974b173e31
erik-vojtas/Algorithms-and-Data-Structure-I
/MergeSortAlgorithm.py
1,923
4.21875
4
# Merge Sort Algorithm # https://www.programiz.com/dsa/merge-sort # split an array into two halves and then again until we get lists which consist one item, merge and sort then two lists together, then again until we get full list which is ordered # https://www.studytonight.com/data-structures/merge-sort # Worst Case ...
true
f7c20d23f3329603dab4eb4c78067494fa33ec9e
chutianwen/LeetCodes
/LeetCodes/uber/640. Solve the Equation.py
1,868
4.28125
4
''' Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient. If there is no solution for the equation, return "No solution". If there are infinite solutions for the equation, return "Infinite solutions". If t...
true
d5998dc7bfc0427f1e471b26732ed1a30d3da004
chutianwen/LeetCodes
/LeetCodes/Array/MergeSortedArray.py
1,192
4.1875
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively. """ clas...
true
8fbbb5cc859758fb997b4f6bc0bc31190165ca15
chutianwen/LeetCodes
/LeetCodes/Consistency.py
706
4.3125
4
''' when set includes alphabet letter, then order won't be same every time running program, however, when set has all number the order seems to be same every time. Also difference between python2 and python3. Python2 will print same order all the time, python3 won't for letter cases. ''' a = set(range(5)) print("print ...
true
ea63e5c210cf599b45695ffc1d6b58459a844585
chutianwen/LeetCodes
/LeetCodes/summary/IteratorChange.py
260
4.1875
4
# list iterator can change a = [1,2,3,4] for x in a: print(a.pop()) print("*"*100) # we can append to the iterator like this. -x, "," is important for x in a: print(x) if x > 0: a += -x, # set iterator cannot change b = {1,2,3,4} for x in b: b.pop()
true
692b8995a37443f50512dfbcc5d7d799c8ff93e5
chutianwen/LeetCodes
/LeetCodes/stackexe/NestedListWeightSumII.py
2,916
4.28125
4
''' Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Different from the previous question where weight is increasing from root to leaf, now the weight is defined from...
true
6418042ad3eed02e18886ff8352cd892380e95cc
VladaOliynik/python_labs_km14_Oliynik
/p4_oliynik/p4_oliynik_1.py
597
4.25
4
#below we make variables for input name = input('Enter your name: ') surname = input('Enter your surname') number = input('Enter your phone number: ') street = input('Enter your street name:') building = input('Enter your building number') apartment = input('Enter your apartment number') city = input('Enter your city n...
true
6c003faa8da4af035c548cffcb76b8d67d6eb3a5
muon012/python3HardWay
/ex44.py
2,305
4.5625
5
# INHERITANCE vs COMPOSITION # =========================================== INHERITANCE =========================================== # Implicit Inheritance # The child class inherits and uses methods from the Parent class even though they're not defined in the Child class. class Parent(object): def implicit(self): p...
true
b04b7bba927f04b8932cb62895dece46929d7479
pablomdd/EPI
/Primitive/4_7_compute_power.py
602
4.46875
4
def power(x: float, y: int) -> float: result = 1.0 power = y # tweek for the algorithm work with negative power if y < 0: power, x = -power, 1.0 / x # if power < 0 evaluates False # that happens when bits shift down to 0 or less while power: # evaluates if power is odd ...
true
73c2e0ea222185ecb9e6a506373c09de646288c0
schatfield/classes-pizza-joint
/UrbanPlanner/building.py
1,479
4.34375
4
# In this exercise, you are going to define your own Building type and create several instances of it to design your own virtual city. Create a class named Building in the building.py file and define the following fields, properties, and methods. # Properties # designer - It will hold your name. # date_constructed - T...
true
376ecda95125c6d26e8983d9971aaabea717ef9e
sourav2406/nutonAkash
/DataStructure/BinaryTree/reverseLevelOrder.py
1,037
4.4375
4
# A recursive python process to print reverse level order #Basic node for binary tree class Node: def __init__(self,data): self.data = data self.left = None self.right = None #compute the height of a binary tree def _height(node): if node is None: return 0 else: lhe...
true
959618ab34fb6f1f42843fb2c79c0af724c6746b
ramachandrajr/lpthw
/exercises/ex33.py
446
4.25
4
numbers = [] def loop_through(x, inc): for i in range(x): print "At the top i is %d" % i numbers.append(i) # We do not need this iterator anymore and # even if we use it the i value will be over # written by for loop. # i = i + inc print "Numbers now: ", num...
true
a388c5679b909776fbda190c98f6f57c49ff0193
1258488317/master
/python/example/continue.py
445
4.21875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # while True: # s =input('enter something:') # if s == 'quit': # break # if len(s) < 3: # print('too samall') # else: # print('input is of suffivient length') # print('done') while True: s = input('Enter something : ') if s == 'qu...
true
bbdc8374a9f16c165ef6252f6715b74457c92616
charlescheung3/Intro-HW
/Charles Cheung PS16a.py
263
4.25
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: February 11, 2020 #This program prompts the user for the number of kilograms and then print out the number of pounds. weight = input("Enter weight in kilos:") weight = float(weight) kg = weight*2.20462262185 print(kg,"lb")
true
db1af7f0d6e99aadd85081703ab55905fb3dd400
charlescheung3/Intro-HW
/Charles Cheung PS37.py
687
4.5
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: March 10, 2020 #This program asks the user for a string, then counts and prints the number of characters that are uppercase letters, lowercase letters, numbers and special characters. codeWord = input("Please enter a codeword:") number = 0 upper =...
true
a6eee61b1e72ae980b41dbf283c5b2c67cbb0eb2
charlescheung3/Intro-HW
/Charles Cheung PS18.py
435
4.21875
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: February 18, 2020 #This program will tell you how many coins your cents input will return centsinput = int(input("Enter number of cents as an integer")) quarters = centsinput // 25 print("Quarters:", quarters) rem = centsinput % 25 dimes = rem /...
true
7119908972cd42c33ca71cfb798b1d4716e13ca6
MandeepKaur92/c0800291_EmergingTechnology_assignment1
/main.py
1,646
4.65625
5
import datetime def reverse(fname, lname): print(f"First Name:{fname}\nLast Name:{lname}") print("---------------reverse------------------ ") #print name in reverse print(f"{lname}" + " " + f"{fname}") def circle_radius(radius): #calculate area of radius area=(22/7)*radius**2 print("-------...
true
9c6f3fdfdb384d75d1fd482f3009148fe0ebb06d
tthompson082/Sorting
/src/iterative_sorting/iterative_sorting.py
2,070
4.34375
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) # create a loop that starts a...
true
b4c7b046b68acb11781f471bd72297bf8de53f80
aduo122/Data-Structures-and-Algorithms-Coursera-UCSD
/Graph/week5/connecting_points.py
1,072
4.125
4
#Uses python3 import sys import math import heapq def minimum_distance(x, y): result = 0. #write your code here #setup parameters queue = [[0,x[0],y[0],0]] heapq.heapify(queue) visited = [0 for _ in range(len(x))] v_length = 0 while v_length < len(visited): # select start heap...
true
b4bc51deb6a766cfc134ba59de57efa3a3729960
rampreetha2/python3
/natural.py
228
4.125
4
num = int(input("Enter the value of n:")) hold = num sum = 0 if sum<=0; print("Enter a whole positive number!") else: while num>0: sum sum + num num =num -1; print("Sum of first",hold, "natural numbers is":,sum)
true
f57c76a359ca492ab92052fb995011673bdd8b86
Jodabjuan/intro-python
/while_loop.py
511
4.28125
4
"""" Learn Conditional Repetition Two types of loops: for-loops and while-loops """ counter = 5 while counter !=0: print(counter) # Augmented Opperation counter -=1 counter = 5 while counter: print(counter) # Augmented Opperation counter -=1 # Run forever while True: print("Enter a numbe...
true
122b570d2b95df96d5c9c36db57cdc3cc4d7fc09
Jodabjuan/intro-python
/me_strings.py
1,357
4.40625
4
""" Learn more about strings """ def main(): """ Test function :return: """ s1 = "This is super cool" print("Size of s1: ", len(s1)) # concatenation "+" s2 = "Weber " + "State " + "University" print(s2) # join method to connect large strings instead of "+" teams = ["Real M...
true
0296546419117c17ca88673faf6861ca24a3a51c
toxine4610/codingpractice
/dcp65.py
1,810
4.34375
4
''' Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]] ''' def nextDirection(direction): if direction == "right": return "down" elif direction == "down": ...
true
f77236d54686a8ea79e1989c06329169cd453880
toxine4610/codingpractice
/dcp102.py
808
4.25
4
''' This problem was asked by Lyft. Given a list of integers and a number K, return which contiguous elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4]. ''' def get_contiguous_sum(A, k): sum_so_far = dict() # this stores the sums and the indices ...
true
b69667d2cac84aa9a1dab4847b619425a02d2218
CanekSystemsHub/Python_Data_Structures
/3 Recursion/countdown_start.py
296
4.28125
4
# use recursion to implement a countdown counter global x x = int(input("Type the number you want to countdwon ")) def countdown(x): if x == 0: print("You're done!") return else: print(x, " ... the countdown stills running") countdown(x-1) countdown(x)
true
e411395d691e88bd43c137eef6556c2d90d8fe07
PoornishaT/positive_num_in_range
/positive_num.py
344
4.25
4
input_list = input("Enter the elements of the list separated by space : ") mylist = input_list.split() print("The entered list is : \n", "List :", mylist) # convert into int for i in range(len(mylist)): mylist[i] = int(mylist[i]) print("The positive terms in list is :\n") for x in mylist: if x > 0: ...
true
567ecb1015e77b44c6e5840b1363887c00e94019
SushantBabu97/HackerRank_30Days_Python_Challenge-
/Day28.py
907
4.59375
5
# RegEx, Patterns, and Intro to Databases """ Task Consider a database table, Emails, which has the attributes First Name and Email ID. Given n rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in @gmail.com. Sample Input::: 6 riya riya@gm...
true
92367542b27c2e121bd491fe2d9e3469caf3016d
lokitha0427/pythonproject
/day 7- Patterns/strong number.py
293
4.21875
4
n=int(input("enter the number")) sum=0 t=n while t>0: fact=1 digit=t%10 for i in range(1,digit+1): fact=fact*i sum=sum+fact t//=10 if(sum==n): print("the given number is a strong number") else: print("the given number is not a strong number")
true
0721265e0f7f1dfb6345120b4a79b72b978f1ec3
khanshoab/pythonProject1
/Function.py
1,776
4.375
4
# Function are subprograms which ar used to compute a value or perform a task. # Type of function # 1. built in function e.g print() , upper(), lower(). # 2. user-defined function # ** Advantage of Function ** # write once and use it as many time as you need. This provides code re-usability. # Function facilities cas...
true
93035b2efc77dab6e1d7cbb2aa8a398446f3ff36
khanshoab/pythonProject1
/mul+di+arr.py
262
4.15625
4
# Multi-dimensional Array means 2d ,3d ,4d etc. # It is also known as array of arrays. # create 2d array using array () function. from numpy import * a = array([[23,33,32,43], [54,23,35,23]]) print(a,dtype) print(a[1][3]) a[0][1] = 100 print(a[0][1])
true
e8613d9746bb6c1a99ea312d84132ffe00409f98
khanshoab/pythonProject1
/repetition+operator.py
224
4.125
4
# Repetition operator is used to repeat the string for several times. # It is denoted by * print("$" * 10) str1 = "MyMother " print(str1 * 10) # slicing string str2 = "my dream " print(str2[0:2] * 5) # To printing the 'my
true
e6f6c9b17fc7c8e400d26b16940c127b31504852
Maxud-R/FizzBuzz
/FizzBuzz.py
1,557
4.1875
4
#Algorithm that replaces every third word in the letter to Fizz, and every fifth letter in the word to Buzz. #Length of the input string: 7 ≤ |s| ≤ 100 class FizzBuzz: def replace(self, rawstr): if len(rawstr) < 7 or len(rawstr) > 100 or not (rawstr in rawstr.lower()) or rawstr.isdigit(): raise ...
true
644a34827d6c7fc97d7c5afb3c3a95bba6263c29
brandon98/variables
/string exercise 2.py
297
4.21875
4
#Brandon Dickson #String exercise 2 #8-10-2014 quote=input("Please enter quote:") replacement= input( "What word would you like to replace?") replacement2=input( "What word would you like to replace it with?") answer= quote.capitalize() output= quote.replace(replacement, replacement2) print(output)
true
1f2b406a39f0a5094c5206899dd2795f12d043ad
Hu-Wenchao/leetcode
/prob218_the_skyline_problem.py
2,271
4.3125
4
""" A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a program to output the skyline formed by these buildings collect...
true
f1fa96f1a965889d29151b30eb26d039a7840bf7
MrShashankBisht/Python-basics-
/Class 11th complete/7) Continue_Breake_Statement/break.py
406
4.3125
4
# this is a programe to break your loop and make your programe to jump unconditionaly from loop # in this programe we take inpute from user and quit loop(uncondionaly break the middle term ) num = int(input('Enter the Ending limit of the loop ')) for i in range (num): print("you are in loop and this is looping num...
true
194f0af0d91d825b2e4542432d69ee6e54791d99
MrShashankBisht/Python-basics-
/Class 11th complete/7) Continue_Breake_Statement/Continue.py
377
4.125
4
# this is a programe to continue to loop and make your programe to jump unconditionaly from loop for i in range(0,3): a = int(input("enter first number")) b = int(input("enter second number ")) if(b == 0): #here we use conditional operater == print("b can't be zero ...
true
6e9bfef9a57a241c80fe0b28905a4bbbb44a92ee
Kylekibet/days_to_birthday
/no_of_days_to_birthday.py
1,674
4.59375
5
#!/usr/bin/python3 import datetime # Get todays date dttoday = datetime.date.today() print("today is {}".format(dttoday)) while True: # Get users birtday date. bday = input("\nPlease enter you birthday(year-month-day) : ") # Check weather user entered date in the formart provided(year-month-day) try: ...
true
c123970f36c7f6c7b9c19a1bf21104ff1f196f27
gokadroid/pythonExample-2
/pythonExample2.py
571
4.34375
4
#Simple program to reverse a string character by character to show usage of for loop and range function def reverseString(sentence): reversed=[] #create empty list for i in range(len(sentence),0,-1): #starting from end, push each character of sentence into list as a character reversed.append(sentence[i-...
true
b259a0b53eabfcf8f3f31e4e7742bc1c7312c173
abbhowmik/PYTHON-Course
/Chapter 6.py/pr no.5.py
267
4.15625
4
a = input("Enter a name : \n: ") list = ["mohan", "rahul", "Ashis", "Arjun", "Sourav", "Amit"] if(a in list ): print("The name you choice from the list is present in the list ") else: print("The name you choice from the list is not present in the list")
true
6eae4ee9fb61284dfa148637bf2f8c971cae3379
abbhowmik/PYTHON-Course
/practice 4.py
1,022
4.53125
5
# name = input("Enter your name\n") # print("Good Afternoon," + name) # a = input("Enter your name\n") # print("Good Afternoon," + a ) letter = '''Dear <|Name|>, you are selected!,welcome to our coding family and we are noticed that you are scoring well in exam as before like. That's why your selected in our partne...
true
fd5a9faf7610477b3ba53f57764a5deed927fe47
mkhlvlkv/random
/like.py
952
4.15625
4
# -*- coding: utf-8 -*- def like(text, pattern, x='*'): """ simple pattern matching with * """ if pattern.startswith(x) and pattern.endswith(x): return pattern.strip(x) in text elif pattern.startswith(x): return text.endswith(pattern.strip(x)) elif pattern.endswith(x): return te...
true
c707df33626c32086a61f0ae1086b667bf500bce
ManiNTR/python
/Adding item in tuple.py
290
4.3125
4
values=input("Enter the values separated by comma:") tuple1=tuple(values.split(",")) print("The elements in the tuple are:",tuple1) key=input("Enter the item to be added to tuple:") list1=key.split(",") list2=list(tuple1) list2.extend(list1) print("The tuple elements are: ",tuple(list2))
true
2e471dab649540a085eee4b0730b18cca2902002
ManiNTR/python
/RepeatedItemTuple.py
307
4.46875
4
#Python program to find the repeated items of a tuple values=input("Enter the values separated by comma:") list1=values.split(",") tuple1=tuple(list1) l=[] for i in tuple1: if tuple1.count(i)>1: l.append(i) print("The repeated item in tuple are: ") print(set(l))
true
7a8c0d75d17d2fa9464fc8a21375947234310df9
SARANGRAVIKUMAR/python-projects
/dice.py
275
4.21875
4
import random # select a random number min = 1 max = 6 roll="yes" while(roll == "yes"or roll=="y"): print ("dice is rolling\n") print("the values is") print (random.randint(min,max)) #selecting a random no from max and min roll = input("Roll the dices again?")
true
34419cbbbbcd1e10d1c6205f2f9ec62a234dfb7e
SeanUnland/Python
/Python Day 5/main.py
1,869
4.28125
4
# for loops fruits = ["Apple", "Pear", "Peach"] for fruit in fruits: print(fruit) print(fruit + " Pie") # CODING EXERCISE # 🚨 Don't change the code below 👇 student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] ...
true
90ab88a33387a70de53d0eea736072ed7faad3ff
olszebar/tietopythontraining-basic
/students/marta_herezo/lesson_02/for_loop/adding_factorials.py
257
4.15625
4
# Given an integer n, print the sum 1!+2!+3!+...+n! print('Enter the number of factorials to add up: ') n = int(input()) factorial = 1 sum = 0 for i in range(1, n + 1): factorial = factorial * i sum += factorial print('Result = ' + str(int(sum)))
true
b74c18f10daa14b813dff047f81d76fa6fef9edc
lyoness1/skills-cd-data-structures-2
/recursion.py
2,907
4.59375
5
# --------- # # Recursion # # --------- # # 1. Write a function that uses recursion to print each item in a list. def print_item(my_list): """Prints each item in a list recursively. >>> print_item([1, 2, 3]) 1 2 3 """ if not my_list: return print my_list[0] ...
true
5b95b484392c7e58a9bf5a98cb8db1cf91e400b4
jorgeaugusto01/DataCamp
/Data Scientist with Python/21_Supervised_Learning/Cap_2/Pratices4_5.py
2,944
4.21875
4
#Train/test split for regression #As you learned in Chapter 1, train and test sets are vital to ensure that your supervised learning model # is able to generalize well to new data. This was true for classification models, and is equally true for # linear regression models. #In this exercise, you will split the Gapminde...
true
e56eb114b90742ca083d9812ce7e11e5d9504c2e
daniloaleixo/30DaysChallenge_HackerRank
/Day08_DictionairesAndMaps/dic_n_maps.py
2,134
4.3125
4
# Objective # Today, we're learning about Key-Value pair mappings using a Map or Dictionary data structure. Check out the Tutorial tab for learning materials and an instructional video! # Task # Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will...
true
b8c2b94be9e48ae10bf5c47817f6af19109ced0c
LouisTuft/RSA-Calculator-and-Theory
/1.RSAValues.py
2,147
4.25
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 30 02:13:03 2020 @author: Louis """ """ The theory behind RSA is explained in the Readme file in the repository. This python file is the first of three that form a complete RSA system. This file in particular will allow you to construct your own set of keys for RSA. The...
true
b14350b1729a7ad4dca30edae721cd6f82b04d42
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Manipulations/PythonSetExmpl.py
709
4.1875
4
# initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use | operator # Output: {1, 2, 3, 4, 5, 6, 7, 8} print(A | B)#Union is performed using | operator. print(A.union(B))#union using Function #Intersection of A and B is a set of elements that are common in both sets. print(A & B) #Intersection is performe...
true
f70aa44924847d48183279a297ef6cda93f1b3d0
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Python_Tuple.py
1,153
4.6875
5
#tuples are immutable. #defined within parentheses () where items are separated by commas #Tuple Index starts form 0 in Python. x=('python',2020,2019,'django',2018,20.06,40j,'python') #Tuple # you can show tuple using diffrent way print('Tuple x : ',x[:]) # we can use the index with slice operator [] to access an ite...
true
c3f0fe5252715fd2df8084c40d654f73913977b7
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Python_Dictionary.py
1,315
4.5625
5
"""" dictionaries are defined within braces {} with each item being a pair in the form key:value. Key and value can be of any type. """ #keys must be of immutable type and must be unique. d = {1:'value_of_key_1','key_2':2} #Dictionary print('d is instance of Dictionary : ',isinstance(d,type(d))) #To access values,...
true
a0fe310c8be1f85b9fbeb61c83c833104ebdd6ef
morganhowell95/TheFundamentalGrowthPlan
/Data Structures & Algorithms/Queues & Stacks/LLImplOfStack.py
1,460
4.28125
4
#Stack is a Last In First Out (LIFO) data structure #Data is stored by building the list "backwards" and traversing forwards to return popped values class Stack: def __init__(self): self.tail = None def push(self, d): #create new node to store data node = Stack.Node(d) #link new node "behind" the old node ...
true
14901244b9c06406fa9c8e721febc1108f2885c9
masterbpk4/matchmaker_bk
/matchmaker_bk.py
2,927
4.1875
4
##Brenden Kelley 2020 All Rights Reserved ##Just kidding this is all open source ##Just make sure you credit me if you realize that this is a marvel of coding genius and decide to use it in the future ##First we need to get our questions placed in an array and ready to be pulled on command, we'll also need an empty ...
true
6bf9042e0c296379fbe1c557904bfc04c224f31f
rajatpanwar/python
/Dictonary/Dictionary.py
2,580
4.625
5
/// A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets <--------example1-------> thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) <-------example2---------> // how to access the element in dictionary de...
true
a0444ca1776cae4cc5a73af7e82a9dc4f4577080
mornville/Interview-solved
/LeetCode/September Challenge/word_pattern.py
950
4.21875
4
""" Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Example 1: Input: pattern = "abba", str = "dog cat cat dog" Output: true Example 2: Input:pattern = "abba", str = "dog cat...
true
0c359a7b16b7fbece29a96fa1b19e49aaddfed73
bluella/hackerrank-solutions-explained
/src/Arrays/Minimum Swaps 2.py
974
4.375
4
#!/usr/bin/env python3 """ https://www.hackerrank.com/challenges/minimum-swaps-2 You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order. """ im...
true
e477ab371361b476ded3fbeb89c663c253ee77a6
bluella/hackerrank-solutions-explained
/src/Warm-up Challenges/Jumping on the Clouds.py
1,623
4.1875
4
#!/usr/bin/env python3 """ https://www.hackerrank.com/challenges/jumping-on-the-clouds There is a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. The player can jump on any cumulus cloud having a number that is equal to the number of the curren...
true
a5259c0f1618344c5788637a406943352a01b5d9
anoubhav/Project-Euler
/problem_3.py
971
4.15625
4
from math import ceil def factorisation(n): factors = [] # 2 is the only even prime, so if we treat 2 separately we can increase factor with 2 every step. while n%2==0: n >>= 1 factors.append(2) # every number n can **at most** have one prime factor greater than sqrt(n). Thus...
true
97f21e92543f97bf7be3a7603c366c371fbbe0a8
luabras/Angulo-vetores
/AnguloEntreVetores.py
1,829
4.28125
4
import numpy as np import matplotlib.pyplot as plt def plotVectors(vecs, cols, alpha=1): """ Plot set of vectors. Parameters ---------- vecs : array-like Coordinates of the vectors to plot. Each vectors is in an array. For instance: [[1, 3], [2, 2]] can be used to plot 2 vectors. ...
true
31c247fdb56a75015b434f3721249b5711901b57
2pack94/CS50_Introduction_to_Artificial_Intelligence_2020
/1_Knowledge/0_lecture/0_harry.py
1,540
4.125
4
from logic import * # Create new classes, each having a name, or a symbol, representing each proposition. rain = Symbol("rain") # It is raining. hagrid = Symbol("hagrid") # Harry visited Hagrid. dumbledore = Symbol("dumbledore") # Harry visited Dumbledore. # Save sentences into the Knowledge...
true
182456c4be118753b0ca6ece47d81a041e3aa3db
zackkattack/-CS1411
/cs1411/Program_01-1.py
500
4.65625
5
# Calculate the area and the circumfrence of a circle from its radius. # Step 1: Prompt for radius. # Step 2: Apply the formulas. # Step 3: Print out the result. import math # Step 1 radius_str = input("Enter the radius of the circle: ") radius_int = int(radius_str) # Convert radius_str into a integer # Step 2 circ...
true
70de8dc6a37fd9e059bb23d8a96ec2139ffc8257
WinnyTroy/random-snippets
/4.py
670
4.1875
4
# # Order the list values = [1, 3, -20, -100, 200, 30, 201, -200, 9, 3, 4, 2, -9, 92, 99, -10] # # a.) In ascending Order values.sort() print values # # b.) In descending Order values.reverse() print(values) # # c.) Get the maximum number in the list print max(values) # # d.) Get the minimum number in the lis...
true
c3cae72e8baded407d00e9bd9ad6c50bfce2547e
nabin2nb2/Nabin-Bhandari
/introEx2.py
246
4.53125
5
#2.Gets the radius of a circle and computes the area. Radius = input("Enter given Radius: ") Area = (22/7)*int(Radius)**2 #Formula to calculate area of circle print ("The area of given radius is: "+ str(Area.__round__(3)))
true
ca18170a10f6b4ecfa367cdb6b90aa1b8c9b2efe
skalunge1/python-p
/DictPgm.py
1,004
4.71875
5
# How to access elements from a dictionary? # 1. with the help of key : # 2. using get() method : If the key has not found, instead of returning 'KeyError', it returns 'NONE' my_dict = {'name':'Jack', 'age': 26} # Output: Jack print(my_dict['name']) print(my_dict.get('name')) # Output: 26 print(my_dict.get('age')) pr...
true
b4e460797dcf9d15466f25559adcaa19b0cd86eb
skalunge1/python-p
/DemoDeleteDict.py
1,261
4.46875
4
# How to delete or remove elements from a dictionary? # 1. pop() : Remove particular item from list # : It removes particular item after providing key and returns removed value squares = {1:1, 2:4, 3:9, 4:16, 5:25} print(squares.pop(4)) print(squares.pop(2)) print(squares) print(squares.popitem()) print(squares)...
true
cce65666f67ef2fb7a33c9372f03cdacf67ac500
FabrizioFubelli/machine-learning
/05-regressor-training.py
1,269
4.25
4
#!/usr/bin/env python3 """ Machine Learning - Train a predictive model with regression Video: https://youtu.be/7YDWaTKtCdI LinearRegression: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html """ from sklearn.datasets import load_boston from sklearn.linear_model import Line...
true
754e26560f3768a87fc88f9f4ce9fbc2b9648d40
FabrizioFubelli/machine-learning
/01-hello-world.py
1,390
4.28125
4
#!/usr/bin/env python3 """ Machine Learning - Hello World Video: https://www.youtube.com/watch?v=hSZH6saoLBY 1) Analyze input data 2) Split features and target 3) Split learning data and test data 4) Execute learning with learning data 5) Predict result of learning data and test data 6) Compare the accuracy scores b...
true
950c0661c44ff43eaef662c124d1d3a9057122e1
EgorKolesnikov/YDS
/Python/Chapter 01/01. Basics/02. Shuffling the words.py
1,095
4.15625
4
## Egor Kolesnikov ## ## Shuffling letters in words. First and last letters are not changing their positiona. ## import sys import random import string import re def shuffle_one_word(word): if len(word) > 3: temp_list = list(word[1:-1]) random.shuffle(temp_list) word = word...
true
3127d121f6f06faa85a09de26f6879220b6fd00d
paarubhatt/Assignments
/Fibonacci series.py
634
4.34375
4
#Recursive function to display fibonacci series upto 8 terms def Fibonacci(n): #To check given term is negative number if n < 0: print("Invalid Input") #To check given term is 0 ,returns 0 elif n == 0: return 0 # To check given term is either 1 or 2 because series for ...
true
a48e9a490f51dbd08f9cec47f9de5bd6eab47712
megha-20/String_Practice_Problems
/Pattern_Matching.py
544
4.34375
4
# Function to find all occurrences of a pattern of length m # in given text of length n def find(text,pattern): t = len(text) p = len(pattern) i = 0 while i <= t-p: for j in range(len(p)): if text[i+j] is not pattern[j]: break if j == m-1: ...
true
8f70983510f211453fb51f8f9c396f58eaee33b7
pauleclifton/GP_Python210B_Winter_2019
/students/douglas_klos/session8/examples/sort_key.py
1,286
4.3125
4
#!/usr/bin/env python3 """ demonstration of defining a sort_key method for sorting """ import random import time class Simple: """ simple class to demonstrate a simple sorting key method """ def __init__(self, val): self.val = val def sort_key(self): """ sorting key func...
true
0bd34168459f1da60426f683ac7ce4ffb5eebc4a
pauleclifton/GP_Python210B_Winter_2019
/students/jeremy_m/lesson03_exercises/slicing_lab.py
1,499
4.5
4
#!/usr/bin/env python3 # Lesson 03 - Slicing Lab # Jeremy Monroe def first_to_last(seq): """ Swaps the first and last items in a sequence. """ return seq[-1] + seq[1:-1] + seq[0] # print(first_to_last('hello')) assert first_to_last('dingle') == 'eingld' assert first_to_last('hello') == 'oellh' def every_oth...
true
4e71942f4dfb235107981620e653050980bd8f5d
pauleclifton/GP_Python210B_Winter_2019
/students/jesse_miller/session02/print_grid2-redux.py
931
4.375
4
#!/usr/local/bin/python3 # Asking for user input n = int(input("Enter a number for the size of the grid: ")) minus = (' -' * n) plus = '+' """Here, I'm defining the variables for printing. Made the math easier this way""" def print_line(): print(plus + minus + plus + minus + plus) """This defines the tops and bot...
true
4bad0ec8024dea5b25d678ea50a74313474066f5
pauleclifton/GP_Python210B_Winter_2019
/students/elaine_x/session03/slicinglab_ex.py
1,915
4.40625
4
''' ########################## #Python 210 #Session 03 - Slicing Lab #Elaine Xu #Jan 28,2019 ########################### ''' #Write some functions that take a sequence as an argument, and return a copy of that sequence: #with the first and last items exchanged. def exchange_first_last(seq): '''exchange the first ...
true
9e2062f46a32508373a55afb7fb110dda8579d4e
markuswesterlund/beetroot-lessons
/python_skola/rock_paper_scissor.py
651
4.28125
4
import random print("Let's play rock, paper, scissor") player = input("Choose rock, paper, scissor by typing r, p or s: ") if player == 'r' or player == 'p' or player == 's': computer = random.randint(1, 3) # 1 == r # 2 == p # 3 == s if (computer == 1 and player == 'r' or computer == 2 and player ...
true
d57b6adc5a6e62ce236f104c577c1329925b84ae
markuswesterlund/beetroot-lessons
/python_skola/Beetroot_Academy_Python/Lesson 4/guessing_game.py
557
4.25
4
import random print("Try to guess what number the computer will randomly select: ") numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] player = input("Choose a number between 1-10: ") if int(player) in numbers: computer = random.randint(1, 10) if player == computer: print("The computers number was:", computer,...
true
6e3ce3b082ca45aa478ee73fdc200b84f13e7b45
manuel-garcia-yuste/ICS3UR-Unit6-04-Python
/2d_list.py
1,456
4.46875
4
#!/usr/bin/env python3 # Created by: Manuel Garcia Yuste # Created on : December 2019 # This program finds the average of all elements in a 2d list import random def calculator(dimensional_list, rows, columns): # this finds the average of all elements in a 2d list total = 0 for row_value in dimensiona...
true
9981b9084b75157e002eeab791beda9a40af6555
Linh-T-Pham/Study-data-structures-and-algorithms-
/palindrome_recursion.py
1,326
4.34375
4
""" Write a function that takes a string as a parameter and returns True if the string is a palindrome, False otherwise. Remember that a string is a palindrome if it is spelled the same both forward and backward. For example: radar is a palindrome. for bonus points palindromes can also be phras...
true