blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
f598e6b3c1b2dd6ee97f75f7b2225593ef59b09e | mvillaloboz/learnPython | /ex3.py | 960 | 4.625 | 5 | # display that we are about to count chickens
print "I will now count my chickens:"
# displaying our Hens, then Roosters
print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4
# display the fact that we are about the count the eggs
print "Now I will count the eggs:"
# calculate the amount of eggs
print 3 + 2 +... | true |
f947d431d899051a22acecbb6be3964485276555 | ashwinitangade/PythonProgramming | /PythonAss1/7.py | 954 | 4.3125 | 4 | #Create a list with at least 10 elements having integer values in it;
Print all elements
Perform slicing operations
Perform repetition with * operator
Perform concatenation with other list.
myList = ['one', 2, 3.14, [1,'two',(2017,2018)], ('python', 'hello')]
print('the elements in list are... | true |
4dfa6d6dc22d7a6a828eb5179b233d1b2e4d1c91 | ashwinitangade/PythonProgramming | /PythonAss1/1.py | 713 | 4.25 | 4 | #Write a program to Add, Subtract, Multiply, and Divide 2 numbers
def myadd(x, y):
return x + y
def mysub(x, y):
return x - y
def mymul(x, y):
return x * y
def mydivide(x, y):
return x / y
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
print("Enter which opera... | true |
f466ebbbb9ce58328f860c0bea23d659fcc7540d | nrepesh/Richter-Coin-Blockchain- | /Assignments/assignment3.py | 1,332 | 4.125 | 4 | # 1) Create a list of “person” dictionaries with a name, age and list of hobbies for each person. Fill in any data you want.
persons = [{
'name':'Batman',
'age':21,
'hobby': 'MMA'
},
{
'name': 'Spiderman',
'age': 19,
'hobby': 'Slinghshot'
},
{
'name':'Superman',
'age':65,... | true |
374191152187785a1bd06c2cf2dd9d1735b3a63c | ymanzi/42bootcamp_machine_learning | /module06/ex10/minmax.py | 538 | 4.1875 | 4 | import numpy as np
def minmax(x):
"""Computes the normalized version of a non-empty numpy.ndarray using the min-max standardization.
Args:
x: has to be an numpy.ndarray, a vector.
Returns:
x' as a numpy.ndarray.
None if x is a non-empty numpy.ndarray.
Raises:
This function shouldn't raise any Exception.
"""
... | true |
d0b2d74d0e6ce10cd17770161733a573911fcb48 | ymanzi/42bootcamp_machine_learning | /module07/ex10/polynomial_model.py | 832 | 4.15625 | 4 | import numpy as np
def add_polynomial_features(x: np.ndarray, power: int) -> np.ndarray:
"""
Add polynomial features to vector x by raising
its values up to the power given in argument.
Args:
x: has to be an numpy.ndarray, a vector of dimension m * 1.
power: has to be an int, the power up to which the... | true |
b6040a20c5b5ed027d882919e87606ffc64dce04 | cppignite/python | /RPS/completed/RockPaperScissors.py | 836 | 4.1875 | 4 | user1_answer = input("Player 1, do you want to choose rock, paper or scissors?")
user2_answer = input("Player 2, do you want to choose rock, paper or scissors?")
if user1_answer == user2_answer:
print("It's a tie! The scores weren't changed.")
elif user1_answer == 'rock':
if user2_answer == 'scissors':
... | true |
dd03a11993a8f427edcb7e2893837ae874a5c13a | nikhilraghunathan/ICT-Full-Stack-Developer | /python/day2/inheritance.py | 314 | 4.53125 | 5 | #inheritance
#defining class vehicle
class Vehicle:
type="Sedan"
YoM=2000
mileage=14
#create new class Bus by inheriting class Vehicle
class Bus(Vehicle):
type = "Coach"
YoM=2005
Mileage=6
#creating new object myBus of the new class
myBus = Bus()
print(myBus.type,myBus.YoM,myBus.Mileage) | true |
0faf1f58b090fda2f5baa9b7b7b46362988f3b1d | standrewscollege2018/2019-year-13-classwork-A-Load-Of-c0de | /option_menu2.py | 1,176 | 4.4375 | 4 | # this program demonstrates how to create an option menu that tells the user which person has been selected
from tkinter import *
root = Tk()
root.geometry('300x200')
def update_label():
""" This function gets the entry field text and displays it in a label. """
label_var.set(selected_name.get() + " has... | true |
6a138e76a852cdcd98a659a4f643c6ed35a9bc6e | standrewscollege2018/2019-year-13-classwork-A-Load-Of-c0de | /pythonrefresher.py | 1,564 | 4.53125 | 5 | # print() is a function
print("Hello world")
print(25)
# variables don't have a dollar sign!
# when naming we use snake_case, so no uppercase letter or symbols other than under underscore
first_name = "John"
last_name = "Smith"
# we can print variables or even text and variables
print(first_name)
print("Hello", first... | true |
21960188861544faff2dbc0f6aa8d4492823bbdc | henrypj/HackerRank | /Implementation/UtopianTree.py | 1,036 | 4.28125 | 4 | #!/bin/python3
import sys
# The Utopian Tree goes through 2 cycles of growth every year. Each spring,
# it doubles in height. Each summer, its height increases by 1 meter.
# Laura plants a Utopian Tree sapling with a height of 1 meter at the onset
# of spring. How tall will her tree be after growth cycles?
#
# In... | true |
11acb550b246406213b52313c558342ae1374c77 | henrypj/HackerRank | /Strings/CaesarCypher.py | 2,356 | 4.34375 | 4 | #!/bin/python3
import sys
"""
# Description
# Difficulty: Easy
#
# Julius Caesar protected his confidential information by encrypting it in a
# cipher. Caesar's cipher rotated every letter in a string by a fixed number, K,
# making it unreadable by his enemies. Given a string, S, and a number, K, encrypt
# S and prin... | true |
7ce5db7508aa1711d4da349f918c6c7c3bbbc3d9 | uniqstha/PYTHON | /questions of day3/Q3.py | 304 | 4.34375 | 4 | #Given the integer N - the number of minutes that is passed since midnight -
# how many hours and minutes are displayed on the 24h digital clock?
N=int(input('Enter the no. of minutes that passed since midnight'))
hr= N//60
min=N%60
print(f'{hr} hours and {min} minutes is displayed in the 24 hr clock') | true |
c2105d51c4f4b6683fa9b5b438f60c387b96e272 | uniqstha/PYTHON | /questions of day6/Q4.py | 203 | 4.21875 | 4 | #Write a Python program that print hello world 10 times.
#Use for loop and while loop
for i in range(10):
print('Hello World')
using while loop
i=1
while i<=10:
print ('Hello World')
i=i+1 | true |
c121ca9fb9e58ea47a7c06d769e9fe5b6b3af32b | uniqstha/PYTHON | /questions of day2/Q5.py | 233 | 4.4375 | 4 | #Check whether the user input number is even or odd and display it to user.
a=int(input("Enter a number"))
check=a%2
if check==0:
print("The given number is even")
else:
print('The given number is odd')
print ('program end') | true |
6cba118aa6688920ff839d2e74a0db88e30eff60 | harkaranbrar7/30-Day-LeetCoding-Challenge | /Week 2/backspace_String_Compare.py | 1,951 | 4.15625 | 4 | '''
Backspace String Compare
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
Example 1:
Input: S = "ab#c", T = "ad#c"
Output: true
Explanation: Both S and T become "ac".
Example 2:
Input: S = "ab##", T = "c#d#"
Output: true
Explanation: ... | true |
cdf29bed6603ff19d733b244a4b6c6400afc1c5c | SandhyaKamisetty/CSPP-1 | /cspp1-assignments/m6/p1/p3/p3/digit_product.py | 451 | 4.21875 | 4 | '''
Given a number int_input, find the product of all the digits
example:
input: 123
output: 6
'''
def main():
'''
@author : SandhyaKamisetty
Given a number int_input, find the product of all the digits
Read any number from the input, store it in variable int_input.
'''
n_s = 123
t... | true |
f36349d332dcd1e88b1a54371069a21c179f736c | SandhyaKamisetty/CSPP-1 | /cspp1-assignments/m11/p2/p2/assignment2.py | 1,301 | 4.125 | 4 | '''
#Exercise: Assignment-2
#Implement the updateHand function. Make sure
this function has no side effects: i.e., it must not
mutate the hand passed in. Before pasting your function
definition here, be sure you've passed the appropriate tests in test_ps4a.py.
'''
import copy
def updatehand(hand, word):
"""
... | true |
7bdfade4f03a5fffd236413dceae16a026ede50e | chemxy/MazeRunnerAI | /versions/1.1/src/Map.py | 1,121 | 4.21875 | 4 | from Node import Node
from Object import Object, Food, Wall
class Map:
def __init__(self, nodeList=None):
if nodeList == None:
nodeList = []
self.nodeList = nodeList
"""
* this method returns a list of nodes in a map.
"""
def nodes(self):
return self.nodeLi... | true |
016ef0782abed9f6e4273294b967b22deb5ab6d7 | hu820/python_proj | /data_type/list.py | 1,241 | 4.5 | 4 | # list []
xs = [3, 1, 2] # Create a list
print(xs, xs[2]) # Prints "[3, 1, 2] 2"
print(xs[-1]) # Negative indices count from the end of the list; prints "2"
xs[2] = 'foo' # Lists can contain elements of different types
print(xs) # Prints "[3, 1, 'foo']"
xs.append('bar') # Add a new element to the end of the list
... | true |
cb999c7c63e0d785280842f361c15958e7829a73 | Divya171/EDUYEAR-PYTHON-20 | /Day_8.py | 833 | 4.28125 | 4 |
# coding: utf-8
# In[10]:
# 1. Take a number from user and check whether it is prime or not. Use paramters to send the number to the function
#eg. Enter a nnumber 3
# 3 is prime
def prime(num):
found = False
if num > 1:
for i in range(2,num):
if num%i == 0:
found = True... | true |
51461ac41288cb9e41e374f5638b34efccce829e | prith25/daily_programming | /Daily Coding/python/union_count.py | 438 | 4.15625 | 4 | #Find the union of two arrays and print the number elements in the resultant array
a = []
print("Enter the length of both arrays: ")
len1 = int(input())
len2 = int(input())
print("Enter the first array: ")
for i in range(len1):
temp = int(input())
a.append(temp)
print("Enter the second array: ")
for i in range(... | true |
f868c9a38fb78f4546739d63ba1824c8e3012e31 | luceva/GUIProjects | /gameRandomizer.py | 1,448 | 4.1875 | 4 | '''
Ante Lucev
Feb, 5, 2020
At the beginning of many board games a random person must be chosen to go first.
This program should allow the user to enter a list of names in a box, separated by newlines, press a ‘Pick Player’ button,
and a random name is displayed. Every time the button is clicked a different name is c... | true |
76589de696c885a6c043bdef0367d73aca8ddcf3 | Hari-krishna-tech/Leetcode-questions-and-Answer-in-python | /a8-leetcode_question.py | 911 | 4.25 | 4 | """
Longest Substring Without Repeating Characters
------------------------------
Given a string, find the length of the longest substring without
repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the ans... | true |
7705fdd739657eb84fd2fe14ee12e7d41215b418 | lollek/scripts-and-stuff | /language-testing/guess_number/guess_number.py | 723 | 4.15625 | 4 | #! /usr/bin/env python3
from random import randint
print("Guess-a-number game!",
"I am thinking of a number between 1 and 100",
"What's your guess?",
sep="\n")
target = randint(1, 100)
number = 0
current = 0
while 1:
number += 1
current = int(input("Guess %d: " % number))
if current ... | true |
b2534c0dd1e27e896cf5e4d92d44a9010e3a18b2 | Arshdeep-kapoor/Python | /chapter08-ques06.py | 261 | 4.1875 | 4 | input=input("enter a string to count number of letters")
def countLetters(s):
c=0
for i in range(0,len(input)):
if input[i].isalpha():
c+=1
return c
print(countLetters(input), "is total number of letters in the",input) | true |
70da0dc8276415c05cd0093bc639e5f39e1c0a86 | andiazfar/laptop_price_ML | /laptop_price_ML.py | 1,938 | 4.25 | 4 | # ML Test on Prices of Laptops using scikit-learn
import pandas as pd
from sklearn.tree import DecisionTreeRegressor
print("Initiliazing path to read data...")
laptop_data_path = "laptops.csv"
print("Reading csv files using pandas. Encoding used: \"ISO-8859-1\"")
print("Encoding is used so that we are able to read th... | true |
70b0dbebbb01b9a1e9bd9af0555a4ef13124b081 | AbCreativeAmid/Point_of_sale | /__init__.py | 1,277 | 4.1875 | 4 | from product_operations import *
"""this is the main file of poject it takes show the menu to the user and handle the user request"""
def request_for_input():
"""show menu to the user and ask user for input and validate the input"""
#select menu option:// this function returns the option user select
print(... | true |
4970f84fc5abc7a802c95e74efb5d4775cec1021 | djaustin/python-learning | /3-lists/names.py | 2,235 | 4.8125 | 5 | names = ['adam', 'brandon', 'carl', 2]
# Accessing elements notice the method of accessing the final element of the list
print(names[0])
print(names[1])
print(names[-1])
# Iterate over all list elements using for-in syntax
for name in names:
print("Hello " + str(name).title() + "!")
motorcycles = ['honda', 'yam... | true |
bd2a9eea2977253a122e26d9b1a82795ae39d68b | syedbilal07/python | /Basic Tutorial/Chapter 12 - Functions/script10.py | 494 | 4.15625 | 4 | # The return Statement
# The statement return [expression] exits a function, optionally passing back an
# expression to the caller. A return statement with no arguments is the same as
# return None.
# Function definition is here
def sum(arg1, arg2):
"This is a function"
# Add both the parameters and return t... | true |
ff7180f5110b873ceb2e822f20208b38b0eaabfe | YahyaNaq/INTENSIVE-PROGRAMMING-UNIT | /LongestWord_ret.py | 300 | 4.4375 | 4 | # Python Program to Read a List of Words and Return the Length of the Longest One
words=["abcde","b","c","ab","abc"]
len_Lword=len(words[0])
for i in range(1,len(words)):
len_word=len(words[i])
if len_word>len_Lword:
len_Lword=len_word
print("Length of longest word is: ",len_Lword)
| true |
ae484c59c8bb8fe7f1f86660eee68daaf9096b21 | YahyaNaq/INTENSIVE-PROGRAMMING-UNIT | /num_check.py | 271 | 4.5 | 4 | #Python Program to Check Whether a Number is Positive or Negative
number=eval(input("Please enter a number: "))
if number>0:
print("Entered number is positive")
if number<0:
print("Entered number is negative")
if number==0:
print("Entered number is neutral")
| true |
fd20f429fef017c2c05f29a2a49b7bad3d25eead | YahyaNaq/INTENSIVE-PROGRAMMING-UNIT | /sum_series1.py | 235 | 4.25 | 4 | # Python Program to Find the Sum of the Series: 1 + 1/2 + 1/3 + ... + 1/N
plus=0
n=int(input("Please enter the last term number of the required series: "))
for i in range(1,n+1):
plus+=1/i
print("Sum of the given series is",plus)
| true |
5a0bb941bbd302919a773b9858e3d5d7c0370c78 | SCRK16/ProjectEuler | /src/1-100/18.py | 1,331 | 4.1875 | 4 | def max_row(r):
"""
Calculate the maximum for each two consecutive numbers in a row
Return the resulting list of maximums
"""
if len(r) == 1:
return r
result = []
for i in range(len(r)-1):
result.append(max(r[i], r[i+1]))
return result
with open("18.txt") as f:
conte... | true |
98506579a15b4d502b64b09304c591f6b4c9237f | sadabjr/CFC--assing-pyboot | /GCD of two numbers.py | 443 | 4.25 | 4 | # import math
# print(f"The GCD of {num1} & {num2} is :", end =" " )
# print(math.gcd(num1, num2))
#This program is for find the gcd of two numbers
num1 = int(input("Inter the first number :"))
num2 = int(input("Inter the second number :"))
if num2>num1:
mn = num1
else:
mn = num2
for i in range... | true |
c7434fcbc9f1428baceaa81148290b6297d3f8b5 | varshinireddyt/Python | /GoldManSachs/StringCompressionReplace*.py | 1,086 | 4.3125 | 4 | """
Problem Description: Given a string replace the largest repeated substring at every point with an asterisk(*). The goal is end result should be a minimal length string after compression
For example, s = "abcabcd" should become "abc*d", Reason: we know abc has repeated twice, so replace the entire second instance o... | true |
4bbd0b2ed581998b8491705ed2aa635013b33867 | varshinireddyt/Python | /Challange/MaxDistanceArray.py | 1,269 | 4.21875 | 4 | """
Leetcode 624. Maximum Distance in Arrays
Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one)
and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|.
Your task is ... | true |
baf3305de039a386b95392e77d93171c538f8964 | varshinireddyt/Python | /CCI/Trees and Graphs/ListOfDepths.py | 1,316 | 4.125 | 4 | """
List of Depths: Given a binary tree, design an algorithm which creates a linked list of all the nodes
at each depth (e.g., if you have a tree with depth D, you'll have D linked lists).
"""
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
sel... | true |
adf3abe4203c0dcc7f7411b5019f22fb64cf040b | varshinireddyt/Python | /Challange/Count Ways To Split.py | 1,886 | 4.21875 | 4 | """You are given a string s. Your task is to count the number of ways of splitting s into three non-empty parts a, b and c (s = a + b + c) in such a way that a + b, b + c and c + a are all different strings.
NOTE: + refers to string concatenation.
Example
For s = "xzxzx", the output should be countWaysToSplit(s) = 5.
C... | true |
ba54675285d8dda84cd9abefe08546759a129d57 | varshinireddyt/Python | /Challange/LargestNumber.py | 582 | 4.25 | 4 | """
Given a list of non negative integers, arrange them such that they form the largest number.
Example:
Input: [10,2]
Output: "210"
Input: [3,30,34,5,9]
Output: "9534330"
"""
from functools import cmp_to_key
def largestNumber(nums):
func = lambda a,b: 1 if a + b < b + a else -1 if b + a < a + b else 0
# s = [s... | true |
6f5eff1bbb7a88a4b483ef78e39a6657206a35f4 | wesenu/MITx600 | /BookCodes/em_6_1_1_copy.py | 324 | 4.1875 | 4 | def copy(l1, l2):
"""Assumes l1, l2 are lists
Mutates l2 to be a copy of l1"""
while len(l2) > 0: # remove all elements from l2.
l2.pop() # remove last element of l2.
for e in l1: # append l1's elements to initially empty l2
l2.append(e)
l1 = [1, 2, 3]
l2 = l1
copy(l1, l2)
print(... | true |
985059362425f8db3897ecab22b0ff818142911d | dvbnrg/lpthw | /ex5.py | 524 | 4.15625 | 4 | name = 'just dave'
age = 28
height = 67
convertedHeight = height * 2.54
weight = 157
convertedWeight = weight * 0.45
eyes = 'brown'
teeth = 'white'
hair = 'black'
print(f"Hi!, My name is: {name}")
print(f"I'm {height} inches tall")
print(f"I'm {convertedHeight} centimeters tall")
print(f"I'm {weight} pounds")
print(f"... | true |
4e8f06660a2fdc0dbaf9d76031c2154cf53a08a8 | wint-thiri-swe/cp1404practicals | /prac05/word_occurrences.py | 1,071 | 4.5 | 4 | """
Github link: https://github.com/wint-thiri-swe/cp1404practicals/blob/master/prac05/word_occurrences.py
CP1404/CP5632 Practical
Words in a dictionary
Counting word occurrences
"""
words_to_count = {} # empty dictionary
def count_occurrences(words):
# for loop to count the number of occurrence
for word i... | true |
ee52e250cb25833096c2de3ceb0d33e9fbe2d9b0 | karenTakarai/Python-Exercise | /ex11.py | 1,219 | 4.21875 | 4 | #show a string and avoid the line end with a new line
print("How old are you", end=' ')
#get the answer of the user and save it in the age variable
age = input()
#show a string and avoid the line end with a new line
print("how tall are you?", end=' ')
#get the answer of the user and save it in the height variable
heigh... | true |
fcb9bdd16b9ebde7b675cc02823774197a5b98a4 | andrewwhite5/CS-Unit-5-Sprint-2-Data-Structures | /DataStructuresI/stack.py | 1,606 | 4.21875 | 4 | # lets look at the idea of another data structure
# a Stack like a stack of plates or books
# LIFO (last in first out)
# we can push items on to the stack
# we can pop items off a stack
# and we can peek at the item at the top of the stack
# think of how you could utilise a linked list to form a stack
"""
A stack is... | true |
32514e18e5a9f3a37dc7cfac77e6c8e7e140d4c6 | chrisli12/MiniGame | /game.py | 2,492 | 4.21875 | 4 | from random import randint
# player_name = "Chris"
# player_attack = 10
# player_heal = 5
# player_health = 100
# this is a list in python, it can store different type of data
# player = ["Chris", 10, 5, 100]
game_running = True
# game begin here
# while game_running is true, its gonna repeat runing this block of c... | true |
2f12f5fe07bc9b2d9bced407f76c090e1bc1c5e3 | langleyinnewengland/Complete_Python_Course | /29 - Destructuring Syntax.py | 358 | 4.3125 | 4 | #deconstructuring is taking a tuple and making many variables from it
#here is a tuple
currencies = 0.8, 1.2
#variables for the tuple
usd, eur= c urrencies
#4 tuples
friends = [("Rolf", 25), ("Anne", 37), ("Charlie", 31), ("Bob", 22)]
#assigns name and age to items in tuple
for name, age in friends:
... | true |
8e4fcb017b96f5bfc33a708207a8300942ddbe92 | langleyinnewengland/Complete_Python_Course | /14 - Booleans.py | 1,142 | 4.25 | 4 | #booleans should be equal to true
#age = int(input("Enter your age: "))
can_learn_programming = age > 0 and age < 150
#returns true of can_learn_programming is between 0-150. False otherwise
print(f"You can learn programming: {can_learn_programming}.")
#determine if you are of working age
age = int(input("En... | true |
5bcd02b4e33ed14cff242b1c3e0223117076f6d0 | santoshgawande/PythonPractices | /ds/nooccurence.py | 333 | 4.1875 | 4 | #No. of Occurence of each word in given string.
def count(str1):
count = dict()
words = str1.split()
for word in words :
if word in count :
count[word] += 1
else :
count[word] = 1
return count
str1 = 'india is my country all indian are my brothers and sister I love my country'
print(... | true |
0c966bce80c10e50d71d85f22861e471e26a161b | santoshgawande/PythonPractices | /ds/queue_using_collections.py | 362 | 4.3125 | 4 | #Queue using Collection.dequeue
"""use Dequeue from collection it will append and pop fastly in both end. """
from collections import deque
queue = deque([2,3,4,5,6,8])
print("original queue: ",queue)
print(type(queue))
#Operations
#enqueue at last
queue.append(9)
print("after enqueue :", queue)
#dequeue at first
que... | true |
14bba4e8e68a2db4e7119dbd8fbef836b8cd57da | duiliohelf/PYTHON_learning | /DHPS_NumberGuess.py | 1,063 | 4.1875 | 4 | #This finds out what number you are thinking about in a range of 0 to 100.
#It uses a bisectin method.
sec = 100
epsilon = 0.01
num_guesses = 0
low = 0
high = sec
guess = (high + low)/2.0
c = guess
print('Please think of a number between 0 and 100!')
print('Is your secret number '+ str(guess) + '?')
... | true |
afccd923fdb938f2cd1554a1f00e15209502133f | adhowa/Lab9 | /lab9-85pt.py | 563 | 4.25 | 4 | ############################################
# #
# 85pt #
# Who has a fever? #
############################################
# Create a for loop that will search through temperatureList
# and create a new list that inc... | true |
0621b4a4a169ec30729a27274f8463fb6b77fc3a | kramer99/algorithms | /bst.py | 1,459 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A simple binary search tree. Works with simple key types numeric or string.
"""
class Node:
def __init__(self, key, value):
self.left = None
self.right = None
self.key = key
self.value = value
class BinarySearchTree:
def __i... | true |
7f3aa4e4c9e42255112a74ed5be8c80672f4451a | pinstripezebra/Sp2018-Online | /students/alex_skrn/Lesson01/comprehensions_music.py | 1,223 | 4.1875 | 4 | #!/usr/bin/env python3
"""Solutions to Lesson01 comprehensions assignment re music."""
import pandas as pd
# Instructions summary:
# 1) get artists and song names for tracks with danceability scores over 0.8
# and loudness scores below -5.0.
# 2) these tracks should be sorted in descending order by danceability
# 3) t... | true |
577c87107218e3392d172e84013df518aa3ac2ef | clwangje/cs290-hw1 | /temp_convert.py | 320 | 4.25 | 4 | # Author: Chenliang Wang
# Date: 10/3/2019
# Description: Asks the user for temperature in Celsius and then
# converts and prints out the temperature in Fahrenheit
print('Please enter a Celsius temperature.')
Cel = float(input())
print('The equivalent Fahrenheit temperature is:')
print((9 / 5) * C... | true |
d6fbd5afa53282c94accc79880ae4c24a6177205 | jmaple4/Nickleforth | /nickleforth.py | 683 | 4.5 | 4 | # This is a program that prompts for a file name, then opens that file and
# reads through the file, and print the contents of the file backwards.
# you know...so Nicklebackk lyrics look like devil verses
fileName = input("Enter file name: ")
try:
fileHandle = open(fileName)
except:
print('File cannot be op... | true |
d165ef7ed65511a627e011ed21bcbdb01190259b | BakerC1216/cti110 | /M5HW1_DistanceTraveled_Baker.py | 599 | 4.40625 | 4 | # CTI-110
# M5HW1 - Distance Traveled
# BakerC1216
# 10/22/17
# Initialize the accumulator
total = 0
# Get the miles traveled for each hour.
for hour in range(1, 4):
# Prompt the user.
print("What is the speed of the vehicle in MPH?")
speed = float(input("Speed: "))
# Input the spe... | true |
8ec48fe9796cec3b950254398e87172ca174beb4 | momopranto/CTFhub | /ctfstuff/caeserbruteforce.py | 431 | 4.125 | 4 | plainText = raw_input("What is your plaintext/ciphertext? ")
def caesar(plainText, shift):
cipherText = ""
for ch in plainText:
if ch.isalpha():
stayInAlphabet = ord(ch) + shift
if stayInAlphabet > ord('z'):
stayInAlphabet -= 26
cipherText += chr(stayInAlphabet)
else:
cipherText += ch
print "S... | true |
b76916f50fbdac4b887863b30f8d92430bf14306 | rcmccartney/TA_code | /2014S/CSCI141/wk01/triangleWheel.py | 629 | 4.3125 | 4 | #!/usr/local/bin/python3
"""
Using turtle to show how to make functions and the
value of function re-use.
It takes more to code initially, but gives us much
more flexibility to re-use our drawTriangle function
at a later time (shown by the one triangle off to the
right after our original figure is drawn).
"""
from ... | true |
7cbbe9e4344cd8d8dc62627d3c468b7cd673a2dc | cpchoi/qbb2015-homework | /day2/types.py | 1,015 | 4.125 | 4 | #!/usr/bin/env python
# String
s = "A String"
# Integer (can be unlimited!)
i = 10000
# Floating point / real number
f = 0.333
# Coerce a integer into a float, vice versa float into integer (will round)
i_as_f = float(i)
f_as_i = int(f)
# Boolean
truthy = True
falsy = False
# Dictionary (very improtant - becaus... | true |
75147fb46fe5aa27f2d710df3d8a0f30c971f718 | aratik711/grokking-the-coding-interview | /two-pointers/remove-duplicates/remove-duplicates-sorted.py | 852 | 4.1875 | 4 | """
Given an array of sorted numbers, remove all duplicates from it. You should not use any extra space; after removing the duplicates in-place return the length of the subarray that has no duplicate in it.
Example 1:
Input: [2, 3, 3, 3, 6, 9, 9]
Output: 4
Explanation: The first four elements after removing the dupli... | true |
ca0249c71dbaa7cb569d7fa6915360dda72cd741 | aratik711/grokking-the-coding-interview | /sliding-window/no-repeat-substring/no-repeat-substring-sliding.py | 874 | 4.4375 | 4 | """
Given a string, find the length of the longest substring, which has no repeating characters.
Example 1:
Input: String="aabccbb"
Output: 3
Explanation: The longest substring without any repeating characters is "abc".
Example 2:
Input: String="abbbb"
Output: 2
Explanation: The longest substring without any repeat... | true |
cb086d04229636bda9be570f553cfc3b55c97eff | aratik711/grokking-the-coding-interview | /sliding-window/permutation-string/permutation-string-sliding.py | 2,148 | 4.40625 | 4 | """
Given a string and a pattern, find out if the string contains any permutation of the pattern.
Permutation is defined as the re-arranging of the characters of the string. For example, “abc” has the following six permutations:
abc
acb
bac
bca
cab
cba
If a string has ‘n’ distinct characters, it will have n! permutat... | true |
1132fb08049e3b5368944d291a7945cac7794b99 | prefect12/github | /LeetCode/62. Unique Paths.py | 2,257 | 4.375 | 4 | '''
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
A... | true |
1346f067b6eb13331bf89f5f428617d094108129 | tysonchamp/loan-calculator | /calculator.py | 1,693 | 4.46875 | 4 | # Loan Calculator
# Function to calculate monthly payment
def _mon_pay_(loan, interest, duration):
# Interest rate
r = ((interest / 100) / 12)
# number of months
mon = float(duration) * 12
# Calculate and return the monthly payments
if interest > 0:
mon_pay = loan * r * ((1 + r) ... | true |
91b05e647a9d2cfbc2966b294da72bb43a75ee01 | AmitavaSamaddar/python_challenge | /pybank/bank_data.py | 2,538 | 4.21875 | 4 | # Importing os and csv module
import os
import csv
# Initializing local variables
row_count = 0
total_amt = 0
total_change = 0
amount = 0
previous_amt = 0
max_change = 0
max_change_month = ""
min_change = 0
min_change_month = ""
# csv file path
csvpath = os.path.join(".."... | true |
a2e7d477eab8851475257dab854e0aafba646d8c | jish6303/Python | /CourseraCourse ProgrammingforEverybody/Code/Wk4q6.py | 837 | 4.3125 | 4 | #Write a program to prompt the user for hours and rate per hour using raw_input
#to compute gross pay. Award time-and-a-half for the hourly rate for all hours
#worked above 40 hours. Put the logic to do the computation of time-and-a-half
#in a function called computepay() and use the function to do the computation.
#Th... | true |
6db7394c57a52bf712abbf3758f5ab8b8f2c7712 | gakshay198/python101 | /ex15.py | 530 | 4.4375 | 4 | from sys import argv
script, file = argv # Taking filename from command line.
# Opening a file.
txt = open(file)
print(f"Here's your file {file}")
# read() is used to read the opened file.
# So we call read() function on txt to read the file.
print(txt.read()) # Reading the file and printing it.
txt.close() # Cl... | true |
56bebb2e38ac49f34effbfaabc6dd696e4a0c577 | geekycaro/python-101 | /Day1-Python/Input.py | 973 | 4.375 | 4 | # Create a variable called user_name that captures the user's first name.
user_name = input("What's your name ")
# Create a variable called neighbor_name that captures the name of the user's neighbor.
neighbor_name = input("What's his name? ")
# Create variables to capture the number of months the user has been codin... | true |
a83ff8ebb975af99707f0d0f196a942852d09fab | alinefutamata/Python_Beginners | /Name_Length.py | 231 | 4.28125 | 4 | full_name = input("What's your full name? ")
if len(full_name) <3:
print("Name mus be at least 3 characteres")
elif len(full_name) > 50:
print("Name can be a maximum of 50 characteres")
else:
print("Name looks good!") | true |
7bb22f454649d1c8da9b9eccc0ef44675315fbae | KevinChuang2/Foobar-With-Google | /Q2/Q2.5.py | 1,974 | 4.125 | 4 | #given a list of digits, find the largest number you can make out of
#the digits that is divisible by 3.
#for example: {3,1,4,1} would return 4311 because it is divisible by 3
def answer(l):
list_finished = []
list1 = []
list2 = []
for num in l:
#if the number is divisible by 3, it is always inc... | true |
8871d0a5dc506243c9bdf3ce7f6d04751154f281 | chl218/leetcode | /python/leetcoding-challenge/02-feb/10_copy_list_with_random_pointer.py | 2,557 | 4.25 | 4 | """
A linked list of length n is given such that each node contains an additional random pointer, which could point to any
node in the list, or null.
Construct a deep copy of the list. The deep copy should consist of exactly n brand new nodes, where each new node has
its value set to the value of its corresponding ori... | true |
7bb97587a87350568637f8ba10ae2618cc1d5415 | chl218/leetcode | /python/hash-maps/049_group_anagrams.py | 917 | 4.21875 | 4 | """
Given an array of strings strs, group the anagrams together. You can return the
answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different
word or phrase, typically using all the original letters exactly once.
Example 1:
Input: strs = ["eat","tea","tan","ate","nat","bat... | true |
b7e5128724b4a3761ac54cd3811c50deb7835e09 | chl218/leetcode | /python/leetcoding-challenge/04-apr/brick_wall.py | 2,889 | 4.5 | 4 | from collections import Counter
from itertools import accumulate
"""
There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same
height but different width. You want to draw a vertical line from the top to the bottom and cross the least bricks.
The brick wal... | true |
4bf06c7e422673abda64883e9d8a24aded68d900 | chl218/leetcode | /python/arrays-and-strings/remove_element.py | 1,952 | 4.125 | 4 | """
Given an integer array nums and an integer val, remove all occurrences of val
in nums in-place. The relative order of the elements may be changed.
Since it is impossible to change the length of the array in some languages, you
must instead have the result be placed in the first part of the array nums.
More formall... | true |
4aa4c6c252f53f41517afa75f20749b7988dcb3d | wpkeen/SSW540 | /p3-wkeen.py | 942 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 9 16:32:36 2020
@author: keenw
William Patrick Keen
17th of February, 2020
Stevens Institute of Technology
SSW 540 - Python Assignment #3
This script will take three inputs from the user, pass them to a user defined function and return the max of the three inputs.
Par... | true |
96b7d3c1943203be5ea71409490844f1260ca705 | palandesupriya/python | /basic/fucntions/var_Arg_add.py | 485 | 4.125 | 4 | '''
WAP to accept n numbers from user and display their addition.
Note: use variable number of arguments
'''
def add(*iNum):
iSum = 0
for iTemp in iNum:
iSum += iTemp
return iSum
def main():
print("Addition of two numbers:{}".format(add(2,3)))
print("Addition of three numbers:{}".format(add(2,5,... | true |
3c093a08019d68316dc52febb42dabe79d88150b | palandesupriya/python | /regular expression/countoccurence_regexp.py | 608 | 4.15625 | 4 | '''
WAP to accept pattern and string from user and count occurences of pattern in string
using search method
'''
import re
def countalloccurence(pattern, st):
lst = []
x = re.search(pattern, st)
iStart = 0
iCnt = 0
while x != None:
if pattern == st[x.start() + iStart: x.end() + iStart]:
iCnt += 1
iStart += ... | true |
2432af62b249bff14601613c5c46ed8d6affe74b | akshays-repo/learn.py | /files.py/basicANDtask/akshays_task1.py | 1,969 | 4.15625 | 4 |
#1 : Write a python program to print “Hello World!”
print("Hello World")
#2 : Write a python program to add 3 numbers with and without using user input.
print("with out int \n a = 1 \n b=2 \n c=3 ")
a,b,c = 1,2,3
print("sum of a + b + c = ",(a+b+c))
x, y, z = input("Enter a three value to add use spacebar: ").split()... | true |
5384f8764893a53f3723a3e368cabda950f71869 | khygu0919/codefight | /Intro/sudoku.py | 901 | 4.21875 | 4 | '''
Sudoku is a number-placement puzzle.
The objective is to fill a 9x9 grid with digits
so that each column, each row, and each of the nine 3x3 sub-grids that compose the grid contains all of the digits from 1 to 9.
This algorithm should check if the given grid of numbers represents a correct solution to Sudoku.
'''... | true |
39a90b263de9eb6b5636e3e311d18a18b5834708 | julionav/algorithms | /sorting.py | 1,941 | 4.1875 | 4 | def insertion_sort(array):
for slot in range(1, len(array)):
element = array[slot]
for sorted_slot in range(slot - 1, -1, -1):
sorted_element = array[sorted_slot]
if element < sorted_element:
array[sorted_slot] = element
array[sorted_slot + 1] ... | true |
f216d153b74b9269b5fe3a376c22f7794278b192 | omitogunjesufemi/gits | /PythonBootcamp/day4/Assignment Four/Question_8.py | 2,225 | 4.25 | 4 | import math
another_calculation = ("y" or "Y")
while (another_calculation == "y") or (another_calculation == "Y"):
import math
first_number = float(input("Enter a number: "))
print(f"""
Supported Operations
+ - Addition
- - Subtraction
* - Multiplication
/ - Division
mod - M... | true |
98ef1a203fa563107159f4be8fc74903edff0cde | omitogunjesufemi/gits | /PythonBootcamp/day2/Assignment Two/Question5.py | 202 | 4.28125 | 4 | # Calculating Interest
balance = int(input("Enter balance: "))
interest_rate = float(input("Enter interest rate: "))
interest = balance * (interest_rate / 1200)
print("The interest is " + str(interest)) | true |
dd30e2eb36ef307c4f6bc9910235d16c02581eb4 | Kyotowired/Test | /Collatz.py | 853 | 4.46875 | 4 | #!/usr/bin/python
###
"The purpose of this script is to verify the Collatz conjecture by inputting a single natural number (n), then, if even, enter the number into the formula n/2. If odd 3n+1."
###
n = raw_input("Enter a natural number to begin.>>> ")
start = n
n = int(n)
print ""
print ""
##This definition v... | true |
34d910882bac4e900eb8069e6f86a826faeae836 | AveyBD/HelloPy | /7.formated string.py | 341 | 4.28125 | 4 | first_name = input('What is your first name')
last_name = input("What is your last name")
#Lets Add two Name
con = first_name + last_name
print(con)
#formated String
formated = f'{first_name} [{last_name}] is a computer programmer]'
print(formated)
#We Can also directly print.
print(f'{first_name} [{last_name}] is a c... | true |
1bf62ec36bc567bac74f580d98ff644ecc4fbd22 | AveyBD/HelloPy | /9.arithmetic.py | 287 | 4.40625 | 4 | #We can do all the mathematics operation in python
print(10+5)
print(10-5)
print(10/5)
print(10*5)
print(7 % 3)
#We can print without the decimal value. Just we have to add another forward slash
print(7 // 2)
#Power of a int
print(10 ** 7 )
#augmented variable
x = 5
x += 3
print(x) | true |
ff0ee816edb67660fd8063add3ef4388ac138b30 | mischelay2001/WTCSC121 | /CSC121Lab01_Lab08_Misc/CSC121Lab5Problem4_RandomIntergerSearch.py | 1,575 | 4.34375 | 4 | __author__ = 'Michele Johnson'
# Program Requirements
# Write a Python program to do the following:
# (a) Ask the user to enter 6 integers. Store them in a list. Display the list.
# (b) Select elements that are larger than 20.
# Copy these elements to another list. Display that list.
# Introduce program
... | true |
5c38f9c088f9e0a651f2d91276b6a1ee09f5f338 | mischelay2001/WTCSC121 | /CSC121Lab01_Lab08_Misc/CSC121Lab7Problem1_BMIAndBPCalculator.py | 2,043 | 4.65625 | 5 | __author__ = 'Michele Johnson'
# Program Requirements
# A health insurance company wants a program to promote health and fitness.
# This program can do two things: calculate BMI (Body Mass Index) and determine
# whether a person has high blood pressure.
# To calculate BMI, the user must enter his height (in inch... | true |
e78131f7e768fd2af6bdfb17d89dee17486ebead | mischelay2001/WTCSC121 | /CSC121Lab01_Lab08_Misc/CSC121Lab3Problem2_BTUExtraSunlight.py | 2,929 | 4.5625 | 5 | __author__ = 'Michele Johnson'
# Program requirements:
# The program asks the user to enter the room’s length, width and height,
# and uses the following formula to calculate the number of btu needed:
# btu needed = room volume * 3.5
# Now we want to add one more consideration.
# If the room gets a lot of sunligh... | true |
ecd015be24e95166d0bc9b5f1cec8207e5d175f4 | mischelay2001/WTCSC121 | /CSC121Lab01_Lab08_Misc/CSC121Lab6Problem3_CopyLists.py | 1,026 | 4.1875 | 4 | __author__ = 'Michele Johnson'
# Program Requirements
# Write a Python program to do the following:
# (a) Create a list named list1 to store this sequence of numbers: 4, 7, 5, 8, 1, 2, 6, 3.
# (b) Create a list named list2. Copy all elements of list1 to list2.
# Display list2.
# (c) Create a list named list3. ... | true |
e4fb9e7d9e0d52234ed6cb7193d8915087b9d890 | mischelay2001/WTCSC121 | /CSC121Lab13_OOP/CSC121Lab13Problem3_OOP_DriveNewCar/car.py | 2,163 | 4.125 | 4 | __author__ = 'Michele Johnson'
""" Write a new version of the DriveCar project you wrote in Problem 1.
Create a new Python project DriveCarNew and copy the files from the old project.
Make the following changes to class Car:
(a) Change all instance variables to private
(b) Write getter method for speed.
(... | true |
68fd4a164ae5beb5bb00d1ff1eaa2ada28cd0d67 | Clucas0311/hangman.py | /already_guessed.py | 778 | 4.21875 | 4 | already_guessed = "ijklm"
while True: # Loop will keep asking the player for a letter until
# they enter a letter that hasn't already been guessed
guess = input("Guess a letter: ")
guess = guess.lower()
if len(guess) != 1: # if guess is not a single letter
print("Please ent... | true |
245b74a5b576dff83efaeab903c4767bb04b6acf | MayuriTambe/FellowshipPrograms | /LeapYear.py | 495 | 4.3125 | 4 | #Print the year Leap year or not
year=int(input("Enter the year")) #Take input from user
def LeapYear():#Defining function LeapYear
if ((year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0))): #if the year is divisible 400 OR year is divisible by 4
# but not divisible by 100
print("This is ... | true |
633190ded36f318c11a4b2b6b4c38c61b0aa4445 | DarrenMannuela/I2P-Exercise-3 | /Exercise 3 I2P_no.1.py | 465 | 4.25 | 4 |
def convert_to_days():
hours = int(input("Enter number of hours:"))
minutes = int(input("Enter number of minutes:"))
seconds = int(input("Enter number of seconds:"))
hours_to_days = hours/24
minutes_to_days = minutes/1440
seconds_to_days = seconds/86400
days = round(hours_to_day... | true |
8820963655a764f8ec11af96cc107f2505aae5db | sumedhbadnore/Python-Projects | /Tkinter projects/Basics/entry.py | 656 | 4.34375 | 4 | from tkinter import *
root = Tk()
# to create input box
e = Entry(root, width=30)
e.pack()
e.insert(0,"Enter Your Name:")
def Button1():
hello = "Hello! " + e.get()
label1 = Label(root, text=hello)
label1.pack()
# to create and display button
# remember not use () after calling a function h... | true |
6c604376ab08be9ded3a08eea2ffa163f38687b3 | sumedhbadnore/Python-Projects | /Tkinter projects/Basics/grid.py | 275 | 4.1875 | 4 | from tkinter import *
root = Tk()
# Creating label
myLabel = Label(root, text="Hello World!")
myLabel2 = Label(root, text="My name is Sumedh, nice to meet you!")
# Shoving it onto screen
myLabel.grid(row=0, column=0)
myLabel2.grid(row=1, column=0)
root.mainloop()
| true |
84f42f565ac6a83f3cb8fa8dac689acd8f5bcacf | lulu-mae/Sign-Language-App | /main.py | 631 | 4.40625 | 4 | import sqlite3
with sqlite3.connect('countryinfo.db') as db:
pass
CREATE TABLE countryInfo(
CountryName text,
Vaccine text,
WaterStatus text,
Allergies text,
Weather text,
LGBTQsafety text,
WomenSafety text,
Primary Key(CountryName));
def display_info (place):
choice = input("Wh... | true |
7da4973e9c7579c8454f6adf4058566b3b4e2c4b | mike03052000/python | /Training/2014-0110-training/Code_python/Database/Solutions/db_read_simple.py | 1,265 | 4.6875 | 5 | #!/usr/bin/env python
"""
Sample of simple database query using the Python DB API.
Show how to use the cursor object (1) to fetch rows and
(2) to use the cursor object as an iterable.
"""
import sys
import sqlite3
def test():
args = sys.argv[1:]
if len(args) != 1:
sys.stderr.write('\nusage: python ... | true |
999e23eab446d2d67def4ee4eb95f733849952ae | mike03052000/python | /Training/2014-0110-training/Code_python/TextAndFiles/Solutions/words3.py | 1,742 | 4.3125 | 4 | #!/usr/bin/env python
"""
Split each line in a file into words. Count the words. Use re.split().
Usage:
python words.py [options] infile
Options:
-h, --help Display this help message.
Example:
python words.py myfile.txt
"""
#
# Imports:
import sys
import getopt
import re
def count_words(infilen... | true |
c2860edf6b587e0637914bfb9f1ddded78c87deb | mike03052000/python | /Training/2014-0110-training/Exercises_python/Solutions/elementtree_walk.py | 2,336 | 4.3125 | 4 | #!/usr/bin/env python
"""
Synopsis:
Process an XML document with elementtree.
Show the document tree.
Modify the document tree and then show it again.
Usage:
python elementtree_walk.py [options] infilename
Options:
-h, --help Display this help message.
Example:
python elementtree_walk.py m... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.