blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
d8ca1f9146fa6dad6de66701e10e45f054f37c39
dgervais19/Eng74_Python
/dictionaries.py
1,694
4.65625
5
# What is a dictionary # Dictionary (arrays) is another way managing data more Dynamically # Key value pairs to store and manage data # Syntax : {"name": "James"} # a = {"key": "value"} # what type of data can store/manage # Let's create one devops_student_data = { "key": "value", "name": "james", "stream"...
true
8d8a4983bc39fb8c6870cb7e7f275b43d160baea
bhawnabhatt2012/python_lab_exp
/2.b.py
497
4.21875
4
index = 0 string = input("Enter the string: ") substring = input("Enter the substring: ") if substring in string: print(substring," is present in ",string) while index < len(string): index = string.find(substring, index) if index == -1: break print(substring, ' found...
true
edc8eefa43d0a05859412b8ca21107af71e8237c
lanaelsanyoura/CommentedPythonIntermediateWorkshop
/Person.py
1,226
4.25
4
from datetime import date, datetime #for date class Person: """ A person class ==== Attributes ==== firstname: str lastname: str birthdate: date YEAR, MONTH, DAY address: str """ def __init__(self): #, firstname, lastname, birthdate, address): #self.firstname = firstname ...
true
13c0b258a492922a560d61c522efd7d6217fc045
michaelkemp2000/vader
/ex20.py
1,186
4.375
4
from sys import argv # Pass in an argument from command line script, input_file = argv # Function to print the whole file def print_all(f): print f.read() # Function to go the the begining of a file def rewind(f): f.seek(0) #Function to print a line of the file that you pass in def print_a_line(line_count, f): p...
true
d6edafab430c4d6585a2edc62ca1336901199f95
michaelkemp2000/vader
/ex3.py
1,104
4.375
4
# Print the text print "I will now count my chickens." # Print test and the sum answer after the comma print "Hens", 25.645 + 30.5943 / 6 # Print test and the sum answer after the comma print "Roosters", 100 - 25 * 3 % 4 # Print the text print "Now I will count the eggs." # Prints the answer to the sum. Not sure w...
true
210c5757a96f915bfdcba3d80cda9a7dddae74c1
miguelgaspar24/BoardgamePrices
/utilities.py
728
4.65625
5
#!/usr/bin/env python # coding: utf-8 def convert_chars(string): ''' Converts problematic characters. Usually, tend to be accented vowels. Takes the following parameters: string (str): a string where one or more characters raise a UnicodeEncodeError. Returns a modified string. ''' ...
true
ecccdec592c1cccb123c9ab92170438df90e8fed
jeffkt95/ProjectEuler
/problem0005.py
945
4.15625
4
import sys import os import math def main(): highestNumber = 20 maxCheck = highestNumber * 100000000 # Starting with highestNumber, go up by multiples of highestNumber # e.g. if your highestNumber was 10, check 10, 20, 30, 40, etc. for numForCheck in range(highestNumber, maxCheck, highestNumber): #Assume it'...
true
60cfdeffffb011a932a51daf21ddfb9d42c50bb4
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m10/biggest Exercise/biggest Exercise/biggest_exercise.py
1,025
4.125
4
#Exercise : Biggest Exercise #Write a procedure, called biggest, which returns the key corresponding to the entry with the largest number of values associated with it. If there is more than one such entry, return any one of the matching keys. def biggest(aDict): ''' aDict: A dictionary, where all the values a...
true
f3b2c0443d86d4b7deedc30384e3a0aa7868b4c0
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m3/hello_happy_world.py
234
4.125
4
''' @author : gvnaakhilsurya Write a piece of Python code that prints out the string 'hello world' if the value of an integer variable, happy,is strictly greater than 2. ''' HAPPY = int(input()) if HAPPY > 2: print("hello world")
true
68cc3286321708fcf077d10f169acfbe5e326715
dineshagr/python-
/multiDimentionalLists.py
641
4.40625
4
# this is a one dimentional list x = [2,3,4,5,6,7,8] # this is a 2 dimentional list y = [[5,4], [3,4], [7,9], [2,8]] # 0 1 0 1 0 1 0 1 these are the individual positions of inner lists # 0 1 2 3 these are the positions of outer lists print(y) print(y[3][1]) # this is a multidimenti...
true
b689d8c576b9731b116d987bb1282437803f63a9
onatsahin/ITU_Assignments
/Artificial Intelligence/Assignment 2/block_construction_constraint.py
2,980
4.125
4
#Onat Şahin - 150150129 - sahino15@itu.edu.tr #This code include the Block class and the constraint function that is used for the csp problem. #This code is imported from csp_str_1.py and csp_str_2.py which create the model and solve the problem. blocklist = [] #A list that holds block objects. Filled in the other co...
true
41eec34b60ce8f0152543d9464e064039a974cae
sebutz/python101code
/Chapter 4 - Conditionals/conditionals.py
2,148
4.34375
4
# a simple if statement if 2 > 1: print("This is a True statement!") # another simple if statement var1 = 1 var2 = 3 if var1 < var2: print("This is also True") # some else if var1 > var2: print("This should not be printed") else: print("Ok, that's the good branch") # -1 -----0 ----...
true
1d76d63c49fba58705754cb77cc6228a3bb891c0
isaiahb/youtube-hermes-config
/python_publisher/logs/logger.py
957
4.1875
4
"""This module creates a logger that can be used by any module to log information for the user. A new logger is created each time the program is run using a timestamp to ensure a unique name. """ import logging from datetime import datetime class Logger(): """Creates a timestamped log file in the logs/ directory a...
true
c3298fa7e323160b821295148c7e7094e9d47364
lradebe/simple_programming_problems
/largest_element.py
219
4.1875
4
def largest_element(mylist): largest_element = 0 for element in mylist: if element >= largest_element: largest_element = element print(largest_element) largest_element([1, 2, 3, 4, 5])
true
0177a475d7829b46e61a98456b99d438e3250bb8
lradebe/simple_programming_problems
/find_intersection.py
726
4.375
4
def find_intersection(Array): '''This function takes in a list with two strings \ it must return a string with numbers that are found on \ both list elements. If there are no common numbers between \ both elements, return False''' first = list(Array[0].split(', ')) second = list(Array[1].split(', ')) s...
true
361d5439ded4c00ad770618c6c99cf927c8117a7
Harsh-Modi278/dynamic-programming
/Fibonacci Sequence/solution.py
534
4.3125
4
# Initialising a dictionary to store values of subproblems memo_dict = {} def fibonacci(n): # If answer to the nth fibonacci term is already present in the dictionary, return the answer if(n in memo_dict): return(memo_dict[n]) if n <= 2: return (1) else: # Store the answer to t...
true
ff45174dacc0319d4cb1faa28984f5ed10cf6662
TheBrockstar/Intro-Python
/src/days-1-2/fileio.py
468
4.1875
4
# Use open to open file "foo.txt" for reading foo = open('foo.txt', 'r') # Print all the lines in the file print(foo.read()) # Close the file foo.close() # Use open to open file "bar.txt" for writing bar = open('bar.txt', 'w') # Use the write() method to write three lines to the file bar.write('''"To be, or not to...
true
ac3e0974a676ea2cec4025da88171668aafa7062
mukesh25/python-mukesh-codes
/pattern/pattern9.py
332
4.1875
4
# 1 # 2 2 # 3 3 3 # 4 4 4 4 # No. of spaces in every row:(n-i-1) # which symbol: (i+1) # How many times: (i+1) # with in each row same symbol are taken # inside row symbol are not changing that's why nested loop is not required. n= int(input('Enter n value: ')) for i in range(n): print(' '*(n-i-1)+(str(i+1)+'...
true
90ee5d614355f201a11e5a5f8d64dd2632427dac
urskaburgar/python-dn
/naloga-8/calculator/calculator.py
417
4.21875
4
first_number = int(input("Enter the first number: ")) second_number = int(input("Enter the second number: ")) operation = input("Choose operation (+, -, *, /): ") if operation == "+": print(first_number + second_number) elif operation == "-": print(first_number - second_number) elif operation == "*": prin...
true
f0eb2816abe1464ed57b923664a5a97737c8f1f0
dgampel/passion-learn
/examples/binary_search.py
908
4.28125
4
def binary_search(array,first,last,x): array.sort() if last >= 1: #base case middle = 1 + (last - 1) // 2 if array[middle] == x: #if element is present at middle return middle if array[middle] > x: #if element is in left half ...
true
e89644f9ae975b08815394c47a0669ee65627f07
gopalanand333/Python-Basics
/dictionary-basic.py
333
4.71875
5
#! /usr/bin/env python03 # a dictionary is searchable item with key-value pair x = {"one": 1, "two":2, "three":3, "four":4,"five":5} # a dictionary for key in x: print(key) # this will print the keys for key, v in x.items(): print('key: {} , value:{}'.format(key, v)) # this will return the key val...
true
cd93ecfa1c20132aa72909ed314b4ba3d2fe177b
blakexcosta/Unit3_Python_Chapter5
/main.py
1,208
4.3125
4
def main(): # booleans number1 = 1 number5 = 5 # boolean values are written as True and False if (number1 > number5): print("this statement is true") else: print("this statement is false") # list of comparison operators # https://education.launchcode.org/lchs/chapters/b...
true
ba025910735dc60863ef5b6525cc20bace3675cb
CAWilson94/MachineLearningAdventures
/ex2/python/iris.py
2,446
4.4375
4
# Charlotte Wilson # SciKit learn example # How starting from the original problem data # can shaped for consumption in scikit-learn. # importing a dataset from sklearn import datasets # data member is an n_sample and n_features array iris = datasets.load_iris(); digits = datasets.load_digits(); # digits.data access...
true
42733c4983449b3967f4b450f35c6b319f8cbd9b
alexgneal/comp110-21f-workspace
/exercises/ex01/hype_machine.py
273
4.15625
4
"""Use concantonations to build up strings and print them out using my name.""" __author__ = "730332719" name: str = input("What is your name? ") print(name + ", you are awesome!") print("You're killing it, " + name) print("Wow, " + name + ", you are an absolute queen!")
true
617bcc056e3011b6b303ab1c1de87d3e9af49417
Benneee/PythonTrips
/Assignment_Wk4_Day1_QuadRoots_App.py
2,135
4.34375
4
#The Quadratic Roots Programme #ALGORITHM #1 Introduce the program to the user #2 Give the required instructions to run program appropriately #3 Request values for a, b, c #4 Define a variable for the discriminant #- Solve the discriminant #- Solve the square root of the discriminant #- import math m...
true
c76cf6d1d8d193a0f2a9036d06558344caf2f066
jerthompson/au-aist2120-19fa
/1130-A/0903-primeA.py
300
4.25
4
n = 2 max_factor = n//2 is_prime = True # ASSUME it is prime for f in range(2, max_factor + 1): # INCLUDE max_factor by adding 1 if n % f == 0: print(n, "is not prime--it is divisible by", f) #exit() is_prime = False break if is_prime: print(n, "is prime")
true
f28949cd50fe4a1d5e80c4f0fad20d6172a0531a
hbinl/hbinl-scripts
/Python/C5 - MIPS/T3 - new_power.py
1,762
4.21875
4
""" FIT1008 Prac 5 Task 3 @purpose new_power.py @author Loh Hao Bin 25461257, Derwinn Ee 25216384 @modified 20140825 @created 20140823 """ def binary(e): """ @purpose: Returns a binary representation of the integer passed @parameter: e - The integer to be converted to binary @precondition: A positive i...
true
6f5abd237c95b6590f222c0e5c2dbaf1c7243e99
itsformalathi/Python-Practice
/iteratingdictionery.py
473
4.78125
5
#No method is needed to iterate over a dictionary: d = {'A': 'Apple', 'B': 'Ball', 'C': 'Cat'} for Key in d: print(Key) #But it's possible to use the method iterkeys(): for key in d.iterkeys(): print(key) #The method itervalues() is a convenient way for iterating directly over the values: f...
true
8beb44bb1abf99b16cc7b4a05f3dca7b6b3f6c93
derekyang7/WSIB-Coding-Challenge
/code-obfuscation.py
811
4.15625
4
def myfunction(): num = input("Enter string:") a = "" b = num while len(b) > 0: if len(b) > 0: c = b[-1] b = b[:-1] a += c else: break if a == num: return True else: return False """Function that reverses the order ...
true
b1e254e649b83072a1ea2a09f3e40d5a7f6b5a5d
siggij91/TileTraveller
/tile_traveller.py
2,353
4.1875
4
##Project 5 Tile Traveler https://github.com/siggij91/TileTraveller #Create tile structure and label it #Append allowable moves to file structure #N = +1 in second index and S = -1 #E = +1 in first index and W = -1 #Once in new tile, show the allowable moves #Once player enters 3, 1 show them that they win. def can...
true
4a578dd7fcd9cc12e0a6e28051f5641d2a9c22fe
vijaypal89/algolib
/ds/linkedlist/intro2.py
593
4.125
4
#!/usr/bin/python import sys class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self.head while temp: print temp.data, temp = temp.next ...
true
9114541f1b9aa4b177fafd0ac50ef8b81ce76da0
AlreadyTakenJonas/pythonBootCamp2021
/easyExercise_12_regression/easyExercise_12_regression.py
2,208
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 14 17:20:35 2021 @author: jonas """ # IMPORT MODULES # Handling linear regression from sklearn.linear_model import LinearRegression # Handling exponential regression from scipy.optimize import curve_fit # Handling numbers and arrays import numpy as...
true
7736bd8f305be6ea6e633d1fd34a7fe4e3ec33e3
missweetcxx/fragments
/segments/sorting/d_insert_sort.py
2,061
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class InsertSort: """ Insert Sort divide list into two lists: sorted one and unsorted one; each time insert an element from unsorted list into sorted one at correct position; Complexity: O(n^2) in worst case Memory: O(1) """ @staticmethod...
true
25d5e2d5f13b3580b96f8a8496ba1377b28171a6
missweetcxx/fragments
/segments/binary_tree/binary_tree.py
1,895
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from segments.binary_tree.node import Node class BinaryTree(object): """ generate binary tree """ def __init__(self): self.root = None pass # create a binary tree with nodes def _add_node(self, val): # create root node of...
true
3db4db9c93004441a249355b1a923a8439e78aa8
jgerity/talks
/2016/computing_workgroup/intro-to-python/firstclassfunctions_example.py
1,431
4.59375
5
#!/usr/bin/env python def makeAddFunction(x): """ This function represents breaking the operation x+y into two steps, by returning a function F(y) that "knows" what value of x to use. In more specific terms, the value of x is stored in the "closure" of the function that is created. """ de...
true
0062eb73333fbb36791f164a7d3743691eb36490
vbanurag/python_set1
/set_1/Ques_2.py
687
4.125
4
a=[1,1,2,3,5,8,13,21,34,55,98] #part 1 #prints all elements of the list which are less than 5 print "\nThe no. are less than 5 is : ",[x for x in a if x<5] #part 2 #print a seperate list and stored a no which is less than 5 new_a=[] for x in a: if x<5: new_a.append(x) print "\n New list is ",new_a #...
true
aed55c61659e5efbc2c9330ca54947651c00bb67
KareliaConsolidated/CodePython
/Basics/08_Functions.py
1,431
4.125
4
# Create variables var1 and var2 var1 = [1, 2, 3, 4] var2 = True # Print out type of var1 print(type(var1)) # Print out length of var1 print(len(var1)) # Convert var2 to an integer: out2 out2 = int(var2) # Create lists first and second first = [11.25, 18.0, 20.0] second = [10.75, 9.50] # Paste together first and s...
true
23ce14c416b32d4aa28e7c342c9ab201b8f640df
KareliaConsolidated/CodePython
/Basics/49_Functions_Ex_09.py
312
4.25
4
# Write a function called multiply_even_numbers. This function accepts a list of numbers and returns the product all even numbers in the list. def multiply_even_numbers(li): total = 1 for num in li: if num % 2 == 0: total *= num return total print(multiply_even_numbers([1,2,3,4,5,6,7,8,9,10])) # 3840
true
873d59c466d5d1b9820cfb3ce30d8fce24f74876
KareliaConsolidated/CodePython
/Basics/17_Conditional_Statements.py
1,008
4.25
4
# Conditional logic using if statements represents different paths a program can take based on some type of comparison of input. name = "Johny Stark" if name == "Johny Stark": print("Hello, " +name) elif name == "John Fernandes": print("You are not authorized !" +name) else: print("Calling Police Now !") # In Pyth...
true
4dac05e28d6efd9441100f9d70a9f61318e8bb65
KareliaConsolidated/CodePython
/Basics/21_Loops.py
613
4.34375
4
# In Python, for loops are written like this: for item in iterable_object: # do something with item # An iterable object is some kind of collection of items, for instance; a list of numbers, a string of characters, a range etc. # item is a new variable that can be called whatever you want # item references the curr...
true
f6f144ae9939c97e2f3ee45dff82029100277512
KareliaConsolidated/CodePython
/Basics/166_Python_Ex_27.py
443
4.21875
4
# nth # Write a function called nth, which accepts a list and a number and returns the element at whatever index is the number in the list. If the number is negative, the nth element from the end is returned. # You can assume that number will always be between the negative value of the list length, and the list length ...
true
84dea473a9911b96684c54d1f339a442ecac41a6
KareliaConsolidated/CodePython
/Basics/158_Python_Ex_19.py
400
4.25
4
# Vowel Count # Write a function called vowel_count that accepts a string and returns a dictionary with the keys as the vowels and values as the count of times that vowel appears in the string. def vowel_count(string): lower_string = string.lower() return {letter:lower_string.count(letter) for letter in lower_string ...
true
c06f926ba0c3bf416e403eed81a0497605ab1eeb
KareliaConsolidated/CodePython
/Basics/160_Python_Ex_21.py
781
4.375
4
# Write a function called reverse_vowels. This function should reverse the vowels in a string. Any characters which are not vowels should remain in their original position. You should not consider "y" to be vowel. def reverse_vowels(s): vowels = 'aeiou' string = list(s) i, j = 0, len(s) - 1 while i < j: if string...
true
bbbb95519e1f58642b25b4642b7ef20bc0bbbf05
neoguo0601/DeepLearning_Python
/Python_basic/python_basic/python_basic_1.py
2,066
4.5
4
days = 365 print(days) days = 366 print(days) #Data Types #When we assign a value an integer value to a variable, we say that the variable is an instance of the integer class #The two most common numerical types in Python are integer and float #The most common non-numerical type is a string str_test = "China" int_tes...
true
d78a38eb6e954225d81984b05cd5cc782b5b93b8
bitlearns/TurtleGraphics
/Assignment14_RegularPolygonsWithTurtleGraphics.py
2,672
4.9375
5
#Program Description: The following program will use turtle graphics to draw #polygons based on the user's input of how many sides it will have. #Author: Madeline Rodriguez #Imports turtle graphics and random from turtle import * import random #The sides function will take in the user's input of number of sides and ...
true
a64fee29b65474879949c905b005046e61298a8e
Isaac-Tait/Deep-Learning
/Python/scratchPad4.py
893
4.15625
4
# Exponent functions def raise_to_power(base_num, pow_num): result = 1 for index in range(pow_num): result = result * base_num return result print(raise_to_power(3, 2)) # 2D list number_grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], [10] ] print(number_grid[2][2]) print("It is time to...
true
e5dfd182fe3810d77335f56d8d73ff6d26603be0
paulram2810/Python-Programs
/armstrong.py
265
4.125
4
num = eval(input("Enter number to check for armstrong : ")) x = num flag = 0 while x!=0 : temp = x%10 flag = flag+(temp**3) x = x//10 if flag==num: print(num," is an armstrong number.") else: print(num," is not an armstrong number.")
true
3be02701f737d06284c9a26f1c719cdab2c721d1
bmlegge/CTI110
/P3T1_AreasOfRectangles_Legge.py
737
4.15625
4
#CTI-110 #P3T1: Areas of Rectangles #Bradley Legge #3/3/2018 print("This program will compare the area of two rectangles") recOneLength = float(input("Enter the length of rectangle one: ")) recOneWidth = float(input("Enter the width of rectangle one: ")) recOneArea = float(recOneLength * recOneWidth) rec...
true
f4757eb581419b63362df05cbdebee759ec302d3
flerdacodeu/CodeU-2018-Group7
/lizaku/assignment2/Q2.py
2,129
4.15625
4
from Q1 import Node, BinaryTree, create_tree def find_lca(cur_node, node1, node2): result = find_lca_(cur_node, node1, node2) if not isinstance(result, int): raise KeyError('At least one of the given values is not found in the tree') return result def find_lca_(cur_node, node1, node2): # This...
true
b93f8ec573992e03b78f890fc8218ff4404ed435
flerdacodeu/CodeU-2018-Group7
/EmaPajic/assignment4/assignment4.py
1,923
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: EmaPajic """ def count_islands(rows,columns,tiles): """ I am assuming that we can change tiles (set some values to false). If we couldn't do that, we could just make another matrix where we would store flags so that we don't visit same tile tw...
true
c318ca570f5bffa95560fc13a6db502472133dc5
oskarmampe/PythonScripts
/number_game/program.py
538
4.15625
4
import random print("----------------------------------") print(" GUESS THAT NUMBER GAME ") print("----------------------------------") the_number = random.randint(0, 100) while True: guess_text = input("Guess a number between 0 and 100: ") guess = int(guess_text) if the_number > guess: ...
true
3049443c9a563cdcecd50556ecd1aeb8e1db0e6b
StefGian/python-first-steps
/maxOfThree.py
370
4.40625
4
#Implement a function that takes as input three variables, #and returns the largest of the three. Do this without using #the Python max() function! a = int(input("Type the first number: ")) b = int(input("Type the second number: ")) c = int(input("Type the thrid number: ")) if a>b and a>c: print(a) elif...
true
412a520a55edcaa026306556a477ff4fe01bed4a
Akhichow/PythonCode
/challenge.py
632
4.125
4
vowels = set(["a", "e", "i", "o", "u"]) print("Please enter a statement") sampleText = input() finalSet = set(sampleText).difference(vowels) print(finalSet) finalList = sorted(finalSet) print(finalList) # [' ', 'I', 'c', 'd', 'm', 'n', 'r', 's'] # My solution - # finalList = [] # # while True: #...
true
60d00c0a404a950786d0f83affd95e35f8fe00f3
JasmineEllaine/fit2004-algs-ds
/Week 1/Tute/8-problem.py
623
4.25
4
# Write code that calculates the fibonacci numbers iteratively. # F(1) == F(2) == 1 def fibIter(x): seq = [1, 1] # Return fib(x) immediately if already calculated. if (x <= len(seq)): return 1 for i in range(1, x-1): seq.append(seq[i]+ seq[i-1]) return seq[-1] """ Time complexity: ...
true
1693a547bd0278f0675a13ee34e1fa63ee86a00c
davidcotton/algorithm-playground
/src/graphs/bfs.py
1,790
4.1875
4
"""Breadth-First Search Search a graph one level at a time.""" from collections import deque from typing import List, Optional from src.graphs.adjacencylist import get_graph from src.graphs.graph import Graph, Vertex def bfs_search(start: Vertex, goal: Vertex) -> Optional[List[Vertex]]: """Search for the goal v...
true
660aea75a1024b16e007b6dcdef4aca6cdf6ae77
blane612/for_loops
/tertiary.py
470
4.40625
4
# -------------------- Section 3 -------------------- # # ---------- Part 1 | Patterns ---------- # print( '>> Section 3\n' '>> Part 1\n' ) # 1 - for Loop | Patterns # Create a function that will calculate and print the first n numbers of the fibonacci sequence. # n is specified by the user. # # NOT...
true
d6192566a5778e4c5ec9536c5f30db470bca7439
WeeJang/basic_algorithm
/ShuffleanArray.py
1,260
4.28125
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returne...
true
023e609eb767a6e0ec588b79fd38567e82c84225
JakeJaeHyongKim/I211
/lab 3-4(list comp, combined number in list).py
549
4.15625
4
#lab practical example #appeal only what I need as output, #1= sort it nums = ["123", "321", "435", "2468"] num_order = [num for num in nums if [digit for digit in num] == \ sorted([digit for digit in num])] print(num_order) lst1 = [1,2,3] lst2 = sorted([1,2,3]) #2= only odd numbers as ...
true
5bf0db55a5bc7ca89f4e02cc1d0bbf195629bf45
JakeJaeHyongKim/I211
/lab 3-3(list comprehension, word to upper case).py
378
4.1875
4
#word list comprehension #if word contains less than 4 letters, append as upper case #if not, leave it as it is words= ["apple", "ball", "candle", "dog", "egg", "frog"] word = [i.upper() if len(i) < 4 else i for i in words] #not proper: word = [word.upper() if len(words) < 4 else word for word in words] #learn ...
true
6168e7579f4d014b666e617f5ff9869cea0d68b4
mayanksh/practicePython
/largestarray.py
521
4.34375
4
#def largest(array, n): # max = array[0] #initialize array # for i in range (1, n): # if array[i] > max: # max = array[i] # return max #array = [1,2,3,4,5] #n = len(array) #answer = largest(array, n) #print("largest element is: " , answer) arr=int(input('Enter the element of an array:')...
true
617e98aa40ff5d01a7c2e83228c011705de0b928
timlindenasell/unbeatable-tictactoe
/game_ai.py
2,347
4.3125
4
import numpy as np def minimax(board, player, check_win, **kwargs): """ Minimax algorithm to get the optimal Tic-Tac-Toe move on any board setup. This recursive function uses the minimax algorithm to look over each possible move and minimize the possible loss for a worst case scenario. For a deeper under...
true
167b3a56792d0be21f40e0e8d2208fd7943ccddc
Vibhutisavaliya123/DSpractice
/DS practicel 6.py
1,624
4.4375
4
P6#WAP to sort a list of elements. Give user the option to perform sorting using Insertion sort, Bubble sort or Selection sort.# Code:Insertion sort def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of arr[0.....
true
5d7d4bc98ca3fc5b18b7206343bc8da663b29543
sergady/Eulers-Problems
/Ej1.py
354
4.15625
4
# 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. listNums = [] for i in range(1000): if(i%3 == 0 or i%5 == 0): listNums.append(i) sum = 0 for s in (listNums...
true
076a1ff1556bf140d838529270121ebd99ecc86f
halljm/murach_python
/exercises/ch02/test_scores.py
660
4.375
4
#!/usr/bin/env python3 # display a welcome message print("The Test Scores program") print() print("Enter 3 test scores") print("======================") # get scores from the user score1 = int(input("Enter test score: ")) score2 = int(input("Enter test score: ")) score3 = int(input("Enter test score: ")) total_score ...
true
c2c2bf4bcf47b7a4bc15bbf0b333ff6fe52eda3b
jhertzberg1/bmi_calculator
/bmi_calculator.py
1,364
4.375
4
''' TODO Greeting Create commandline prompt for height Create commandline prompt for weight Run calculation Look up BMI chart Print results ''' def welcome(): print('Hi welcome to the BMI calculator.') def request_height(): height = 0 return height def request_weight(): '''Commandline user input fo...
true
7df861ce3467cb871fce042f17a4b839f2193379
Liam-Hearty/ICS3U-Unit5-05-Python
/mailing_address.py
1,981
4.21875
4
#!/usr/bin/env python3 # Created by: Liam Hearty # Created on: October 2019 # This program finds your mailing address. def find_mailing_address(street, city, province, postal_code, apt=None): # returns mailing_address # process mailing_address = street if apt is not None: mailing_address = ...
true
cb7e966781a96121035c9489b410fcc1ace84537
yashaswid/Programs
/LinkedList/MoveLastToFirst.py
1,325
4.28125
4
# Write a function that moves the last element to the front in a given Singly Linked List. # For example, if the given Linked List is 1->2->3->4->5, then the function should change the list to 5->1->2->3->4 class Node: def __init__(self,val): self.data=val self.next=None class Linkedli...
true
4e35112282fbaccdf62d4aea0ae67bd9446e6117
Viole-Grace/Python_Sem_IV
/3a.py
1,688
4.28125
4
phones=dict() def addentry(): global phones name=raw_input("Enter name of the phone:") price=raw_input("Enter price:") phones.update({name:price}) def namesearch(name1): global phones for key,value in phones.items(): if name1==key: print "Found, its price is ",value def price...
true
571c1db047fd45cf9a73414eb1b246f15ce3f3e3
hickmanjv/hickmanjv
/CS_4085 Python/Book Examples/coin_toss_demo.py
401
4.25
4
import coin def main(): # create an object of the Coin class my_coin = coin.Coin() # Display the side of the coin that is facing up print('This side is up: ', my_coin.get_sideup()) # Toss the coin 10 times: print('I am going to toss the coin 10 times:') for count in range(10): my_...
true
94b508503ea89642213964b07b0980ca81e354e2
lucaslb767/pythonWorkOut
/pythonCrashCourse/chapter6/favorite_languages.py
567
4.375
4
favorite_languages = { 'jen':'python', 'sarah':'C', 'jon':'ruby' } print('Jon favorite language is ', favorite_languages['jon']) friends = ['sarah'] #using a list to sort a dictionary's value for name in favorite_languages: print(name.title()) if name in friends: print('Hi', name.title()...
true
6c543e8cfcb156f3265e3bbd01b287af45c318f3
MariaBT/IS105
/ex3.py
961
4.34375
4
# Only text describing what will be done print "I will count my chickens:" # Print the result of the number of hens print "Hens", 25 + 30 / 6 # Print the result of the number of roosters print "Roosters", 100 - 25 * 3 % 4 # Plain text explaining what will be done next print "Now I will count the eggs:" # The resu...
true
879c5858fa8ab9debf0c78559777687fbd2e2d6f
saikrishna-ch/five_languages
/pyhton/NpowerN.py
252
4.28125
4
Number = int(input("Enter a number to multilply to itself by it's number of times:")) print("{} power {} is".format(Number, Number), end = "") Product = 1 for Counter in range(Number): Product = Product * Number print(" {}.".format(Product))
true
b4e26837cb1813bb939df3c6f783aea9f0d7eb88
MahadiRahman262523/Python_Code_Part-1
/operators.py
883
4.53125
5
# Operators in Python # Arithmetic Operators # Assignment Operators # Comparison Operators # Logical Operators # Identity Operators # Membership Operators # Bitwise Operators # Assignment Operator # print("5+6 is ",5+6) # print("5-6 is ",5-6) # print("5*6 is ",5*6) # print("5/6 is ",5/6) # print("16//6...
true
6141032532599c2a7f307170c680abff29c6e526
MahadiRahman262523/Python_Code_Part-1
/practice_problem-25.py
340
4.34375
4
# Write a program to find whether a given username contaoins less than 10 # characters or not name = input("Enter your name : ") length = len(name) print("Your Name Length is : ",length) if(length < 10): print("Your Name Contains Less Than 10 Characters") else: print("Your Name Contains greater ...
true
9ef906ae918956dbdb2f48ea660293284b719a94
asselapathirana/pythonbootcamp
/2023/day3/es_1.py
2,425
4.34375
4
import numpy as np """Fitness function to be minimized. Example: minimize the sum of squares of the variables. x - a numpy array of values for the variables returns a single floating point value representing the fitness of the solution""" def fitness_function(x): return np.sum(x**2) # Example: minimiz...
true
6c375d41e8430694404a45b04819ef9e725db959
asselapathirana/pythonbootcamp
/archives/2022/day1/quad.py
781
4.15625
4
# first ask the user to enter three numbers a,b,c # user input is taken as string(text) in python # so we need to convert them to decimal number using float a = float(input('Insert a value for variable a')) b = float(input('Insert a value for variable b')) c = float(input('Insert a value for variable c')) # now print ...
true
cddcfc2c1a2d3177bcf784c7a09fd3fb1f2a69ec
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 1/Problem/Mathematics/Exactly 3 Divisors.py
1,438
4.25
4
Exactly 3 Divisors Given a positive integer value N. The task is to find how many numbers less than or equal to N have numbers of divisors exactly equal to 3. Example 1: Input: N = 6 Output: 1 Explanation: The only number with 3 divisor is 4. Example 2: Input: N = 10 Output: 2 Explanation...
true
519a1790c47049f2f6a47a6362d45a6821c3252b
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 3/Strings/Problems/Convert to Roman No.py
1,354
4.3125
4
Convert to Roman No Given an integer n, your task is to complete the function convertToRoman which prints the corresponding roman number of n. Various symbols and their values are given below. I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Example 1: Input: n = 5 Output: V Example 2: Input: n =...
true
dab1464351b112f48570a5bf6f23c42912163925
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 9/Heap/Problems/Nearly sorted.py
2,018
4.1875
4
Nearly sorted Given an array of n elements, where each element is at most k away from its target position, you need to sort the array optimally. Example 1: Input: n = 7, k = 3 arr[] = {6,5,3,2,8,10,9} Output: 2 3 5 6 8 9 10 Explanation: The sorted array will be 2 3 5 6 8 9 10 Example 2: Input: n = 5...
true
741480f8b2500ef939b9951b4567f5b16172379a
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 1/Problem/Arrays/Find Transition Point.py
1,237
4.1875
4
Find Transition Point Given a sorted array containing only 0s and 1s, find the transition point. Example 1: Input: N = 5 arr[] = {0,0,0,1,1} Output: 3 Explanation: index 3 is the transition point where 1 begins. Example 2: Input: N = 4 arr[] = {0,0,0,0} Output: -1 Explanation: Since, there i...
true
0e9e0bab41e6810a4b6c41d69ae01df699977570
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 3/Matrix/Transpose of Matrix.py
1,798
4.59375
5
Transpose of Matrix Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows. Example 1: Input: N = 4 mat[][] = {{1, 1, 1, 1}, {2, 2, 2, 2} {3, 3, 3, 3} {4, 4, 4, 4}} Output: ...
true
48c9c87ca2976207c5f379fd9b42df86faa877b5
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 4/Linked LIst/Reverse a Linked List in groups of given size.py
2,725
4.25
4
Reverse a Linked List in groups of given size. Given a linked list of size N. The task is to reverse every k nodes (where k is an input to the function) in the linked list. Example 1: Input: LinkedList: 1->2->2->4->5->6->7->8 K = 4 Output: 4 2 2 1 8 7 6 5 Explanation: The first 4 elements 1,2,2,4 are r...
true
b1acad41a07b4a5a1b38fdad15619ebeec5dd70d
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 3/Bit Magic/Rightmost different bit.py
1,708
4.15625
4
Rightmost different bit Given two numbers M and N. The task is to find the position of the rightmost different bit in the binary representation of numbers. Example 1: Input: M = 11, N = 9 Output: 2 Explanation: Binary representation of the given numbers are: 1011 and 1001, 2nd bit from right is differen...
true
27f267d66c25e89ed823ddd1f003b33fe09cc3cc
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 1/Problem/Arrays/Remove duplicate elements from sorted Array.py
1,554
4.1875
4
Remove duplicate elements from sorted Array Given a sorted array A of size N, delete all the duplicates elements from A. Example 1: Input: N = 5 Array = {2, 2, 2, 2, 2} Output: 2 Explanation: After removing all the duplicates only one instance of 2 will remain. Example 2: Input: N = 3 Array = ...
true
4a44a1c4851060d4114ea4ae3d509800781378e0
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 3/Strings/Problems/Longest Substring Without Repeating Characters.py
2,507
4.125
4
Longest Substring Without Repeating Characters Given a string S, find the length of its longest substring that does not have any repeating characters. Example 1: Input: S = geeksforgeeks Output: 7 Explanation: The longest substring without repeated characters is "ksforge". Example 2: Input: S = abbcd...
true
d3d0dabc882f6021df69bebe4a00e4b97c6878bf
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 9/Heap/Problems/Heap Sort.py
2,223
4.3125
4
Heap Sort Given an array of size N. The task is to sort the array elements by completing functions heapify() and buildHeap() which are used to implement Heap Sort. Example 1: Input: N = 5 arr[] = {4,1,3,9,7} Output: 1 3 4 7 9 Explanation: After sorting elements using heap sort, elements will be in order as 1,3,4,7,...
true
0bb5128f7e3bbd1ee480e189c182cb7933143ae1
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 3/Strings/Problems/Isomorphic Strings.py
2,802
4.4375
4
Isomorphic Strings Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other. Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2 while preserving the order. Note: All occurrences of eve...
true
261cfa1feb28124e9113c400707c5dedf9e30249
Technicoryx/python_strings_inbuilt_functions
/string_08.py
609
4.40625
4
"""Below Python Programme demonstrate expandtabs functions in a string""" #Case1 : With no Argument str = 'xyz\t12345\tabc' # no argument is passed # default tabsize is 8 result = str.expandtabs() print(result) #Case 2:Different Argument str = "xyz\t12345\tabc" print('Original String:', str) # tabsize is set to 2 p...
true
cf11c056ca6697454d3c585e6fa6eea6a153deae
Technicoryx/python_strings_inbuilt_functions
/string_06.py
204
4.125
4
"""Below Python Programme demonstrate count functions in a string""" string = "Python is awesome, isn't it?" substring = "is" count = string.count(substring) # print count print("The count is:", count)
true
da915e308927c3e5ed8eb0f96937f10fd320c8ab
Technicoryx/python_strings_inbuilt_functions
/string_23.py
360
4.46875
4
"""Below Python Programme demonstrate ljust functions in a string""" #Example: # example string string = 'cat' width = 5 # print right justified string print(string.rjust(width)) #Right justify string and fill the remaining spaces # example string string = 'cat' width = 5 fillchar = '*' # print right justified stri...
true
68285e9fdf5413e817851744d716596c0ff2c926
anton515/Stack-ADT-and-Trees
/queueStackADT.py
2,893
4.25
4
from dataStructures import Queue import check # Implementation of the Stack ADT using a single Queue. class Stack: ''' Stack ADT ''' ## Stack () produces an empty stack. ## __init__: None -> Stack def __init__(self): self.stack = Queue () ## isEmpty(self) returns True if the...
true
ce6d86586bb5d7030312ade00c8fc3ca7a0d2273
vamsi-kavuru/AWS-CF1
/Atari-2.py
1,182
4.28125
4
from __future__ import print_function print ("welcome to my atari adventure game! the directions to move in are defined as left, right, up, and down. Enjoy.") x = 6 y = -2 #move = str(input('Make your move! Type in either "Left", "Right", "Up", "Down" or type "Exit" to exit the game:')).lower() def game(): globa...
true
562c78526d055d1ca782cc39096decf79a585bb6
AmbyMbayi/CODE_py
/Pandas/Pandas_PivotTable/Question1.py
310
4.125
4
"""write a pandas program to create a pivot table with multiple indexes from a given excel sheet """ import pandas as pd import numpy as np df = pd.read_excel('SaleData.xlsx') print(df) print("the pivot table is shown as: ") pivot_result = pd.pivot_table(df, index=["Region", "SalesMan"]) print(pivot_result)
true
8b0716fd554604776390c6f6ab40619d19fc5e12
KWinston/PythonMazeSolver
/main.py
2,559
4.5
4
# CMPT 200 Lab 2 Maze Solver # # Author: Winston Kouch # # # Date: September 30, 2014 # # Description: Asks user for file with maze data. Stores maze in list of lists # Runs backtracking recursive function to find path to goal. # Saves the output to file, mazeSol.txt. If no file given, it wil...
true
b37a727c6653dafcfa480283e68badbd87c408f2
skynette/Solved-Problems
/Collatz.py
1,737
4.3125
4
question = """The Collatz Sequence Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that lets the user type in an inte...
true
0081eac284bb86e948aeef7e933796385df12000
ddbs/Accelerating_Dual_Momentum
/functions.py
374
4.15625
4
from datetime import datetime, date def start_of_year(my_date): """ Gives the starting date of a year given any date :param my_date: date, str :return: str """ my_date = datetime.strptime(my_date, '%Y-%m-%d') starting_date = date(my_date.year, my_date.month, 1) starting_date = starti...
true
d545e90149dfca91045aed7666b8456644c8f9a8
jyotisahu08/PythonPrograms
/StringRev.py
530
4.3125
4
from builtins import print str = 'High Time' # Printing length of given string a = len(str) print('Length of the given string is :',a) # Printing reverse of the given string str1 = "" for i in str: str1 = i + str1 print("Reverse of given string is :",str1) # Checking a given string is palindrome or not str2 = 'abb...
true
d5e49df7f61a6e15cf1357aa09e33a81e186627b
Botany-Downs-Secondary-College/password_manager-bunda
/eason_loginV1.py
2,002
4.4375
4
#password_manager #store and display password for others #E.Xuan, February 22 name = "" age = "" login_user = ["bdsc"] login_password = ["pass1234"] password_list = [] def menu(name, age): if age < 13: print("Sorry, you do not meet the age requirement for this app") exit() else...
true
baa45a884596594e89c2ca311973bf378c756e77
SinCatGit/leetcode
/00122/best_time_to_buy_and_sell_stock_ii.py
1,574
4.125
4
from typing import List class Solution: def maxProfit(self, prices: List[int]) -> int: """ https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maxim...
true
c5eadaf692c43bc0ad5acf88104403ca6b7266dc
HarryVines/Assignment
/Garden cost.py
323
4.21875
4
length = float(input("Please enter the length of the garden in metres: ")) width = float(input("Please enter the width of the garden in metres: ")) area = (length-1)*(width-1) cost = area*10 print("The area of your garden is: {0}".format(area)) print("The cost to lay grass on your garden is : £{0}".format(cost)) ...
true