blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8b70021aa4d42681dcf3f766b96111030e367959
myke2424/my-python-learning
/super.py
2,048
4.53125
5
# At a high level, super() gives you access to methods in a parent class from the subclass that inherits from it # super() alone returns a temporary object of the parent class that then allows you call that superclass's methods # A common use case is building classes that extend the functionality of previously built...
true
3aabc19b3d1d49476d0f9b519f1e04c0b4e37f7e
myke2424/my-python-learning
/lambdas.py
1,463
4.46875
4
# Lambdas are just anonymous functions (e.g. js arrow function cb) # Taken literally, an anonymous function is a function without a name. # In Python, an anonymous function is created with the lambda keyword. # We can apply the an argument to the lambda by surrounding the func and its arg with parentheses (lamb...
true
b5fa47092ffc8d0a9f927d9769edc5d41daa6aa4
MayowaLabinjo/Guessing-game
/Guessing game.py
421
4.1875
4
import random highest=10 answer=random.randrange(highest) guess=input("guess a number from 0 to %d: " % highest) while(int(guess)!=answer): if(int(guess)<answer): print ("answer is higher") else: print ("answer is lower") g...
true
e7724794b94a65e9a7f6aae136d821de1f33698a
vagmithra123/python
/Operators.py
1,353
4.15625
4
#range, only stop for num in range(10): print(num) #range , start, stop for num in range(2, 10): print(num) #range , start, stop, step for num in range(2, 10, 2): print(num) print(list(range(0, 11, 2))) #Generator is a special type of function, it will generate information instead of saving it all to memory. in...
true
1db8c24dbf53530312c12a4c105312e55853ab60
dhsabigailhsu/y1math
/t01primeshcflcm_evennumbers.py
255
4.25
4
# What are the even numbers from 1 to num? #num is 123 num = 123 #execute a loop from 1 to 123 for i in range(1, num+1): #check if the current number is divisible by 2 if i % 2 == 0: #print out the number, in the same line print(i, end=' ')
true
e188153fc3bae693a94f3d1cdb6cb5bb6683af4b
LucyMbugua/python_bootcamp
/practice_tasks/pythonbasics.py
2,170
4.25
4
#TASK 1: # Write a program which accepts a string as input to print "Yes" if the string is "yes", "YES" or "Yes", otherwise print "No". # Hint: Use input () to get the persons input string = input("Enter a string:") if string == "yes" or string == "YES" or string == "Yes": print("Yes") else: print("No") """...
true
efb0a0ff7d4a195ced46dacb9b8cc5bef1e9391a
varghesechacko/PracticePython
/Exercise1.py
850
4.21875
4
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. # Extras: # Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. (Hint: ...
true
a4e582bfb6d450c57afdf516e69bb0ceae45880d
jmartinknoll/PY4E
/exercise3.1.py
459
4.125
4
# calculate gross pay (user input) # find the breakdown of how much of the gross pay is regular pay and overtime pay # 1.5x pay for overtime x = input('enter hours: ') y = input('enter rate of pay: ') hours = float(x) payrate = float(y) if hours > 40 : print('overtime') regpay = hours * payrate otpay = (hou...
true
edf032ebdb1ee2ba3a9403c5daabd748faf05d92
jmartinknoll/PY4E
/exercise7.2.py
873
4.375
4
# Write a program to prompt for a file name, and then read # through the file and look for lines of the form: # X-DSPAM-Confidence: 0.8475 # When you encounter a line that starts with “X-DSPAM-Confidence:” # pull apart the line to extract the floating-point number on the line. # Count these lines and then compute the t...
true
2d56cebf279f5333ab4139fc5299ad96c2fd43cf
jmartinknoll/PY4E
/exercise10.2.py
802
4.15625
4
# This program counts the distribution of the hour of the day # for each of the messages. You can pull the hour from the “From” line # by finding the time string and then splitting that string into parts using # the colon character. Once you have accumulated the counts for each # hour, print out the counts, one per lin...
true
bb4d1b7eb0f74274f3da3243dbab87a421041def
jmartinknoll/PY4E
/exercise9.4.py
966
4.34375
4
# Add code to the program in exercise 9.3 to figure out who has the # most messages in the file. After all the data has been read and the dictionary has been created, # look through the dictionary using a maximum loop (see Chapter 5) to find who has # the most messages and print how many messages the person has. fnam...
true
bc2ff903e559b4010ae4b52aea7afe6867a1cb3a
KiranJungGurung/tip-calculator
/main.py
1,187
4.375
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 # Print welcome to the tip calculator. print("Welcome to the tip calculator.") #Assign bill,tip and people as a variable name. bill = float(input("What was...
true
211dd14fb065f37996f918e3543851ec7824d00f
Humayungithub/TextEditor
/TextEditor.py
1,317
4.15625
4
#import tkinter from tkinter import * #import filedialog from tkinter.filedialog import * filename = None def newFile(): global filename filename = "untitled" text.delete(0.0, END) def saveFile(): global filename t = text.get(0.0, END) f = open(filename, 'w') f.write(t) f.close() def...
true
56e17ec36959de88aa5eecd836a0e7fb907b2633
melvinm4697/cti110
/P4T2_BugCollector_MorinekiMelvin.py
458
4.28125
4
# This program will calculate total bugs collected over 5 days # March 31, 2020 # CTI-110 P4T2 - Bug Collector # Morineki Melvin # # Set total to 0 # Enter bugs collected each day for five days # Add the bugs collected for the five days # Display the total amount of bugs collected total = 0 for day in ran...
true
66bee0c1e0f28c4d18c0afd73bd6da748657b64d
gabrielb09/Python-For-Lab
/Chp. 2 Problem 1/Problem1.py
1,007
4.25
4
#INSTRUCTIONS: run the program, it will print the information to the command line. #creates a function for calculating the Height and Velocity of the projectile def HandV (h,v,t): #calculates Height based on initial height, velocity, and time H = h + (v*t) - 4.9*(t**2) #calculates Velocity based on initial ...
true
fd1ad85c9b81fc0949ea0ceb836cbd432fbb9496
rajivmanivannan/learning-python
/src/basics/functions.py
2,579
4.6875
5
#!/usr/bin/env python3 # encoding= utf-8 """ Functions A function is a block of code that takes in some data and, either performs some kind of transformation and returns the transformed data, or performs some task on the data, or both. Functions are useful because they provide a high degree of modularity. Similar ...
true
c7246a27cc3c9afa67b060b09de5d4267d5d8338
StevenR152/Connect4-Python
/code/main.py
2,149
4.1875
4
def print_board(board): print("Printing the board...") # write code that prints the board 2d array def get_user_input(valid_inputs, player): users_input = input("Enter the move for player " + str(player) + ":") print("User entered: " + users_input) # TODO Use valid_inputs to check the users input ...
true
4313e649e845d28f81c91ee484d3d844c7554faa
Prince7862/Number-Guessing-Game
/numberguessingGame.py
686
4.15625
4
import random; chances = 0 randomNum = random.randint(1,9) #print(randomNum) #a = (randomNum > number) #print(type(number)) #print(a) while(chances < 5): chances = chances + 1 number = int(input("Guess a Number from 1 to 9: ")) if(number < randomNum): print("The number you have entered is...
true
9a34ae5932e673a307c07cc91f4a305c7d13c680
Tanishk-Sharma/Data-Structures-and-Algorithms
/Data Structures/Queue.py
1,238
4.375
4
class Queue: def __init__(self): #Constructor creates a list self.queue = list() def enqueue(self,data): #Adding elements to queue if data not in self.queue: #Checking to avoid duplicate entry (not mandatory) self.queue.insert(0,data) ...
true
4c07495d4ac8161878fd8f34282e57023c59b4c1
michaelGRU/temp
/lists20.py
977
4.375
4
# data type: list (mutable) # create a list names = ["Chloe", "Victoria", "Jackson"] # find the index of an item names.index("Jackson") # loop through the list for i, name in enumerate(names): pass # print(f"{name} is in index {i}") # adding items: append, insert names.append("Michael") names.insert(...
true
754d28fec133038d9e44f139c1ad1972d1d9e620
michaelGRU/temp
/dic20.py
413
4.1875
4
# dictionary # indexed by keys, can be any immutable type d = {"pet": "dog", "age": 5, "name": "kgb"} print(type(d)) d = dict(pet="dog", age=5, name="spot") print(d.items()) print(d.keys()) print(d.values()) print(d["pet"]) # add an item d["add"] = "sit" # remove an item del d["add"] # the value as...
true
fa9127a292ada7a481b87cd997128e923aaf9a26
GeekGirlDee/FirstProjectWithTakenMind
/FirstProject/venv/Pandas/Pandas Statistics.py
2,036
4.4375
4
from pandas import Series, DataFrame import numpy as np from numpy.random import randn import matplotlib.pyplot as plt # 2d array # np.nan stands for non value array1 = np.array([[10, np.nan, 20], [30, 40, np.nan]]) print array1 # creating a Data Frame # this dataframe will print out the index which is the row number...
true
ca6eadf33cfef18f5767d072dbadf72980f14742
oxygenJing/Big-Data-exercise
/feature-engineering-with-pyspark/No16-Calculate-Missing-Percents.py
1,170
4.5
4
#Calculate Missing Percents ''' Automation is the future of data science. Learning to automate some of your data preparation pays dividends. In this exercise, we will automate dropping columns if they are missing data beyond a specific threshold. Instructions 100 XP Define a function column_dropper() that takes the pa...
true
6be955db0f313c5af57520a9e3b6e9bad7f35854
oxygenJing/Big-Data-exercise
/feature-engineering-with-pyspark/No12-caling-your-scalers.py
2,292
4.40625
4
#Scaling your scalers ''' In the previous exercise, we minmax scaled a single variable. Suppose you have a LOT of variables to scale, you don't want hundreds of lines to code for each. Let's expand on the previous exercise and make it a function. Instructions 100 XP Define a function called min_max_scaler that takes p...
true
726157b25bec6fd17c28310b5e25a6e22c7e79ce
oxygenJing/Big-Data-exercise
/big-data--fundamentals-pyspark/No32-Loading-spam-and-non-spam-data.py
2,044
4.28125
4
#Loading spam and non-spam data ''' Logistic Regression is a popular method to predict a categorical response. Probably one of the most common applications of the logistic regression is the message or email spam classification. In this 3-part exercise, you'll create an email spam classifier with logistic regression usi...
true
c8a9a041e3bf8a1b22ff94f3532db84929554205
oxygenJing/Big-Data-exercise
/big-data--fundamentals-pyspark/No37-Visualizing-clusters.py
1,491
4.125
4
#Visualizing clusters ''' After KMeans model training with an optimum K value (K = 15), in this final part of the exercise, you will visualize the clusters and their cluster centers (centroids) and see if they overlap with each other. For this, you'll first convert rdd_split_int RDD into spark DataFrame and then into P...
true
fbbf3b764a4bcec5c900e1c9c45b70b235b2cbfd
KruZZy/magic-of-computing
/perm_backtracking.py
857
4.125
4
def backtrack(depth, max_level): global solution, appears ## in Python, global variables used inside a function definition should be mentioned beforehand. if depth <= max_level: ## if depth reaches max_level, we have generated a permutation. for i in range(1, max_level+1): if appears[i] == F...
true
845dfa9e7e10caba0ea4862866f7138b0f3a3542
poojitha2803/lab-programs
/lab exp-4.4.py
760
4.40625
4
4.4) In algebraic expressions, the symbol for multiplication is often left out, as in 3x+4y or 3(x+5). Computers prefer those expressions to include the multiplication symbol, like 3*x+4*y or 3*(x+5). Write a program that asks the user for an algebraic expression and then inserts multiplication symbols where approp...
true
bb2d174195cab59c27f2006540c6389f5934bc60
TLyons830/The-Tech-Academy-Basic-Python-Projects
/Python_if.py
278
4.21875
4
num1 = 10 key = False if num1 == 12: if key: print('num1 is EQUAL to 12 and they have the key') else: print('num1 is EQUAL to 12 and they DO NOT have the key') elif num1 < 12: print('num1 is LESS than 12') else: print('num1 is GREATER than 12')
true
92e7aefdb2813c3da5c2d27bd398aaf1f5ece125
IliaIliev94/cs50-psets
/pset6/mario.py
833
4.46875
4
from cs50 import get_int # Main function which calls the get input function and prints the piramid def main(): height = get_user_input() # Prints the piramid on the basis of the number of rows the user has given as input in the height variable for i in range(height): for j in range(i + 1, heigh...
true
fdd668a446e26600bc06b2d3a6c648a63271b270
chen808/python_fundemental_assignments
/assignment_10_Regular_Expression_findword.py
816
4.1875
4
# importing 're' to use Regular expression import re str = 'an example word:cat!!' match = re.search(r'word:\w\w\w', str) # If-statement after search() tests if it succeeded if match: print 'found', match.group() ## 'found word:cat' else: print 'did not find' # searches to see if word 'Bat'...
true
bf5d3eb1e0644ff2c6e1e756f0874778f4022df0
monica-cornescu/learn_python_hackerrank-30-days
/hackerrank_day7.py
484
4.15625
4
#Given an array, , of integers, print 's elements in reverse order as a single line of space-separated numbers. import math import os import random import re import sys if __name__ == '__main__': n = int(input()) arr = list(map(int, input().rstrip().split())) reverseArr = arr[::-1] for ele...
true
73a0b4c8c0c52a314801f74957c52f34069d8d4b
Katiedaisey/Projects
/Solutions/factorial_finder.py
643
4.3125
4
# **Factorial Finder** - # The Factorial of a positive integer, n, is defined as # the product of the sequence n, n-1, n-2, ...1 and the # factorial of zero, 0, is defined as being 1. # Solve this using both loops and recursion. def factorial(num): if num < 2: fact = 1 else: fact = num * factorial(num - 1) ...
true
b2f4654953d024fe23e34af66d4f6922e29b9970
ScottLoPinto/ToyProblems
/src/2021/june/2/switch_sort.py
1,835
4.40625
4
# Have the function SwitchSort(arr) take arr which will be an an array consisting of integers # 1...size(arr) and determine what the fewest number of steps is in order to sort the array # from least to greatest using the following technique: Each element E in the array can swap # places with another element that is ...
true
81600d0a5d82922f89ff10b94157f24de6752067
psnehas/PreCourse-2
/Exercise_3.py
1,226
4.25
4
# Time complexity:O(n) # Space complexxity: O(1) # Node class class Node: # Function to initialise the node object def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): newNode = ...
true
34bea9ae596a785783149b1c97ad0339d63079f8
davidknoppers/interview_practice
/codewars/triplet_sums.py
1,609
4.34375
4
#!/usr/bin/python3 #we import random to generate random arrays to test the algo import random """ triplet_sums finds all groups in an array that add up to the target sum The array and target are both supplied by the user """ def triplet_sums(arr, target): #sort the array to make subsequent subroutines much faster ...
true
e36fc7cb4cd92bbb359491a3e477e059b6379b74
GururajM/SimpleCalculation
/simple_calculation/simple_calculation/logic/calculator.py
2,334
4.40625
4
class Calculator: """ A class used to represent a basic calculator that performs an arithmetic operation on two operands ... Attributes ---------- operand_1 : int An interger value that represents the first operand operand_2 : int An interger value that represents the first op...
true
7c122b2ceeb257b19178075d1b7accb63ed7b5c9
anujvyas/Data-Structures-and-Algorithms
/Data Structures/3. Linked List/node_swap_sll.py
1,193
4.125
4
# Swap two nodes in a given linkedlist without swapping data from singly_linked_list import Node, LinkedList def swap_node(head, x, y): # If both values are same if x == y: return head # Find x prevX = None currX = head while currX != None and currX.data != x: prevX = currX currX = currX...
true
f98705a18fb7e34b4e4a3ba8292aa01d05409e77
honghaoz/DataStructure-Algorithm
/Python/Cracking the Coding Interview/Chapter 5_Bit Manipulation/5.6.py
746
4.21875
4
from Bit import * from operator import xor # Write a program to swap odd and even bits in an integer with as few instructions as possible # (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and so on) # Suppose 32-bit integer def swapOddWithEven(num): oddMask = bitToInt("010101010101010101010101010101...
true
a40e3892dd553267873b17ec1ebecbbadd9e8415
honghaoz/DataStructure-Algorithm
/Python/LeetCode/ZigZag Conversion.py
1,616
4.21875
4
# ZigZag Conversion # The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) # P A H N # A P L S I I G # Y I R # And then read line by line: "PAHNAPLSIIGYIR" # Write the code that will take a...
true
3d21be7ff3d017b4cf4685049a63194743820f83
honghaoz/DataStructure-Algorithm
/Python/Cracking the Coding Interview/Chapter 7_Mathematics and Probability/7.4.py
1,594
4.21875
4
# Write methods to implement the multiply, subtract, and divide operations for integers. # Use only the add operator. # multiply def multiply(a, b): summ = 0 if b == 0: return 0 elif b > 0: for i in xrange(b): summ += a return summ else: for i in xrange(b, 0): summ += a return negate(summ) def sub...
true
8b807ed989dddfecc2e89f7632ca3da1f6ac1f47
caveman0612/python_fundeamentals
/03_more_datatypes/4_dictionaries/03_17_first_dict.py
261
4.125
4
''' Write a script that creates a dictionary of keys, n and values n*n for numbers 1-10. For example: result = {1: 1, 2: 4, 3: 9, ...and so on} ''' dict = {} for i in range(1, 11): value = input(f"input value for {i} key") dict[i] = value print(dict)
true
dedf0e77eb39d7ff8d20d1a79162f43187ce3248
caveman0612/python_fundeamentals
/03_more_datatypes/3_tuples/03_16_pairing_tuples.py
691
4.5
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple If the user enters an odd numbered list, add the last item to a tuple with the number 0. Note: This lab might be challenging! Make sure to discuss it with your me...
true
d124098dda95e3b66e6a78d6d9f65ea76525b1b1
salisquraishi/Python-programming-1
/codes/program17.py
1,957
4.34375
4
# A website requires the users to input username and password to register. # Write a program to check the validity of password input by users. # Following are the criteria for checking the password: # 1. At least 1 letter between [a-z] # 2. At least 1 number between [0-9] # 1. At least 1 letter between [A-Z] # 3. At l...
true
86be9953fb3c6ce6071970af31f4b614ea976e6c
salisquraishi/Python-programming-1
/codes/program29.py
581
4.3125
4
# Define a class named Shape and its subclass Square. # The Square class has an init function which takes a length as argument. # Both classes have a area function which can print the area of the shape # where Shape's area is 0 by default. class Shape(): def __init__(self): pass def area(self): ...
true
db651349442682ab85e0b52b8a136ba374fc9663
salisquraishi/Python-programming-1
/codes/program41.py
425
4.1875
4
# Please write a program which count and print the numbers of each character in a # string input by console. # Example: # If the following string is given as input to the program: # abcdefgabc # Then, the output of the program should be: # a,2 # c,2 # b,2 # e,1 # d,1 # g,1 # f,1 count = {} s = input(">") for c in l...
true
144bee13861744e0a7dd3fd7606e6d906121c43b
Graham-CO/ai_ml_python
/chapter_4/ReLU_applied.py
1,015
4.15625
4
# Graham Williams # grw400@gmail.com # Apply ReLU activation function to a dense layer import numpy as np import nnfs from nnfs.datasets import spiral_data nnfs.init() class Layer_Dense: def __init__(self, n_inputs, n_neurons): self.weights = 0.01 * np.random.randn(n_inputs, n_neurons) self.b...
true
df595a116cc32bd0b410ce437495a46fd4504640
mailgurudev/python
/string_list.py
272
4.375
4
word = input(str("Enter a word ")) new_word = [] for c in word: new_word.append(c) print(new_word) print(list(reversed(new_word))) if new_word == list(reversed(new_word)): print("Its is a pallindrome") else: print("it is not a pallindrome")
true
17de56cea61b7de040969163bdc810fab2df99ea
malliksiddarth/python-program
/sid3.py
297
4.40625
4
#!/usr/bin/python3 # guess what this program does? import random r=random.randint (1,6) #give random number print(r) if r<35: print(r) print(":is less than 35") elif r==30: print("30 is multiple of 10 and 3, both") elif r>=35: print(r,"is greater than 35") else: print("your number is:",r)
true
8d0943d7c1bec41ba89e223b676244e1b55efde7
Cherry-RB/sc-projects
/stanCode_Projects/hangmen_game/complement.py
1,023
4.46875
4
""" File: complement.py Name:Cherry ---------------------------- This program uses string manipulation to tackle a real world problem - finding the complement strand of a DNA sequence. THe program asks uses for a DNA sequence as a python string that is case-insensitive. Your job is to output the complement of it. """ ...
true
49692a5b089f09ed652d3122af53758c56d7f5bf
delos/dm-pta-mc
/src/parallel_util.py
1,791
4.3125
4
""" Collection of useful functions which handle parallelizing the main program """ import numpy as np def generate_job_list(n_proc, total_job_list): """ Will generate the job list to send to the processors. total_job_list - all of the jobs that need to be done """ n_jobs = len...
true
ea78d8f3ebbdf04c9ce4ee372c42eca87b38468b
OlehHnyp/Home_Work_4
/Home_Work_4_Task_3_v2.py
538
4.1875
4
while 1: try: number = input("""Please insert integer number and get \ Fibonacci numbers up to this number:""") if int(number) - float(number) == 0 and int(number) == abs(int(number)): break except ValueError: pass up_border = int(number) former_number = 0 next_number = 1 pr...
true
82aad93d10020fa7ad335e417f69950b53d07123
ThilinaTLM/code-juniors19
/BinaryTree.py
1,592
4.15625
4
""" Add given numbers to a binary tree. Author : Thilina Lakshan Email : thilina.18@cse.mrt.ac.lk """ ## Tree Travels ================================================================================= def getParent(ind): if ind == 0: return None return ((ind + 1)//2) - 1 def g...
true
d51481c812f3d52ed6aa662f69bf3c295985f196
vaishnavi555/ppl_assignment
/ass1_4.py
336
4.28125
4
import random print("welcome to guessing game!") no = random.randrange(1,11) for x in range(3): guess = input("guess the number from 1-10: ") if guess > no: print("guess is greater than no. !") elif guess < no: print("guess is smaller than no. !") else: print("correct guess!") break print("{} was the number...
true
4b449817b6867bce05e8ac54dad93c132cd08ed6
SUKESH127/bitsherpa
/[3] CodingBat Easy Exercises /solutions/Warmup-1/pos_neg.py
334
4.28125
4
#Given 2 int values, #return True if one is negative and one is positive. #Except if the parameter "negative" is True, then return True only if both are negative. def pos_neg(a, b, negative): if negative: return (a < 0) and (b < 0) return a * b < 0 print( pos_neg(1, -1, False), pos_neg(-1, 1, False), pos_neg(...
true
97595b723f01c5c7e07e15347554bd3d72c2580f
simon-pinkmartini/foundations
/class-02/dictionaries.py
303
4.28125
4
#Create a dictionary myself = { "name": "Simon", "age": 35, "home": "Upper East Side" } print (myself) print (myself.keys()) #Reference item in dictionary print ("My name is", myself["name"],".") #Loop through the keys for attribute in myself: print (attribute,":",myself[attribute])
true
bef5d16b5c52b3f37b2046bd452608b8af2c9de1
namratapandit/python-project1
/code/repeatloop.py
1,400
4.28125
4
# program to take 2 numeric inputs and and operation selection from user # the program repeats until the user does not exit # Perform operations like add, sub, mul, divide # keep repeating till user exits # also handle exceptions for invalid inputs def main(): validinput = False # while loop runs till valid en...
true
aa6c909edb7d736d23f630be97a28871ba10fcc9
achilles8work/Python_EDX_MIT
/polysum.py
605
4.125
4
''' Grader A regular polygon has n number of sides. Each side has length s. The area of a regular polygon is: The perimeter of a polygon is: length of the boundary of the polygon Write a function called polysum that takes 2 arguments, n and s. This function should sum the area and square of the perimeter of the regu...
true
090d7811f4d90d89084d6aa8075811995f9e137d
rob-kistner/udemy-python-masterclass
/examples/functions_scope.py
1,477
4.28125
4
################################ # # FUNCTIONS - SCOPE # ################################ from modules.utils import * banner("""showing local function vs. global scope""") ############################## def my_function(): test = 1 print('my_function: ', test) test = 0 my_function() print('global: ', test) ...
true
43120cd6adcbe8a50f8ddb2b4b30e032321ca087
RakeshSuvvari/Joy-of-computing-using-Python
/anagrams.py
298
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 17 22:34:21 2021 @author: rakesh """ str1 = input("Enter the first string: ") str2 = input("Enter the second string: ") if(sorted(str1)==sorted(str2)): print("These are Anagrams") else: print("These are not Anagrams")
true
34f5ee3e01391ac7156c416ceeb87b807ad06701
MarioMarinDev/PythonCourse
/files.py
1,153
4.3125
4
""" r = Read; Shows an error if the file does not exist a = Append; Creates the file if it does not exist w = Write; Creates the file if it does not exist x = Create; Returns an error if the file exists file.read() = Read the entire file file.read(x) = Read the first 'x' chars of the file f...
true
c02ecb661961def9a8d7f92612f007188130ba8f
mycomath/First-Code-Upload
/madlib.py
1,024
4.28125
4
storyFormat = ''' Once upon a time, deep in an ancient jungle, there lived a { animal }. This {animal} liked to eat {food}, but the jungle had very little {food} to offer. One day, an explorer found the {animal} and discovered it liked {food}. The explorer took the {animal} back to {city} where it could eat as ...
true
0d8e4f608cff645d2f765ced84b492c3c3f3338e
mohammedthasincmru/royalmech102018
/greater.py
310
4.15625
4
'''a=int(input("enter the value of a:")) b=int(input("enter the value of b:")) if(a>b): print("a is greater than b") else: print("b is greater than a")''' a=int(input("enter the value of a:")) b=int(input("enter the value of b:")) if(a<b): print("a is lesser than b") else: print("b is lesser than a")
true
07a1f9e9eb5b863e476cc5722cab3437dee44c66
fztest/Classified
/10.bit_manipulation/10.3_L371_Sum_of_two_numbers.py
1,467
4.1875
4
""" Description _______________ Calculate the sum of two integers a and b but you are not allowed to use the operator + and -. Example _____________ Given a = 1 and b = 2, return 3. Approach ______________ a&b - gives you the carry digits a^b - gives you distinctive digits (equals to plus without caring about carry) ...
true
c66d8e382f798362c16cd9f9dd941c7d63db6f1b
fztest/Classified
/2.Binary_Search/2.16_L274_H-Index.py
1,623
4.15625
4
""" Description ______________ Given an array of citations (each citation is a non-negative integer) of a researcher write a function to compute the researcher's h-index. According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each and the other N...
true
5977c9f8b609edfccd873bb3116293e5c402f0b1
fztest/Classified
/3.Binary_Tree_DC/3.15_453_Flatten_Binary_Tree_to_linked_list.py
2,228
4.46875
4
""" Description ___________ Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the next pointer in ListNode. Notice Don't forget to mark the left child of each node to null. Or you will get Time Limit Exceeded or Memory Limit Exceeded. Have you met t...
true
10b1c8ebcb77a4a42e82ad16cb9721d6f5faddeb
fztest/Classified
/6.LinkedList&Array/6.2_599_Insert_Into_a_Cyclic_Sorted_list.py
1,919
4.1875
4
""" Description _________________ Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list. Return the inserted new node. Example ________________ Given a list, and insert ...
true
35db605f8d41a5b2a0a0cd577da438078d289e64
fztest/Classified
/4.BFS/4.11_178_graph_valid_Tree.py
1,947
4.21875
4
""" Description ______________ Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Notice ____________ You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1]...
true
7f639eb12ac60c72593d175c02d2b41dff6cecce
bhavyaagg/python-test
/algs4/sorting/heap.py
1,933
4.21875
4
# Created for BADS 2018 # See README.md for details # Python 3 import sys from algs4.stdlib import stdio """ The heap module provides a function for heapsorting an array. """ def sort(pq): """ Rearranges the array in ascending order, using the natural order. :param pq: the array to be sorted """ ...
true
0ecbbd7c74bffafc2b9270efbba0fb99ff2b2334
bhavyaagg/python-test
/algs4/sorting/merge.py
2,292
4.34375
4
# Created for BADS 2018 # See README.md for details # Python 3 """ This module provides functions for sorting an array using mergesort. For additional documentation, see Section 2.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. """ # Sorts a sequence of strings from standard input using mergesort ...
true
2173ad098596254036763aeafa11b98aebfa1fd4
maro199111/programming-fundamentals
/Exercises/exercise17.py
583
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 16 16:26:29 2019 @author: edoardottt """ #Write a function that take as input three numbers g,m,a (with a odd, in this way we avoid leap years) # and it returns True or False depending on the three numbers make a valid date. #Es. 30/2/2017 False; 1...
true
e0398fb3a6d508963caeb41fa5849c642ea2d414
SairaQadir/python-assignment
/ass2/ass-2.py
1,590
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[3]: print("Enter 'x' for exit."); #question1 print("Enter marks obtained in 5 subjects: "); mark1 = input(); if mark1 == 'x': exit(); else: mark1 = int(mark1); mark2 = int(input()); mark3 = int(input()); mark4 = int(input()); mark5 = int(input()); ...
true
1d16d6b2bcb5ed20b8d80d4644f8faa455f71225
KrystalGates/Bk1Ch4Dictionaries
/dictionaryOfWords.py
1,325
4.59375
5
# """ # Create a dictionary with key value pairs to # represent words (key) and its definition (value) # """ word_definitions = dict() print(word_definitions) # """ # Add several more words and their definitions # Example: word_definitions["Awesome"] = "The feeling of students when they are learning Python" # """ w...
true
dd342084a237127b3358df48285c3541cab20ef3
mrmichaelgallen/Course-Work-TTA
/Python/PythonInADay/Python_Item20_Script.py
428
4.21875
4
# String Manipulation name = "Guido" print name[0] print name.upper() print name.lower() print name.capitalize() # Formate a Date date = "11/12/2013" # Go through string and split # Where there is a '/' date_manip = date.split('/') #Show the outcome print date_manip print date_manip[0] print date_manip[1] pri...
true
d1653e5fed55296e9546b46e7a0865072f55470e
vishrutarya/grpc-calculator
/calculator.py
269
4.1875
4
import math def square_root(num: int): """ Returns the square root of the arg `num`. """ result = math.sqrt(num) return result def square(num: int): """ Returns the square of the `num` param. """ result = num ** 2 return result
true
75d37d4417f0fb4dd3decb8aa3fa506139ad9544
AllieJackson/Rice-Python-Certification
/RPSLS.py
2,772
4.1875
4
# Rock-paper-scissors-lizard-Spock template #Imports import random # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to numbers # as follows: # # 0 - rock # 1 - Spock # 2 - paper # 3 - lizard # 4 - scissors # helper functions # Take the user's ...
true
23e5502f4418219a78ab515e60be0a49de72c492
gmanproxtreme/rps
/rps.py
1,407
4.21875
4
import random, math def Draw(): print("We both picked the same.") return def PWin(): print("Well done you win.") return def CWin(): print("You lose.") return StrUserType = input("Select Paper, Rock or Scissors (P,R or S)") ComputerType = math.floor(random.random()*3) #random.random(3) # 0==...
true
169fc98fcdeec215e501af357eae3122a46a0396
ryandancy/project-euler
/problem145.py
1,361
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Project Euler Problem 145: Some positive integers n have the property that the sum [ n + reverse(n) ] consists entirely of odd (decimal) digits. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such numbers reversible; so 36, 63, 409, and 904 are reversib...
true
3c6b82f854695233a25f58a869b8ed2b3e91239a
ryandancy/project-euler
/problem1.py
439
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Project Euler Problem 1: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ # Add multiples of 3 to multiples of 5 which are no...
true
e474a3325c48bc7ae870cb28bbcccbe756b672e6
CMWelch/Python_Projects
/Python/Python_Exercises/Paper Doll.py
293
4.1875
4
def paper_doll(string): new_string = "" for letter in string: if letter == " ": new_string = new_string + letter else: new_string = new_string + letter * 3 return new_string x = input("Input a string: ") print(paper_doll(x))
true
a8627eb2f89fc73226d44390e7bf7af895f02ff8
benjimortal/face_recognition
/first/toturial/2.py
1,259
4.3125
4
def days_to_units(num_of_days, conversion_unit): if conversion_unit == 'hours': return f"{num_of_days} days are {num_of_days * 24} hours" elif conversion_unit == 'minutes': return f"{num_of_days} days are {num_of_days * 24 * 60} minutes" else: return 'unsupported unit' def validat...
true
b105d2c2229bec44e5e3de2400f883ae3669cc70
benjimortal/face_recognition
/first/Python_Exercises_skolan/6.py
490
4.15625
4
def main(): notes = { '1' : 'George Washington', '2' : 'Thomas Jefferson', '5' : 'Abraham', '10': 'Alexander Hamilton', '20': 'Ulysses S.Grant', '50': 'Andrew Jackson', '100':'Benjamin Franklin' } value = input('Please ente...
true
161e6533b74de7eafb66172b68746e863a40d121
eisendaniel/ENGR_PHYS_LABS
/Lab 1/Python_Intorduction.py
973
4.34375
4
#Lets learn Python 3+4 #if we want to see the result we need to print it print(3+4) #Printing text needs 'quote marks' print('abc') #assign a varible a=1.602**2 print(a+3) #can have creative names newvariblewithmorecreativename=4 print(a+newvariblewithmorecreativename) #Arrays A=[1,2,3,4,5] print(A) #ind...
true
56470a1df35f1b0959fe161adff34183fdc281b9
zhuhanqing/Data-Structures-Algorithms-Goodrich
/Chapter04_Recursion/xPowerN.py
232
4.1875
4
def power(x,n): """ Compute the value of x raised to power n """ if n==0: return (1) else: return (x * power(x,n-1)) #Code Fragment 4.11: Computing the power function using trivial recursion.
true
3bb68bfe85229cc2d0672c672db657c98c31e489
zhuhanqing/Data-Structures-Algorithms-Goodrich
/Chapter04_Recursion/sumOfArray_UsingBinaryRecursion.py
549
4.1875
4
def binary_sum(S,start,stop): """ Return the sum of the numbers in implicit slice S[start:stop]. """ if start >= stop: # zero elements in slice return (0) elif start == stop-1: # One element in slice return (S[start]) else: ...
true
f25516ec401c9387a98463b7fefa334e45a5be15
nathanstouffer/adv-alg
/little-algs/mergesort.py
1,017
4.3125
4
# a short program to mergesort some lists import random # method to recursively divide the mergesort def mergesort(nums): mid = int(len(nums) / 2) if (mid == 0): return nums else: nums1 = nums[:mid] nums2 = nums[mid:] return merge(mergesort(nums1), mergesort(nums2)) # meth...
true
b61305eafd0017a606e4490f18c2cfe30125bbcb
chaoticfractal/Python_Code
/Students_Final_Grades.py
1,979
4.125
4
""" This a little script that will take 3 dictonaries of Students name that contain lists of objects like homework scores, tests scores etc. that are then taken by funcitons to calculate final grade and averages. """ lloyd = { "name": "Lloyd", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40....
true
db553849968f52596e9e8494af602051f0913b3d
TinaArts/leetcode
/array/rotate-array.py
1,220
4.3125
4
"""Rotate Array Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4]...
true
1e2532758ba7e4718381ad1de6f6dff41cb2d675
xyzhangaa/ltsolution
/BTreeInorder.py
1,630
4.15625
4
###Given a binary tree, return the inorder traversal of its nodes' values. # O(n), O(n) def iterative_inorder(self,root,list): stack = [] while root or stack: if root: stack.append(root) root = root.left else: root = stack.pop() list.append(root.val) root= root.right return list def inorder(roo...
true
973c6c4a2bc42f7774c6cedb01100948e1e5af8e
xyzhangaa/ltsolution
/ReverseWordsinaStringII.py
808
4.125
4
# Time: O(n) # Space:O(1) # # Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters. # # The input string does not contain leading or trailing spaces and the words are always separated by a single space. # # For example, # Given s = "the sky is blue", # return...
true
ad67bdef83de3cc2f3bb7dd4c16bc06f60e3cdce
Quinneth/Election_Analysis
/Temperature.py
293
4.5625
5
#delcared by asking user to input int() wrapped statement-->converts user input type from string to integer then used to assess if-else statement temperature = int(input("What is the temperature outside")) if temperature > 80: print("turn on the AC.") Else: print("Open the windows.")
true
8932a7e8052a2835b793425407c36b84546d1cfc
Jmarshall1994/PRG105
/99bottles.py
227
4.125
4
bottles = input('How many bottles?') while bottles > 0: print bottles, 'bottles of beer on the wall, ',bottles,' of beer. Take one down and pass it around,', bottles-1,' bottles of beer on the wall' bottles = bottles -1
true
35c01a577cc7c7fb9517413e112b8c8711699c3d
arinablake/python-selenium-automation
/hw_algorithms_1/Return Negative.py
317
4.46875
4
#In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative? def make_negative( number ): if number > 0: return - number elif number < 0: return number else: return 0 print(make_negative(-10)) print(make_negative(25))
true
60cfd5e18f77aaef3ed49a163311c3eed17d819e
benjamin22-314/learn_python_the_hard_way
/ex31.py
649
4.1875
4
print("""You enter a room. There is a chair in the room. There is a door in the room.""") print("""Do you sit on the chair (press '1') or go through the door (press '2')""") choice = input("> ") if choice == '1': print("The chair is an illusion, you fall on your bum") elif choice == '2': print("The door is j...
true
64a6261b37c4498244a300a8930776e330703f8f
huynhtritaiml2/Python_Basic_Summary
/list2.py
2,867
4.28125
4
greetings = ["hi", "hello", "wassap"] print(greetings[2]) # wassap print(len(greetings)) # 3 # n --> list size # highest index = n - 1 # for item in greetings: print(item) for i in range(len(greetings)): print(greetings[i]); # backpack = ["sword", "rubber duck", "slice of pizza", "parachute", "sword", "sw...
true
c4beb3d5a41bbcd6c6c115a13ef7f0f85a60f0da
alinasansevich/coding-playground
/grokking_algorithms/g_a_Ch2_SortSmallestToLargest.py
870
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 10 14:49:32 2021 @author: alina Code from the book "Grokking Algorithms", exercises, examples, my experiments with it, etc. """ def find_smallest(arr): """ (list of int) -> int Returns the smallest integer in a list of integers (I co...
true
1206e0ce85952fbe5508676e1a7bfa99e75195d9
pronouncedlyle/DS-and-Algos-Practice
/Sandbox/linked_list.py
1,551
4.1875
4
import time #define node (like the constructor) class node: def __init__(self, data = None): self.data = data self.next = None # define a linked list (using the definition of node) class linked_list: def __init__(self): self.head = node() #add to a linked list def append (self, dat...
true
0dea9e43ee7c33731ce954ac2eef9b6d661fb30a
holdbar/misc_python_stuff
/patterns/creational_patterns/abstract_factory.py
1,404
4.3125
4
# -*- coding: utf-8 -*- from abc import ABCMeta, abstractmethod class Beer(metaclass=ABCMeta): pass class Snack(metaclass=ABCMeta): @abstractmethod def interact(self, beer: Beer) -> None: pass class AbstractShop(metaclass=ABCMeta): @abstractmethod def buy_beer(self) -> Beer: ...
true
1e68f059b845813c5070ba6c5ec2e050c96b6050
spettigrew/cs2-fundamentals-practice
/mod1-Python_Basics/basic_operations.py
388
4.34375
4
""" 1. Assign two different types to the variables "a" and "b". 2. Use basic operators to create a list that contains three instances of "a" and three instances of "b". """ # Modify the code below to meet the requirements outlined above a = "Goodbye " b = "Lambda" both = a + b print(both) a_list = [a] * 3 b_list = [...
true
3dcc4ac57b0ce744901cf619bb131b7410435c04
RAMKUMAR7799/Python-program
/Beginner/Gnumbers.py
286
4.25
4
num1=int(input("Enter your number")) num2=int(input("Enter your number")) num3=int(input("Enter your number")) if(num1>=num2 and num1>=num3): print(num1,"is greatest number") elif(num2>=num1 and num2>=num3): print(num2,"is greatest number") else: print(num3,"is greatest number")
true