blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
56358db697404cbacbc88254633694377872350b
dsf3449/CMPS-150
/Programming Assignments/pa1/pa1.py
1,420
4.1875
4
# Author: David Fontenot # CLID/ULID: dsf3449/C00177513 # Course/Section: CMPS 150 - Lecture Section #002 # Assignment: pa1 # Date Assigned: Tuesday, January 24, 2017 # Date/Time Due: Friday, January 27, 2017 -- 11:55pm # # Description: This program uses string and numeric input. # ...
true
995a8e5f5ba43db1a0177b4e79512ddf2dd71e3a
piplani/doubly_linked_list
/add_after_given_node.py
1,082
4.25
4
class Node: def __init__(self, data): self.data = data self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None def printlist(self): temp = self.head while temp: last = temp print temp.data, ...
true
9b153f8734b15740fb07409fbab7de01b85f6ed4
jefimenko/data-structures
/queue.py
1,267
4.1875
4
class Node(object): """ Node class to be used by Queue class """ def __init__(self, data, next=None): self.data = data self.next = next class Queue(object): """ Queue class that makes an empty queue """ def __init__(self): self.head = None self.tail = Non...
true
e61abd6ac0ed7e2f1459341bdc3d7bec03ec8ec2
mariuspodean/CJ-PYTHON-01
/lesson_3/mihaela_vaida/other_files/ilas_lorena/Missing methods.py
862
4.4375
4
# Using the python documentation find out the missing methods and play with them to figure out what they do. # Write code snippets for each method proving the usefulness of the methods. # list.sort() numbers = [10, 15, 3, 5] print(numbers) numbers.sort() print(numbers) # list.reverse() numbers.reverse() print(nu...
true
4153a8c1b04022712b84f5c307aa7be7fec2ad1c
mariuspodean/CJ-PYTHON-01
/lesson_7/mosut_sorin/hw_lesson7_decorators_mosut_sorin1.py
547
4.21875
4
''' Given the following function: def greet(name): return "Greetings {}!".format(name) Create a decorator called uppercase that will uppercase the result @uppercase def greet(name): return "Greetings {}!".format(name) print(greet("World")) "GREETINGS WORLD!" def greet(name): return "Greetings {}!".for...
true
3838c9b9005c757460416aa534a040a176ba263e
PrabSandy/Python-Projects
/Hangman-DataFlair/Develop_a_loop.py
960
4.3125
4
# A loop to re-execute the game when the first round ends: def play_loop(): global play_game play_game = input("Do You want to play again? y = yes, n = no \n") while play_game not in ["y", "n","Y","N"]: play_game = input("Do You want to play again? y = yes, n = no \n") if play_game == "y...
true
27c649ab8a967c4c1bfdd425b4f87e7417b489a4
hosmanadam/coding-challenges
/@Project Euler/001_multiples-of-3-and-5/multiples-of-3-and-5.py
368
4.15625
4
"""https://projecteuler.net/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. """ multiples_of_3_or_5 = set() for n in range(1000): if n%3==0 or n%5==0: multiples_of...
true
008c274eac29e94cbe9ecdbe4851250586a136de
dzyounger/python
/iowa/Iowa09mergeSort.py
2,079
4.125
4
import random import time def merge(L, first, mid, last): i = first # index into the first half j = mid + 1 # index into the second half tempList = [] # This loops goes on as long as BOTH i and j stay within their # respective sorted blocks while (i <= mid) and (j <= last):...
true
11088c7355b8f285ffe839fd02d6a99aa67aa5eb
DanielJMcCarthy/PythonLabs
/lab7_functions_and_module_for_data_analytics.py
2,438
4.5
4
import math """ Write a function called powerV1. When you call this function (from your main function) it should ask the user for a base number and a power number. It should then print out the result of raising the base number to the power of the second number. Sample output below: Please enter bas...
true
55c5dd11bcb071295cae348305cffd3afa75cff3
thisisnitish/Data-Structures-With-Python
/Sorting/BubbleSort.py
738
4.28125
4
#Python code for bubble sort class BubbleSort: def bubblesort(self, arr, size): for Round in range(size): flag = 0 for i in range(size-1-Round): if arr[i] > arr[i+1]: flag = 1 arr[i], arr[i+1] = arr[i+1], arr[i] ...
true
24c7f1d82ff4d88e6fbb5508bfad3cbe658688d2
MaxPoon/EEE-Club-Python-Workshop
/syntax/1_beginning_with_python/3_arithmetic.py
310
4.1875
4
a = 2 + 3 print(a) print(2*5) print((1.5+2.5)*(3.5+4.5)) print() # doubled division symbol // for the operation that produces just the integer quotient # symbol % for the operation of finding the remainder print(10/3) print(10//3) print(10%3) print() x = 5 x += 1 print(x) print() print(2**5) print(10**2.5)
true
5e3a8f84bfca11816f8467a571fe77ee9cadfa7c
saetar/pyEuler
/done/py/euler_059.py
2,431
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Jesse Rubin - project Euler """ XOR decryption Problem 59 Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 1...
true
bf373cb60be97d2395eb285aac8f6985b92854fd
saetar/pyEuler
/not_done/py_not_started/euler_360.py
621
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # ~ Jesse Rubin ~ project Euler ~ """ Scary Sphere http://projecteuler.net/problem=360 Given two points (x1,y1,z1) and (x2,y2,z2) in three dimensional space, the Manhattan distance between those points is defined as |x1-x2|+|y1-y2|+|z1-z2|. Let C(r) be a sphere with radiu...
true
9fcb10bb749d05c3f4218ef0b064f97edf18a1f5
saetar/pyEuler
/not_done/py_not_started/euler_540.py
603
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # ~ Jesse Rubin ~ project Euler ~ """ Counting primitive Pythagorean triples http://projecteuler.net/problem=540 A Pythagorean triple consists of three positive integers a, b and c satisfying a^2+b^2=c^2. The triple is called primitive if a, b and c are relatively prime. Le...
true
dbeef9bc51357528760d1a5dd60b324f2814ce7f
unnievarghese/originalpythonluminar
/flowcontrols/decesionmaking/agecalculation.with.year.mnth.day.py
564
4.34375
4
print("enter date of birth") birthyear=int(input("enter the year:")) birthmonth=int(input("enter the month:")) birthday=int(input("enter the day:")) print("enter current date") currentyear=int(input("enter the year:")) currentmonth=int(input("enter the month:")) currentday=int(input("enter the day:")) if currentmonth>...
true
c5721dc6f15f9e00bd69d023a6ee6b449fa78004
JiaXin1/Automatetheboringstuff
/mydrinks.py
314
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 14 15:51:30 2018 @author: CLin """ drinks = ['latte','hot chocolate', 'milk','coke'] print('Enter a drink:') name = input() if name not in drinks: print('I do not have' + name+ 'on the menu.') else: print(name + 'is not on the menu.')
true
a43525b11434f30f8d0f63a5e0d51fdf72409441
EshrakRahman/Daily-Python-problem
/Desks/main.py
588
4.1875
4
# reads number of student in the class group_one_student = int(input()) group_two_student = int(input()) group_three_student = int(input()) # calculate required desk group_one_desk = group_one_student // 2 group_two_desk = group_two_student // 2 group_three_desk = group_three_student // 2 # if the number is odd odd_g...
true
74c6163d14796467338a9599c3db3b5a8c57d3d7
SauravRJoshi/python-basic-questions
/F_question4.py
253
4.40625
4
def reverse_str(your_string): final_list = [] for i in your_string[-1::-1]: final_list.append(i) return ''.join(final_list) input_str = list(input("Enter a string : ")) print('Your reversed string is : ',reverse_str(input_str))
true
50c20e0195c57c24c70a6781637158c7ab05808a
SauravRJoshi/python-basic-questions
/question2.py
361
4.15625
4
#!/usr/bin/python3 def get_string(first,second,second_last,last): final_string = str(first) + str(second) + str(second_last) + str(last) return final_string your_string = list(input("Enter your string :")) if len(your_string) >= 2: final = get_string(your_string[0],your_string[1],your_string[-2],your_strin...
true
04246cf87aa4a047f9f78af934aa3ebae309fc83
pampew10/NTS370
/3-2script.py
909
4.1875
4
#!/usr/bin/python3 #defining the arrays for future use (a and b) a = [] b = [] #grabs user input for starting number and ending number. input1 = input("Put your starting range number here: ") input2 = input("Put your ending range number here: ") #Assigns input values to integer. test = int(input1) test2 = int(input2)...
true
ef0981aaa805be5d3307583656dd8d8424a5d979
NoahGoldstein13/TestRepo
/Alice.py
1,222
4.5625
5
#Dictonary creation challenge user = {'name': 'Alice', 'height': '1.60 meters', 'shoe_size': 'American size 6.5, European size 37', 'hair': 'brown', 'eye_color': 'brown'} print(user["name"], user["height"], user["shoe_size"], user["hair"], user["eye_color"]) print(f"My name is {user['name']}, my height is {user['hei...
true
b7c2b6e6498600fdd93cbecea0255d9608668c72
inshaal/DPSB-Lab-Practicals
/AHZ PRACTICAL PAPER/Received from QA/Q24.py
1,090
4.21875
4
#write a program to accept 3*3 array of integers and check whether if forms a magic square or not #------------------------------------------------------------------------------INPUT---------------------------------------------------- def magic_square(lst): """ >>> magic_square([[2,7,6],[9,5,1],[4,...
true
21e3a1fe856d41defa5c7dba7f577e8a563ef14f
inshaal/DPSB-Lab-Practicals
/AHZ PRACTICAL PAPER/Received from QA/Q1.py
840
4.21875
4
''' Swapping of all evenly located elements of list with following odd locations using a user defined function named swap.... eg-list=[0,1,2,3,4,5] , swapped list=[1,0,3,2,5,4]''' def swap(lst,sz): #arguments- lst means list and sz means it's size for i in range(0,sz...
true
13de93684840fd291d2ac4549ac24db94a10fa9a
inshaal/DPSB-Lab-Practicals
/recursive_function_example.py
350
4.25
4
#Recursive funtionc example! def fact(n): if(n==0): return 1 else: return n*fact(n-1) n=input("Enter any number ") print fact(n) ''' extra recursive function to find the sum of 1 to n def sum(n): if(n==0): return 0 else: return n+(sum(n-1)) n=input("...
true
809d06faf2626b71019136e0b630c648af3090dd
scott-likes-coffee/CyberSec
/calc1.py
759
4.34375
4
#!/usr/bin/python3 print("Basic Calculator 2") ###Taking values for X & Y x = int(input("\nEnter a value for x: ")) y = int(input("Enter a value for y: ")) ###Choosing an operation choice = input("\nChoose from the following operations: \n'add' for addition \n'sub' for subtraction \n'div' for division \n'mul' for mu...
true
3af6f41431a5a127ca71b21f8b80807315b64c19
WaiAbuAhmad/Foundation
/HackerRank Challanges/Map_and_Lambda_Function.py
405
4.15625
4
cube =lambda x: x**(3) def fibonacci(n): # return a list of fibonacci numbers if n ==0 : fib_numbers=[] return fib_numbers elif n==1: fib_numbers=[0] return fib_numbers else: fib_numbers=[0,1] for i in range (2,n): fi...
true
8860dae62152fde48efb614d0dd817f8a4962002
jcamp3006/PythonStuff
/PythonStuff/DataMiningStuff/HelloPandas_Intro.py
1,915
4.21875
4
#This programs shows how to create and manipulate arrays of data using Pandas data frames #Also includes many helpful commands in comments import pandas as pd import numpy as np my_dict = {'name' : ['a','b','c','d','e','f','g'], 'age' : [20,21,23,45,34,56,32], 'designation' : ['...
true
30e6a46f1ca957c86bf132f32ef19ca012c126fb
trkhanh/learning-mit-algo
/python/data_structures/queue/double_ended_queue.py
966
4.5625
5
# Python code to demonstrate working of # extend(), extendleft(), rotate(), reverse() import collections de = collections.deque([1, 2, 3]) # using extend() to add numbers to right end de.extend([4, 5, 6]) print("The deque after extending deque at end is : ") print(de) de.extendleft([7, 8, 9]) print("The deque after ...
true
63849028d270902670e8e8873f2bfca24a68950b
Florian-Projects/TI_Innovator_Rover
/ti_rover.py
1,709
4.1875
4
#TODO Füge alle commands ab I/O hinzu. #TODO Duplikate durch method overloading ersetzen #Drive def forward(distance): """Move the rover forwards. distance in 0.1m""" def forward_time(time): """Move the rover forwards for a specific amount of time. time in seconds""" def backward(distance): """Move the r...
true
216535611a7590cc764e7d2f9550d11447a49b4d
Gauravshrestha4/second_largest_number
/assignment.py
1,206
4.25
4
""" Write a function that takes an array of integers given a string as an argument and returns the second max value from the input array. If there is no second max return -1. 1. For array ["3", "-2"] should return "-2" 2. For array ["5", "5", "4", "2"] should return "4" 3. For array ["4", "4", "4"] should return "-1" ...
true
caca9ec71b06e7c5ba6e28aaa9f62d3f6b20d9e3
wajdm/ICS3UR-5-03-Python
/mark_finder.py
1,444
4.3125
4
# !/usr/bin/env python3 # Created by: Wajd Mariam # Created on: November 2019 # This program is MARK FINDER for students in Ontario def percentage(level_string): # this function find the percentage of the mark entered # the list of levels and its corresponding percentage if level_string == "4+": ...
true
3373b48db570427165317f853d695bb2792b5760
vatsaakhil/turtle-fun
/turtle_race.py
1,209
4.28125
4
from turtle import * #Importing every func from turtle file from random import randint speed(10) #Speeding up the turtle penup() #Lifts up the pencil, so no markings are done goto(-140,140) #Goes to the specified location for step in range(15): #Writes step no. at each 20 distance write(step,align='ce...
true
a912230f896193f49fb0ce28432e95cc21e2e16f
murakumo512/Alpro-Python-2019-2020
/Pertemuan 12/UG/444.py
560
4.1875
4
my_tuple = (((3,9),2,3,(2,3),5,6,(7,2),8,9,(10,11))) # converting the tuple to the list my_list = list(my_tuple) print (my_list) # output: [10, 20, 30, 40, 50] # Here i wanna remove the element "50" my_list.remove(3) # output: [10, 30, 40] # again converting the my_list back to my_tuple my_tuple = tuple...
true
677fdf5959968985792831f98bca638f45dc1204
AnishaSabu/Python-Learning-
/task2_list.py
267
4.1875
4
list=[] i=int(raw_input("enter the number of elements in list: ")) print "enter the elements: " for j in range(i): list.append(input()) print list large=list[0] for j in range(i): if list[j]>large: large=list[j] print "largest element in list: %d"%(large)
true
f120551924069c748554721c98d43bf47663529d
AnishaSabu/Python-Learning-
/func_calling_arguments.py
1,629
4.5
4
print "Function calling" def printfunc(str): #defininf function to print string print str return printfunc("Today i have to go to supermarket") #calling function printfunc("I have a long list to deal with") #calling function print "pass by reference" def listfunc(list): #defining function list.append(89)...
true
b71288349fe8337a4a05be47c88707efc3d99719
kar10tik/Elementary_DSA
/Python/doublelink.py
1,640
4.4375
4
#Doubly Linked List Implementation import sys class Node: def __init__(self, next = None, prev = None, data = None): self.next = next self.prev = prev self.data = data class double_linked_list: def __init__(self): self.head = None def insert_node(self, new_data): ...
true
483ea1dbf88f99b7f73fd939b5027c0b4c3e0be9
shahrohan05/LearningPython
/hands_on_advanced1/sorting/main.py
948
4.15625
4
from algorithm import Algorithm from sorting import Sorting algorithm_choices = """ Please choose an algorithm to sort with: 1. Quick Sort 2. Bubble Sort 3. BFS 4. DFS 5. Merge Sort ----------------------------- Your Choice: """ algorithm = Algorithm() algorithm_map = { "1": algorithm.quick_sort, "2": algorit...
true
1b31cc70674b9369614fcc4b003003ec29945b4e
ngjs66/hangman-python
/hangman.py
2,185
4.40625
4
#!/usr/bin/env python3 # This is a Hangman program written in Python. # import random # import sys # wordList = ["samsung", "apple", "huawei", "motorola" , "oneplus", "honor", "xiaomi", "google"] # def choose(): # # gets a random word from a list # wordList = random.choice(word) # def hint(word): # pri...
true
bdde802cc230515eff1ac694e6139a94e3eb6a24
jingyuexing/py-emmet
/emmet/stylesheet/score.py
1,201
4.125
4
def calculate_score(abbr: str, text: str): """ Calculates fuzzy match score of how close `abbr` matches given `string`. :param abbr Abbreviation to score :param str String to match :return Match score """ abbr = abbr.lower() text = text.lower() if abbr == text: return 1 ...
true
1cbc915ab931e470679f79943f3e64964cbbda1c
derek-johns/List-Comprehension
/list-comprehension.py
781
4.3125
4
# Lists in Python can be defined as a collection of arbitrary objects. # Written as a comma-separated sequence of objects in square brackets. a = ['foo', 'bar', 'baz', 'qux'] print(a) # Important characteristics of lists: # - lists are ordered a = ['foo', 'bar', 'baz', 'qux'] b = ['baz', 'qux', 'bar', 'foo'] print(a ...
true
7edaa6b93de037fb448b8e604e97dcb9a8bf2766
matthewharrilal/InterviewPrepProblems
/recursion-search-algorithms.py
782
4.21875
4
def recursive_permutations(lst): '''Finds all permutations of a string recursively''' # First we handle our error and early exit cases if len(lst) is 0: return None elif len(lst) is 1: return [lst] # Shows that the only permuation is the list itself else: permutation_list...
true
95f1ff518a7d018b3c360845bd5c3876865ba2f5
balintnem3th/balintnem3th
/week-03/day-3/rainbow_box.py
611
4.28125
4
from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() # create a square drawing function that takes 2 parameters: # the square size, and the fill color, # and draws a square of that size and color to the center of the canvas. # create a loop that fills the canvas with rain...
true
8498b12c3b914825d9f9aec72d5fe790309d95f7
miles-pulk/astr-119-hw-1
/data_types_continued.py
810
4.28125
4
#string s = "I am a string." print(type(s)) #will say str #Boolean yes = True #Boolean True print(type(yes)) no = False #Boolean False print(type(no)) # Lists -- ordered and changeable alpha_list = ["a", "b", "c"] #list initialization print(type(alpha_list)) #will say tuple print(type(alpha_list[0]))...
true
b0401fb8c1b52c1bce10fa5c08a55332194a6a8a
10mincode/10mincode
/guessinggame.py
731
4.21875
4
import random comp_guess=random.randint(0,9) print("Welcome to number Guesser Game") print("You have to enter a number between 0 and 9 including both 0 and 9") chanceleft=3 notwin=True while notwin: user_guess=int(input("Write a number between 0 and 9 including 0 and 9")) if comp_guess>user_gues...
true
71fa678bf36c37ff348ad7108e3d7dc67d92deb0
yubanUpreti/IWAcademy_PythonAssignment
/Python Assignment II/Question-8.py
274
4.15625
4
def is_prime(n): """ Checks if the given number is prime or not n: integer number as argument """ for i in range(2,n): # Runs the loop starting from 2 to n if n%i==0: return False break else: if i == n-1: return True print(is_prime(10))
true
1678d575238ed564e590695f51b1e5f0c6cc65d9
yubanUpreti/IWAcademy_PythonAssignment
/Python Assignment/Data Types/question11.py
209
4.125
4
from collections import Counter sample_string = 'python python program to count the occurrences of each word in a given sentence' string_to_list = sample_string.split(' ') print(Counter(string_to_list))
true
2e38f4e2b780e356b037548b1025e70a1be45b2d
thedonflo/Flo-Python
/ModernPython3BootCamp/Lambdas & Built-In Functions/Extremes.py
479
4.25
4
''' Extremes Exercise - Using Min and Max Write a function called extremes which accepts an iterable. It should return a tuple containing the minimum and maximum elements. For example: extremes([1,2,3,4,5]) # (1, 5) extremes((99,25,30,-7)) # (-7, 99) extremes("alcatraz") #( 'a', 'z') REMEMBER, RETURN A TUPLE!!...
true
ff9d845847c23106ce827487f04786e49232744e
thedonflo/Flo-Python
/ModernPython3BootCamp/List Comprehension Exercises/ListCompEx5.py
359
4.375
4
#Using a nexted list comprehension and range(), create a variable called "answer" with the following value #[[0,1,2], [0,1,2], [0,1,2]] #To break it down...start by using range and a list comp to generate the list [0,1,2]. #And then repeat the whole thing 3 times in a nested list comp. answer = [[num for num in range...
true
5bd42b57266ffe9cd754274913659014df67c1e9
thedonflo/Flo-Python
/Murach/.idea/Section 2/Chapter 10 - Strings/Chapter 10-1.py
2,570
4.53125
5
# 1. In IDLE, open the create_account.py file that's in this folder: # python/ exercises/ ch10 # 2. Create and use a function to get a valid email address. To be valid, the address # has to contain an @ sign and end with ".com". # 3. Create and use a function to get a valid phone number. To do that, remove all # sp...
true
2668e5d1f2ae1bd06857d8bedf452a7d9829f26e
thedonflo/Flo-Python
/ModernPython3BootCamp/Functions_Pt_1/multiply_even_numbers.py
374
4.375
4
# Write a function called multiply_even_numbers. This function accepts a list of numbers and returns the product of all even numbers in the list. ''' multiply_even_numbers([2,3,4,5,6]) # 48 ''' def multiply_even_numbers(nums): start = 1 for num in nums: if num % 2 == 0: start *= num re...
true
15caef18f0a62820fe6d1b4c9d71f2f682706314
aamiraak3/Python-Work-1st-Semester
/Finding Max even And Odd.py
784
4.46875
4
# This Program find max odd and even in two separate functions. This is In Python 3x def finding_max_even(): y = 0 for counter in range(3): # Range of numbers can be changed x = int(input("Enter a number: ")) if (x%2 == 0 and x > y): y = x if (y == 1): ...
true
82b6413344b343f7cf0533eb0e2bbfd169a5f9f9
briansu2004/MyLeet
/Python/Find Duplicate Subtrees/main.py
2,801
4.125
4
""" https://leetcode.com/explore/learn/card/hash-table/185/hash_table_design_the_key/1127/ Find Duplicate Subtrees Given the root of a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same...
true
1cf2ef0a8bc851b32a22eec5d10762a95ab3133b
briansu2004/MyLeet
/Python/Search in Rotated Sorted Array/main.py
2,798
4.1875
4
""" https://leetcode.com/explore/learn/card/binary-search/125/template-i/952/ Search in Rotated Sorted Array There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resultin...
true
852a5ffe5ad4c9cbfa0b04eacec88ed1e52c8696
briansu2004/MyLeet
/Python/Longest Common Prefix/main.py
1,302
4.1875
4
""" https://leetcode.com/explore/learn/card/array-and-string/203/introduction-to-string/1162/ Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output...
true
c6edd1f0a813e635bb09f8883234113716f6d408
briansu2004/MyLeet
/Python/Intersection of Two Arrays/main.py
1,515
4.28125
4
""" https://leetcode.com/explore/learn/card/binary-search/144/more-practices/1034/ Intersection of Two Arrays Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: Input: nums1 = [1,2,2,1], nums...
true
e80c62e111a13569bf4f4e2bcbe0df80abab86e4
sbkaji/python-programs
/assignment/36.py
298
4.1875
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 21 03:06:25 2020 @author: Subarna Basnet """ """36. You are given with a list of integer elements. Make a new list which will store square of elements of previous list.""" a=[1,2,3,4,5,6,7,8,9,0] print(a) b=[] for i in a: b.append(i**2) print(b)
true
b7214ec6294880ac4586e5ea8ef9236c4dff2f60
sbkaji/python-programs
/lab19.py
482
4.15625
4
#Python program to accept two no. Check whether 1st no. Is largest, second no. is largest or both are equal. noa=int(input("Enter first no")) nob=int(input("Enter second no")) if(noa==nob): print("Both Numbers {0} and {1} are equal".format(noa,nob)) elif(noa<nob): print("Second Number is largest :...
true
0813644eb776f0b303e30b72875dd24a1e5c4c24
sbkaji/python-programs
/lab44.py
273
4.28125
4
#Write a Python function to create and print a list where the values are square of numbers between 1 and 30 (both included). def my_function(n): list1=[] for i in range(1,n): a=i*i list1.append(a) print(list1) my_function(30)
true
83b4d267b7d6d72d12ed368f47d75cf093b204f1
Anumehra/Udacity
/DA_Project_1/code/visualizations.py
2,653
4.75
5
from pandas import * from ggplot import * def create_dataframe(filename): subway_data = pandas.read_csv(filename) #print subway_data.columns return subway_data def plot_weather_data(turnstile_weather): ''' You are passed in a dataframe called turnstile_weather. Use turnstile_weather along wit...
true
5f07104ae7ac131a9fee968be8d97bb1ea3ea782
HuyenN/fachkurs_master_2016
/01_introduction/guess_a_number.py
2,105
4.25
4
from random import randint def guess_a_number(): """Game to guess a number the computer randomly generated.""" # TODO: # generate a random number (uniformly distributed between 0 and 100) # read input from the user and validate that the input is numeric (use the function check_raw) # check whethe...
true
5bf3e926d71b58f35033c5954c79702959baf8f8
tenny7/dsa
/dsa.py
2,540
4.125
4
class Node(object): def __init__(self, data=None): self.data = data self.next = None class LinkedList(object): def __init__(self, head=None): self.head = head def insert_at_beginning(self, data): new_element = Node(data) if self.head is None: self.head ...
true
3c3f1063d680e64864302f6febec864b786ea1fe
connorgr/Projects
/numbers/fibonacci.py
692
4.53125
5
''' List the Fibonacci sequence up to and including the nth number. Indexing starts at 1. ''' def fibonacci(nth): sequence = [0, 1] if nth > 2: for i in xrange(2, nth): sequence.append(sequence[i-1]+sequence[i-2]) print sequence[:nth] ''' Print the largest Fibonacci number that is less ...
true
83fc713b7fab23df794b313665d79b11a7213bf3
Abhi-Balijepalli/PythonAlgorithms
/Leap-Year/leap_year.py
667
4.28125
4
# Author: Abhi Balijepalli # Date: 1/30/2020 # Description: Check if a year given is leap year # To run the file: python3 python3 leap_year.py def leapyear(): year = input("Please enter a year, and i will tell you if its a leap year or not: ") if int(year) < 0 or int(year) is None: print("Invalid Inpu...
true
0300535bec83db1daa8c2f323d013a5f45c88b1a
that-danya/PracticeAssessment9
/sorting.py
2,806
4.375
4
#Sorting def bubble_sort(lst): """Returns a sorted list using a optimized bubble sort algorithm i.e. using a variable to track if there hasn't been a swap. >>> bubble_sort([3, 5, 7, 2, 4, 1]) [1, 2, 3, 4, 5, 7] """ # identify where to stop in range of list while looping # identify...
true
8d670e3037dc21646c82118fe9143f928a074125
vickyarp/MITx-6.00.1x
/Problem sets/Problem set 2/Problem 1.py
1,874
4.5625
5
#Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. # #The following variables contain values as described below: # #balance - the outstanding balance on the credit card # #annualInterestRate - annua...
true
4d88c436693007978ddf7cc68fe7314c0c78fe53
mthakk3793/Python-
/Week 4/Ass 402.py
1,314
4.375
4
def humanPyramid(row, column): """ Recursive function for weight calculation """ if row < 0 or column < 0: # If row or column value is negative then the value is 0 return 0 if column > row: # Cannot have column greater than r...
true
c22e923223adea5fbb62cdc9cd8569a797f9526f
SSK0001/SDE-Skills
/Week 2/MergeSortedLists.py
1,190
4.4375
4
# Time took : 10 mins ''' Approach 1: can create a additional linked list to store the entire list while traversing the list1 and list2 with two diffrent pointer Time complexity : O(n); Space Complexity: o(n) {Cloning the two diffrent lists} Approach 2: Make a fake node up front and stich the node as you m...
true
c244282a46fc73d84ff433b4985ba88daa49c0f9
bhavya-singh/CP
/WoW/4_levelOrderTraversal.py
2,443
4.34375
4
#Author : Bhavya Singh #Date : 23-May-2020 #Name : Level Order Traversal #PROBLEM: You are given a tree and you need to do the level order traversal on this tree. Level order traversal of a tree is breadth-first traversal for the tree. Level order traversal of above tree is 1 2 3 4 5 Input: First ...
true
7c0bab6cd5947be58a728cd4850625e8619a28f2
msaffarm/InterviewPrep
/LeetCode/Tree/112-pathSum.py
1,317
4.125
4
# Given a binary tree and a sum, determine if the tree has a root-to-leaf # path such that adding up all the values along the path equals the given sum. # For example: # Given the below binary tree and sum = 22, # 5 # / \ # 4 8 # / / \ # 11 13 4 # ...
true
8cc1b9c9263e79aaa1d59f4b165c0b08ea2670d9
TyronSamaroo/kg_tyronsamaroo_2020
/main.py
1,498
4.25
4
import sys from collections import Counter def one_to_one_char_map(s1,s2): """This function determine whether a one-to-one character mapping exist from one string, s1, to another s2. Arguments: s1 {String} -- string of english alphabet letters first command line argument s2 {String} -- ...
true
783594336df697a80abc4b9dfd73835251a3fada
sunsun101/DSA
/1-sunsun.py
2,095
4.4375
4
# This file combines insertion and merge sort together import math def insertion_sort(list): print("*** PERFORMING INSERTION SORT ***") for j in range (1, len(list)): # determine the key key = list[j] # set i to find preceeding element i = j - 1 while i >= 0 and list[i]...
true
d2c94e10abd9e5402cdb0b8cfe26488c09622941
jdweidman/sermacs-workshop
/sermacs_workshop/string_util_bad.py
1,093
4.125
4
""" string_util.py Oh god how do I push things. Misc. string processing functions """ def title_case(sentence): """ Capitalize the first letter of every word. Parameters ---------------- sentence: string The sentence to be put into title case. Returns ---------------- capita...
true
b07116dc58ba9afc1f72315757d44ab865373d41
swingninja/AlgoPython
/find_pair.py
381
4.125
4
# Given an array, find a pair in the array that would add up to the given sum. # Example: # find_pair(array = [1,2,3,4,5], sum = 5) => Pair: 1 and 4 def find_pair(array, sum): for i in range(len(array)): for j in range (i+1, len(array)): if array[i] + array[j] == sum: return [...
true
6d391f1dcb95228065e489686d17414b1a3db873
lruby1203/web-caesar
/caesar.py
1,128
4.28125
4
import string def alphabet_position(letter): #Determine the letter's position in the alphabet_position #Normalize the letter letter = letter.lower() position = string.ascii_lowercase.index(letter) return position def rotate_character(char, rot): #Determine character to replace the original #This function will...
true
573c41cc560ded248f608a2589ac82ac951c0ba6
eaboytes/pynet_testz
/class9/exercise4/mytest/world.py
852
4.125
4
''' 4. Create a class MyClass in world.py. a. This class should require that three variables be passed in upon initialization. b. Write two methods associated with this class 'hello' and 'not_hello'. Have both these methods print a statement that uses all three of the initialization variables. ''' def fu...
true
c2c08515b32b94c513011fe09d0aed18cf0ca1cb
KevinQiu2020/hello-world
/README.md
555
4.25
4
#!/usr/bin/python # -*- coding: utf-8 -*- print("Hello,World!") print("Hello Python World") message="Hello Python World" print(message) message="Hello Python Course world" print(message) name=input('Please enter your name: ') print('Hello, ',name) #清空空格、头字母变大写 first_name=input('Please enter your fist name:, ') first_na...
true
9d93f58087de32fe583d43633bd4691d2f17acf2
marieke-thomas/list-notes
/lists.py
1,375
4.1875
4
first_favorite_food = "sushi" second_favorite_food = "burritos" third_favorite_food = "burgers" fourth_favorite_food = "ribs" fifth_favorite_food = "spaghetti and meatalls" # Let's put foods into a list. # CRUD (Create, Read, Update, Delete) # Create: name_of_list = ["first item","second item"] fav_foods = ["sushi", "...
true
f022faa94362682eef51290df8461b90fd8a0160
eroicaleo/LearningPython
/interview/leet/316_Remove_Duplicate_Letters.py
2,597
4.375
4
#!/usr/bin/env python3 # Example 1: # Input: "bcabc"Output: "abc" # Example 2: # Input: "cbacdcbc" # Output: "acdb" # My thinking process # The first night, my first thought is to move a letter backward # If the letter immediately after it is smaller than it, e.g. # bab, we should move the 1st b back # The difficulti...
true
85494c3f7a0353ce54999aabc1eb605aef107574
dcowgill/codejunk
/dcp/060/060.py
1,477
4.1875
4
#!/usr/bin/env python3 """ Good morning! Here's your coding interview problem for today. This problem was asked by Facebook. Given a multiset of integers, return whether it can be partitioned into two subsets whose sums are the same. For example, given the multiset {15, 5, 20, 10, 35, 15, 10}, it would return true...
true
1b00115d4037a4be092d66cb800d49ee5ac233f7
dcowgill/codejunk
/dcp/081/081.py
1,122
4.28125
4
#!/usr/bin/env python3 """ Good morning! Here's your coding interview problem for today. This problem was asked by Yelp. Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent. You can assume each valid number in the mapping is a singl...
true
b31a9332009702d3d79238179ee036c03c95506a
chithien0909/Competitive-Programming
/Leetcode/Leetcode- Insert Delete GetRandom O(1).py
1,239
4.21875
4
import random class RandomizedSet: def __init__(self): """ Initialize your data structure here. """ self.s = {} def insert(self, val: int) -> bool: """ Inserts a value to the set. Returns true if the set did not already contain the specified element. """...
true
0958c8fe13f2a2d7ddb03179a826938f54382726
chithien0909/Competitive-Programming
/Leetcode/Leetcode - Premium/Google/Valid Parenthesis String.py
1,681
4.375
4
""" Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis ')' must have a corresponding left p...
true
053bcba3cba97a9286b0ae63ce5b531dd98b34b1
chithien0909/Competitive-Programming
/Leetcode/Leetcode - Strobogrammatic Number II.py
1,376
4.125
4
""" A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are of length = n. Example: Input: n = 2 Output: ["11","69","88","96"] """ from collections import deque class Solution: def findStrobogrammatic(self, n: int) -> ...
true
ce61ec4aec41636c23673d0b56cc635e5a1d3bfe
chithien0909/Competitive-Programming
/Leetcode/Leetcode - Premium/Microsoft/Reverse Words in a String II.py
1,470
4.125
4
""" Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] Note: A word is defined as a sequence of non-space characters. The input string does not contain leading or...
true
f46d43f9f73da761fe4b43bdbc61277870391ba3
chithien0909/Competitive-Programming
/Leetcode/Leetcode - Premium/Google/Minimum Window Substring.py
2,721
4.21875
4
""" Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC" Note: If there is no such window in S that covers all characters in T, return the empty string "". If there is such window, yo...
true
efb7cd2b2f7eac08928e55f9e82cc6d99f5988c5
chithien0909/Competitive-Programming
/Leetcode/Leetcode - Reconstruct Itinerary.py
1,639
4.5
4
""" Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK. Note: If there are multiple valid itineraries, you should return the itinerary th...
true
4e534de39cd9d2bac33f84713d8f3e21fa7d4e85
Lordjiggyx/PythonPractice
/Basics/Strings.py
1,707
4.5
4
#Strings #Strings are usually surrounded with single/double quotation marks x = "Hello world" #You can create multiline strings by using a triple quotation a = """ lorem ipsum dolor sit amet """ print(a) #Acessing strings """To access elements of a string you can use square brackets""" print(x[4]) #Slicing ""...
true
8d7342a48c4ee6076d652c6be107f623e86fe926
Lordjiggyx/PythonPractice
/Advanced/Try_Except.py
729
4.21875
4
#Exception Handling "We can use try catchs to handle exceptions" "They try a block of code and then hadnle anything if an error occurs" "Try execpt is like try catches in java " try: print(X) except: print("x does not exist") "You can try multiple exceptions" try: print(Y) except NameError: print("Y ...
true
4b2f17ed6f14fe439631cd9c830287d4aa8e351c
Lordjiggyx/PythonPractice
/Basics/Sets.py
1,022
4.59375
5
#Sets "To create a set you must use {} bracktes" thisset = {1,2,3} print(thisset) "To access an item you must loop through the set the same way you would a list" for x in thisset: print(x) "To check if something is in a set it's the same as a list" "To add a single object to a set use the .add() method" thisset...
true
9221cf6f4f967717264ea18f597ff5b3b55f318a
CaioHRombaldo/PythonClasses
/Ex035.py
365
4.3125
4
print('Enter the length of 3 lines and find out if it is possible to form a triangle.') line1 = int(input('line 1: ')) line2 = int(input('line 2: ')) line3 = int(input('line 3: ')) if line1 + line2 > line3 and line1 + line3 > line2 and line2 + line3 > line1: print('TRIANGLE! They can form a triangle.') else: p...
true
2ec6d134c8403c658ae2ce91c0f60a9c45690c36
usmanadev/algorithms
/python/sorting/bubble_sort.py
416
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: def bubble_sort(items): """Sorts a list of items in ascending order. """ for i in range(len(items)): swapped = False for j in range(len(items) - 1): if items[j] > items[j+1]: swapped = True items[j]...
true
fd3d54419c094dabb9d44b3bfba53ff651b71d2e
moniquesenjaya/exercise_week_5_functions
/number_4.py
513
4.28125
4
from fractions import Fraction def calc_new_height(): width = eval(input("Enter the current width: ")) height = eval(input("Enter the current height: ")) new_width = eval(input("Enter the desired width: ")) value = width/height ratio = Fraction(value).limit_denominator() numbers = [int(i) for i...
true
7e80826ff3e313917a53e46df42accd778189311
apoorvakunapareddy/Python_Codes
/StringList.py
305
4.25
4
String= input("Enter the String: ") print(String) print(String[::-1]) # Using list slicing funtions if String==String[:: -1]: print("Palendrom") # Using for loops x='' for i in range(len(String)): x+= String[len(String) -1 -i] if String==x: print('Palendrom 2') else: print('Not Palendrom')
true
1a72239b056da688a19a397198ca2eef9e6a9bb7
moasslahi/complete-python-journey
/Sections/PythonBasics/dictionaries.py
762
4.28125
4
# Dictionary #data type + data structure #organize our data #key and value pair #unordered ! myDict = [ { 'name': 'Mo', 'age': 20, 'number': [1,2,3] }, { 'name': 'Ahmed' } ] print(myDict[0]['name']) print(myDict[1]['name']) #------------------------ # dictionary methods 1 # 1)get ...
true
d669e519f9ee49a33f806cf77f23390458defc07
moasslahi/complete-python-journey
/Sections/PythonBasics/lists1.py
1,273
4.3125
4
#lists are collection of items #ordered seqeunce of any type #Data structure = organize info into folder Mylist = [1,2,3,4,5] Mylist2 = ['a','b','c'] Mylist3 = [1,2,3,'a', False] amazon_cart = [ 'sunglasses', 'book', 'Iphone', 'Ipad', 'laptop' ] print(amazon_cart[0]) #----------------------------...
true
223e1482ffef6468ac9534782e25eef6090edefa
111098/Data-structures
/linklist.py
2,833
4.125
4
#linked list class Node: def __init__(self, data = None): self.data = data; self.next = None class linkList: def __init__(self): self.headval = None; def printLinkList(self): printvalue = self.headval while printvalue is not None: pr...
true
1597a02bb3df3467ac6e37e536037f5439378310
farnazjmo/CTI-110
/P3HW1_MonthNum_FarnazJeddi Moghaddam.py
618
4.375
4
# CTI-110 # P3HW1 - Month number # Farnaz Jeddi Moghaddam # 10/03/19 #Get the month number input from the user def main(): month=int(input("Please enter the month's numbr (1 through 12): ")) #Create dictionary for month numbers and names monthdict={1:'January',2:'February',3:'March',4:'April',5:'May',6:'June'...
true
e59a99b5de78bbe8e726307b3a535406581593b1
farnazjmo/CTI-110
/P5T1_KilometerConverter_FarnazJeddiMoghaddam.py
683
4.59375
5
# This program converts kilometers to miles # 10.29.19 # CTI-110 P5T1_KilometerConverter # Farnaz Jeddi Moghaddam conversion_factor=0.6214 #The main function gets the distance in kilometers and #calls sho_miles function to convert it def main(): #Get the distance in kilometers kilometers=float(input('Enter ...
true
a376e48a02b71978f9e951a290cc9ff7cc39aca0
erickmel/Data-Structures-Algorithms
/1-Arrays.py
709
4.1875
4
#Arrays strings = ['a','b','c','d'] # 4*4 = 16 bytes of storage is used print(strings[2]) #push strings.append('e') # O(1) #pop strings.pop() strings.pop() # O(1) #addfirstelement strings.insert(0,'x') #O(n) #splice strings.insert(2,'alien') #O(n) print(strings) #%% #Data Structures Exc...
true
2ea88cd7a4033ef448fcd0b4ec23133dcef0dab8
AlexandreL1984/Py4e
/FilePrint.py
289
4.40625
4
# Write a program that prompts for a file name, # then opens that file and reads through the file, # and print the contents of the file in upper case. # Use the file words.txt to produce the output below. fh = open('abc') for lx in fh: ly = lx.rstrip() print(ly.upper())
true