blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a7ee00fd9f9dac5ec77d96e7b1ab8c1a1dbe1b4f
Rggod/codewars
/is alphanumerical/solution.py
592
4.15625
4
''' In this example you have to validate if a user input string is alphanumeric. The given string is not nil, so you don't have to check that. The string has the following conditions to be alphanumeric: At least one character ("" is not valid) Allowed characters are uppercase / lowercase latin letters and dig...
true
57813ddd83679b08db0ca6b7d29ad27d25e32252
falondarville/practicePython
/birthday_dictionary/months.py
495
4.5625
5
# In the previous exercise we saved information about famous scientists’ names and birthdays to disk. In this exercise, load that JSON file from disk, extract the months of all the birthdays, and count how many scientists have a birthday in each month. import json from collections import Counter with open("info.json",...
true
9b505fd7c9d15fedb84b90c9c8443e791d8a9e61
falondarville/practicePython
/birthday_dictionary/json_bday.py
696
4.46875
4
# In the previous exercise we created a dictionary of famous scientists’ birthdays. In this exercise, modify your program from Part 1 to load the birthday dictionary from a JSON file on disk, rather than having the dictionary defined in the program. import json with open("info.json", "r") as f: info = json.load(f...
true
fe8c35b13ecc12fd043023795917be731beda765
alexdistasi/palindrome
/palindrome.py
937
4.375
4
#Author: Alex DiStasi #File: palindrome.py #Purpose: returns True if word is a palindrome and False if it is not def checkPalindrome(inputString): backwardsStr ="" #iterate through inputString backwards for i in range(len(inputString)-1,-1,-1): #create a reversed version of inputString ...
true
8ebfcdfeba3a5e2a8adc7f70ea6bf85a3e423e68
abrambueno1992/Intro-Python
/src/fileio.py
526
4.40625
4
# Use open to open file "foo.txt" for reading object2 = open('foo.txt', 'r') # Print all the lines in the file # print(object) # Close the file str = object2.read() print(str) object2.close() # Use open to open file "bar.txt" for writing obj_bar = open("bar.txt", 'w') # Use the write() method to write three lines to ...
true
81cb9114c1fdd16e8b12863531fdaf860080943b
udbhavkanth/Algorithms
/Find closest value in bst.py
1,756
4.21875
4
#in this question we have a bst and #a target value and we have to find # which value in the bst is closest #to our target value. #First we will assign a variable closest #give it some big value like infinity #LOGIC: #we will find the absolute value of (target-closest) And # (target - tree value) # if th...
true
f132e65fb3e884765ab28eded1b9ededdb09a1b1
artalukd/Data_Mining_Lab
/data-pre-processing/first.py
1,964
4.40625
4
#import statement https://pandas.pydata.org/pandas-docs/stable/dsintro.html import pandas as pd #loading dataset, read more at http://pandas.pydata.org/pandas-docs/stable/io.html#io-read-csv-table df = pd.read_csv("iris.data") #by default header is first row #df = pd.read_csv("iris.data", sep=",", names=["petal_...
true
988dab09d39206865788bc0f8d7c3088b551b337
VictoriaEssex/Codio_Assignment_Contact_Book
/part_two.py
2,572
4.46875
4
#Define a main function and introduce the user to the contact book #The function is executed as a statement. def main(): print("Greetings! \nPlease make use of my contact book by completing the following steps: \na) Add three new contacts using the following format: Name : Number \nb) Make sure your contacts hav...
true
757b60fbc021114cc77faa07b7e828a12ea00072
aholyoke/language_experiments
/python/Z_combinator.py
1,285
4.28125
4
# ~*~ encoding: utf-8 ~*~ # Implementation of recursive factorial using only lambdas # There are no recursive calls yet we achieve recursion using fixed point combinators # Y combinator # Unfortunately this will not work with applicative order reduction (Python), so we will use Z combinator # Y := λg.(λx.g (x x)) (λx....
true
40224c5ba455fb7e03e135ff2cb35e94c150e351
lyoness1/Calculator-2
/calculator.py
1,772
4.25
4
""" calculator.py Using our arithmetic.py file from Exercise02, create the calculator program yourself in this file. """ from arithmetic import * def intergerize(str_list): """returns a list of integers from a list of strings""" return map(int, str_list) def read_string(): """reads the input to determin...
true
1e3e4a200bf8e1db120c6d21463a9186f26b19a5
ashwinimanoj/python-practice
/findSeq.py
805
4.1875
4
'''Consider this puzzle: by starting from the number 1 and repeatedly either adding 5 or multiplying by 3, an infinite amount of new numbers can be produced. How would you write a function that, given a num- ber, tries to find a sequence of such additions and multiplications that produce that number? For example, the n...
true
1377c3aabb11ba82fd0337b1ef56f0baf0c6de21
yunge008/LintCode
/6.LinkedList/[E]Nth to Last Node in List.py
1,236
4.1875
4
# -*- coding: utf-8 -*- __author__ = 'yunge008' """ Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List 3->2->1->5->null and n = 2, return node whose value is 1. """ class ListNode(object): def __init__(self, val, next=None): ...
true
846b0924cec1a3fd9dfb225af2b22404d1ca5268
yunge008/LintCode
/6.LinkedList/[M]Convert Sorted List to Balanced BST.py
1,053
4.125
4
# -*- coding: utf-8 -*- __author__ = 'yunge008' """ Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 2 1->2->3 => / \ 1 3 """ class ListNode(object): def __init__(self, val, next=None): self.val = ...
true
896841b93741f2b09cd36c09ff494f1bb6851059
simplifiedlearning/dummy
/function.py
1,739
4.375
4
######################FUNCTIONS#################### #SYNTAX #using def keyword #without parameters def greet(): print("hello") greet() ###add two number #with parameters def add1(x,y): z=x+y print(z) add1(2,3) ####default arguments def add2(b,c,a=12): print(a+b+c) add2(5,5) ####abritriy...
true
c0620531c0aea733e89fda828f42333573c5dcde
naomi-rc/PythonTipsTutorials
/generators.py
638
4.34375
4
# generators are iterators that can only be iterated over once # They are implemented as functions that yield a value (not return) # next(generator) returns the next element in the sequence or StopIteration error # iter(iterable) returns the iterable's iterator def my_generator(x): for i in range(x): yield...
true
2f7d869fdcce5a45fd4003d771984b3c871bb921
naomi-rc/PythonTipsTutorials
/enumerate.py
417
4.3125
4
# enumerate : function to loop over something and provide a counter languages = ["java", "javascript", "typescript", "python", "csharp"] for index, language in enumerate(languages): print(index, language) print() starting_index = 1 for index, language in enumerate(languages, starting_index): print(index, lang...
true
fbc9bbfbb0b4c12eb7af244cdf85a96fb726b2b2
RayGar7/AlgorithmsAndDataStructures
/Python/diagonal_difference.py
581
4.25
4
# Given a square matrix, calculate the absolute difference between the sums of its diagonals. # For example, the square matrix is shown below: # 1 2 3 # 4 5 6 # 9 8 9 # The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 17. Their absolute difference is abs(15 - 17) = 2. def dia...
true
64466b637b49b744d34c0d37cacd212998177a0b
mohitarora3/python003
/sum_of_list.py
376
4.125
4
def sumList(list): ''' objective: to compute sum of list input parameters: list: consist of elemnts of which sum has to be found return value: sum of elements of list ''' #approach: using recursion if list == []: return 0 else: return(list[0]+sumLi...
true
5cecdc3cb4373a598efbe015f6446f84ee950501
lsalgado97/My-Portfolio
/python-learning/basics/guess-a-number.py
2,369
4.34375
4
# This is a code for a game in which the player must guess a random integer between 1 and 100. # It was written in the context of a 2-part python learning course, and is meant to introduce # basic concepts of Python: variables, logic relations, built-in types and functions, if and # for loops, user input, program ou...
true
4ed6cf981fd362e21ff59c9abbf24035f2e765a3
manovidhi/python-the-hard-way
/ex13.py
650
4.25
4
# we pass the arguments at the runtime here. we import argument to define it here. from sys import argv script, first, second, third = argv #print("this is script", argv.script) print( "The script is called:", script ) # this is what i learnt from hard way print ("Your first variable is:", first) print ("Your se...
true
c01b4306131f6fa4bd8a59f7b68ec758e2b16a5c
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter5/wordLength.py
708
4.40625
4
# Average Words Length # wordLength.py # Get a sentence, remove the trailing spaces. # Count the length of a sentence. # Count the number of words. # Calculate the spaces = the number of words - 1 # The average = (the length - the spaces) / the number of words def main(): # Introduction print('The program cal...
true
2afa7c968a716fcca6cdb879880091093f1d22fc
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter11/sidewalk.py
510
4.125
4
# sidewalk.py from random import randrange def main(): print('This program simulates random walk inside a side walk') n = int(input('How long is the side walk? ')) squares = [0]*n results = doTheWalk(squares) print(squares) def doTheWalk(squares): # Random walk inside the Sidewalk n = len...
true
393e027c2e80d8a2ca901ef0104ac59c6887770d
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter3/distance.py
467
4.21875
4
# Distance Calculation # distance.py import math def main(): # Instruction print('The program calculates the distance between two points.') # Get two points x1, y1, x2, y2 = eval(input('Enter two points x1, y1, x2, y2:'\ '(separate by commas) ')) # Calculate the dis...
true
39c742637396b520ad65097e4a6ac7fc92b16af4
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter8/syracuse.py
447
4.125
4
# syracuse.py # Return a sequence of Syracuse number def main(): # Introduction print('The program returns a sequence of Syracuse number from the first input.') # Get the input x = int(input('Enter your number: ')) # Loop until it comes to 1 while x != 1: if x % 2 == 0: x = ...
true
5dd5876363aa431cb73871182406d6da8cef8503
MakeRafa/CS10-poetry_slam
/main.py
1,376
4.25
4
# This is a new python file # random library import random filename = "poem.txt" # gets the filename poem.txt and moves it here def get_file_lines(filename): read_poem = open(filename, 'r') # reads the poem.txt file return read_poem.readlines() def lines_printed_backwards(lines_list): lines_list = lines...
true
5b4161986fe4af26d3a588ecd8a28347212aecbf
lexboom/Testfinal
/Studentexempt.py
2,121
4.375
4
#Prompt the user to enter the student's average. stu_avg = float(input("Please enter student's average: ")) #Validate the input by using a while loop till the value #entered by the user is out of range 0 and 100. while(stu_avg < 0 or stu_avg > 100): #Display an appropriate message and again, prompt ...
true
3196064e2211728cc382913d1f6c6a0b019364c4
micajank/python_challenges
/exercieses/05factorial.py
365
4.40625
4
# Write a method to compute the `factorial` of a number. # Given a whole number n, a factorial is the product of all # whole numbers from 1 to n. # 5! = 5 * 4 * 3 * 2 * 1 # # Example method call # # factorial(5) # # > 120 # def factorial(num): result = 1 for i in range(result, (num + 1)): result = resu...
true
2501c35e44be4af82b2d46b48d92125109bb245f
DevYam/Python
/filereading.py
967
4.125
4
f = open("divyam.txt", "rt") # open function will return a file pointer which is stored in f # mode can be rb == read in binary mode, rt == read in text mode # content = f.read(3) # Will read only 3 characters # content = content + "20" # content += "test" # content = f.read(3) # Will read next 3 characters...
true
e7ddc640319e91b422cbee450ecb6ce69c13f534
DevYam/Python
/lec10.py
1,270
4.375
4
# Dictionary is a data structure and is used to store key value pairs as it is done in real life dictionaries d1 = {} print(type(d1)) # class dict ==> Dictionary (key value pair) d2 = {"Divyam": "test", "test2": "testing", "tech": "guru", "dict": {"a": "dicta", "b": "dictb"}} print(d2) print(d2["Divyam"]) # Keys o...
true
69c56249896e306fe80e40ce278505d5be077cc4
minwuh0811/DIT873-DAT346-Techniques-for-Large-Scale-Data
/Programming 1/Solution.py
928
4.25
4
# Scaffold for solution to DIT873 / DAT346, Programming task 1 def fib (limit) : # Given an input limit, calculate the Fibonacci series within [0,limit] # The first two numbers of the series are always equal to 1, # and each consecutive number returned is the sum of the last two numbers. # You should ...
true
dd8ec5954a400f30b2af555dc79650c1712437c7
FredC94/MOOC-Python3
/Exercices/20200430 Sudoku Checker.py
1,672
4.15625
4
# Function to check if all the subsquares are valid. It will return: # -1 if a subsquare contains an invalid value # 0 if a subsquare contains repeated values # 1 if the subsquares are valid. def valid_subsquares(grid): for row in range(0, 9, 3): for col in range(0,9,3): temp = [] for r in ra...
true
b441d9cbcccdfa77932e707e4e9c4490cb0e4c78
Shyonokaze/mysql.py
/mysql.py
2,656
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 7 12:41:02 2018 @author: pyh """ ''' This class is for creating database and table easier by using pymysql ''' import pymysql class mysql_data: def __init__(self,user_name,password): self.conn=pymysql.connect(host='127.0.0.1', ...
true
061b1f29b6c5bc4f2717b07a554e3dd5eac13dab
metehankurucu/data-structures-and-algorithms
/Algorithms/Sorting/BubbleSort/BubbleSort.py
399
4.21875
4
def bubbleSort(arr): n = len(arr) for i in range(n): swapped = False #Every iteration, last i items sorted for j in range(n-i-1): if(arr[j] > arr[j+1]): swapped = True arr[j], arr[j+1] = arr[j+1],arr[j] # One loop without swapping mean...
true
fdc1e38708d2d91acaad06ea6cb73545921f6305
jonathan-pasco-arnone/ICS3U-Unit5-02-Python
/triangle_area.py
1,075
4.15625
4
#!/usr/bin/env python3 # Created by: Jonathan Pasco-Arnone # Created on: December 2020 # This program calculates the area of a triangle def area_of_triangle(base, height): # calculate area area = base * height / 2 print("The area is {}cm²".format(area)) def main(): # This function calls gets input...
true
a80210552c4810d0b9d7a1b710934aaddda73b9d
lindagrz/python_course_2021
/day5_classwork.py
2,850
4.46875
4
# 1. Confusion T # he user enters a name. You print user name in reverse (should begin with capital letter) then extra # text: ",a thorough mess is it not ", then the first name of the user name then "?" Example: Enter: Valdis -> # Output: Sidlav, a thorough mess is it not V? # # # 2. Almost Hangman # Write a program t...
true
2b7a758e15f6cd2be76e6cf416a07860663da96b
emilybee3/deployed_whiteboarding
/pig_latin.py
1,611
4.3125
4
# Write a function to turn a phrase into Pig Latin. # Your function will be given a phrase (of one or more space-separated words). #There will be no punctuation in it. You should turn this into the same phrase in Pig Latin. # Rules # If the word begins with a consonant (not a, e, i, o, u), #move first letter to end...
true
55a100f8658a25e2003a382f91c430f993c11a21
findango/Experiments
/linkedlist.py
1,407
4.21875
4
#!/usr/bin/env python import sys class Node: def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return "[Node value=" + str(self.value) + "]" class SortedList: def __init__(self): self.head = None def insert(self, valu...
true
cdfbeaf2c417826e26dc3016f9d42916712fb341
luiscarm9/Data-Structures-in-Python
/DataStructures/LinkedList_def/Program.py
627
4.21875
4
from LinkedList_def.LinkedList import LinkedList; LList=LinkedList() #Insert Elements at the start (FATS) LList.insertStart(1) LList.insertStart(2) LList.insertStart(3) LList.insertStart(5) #Insert Elements at the end (SLOW) LList.insertEnd(8) LList.insertEnd(13) LList.insertEnd(21) LList.insertEnd(34) LList.inse...
true
d5e2382900b729a2e3392882cf95a006a36e57b9
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_IshaSah.py
835
4.34375
4
'''Take input the value of 'n', upto which you will print. -Print the Fibonacci Series upto n while replacing prime numbers, all multiples of 5 by 0. Sample Input : 12 27 Sample Output : 1 1 0 0 0 8 0 21 34 0 0 144 1 1 0 0 0 8 0 21 34 0 0 144 0 377 0 987 0 2584 4181 0 10946 17711 0 46368 0 121393 196418''' import mat...
true
82a0b63b6b46dbc1b0fb456cf23d1554814c3b04
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_devulapallisai.py
922
4.1875
4
# First take input n # contributed by Sai Prachodhan Devulapalli Thanks for giving me a route # Program to find whether prime or not def primeornot(num): if num<2:return False else: #Just checking from 2,sqrt(n)+1 is enough reduces complexity too for i in range(2,int(pow((num),1/2)+1)): ...
true
0319816ef3a65374eaa7dd895288b6eff0f42f4a
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_RolloCasanova.py
1,276
4.3125
4
# Function to print given string in the zigzag form in `k` rows def printZigZag(s, k): # Creates an len(s) x k matrix arrays = [[' ' for x in range (len(s))] for y in range (k)] # Indicates if we are going downside the zigzag down = True # Initialize the row and column to zero col, row = 0, 0 ...
true
5a840100907d0fe49012b75d8707ee142ba80738
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_Candida18.py
703
4.125
4
rows = int(input(" Enter the no. of rows : ")) cols = int(input(" Enter the no. of columns : ")) print("\n") for i in range(1,rows+1): print(" "*(i-1),end=" ") a = i while a<=cols: print(a , end="") b = a % (rows-1) if(b==0): b=(rows-1) a+=(rows-b)*2 print(" "*((rows-b)*2-1),end=" ") print("\n") """ ...
true
d2d56f7fc126004e97d41c53f9b3704d61978473
alexsmartens/algorithms
/stack.py
1,644
4.21875
4
# This stack.py implementation follows idea from CLRS, Chapter 10.2 class Stack: def __init__(self): self.items = [] self.top = 0 self.debug = True def is_empty(self): return self.top == 0 def size(self): return self.top def peek(self): ...
true
58fa55150c3bc3735f3f63be5193eb2433eddd28
Catboi347/python_homework
/fridayhomework/homework78.py
211
4.1875
4
import re string = input("Type in a string ") if re.search("[a-z]", string): print ("This is a string ") elif re.search("[A-Z]", string): print ("This is a string") else: print ("This is an integer")
true
5e0bf04f50e383157a0f4d476373353342f3385e
karngyan/Data-Structures-Algorithms
/Tree/BinaryTree/Bottom_View.py
1,305
4.125
4
# Print Nodes in Bottom View of Binary Tree from collections import deque class Node: def __init__(self, data): self.data = data self.left = None self.right = None def bottom_view(root): if root is None: return # make an empty queue for BFS q = deque() # dict to...
true
487d70507adea1986e7c35271ced0d4f702f1897
karngyan/Data-Structures-Algorithms
/String_or_Array/Searching/Linear_Search.py
480
4.125
4
# Function for linear search # inputs: array of elements 'arr', key to be searched 'x' # returns: index of first occurrence of x in arr def linear_search(arr, x): # traverse the array for i in range(0, len(arr)): # if element at current index is same as x # return the index value if a...
true
d87e3ccfe1dcebc2ba0e3d030b0704c68b52d684
dominiquecuevas/dominiquecuevas
/05-trees-and-graphs/second-largest.py
1,720
4.21875
4
class BinaryTreeNode(object): def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value): self.left = BinaryTreeNode(value) return self.left def insert_right(self, value): self.right = BinaryTreeNode(value...
true
ad6fc102c4ad03ca32dc29b84cdffb1d6108147e
VitaliiUr/wiki
/wiki
2,978
4.15625
4
#!/usr/bin/env python3 import wikipedia as wiki import re import sys import argparse def get_random_title(): """ Find a random article on the Wikipadia and suggests it to user. Returns ------- str title of article """ title = wiki.random() print("Random article's title:") ...
true
80d0e021194a67ff06851523210bc9f7ca635833
jimboowens/python-practice
/dictionaries.py
1,131
4.25
4
# this is a thing about dictionaries; they seem very useful for lists and changing values. # Dictionaries are just like lists, but instead of numbered indices they have english indices. # it's like a key greg = [ "Greg", "Male", "Tall", "Developer", ] # This is not intuitive, and the placeholders give ...
true
735222b563750bceca379969e5cff58224ddf83e
nlin24/python_algorithms
/BinaryTrees.py
1,982
4.375
4
class BinaryTree: """ A simple binary tree node """ def __init__(self,nodeName =""): self.key = nodeName self.rightChild = None self.leftChild = None def insertLeft(self,newNode): """ Insert a left child to the current node object Append the left chil...
true
d22dd3d84f34487598c716f13af578c3d2752bc4
aduV24/python_tasks
/Task 19/example.py
1,720
4.53125
5
#************* HELP ***************** #REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LEAVE A #COMMENT FOR YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL. #************************************ # =========== Write Method =========== # You can use the write() method in order to write to a...
true
473237b007ea679c7b55f3c4c7b5895bdf150ae5
aduV24/python_tasks
/Task 11/task2.py
880
4.34375
4
shape = input("Enter the shape of the builing(square,rectangular or round):\n") if shape == "square": length = float(input("Enter the length of one side:\n")) area = round(length**2,2) print(f"The area that will be taken up by the building is {area}sqm") #====================================================...
true
3427a7d78131b4d26b633aa5f70e2dc7a7dab748
aduV24/python_tasks
/Task 17/disappear.py
564
4.78125
5
# This program asks the user to input a string, and characters they wish to # strip, It then displays the string without those characters. string = input("Enter a string:\n") char = input("Enter characters you'd like to make disappear separated by a +\ comma:\n") # Split the characters given into a list...
true
55d2392b17d505045d5d80d209dc5635c47657f6
aduV24/python_tasks
/Task 17/separation.py
298
4.4375
4
# This program asks the user for a sentence and then displays # each character of that senetence on a new line string = input("Enter a sentence:\n") # split string into a list of words words = string.split(" ") # Iterate thorugh the string and print each word for word in words: print(word)
true
40df8c8aa7efb4fc8707f712b94971bae08dacea
aduV24/python_tasks
/Task 21/john.py
344
4.34375
4
# This program continues to ask the user to enter a name until they enter "John" # The program then displays all the incorrect names that was put in wrong_inputs = [] name = input("Please input a name:\n") while name != "John": wrong_inputs.append(name) name = input("Please input a name:\n") print(f"Incorrect...
true
aa382979b4f5bc4a8b7e461725f59a802ffe3a4e
aduV24/python_tasks
/Task 14/task1.py
340
4.59375
5
# This python program asks the user to input a number and then displays the # times table for that number using a for loop num = int(input("Please Enter a number: ")) print(f"The {num} times table is:") # Initialise a loop and print out a times table pattern using the variable for x in range(1,13): print(f"{num}...
true
ab8491166133deadd98d2bbbbb40775f95c7091b
aduV24/python_tasks
/Task 24/Example Programs/code_word.py
876
4.28125
4
# Imagine we have a long list of codewords and each codeword triggers a specific function to be called. # For example, we have the codewords 'go' which when seen calls the function handleGo, and another codeword 'ok' which when seen calls the function handleOk. # We can use a dictionary to encode this. def handleGo(x)...
true
ee04a317415c9a0c9481f712e8219c92fb719ce0
hackettccp/CIS106
/SourceCode/Module2/formatting_numbers.py
1,640
4.65625
5
""" Demonstrates how numbers can be displayed with formatting. The format function always returns a string-type, regardless of if the value to be formatted is a float or int. """ #Example 1 - Formatting floats amount_due = 15000.0 monthly_payment = amount_due / 12 print("The monthly payment is $", monthly_payment) #F...
true
3d2c8b1c05332e245a7d3965762b2a746d6e5c3d
hackettccp/CIS106
/SourceCode/Module4/loopandahalf.py
899
4.21875
4
""" Demonstrates a Loop and a Half """ #Creates an infinite while loop while True : #Declares a variable named entry and prompts the user to #enter the value z. Assigns the user's input to the entry variable. entry = input("Enter the value z: ") #If the value of the entry variable is "z", break from the loop...
true
824f4f86eaef9c87c082c0f471cb7a68cc72a44f
hackettccp/CIS106
/SourceCode/Module2/converting_floats_and_ints.py
1,055
4.71875
5
""" Demonstrates converting ints and floats. Uncomment the other section to demonstrate the conversion of float data to int data. """ #Example 1 - Converting int data to float data #Declares a variable named int_value1 and assigns it the value 35 int_value1 = 35 #Declares a variable named float_value1 and assigns i...
true
98868a37e12fc16d5a1e0d49cb8e076a5ffb107d
hackettccp/CIS106
/SourceCode/Module10/button_demo.py
866
4.15625
4
#Imports the tkinter module import tkinter #Imports the tkinter.messagebox module import tkinter.messagebox #Main Function def main() : #Creates the window test_window = tkinter.Tk() #Sets the window's title test_window.wm_title("My Window") #Creates button that belongs to test_window that #calls the sho...
true
1af15c312f75e507b4acb77abc76b25ff8022318
hackettccp/CIS106
/SourceCode/Module5/returning_data1.py
815
4.15625
4
""" Demonstrates returning values from functions """ def main() : #Prompts the user to enter a number. Assigns the user's #input (as an int) to a variable named num1 num1 = int(input("Enter a number: ")) #Prompts the user to enter another number. Assigns the user's #input (as an int) to a variable named num...
true
c359aae7e1cd194eedb023b580f34e42b7663c27
hackettccp/CIS106
/SourceCode/Module2/mixed_number_operations.py
1,699
4.46875
4
""" Demonstrates arithmetic with mixed ints and floats. Uncomment each section to demonstrate different mixed number operations. """ #Example 1 - Adding ints together. #Declares a variable named value1 and assigns it the value 10 value1 = 10 #Declares a variable named value2 and assigns it the value 20 value2 = 20 ...
true
188486bfabc4f36413579d6d1af0aaae3da63681
hackettccp/CIS106
/SourceCode/Module10/entry_demo.py
504
4.125
4
#Imports the tkinter module import tkinter #Main Function def main() : #Creates the window test_window = tkinter.Tk() #Sets the window's title test_window.wm_title("My Window") #Creates an entry field that belongs to test_window test_entry = tkinter.Entry(test_window, width=10) #Packs the entry field o...
true
6e470e6f8219a39ebdb2b862ea9bf85c7710c576
alexbehrens/Bioinformatics
/rosalind-problems-master/alg_heights/FibonacciNumbers .py
372
4.21875
4
def Fibonacci_Loop(number): old = 1 new = 1 for itr in range(number - 1): tmpVal = new new = old old = old + tmpVal return new def Fibonacci_Loop_Pythonic(number): old, new = 1, 1 for itr in range(number - 1): new, old = old, old + new return new print(Fib...
true
5af688c66904d3d6b0ad57fbb008c93d2797ddd8
alexeahn/UNC-comp110
/exercises/ex06/dictionaries.py
1,276
4.25
4
"""Practice with dictionaries.""" __author__ = "730389910" # Define your functions below # Invert function: by giving values, returns a flip of the values def invert(first: dict[str, str]) -> dict[str, str]: """Inverts a dictionary.""" switch: dict[str, str] = {} for key in first: value: str = ...
true
43fff8b5123088e2fa7416157b729b0ddb3542a8
cassjs/practice_python
/practice_mini_scripts/math_quiz_addition.py
1,687
4.25
4
# Program: Math Quiz (Addition) # Description: Program randomly produces a sum of two integers. User can input the answer # and recieve a congrats message or an incorrect message with the correct answer. # Input: # Random Integer + Random Integer = ____ # Enter your answer: # Output: # Correct = Congratulations! # In...
true
0970f57aa338249ee6466c1dadadeee769acf7c6
MurphyStudebaker/intro-to-python
/1-Basics.py
2,086
4.34375
4
""" PYTHON BASICS PRACTICE Author: Murphy Studebaker Week of 09/02/2019 --- Non-Code Content --- WRITING & RUNNING PROGRAMS Python programs are simply text files The .py extension tells the computer to interperet it as Python code Programs are run from the terminal, which is a low level interaction with the c...
true
a3c3790812f74749f601c0075b115fbe2a296ca1
sudoabhinav/competitive
/hackerrank/algorithms/strings/pangrams.py
232
4.125
4
# https://www.hackerrank.com/challenges/pangrams from string import ascii_lowercase s = raw_input().strip().lower() if len([item for item in ascii_lowercase if item in s]) == 26: print "pangram" else: print "not pangram"
true
e8cff56a53e29a80d047e999918b43deff019c3e
sauravsapkota/HackerRank
/Practice/Algorithms/Implementation/Beautiful Days at the Movies.py
713
4.15625
4
#!/bin/python3 import os # Python Program to Reverse a Number using While loop def reverse(num): rev = 0 while (num > 0): rem = num % 10 rev = (rev * 10) + rem num = num // 10 return rev # Complete the beautifulDays function below. def beautifulDays(i, j, k): count = 0 ...
true
f2cacc2f354655e601273d4a2946a2b27258624d
YayraVorsah/PythonWork
/conditions.py
1,769
4.1875
4
#Define variable is_hot = False is_cold = True if is_hot: #if true for the first statement then print print("It's a hot day") print("drink plenty of water") elif is_cold: # if the above is false and this is true then print this print("It's a co...
true
881a8e4b1aa1eaed9228782eef2440097c2cb301
siyangli32/World-City-Sorting
/quicksort.py
1,439
4.125
4
#Siyang Li #2.25.2013 #Lab Assignment 4: Quicksort #partition function that takes a list and partitions the list w/ the last item #in list as pivot def partition(the_list, p, r, compare_func): pivot = the_list[r] #sets the last item as pivot i = p-1 #initializes the two indexes i and j to partition with ...
true
150810f760c409533200b7252912130cc72e792b
aiman88/python
/Introduction/case_study1.py
315
4.1875
4
""" Author - Aiman Date : 6/Dec/2019 Write a program which will find factors of given number and find whether the factor is even or odd. """ given_number=9 sum=1 while given_number>0: sum=sum*given_number given_number-=1 print(sum) if sum%10!=0: print("odd number") else: print("Even number")
true
764b1f8af7fee5c6d0d1707ab6462fc1d279be36
dadheech-vartika/Leetcode-June-challenge
/Solutions/ReverseString.py
863
4.28125
4
# Write a function that reverses a string. The input string is given as an array of characters char[]. # Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. # You may assume all the characters consist of printable ascii characters. # Exampl...
true
ca042af11712f32c4b089da67c4a9dcfecd6000d
darkblaro/Python-code-samples
/strangeRoot.py
1,133
4.25
4
import math ''' getRoot gets a number; calculate a square root of the number; separates 3 digits after decimal point and converts them to list of numbers ''' def getRoot(nb): lsr=[] nb=math.floor(((math.sqrt(nb))%1)*1000) #To get 3 digits after decimal point ar=str(nb) for i in ar: ls...
true
01b8496d29a0a14957447204d655e441254aeb75
worasit/python-learning
/mastering/generators/__init__.py
1,836
4.375
4
""" `A generator` is a specific type of iterator taht generates values through a function. While traditional methods build and return a `list` of iterms, ad generator will simply `yield` every value separately at the moment when they are requested by the caller. Pros: - Generators pause execution completely u...
true
c03dd868f24eec310e537c5c224b9627b469a811
rileyworstell/PythonAlgoExpert
/twoNumSum.py
900
4.21875
4
""" Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. If any two numbers in the input array sum up to the target sum, the function should return them in an array, in any order. If not two numbers sum up to the target sum, the function should return an empty...
true
c79ba3a6834fbb5a0f8d5c2ebabe0d4f6f790452
mwongeraE/python
/spellcheck-with-inputfile.py
904
4.15625
4
def spellcheck(inputfile): filebeingchecked=open(inputfile,'r') spellcheckfile=open("words.txt",'r') dictionary=spellcheckfile.read().split() checkedwords=filebeingchecked.read().split() for word in checkedwords: low = 0; high=len(dictionary)-1 while low <= high: ...
true
89038721966e0c3974e91a3c58db4c6245ffa354
robwalker2106/100-Days
/day-18-start/main.py
1,677
4.1875
4
from turtle import Turtle, Screen from random import randint, choice don = Turtle() #don.shape('turtle') don.color('purple3') #don.width(10) don.speed('fastest') screen = Screen() screen.colormode(255) def random_color(): """ Returns a random R, G, B color. :return: Three integers. """ r = randi...
true
a3337bde5cf7d0b0712a15f23d2ab63fed289c2f
nickdurbin/iterative-sorting
/src/searching/searching.py
1,860
4.3125
4
def linear_search(arr, target): # Your code here # We simply loop over an array # from 0 to the end or len(arr) for item in range(0, len(arr)): # We simply check if the item is equal # to our target value # If so, then simply return the item if arr[item] == target: ...
true
c346a76f33f96248e4782304636a32c12238c6aa
adilawt/Tutorial_2
/1_simpsons_rule.py
672
4.15625
4
# ## Tutorial2 Question3 ## a) Write a python function to integrate the vector(in question #2) using ## Simpson's Rule # import numpy as np def simpsonsrule(f, x0, xf, n): if n & 1: print ("Error: n is not a even number.") return 0.0 h = float(xf - x0) / n integral = 0.0 x = float...
true
ab1a0c5e0f29e91a4d2c49a662e3176f4aa158f5
salihbaltali/nht
/check_if_power_of_two.py
930
4.1875
4
""" Write a Python program to check if a given positive integer is a power of two """ def isInt(x): x = abs(x) if x > int(x): return False else: return True def check_if_power_of_two(value): if value >= 1: if value == 1 or value == 2: return True el...
true
89994b56da945167c927ad2617a5b9cbfc2d4a6b
rkovrigin/crypto
/week2.py
2,872
4.25
4
""" In this project you will implement two encryption/decryption systems, one using AES in CBC mode and another using AES in counter mode (CTR). In both cases the 16-byte encryption IV is chosen at random and is prepended to the ciphertext. For CBC encryption we use the PKCS5 padding scheme discussed in the lecture (1...
true
1350fcd3baa866a02f5db2c066420eaa77e00892
BrasilP/PythonOop
/CreatingFunctions.py
1,404
4.65625
5
# Creating Functions # In this exercise, we will review functions, as they are key building blocks of object-oriented programs. # Create a function average_numbers(), which takes a list num_list as input and then returns avg as output. # Inside the function, create a variable, avg, that takes the average of all th...
true
566ff9db1680e613ef013e6918d274b1382c2934
codethat-vivek/NPTEL-Programming-Data-Structures-And-Algorithms-Using-Python-2021
/week2/RotateList.py
646
4.28125
4
# Third Problem: ''' A list rotation consists of taking the first element and moving it to the end. For instance, if we rotate the list [1,2,3,4,5], we get [2,3,4,5,1]. If we rotate it again, we get [3,4,5,1,2]. Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l...
true
1ff1fadb88d860e4d2b97c5c38668bcc880c607c
morzen/Greenwhich1
/COMP1753/week7/L05 Debugging/02Calculator_ifElifElse.py
1,241
4.40625
4
# this program asks the user for 2 numbers and an operation +, -, *, / # it applies the operation to the numbers and outputs the result def input_and_convert(prompt, conversion_fn): """ this function prompts the user for some input then it converts the input to whatever data-type the programmer ha...
true
36e7cd8cc96264f50e49f9cd2b778fc642434312
GaryZhang15/a_byte_of_python
/002_var.py
227
4.15625
4
print('\n******Start Line******\n') i =5 print(i) i = i + 1 print(i) s = '''This is a multi-line string. This is the second line.''' print(s) a = 'hello'; print(a) b = \ 5 print(b) print('\n*******End Line*******\n')
true
a09f9fe6aa0663cf8143ca71d01553918d6d35a1
Sana-mohd/fileQuestions
/S_s_4.py
298
4.34375
4
#Write a Python function that takes a list of strings as an argument and displays the strings which # starts with “S” or “s”. Also write a program to invoke this function. def s_S(list): for i in list: if i[0]=="S" or i[0]=="s": print(i) s_S(["sana","ali","Sara"])
true
ddc89b17a98a81a0e4b2141e487c0c2948d0621a
lfr4704/python_practice_problems
/algorithms.py
1,579
4.375
4
import sys; import timeit; # Big-O notation describes how quickly runtime will grow relative to the input as the input gets arbitrarily large. def sum1(n): #take an input of n and return the sume of the numbers from 0 to n final_sum = 0; for x in range(n+1): # this is a O(n) final_sum += x re...
true
01d9030aa89da902667a6ea05a45bbd9761162ef
DerekHunterIcon/CoffeeAndCode
/Week_1/if_statements.py
239
4.1875
4
x = 5 y = 2 if x < y: print "x is less than y" else print "x is greater than or equal to y" isTrue = True if isTrue: print "It's True" else: print "It's False" isTrue = False if isTrue: print "It's True" else: print "It's False"
true
f2ed037552b3a8fdd37b776d5b9df5709b0e494e
SamWaggoner/125_HW6
/Waggoner_hw6a.py
2,742
4.1875
4
# This is the updated version that I made on 7/2/21 # This program will ask input for a list then determine the mode. def determinemode(): numlist = [] freqlist = [] print("Hello! I will calculate the longest sequence of numbers in a list.") print("Type your list of numbers and then type \"end\"."...
true
35f1a4243a2a56315eee8070401ee4f8dc38bf9c
JordanJLopez/cs373-tkinter
/hello_world_bigger.py
888
4.3125
4
#!/usr/bin/python3 from tkinter import * # Create the main tkinter window window = Tk() ### NEW ### # Set window size with X px by Y px window.geometry("500x500") ### NEW ### # Create a var that will contain the display text text = StringVar() # Create a Message object within our Window window_me...
true
4df8eadf0fe84ff3b194ac562f24a94b778a2588
Zioq/Algorithms-and-Data-Structures-With-Python
/7.Classes and objects/lecture_3.py
2,395
4.46875
4
# Special methods and what they are # Diffrence between __str__ & __repr__ """ str() is used for creating output for end user while repr() is mainly used for debugging and development. repr’s goal is to be unambiguous and str’s is to be readable. if __repr__ is defined, and __str__ is not, the object will behave as...
true
835fff2341216766489b87ac7682ef49a47fb713
Zioq/Algorithms-and-Data-Structures-With-Python
/1.Strings,variables/lecture_2.py
702
4.125
4
# concatenation, indexing, slicing, python console # concatenation: Add strings each other message = "The price of the stock is:" price = "$1110" print(id(message)) #print(message + " " +price) message = message + " " +price print(id(message)) # Indexing name = "interstella" print(name[0]) #print i # Slicing # [0:...
true
9123640f03d71649f31c4a6740ba9d1d3eca5caf
Zioq/Algorithms-and-Data-Structures-With-Python
/17.Hashmap/Mini Project/project_script_generator.py
1,946
4.3125
4
# Application usage ''' - In application you will have to load data from persistent memory to working memory as objects. - Once loaded, you can work with data in these objects and perform operations as necessary Exmaple) 1. In Database or other data source 2. Load data 3. Save it in data structure like `Dictionary` 4...
true
517611d9663ae87acdf5fed32099ec8dcf26ee76
Zioq/Algorithms-and-Data-Structures-With-Python
/20.Stacks and Queues/stack.py
2,544
4.25
4
import time class Node: def __init__(self, data = None): ''' Initialize node with data and next pointer ''' self.data = data self.next = None class Stack: def __init__(self): ''' Initialize stack with stack pointer ''' print("Stack created") # Only add st...
true
002c584b14e9af36fe9db5858c64711ec0421533
PaulSayantan/problem-solving
/CODEWARS/sum_of_digits.py
889
4.25
4
''' Digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers. ''' import unittest def digitalRoot(n:int): ...
true
f99bcedd6bed96991fb8fdf06eba27708ef867b1
dks1018/CoffeeShopCoding
/2021/Code/Python/DataStructures/dictionary_practice1.py
1,148
4.25
4
myList = ["a", "b", "c", "d"] letters = "abcdefghijklmnopqrstuvwxyz" numbers = "123456789" newString = " Mississippi ".join(numbers) print(newString) fruit = { "Orange":"Orange juicy citrus fruit", "Apple":"Red juicy friend", "Lemon":"Sour citrus fruit", "Lime":"Green sour fruit" } veggies =...
true
1c4e7bf09af67655c22846ecfc1312db04c3bfe1
dks1018/CoffeeShopCoding
/2021/Code/Python/Tutoring/Challenge/main.py
967
4.125
4
import time # You can edit this code and run it right here in the browser! # First we'll import some turtles and shapes: from turtle import * from shapes import * # Create a turtle named Tommy: tommy = Turtle() tommy.shape("turtle") tommy.speed(10) # Draw three circles: draw_circle(tommy, "green", 50, 0, 100) draw...
true
760537b38c1899088736d0f4a3ba3d27fe3a29c5
dks1018/CoffeeShopCoding
/2021/Code/Python/Searches/BinarySearch/BinarySearch.py
1,779
4.15625
4
low = 1 high = 1000 print("Please think of a number between {} and {}".format(low, high)) input("Press ENTER to start") guesses = 1 while low != high: print("\tGuessing in the range of {} and {}".format(low, high)) # Calculate midpoint between low adn high values guess = low + (high - low) // 2 high_...
true