blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
813edeb4b243842e4bfbb4a1d0a20e705300fea8 | dundunmao/lint_leet | /mycode/lintcode/Array/two sum/625 partition-array-ii.py | 1,222 | 4.125 | 4 | # -*- encoding: utf-8 -*-
# Partition an unsorted integer array into three parts:
# The front part < low
# The middle part >= low & <= high
# The tail part > high
# Return any of the possible solutions.
#
# 注意事项:low <= high in all testcases.
# 样例
# Given [4,3,4,1,2,3,1,2], and low = 2 and high = 3.
#
# Change to [1,1,... | true |
458a1517122fe9f0b347d3064bdf5284f5244742 | dundunmao/lint_leet | /mycode/leetcode2017/Hash/350. Intersection of Two Arrays II.py | 1,850 | 4.125 | 4 | # Given two arrays, write a function to compute their intersection.
#
# Example:
# Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].
#
# Note:
# Each element in the result should appear as many times as it shows in both arrays.
# The result can be in any order.
# Follow up:
# What if the given array is already... | true |
5810283138b8e106e5ed704d29342c33b7ff4fa8 | dundunmao/lint_leet | /mycode/leetcode2017/String/451. Sort Characters By Frequency.py | 918 | 4.375 | 4 | # -*- encoding: utf-8 -*-
# Given a string, sort it in decreasing order based on the frequency of characters.
#
# Example 1:
#
# Input:
# "tree"
#
# Output:
# "eert"
#
# Explanation:
# 'e' appears twice while 'r' and 't' both appear once.
# So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid an... | true |
3e43d498d3ed43cec67f25ed8d59623f8cf13f59 | Aaqib925/Assignment | /assignment 5.py | 2,883 | 4.25 | 4 | # Question 1
# Write a Python function to calculate the factorial of a number (a non-negative
# integer). The function accepts the number as an argument.
def fact(num):
""" functions which finds a factorial value of the number """
factorial = 1
if num < 0:
return "The factorial of the negative num... | true |
b9afcbbeb6631087b2352ca2423406ff4fb850c9 | maxitaxi03/Python_stuff | /conditions.py | 268 | 4.28125 | 4 | #num= input("Enter number: ")this generates an error because the input function assumes it's a string type
num = int(input("Enter number: "))
if num > 0:
print(f"{num} is positive.")
elif num < 0:
print(f"{num} is negative.")
else:
print(f"{num} is zero.") | true |
6931ae5dafc4d5d0d8b29b879e53098c28edfde7 | acepele/PRG105 | /retirement_savings_calculator.py | 1,049 | 4.15625 | 4 | age = int(input("How old are you currently?"))
retire_age = int(input("At what age do you want to retire?"))
income = float(input("What is your yearly income?"))
percentage = float(input("What percent of your income do you save?"))
savings = float(input("How much money do you currently have in your savings?"))
p... | true |
c107ab318900e779ad761d01eae972b8e4ffccbf | OdessaRadio/Complete_Python_Developer_in_2020-Zero-to-Mastery | /Python_Basics_3/built_in_functions_methids.py | 335 | 4.125 | 4 | print(len('0123456789')) # len -> lenght ofthe string
greet = '0123456789'
print(greet[1:])
print(greet[0:len(greet)])
quote = "to be or not to be"
print(quote.upper())
print(quote.capitalize())
print(quote.find('be'))
print(quote.replace('be','me'))
print(quote) # strings are immutable. So it will print "to be ... | true |
dd3c00d69811963353e85a59072c510846c7a4dd | ananddasani/Python_Practice_Course | /Quick_Basic/9.practice_List_and_tuples.py | 782 | 4.4375 | 4 | # Take DOB from user as a format DD-MM-YYYY and print the name of month the user is born in
months = ["january", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"]
# taking input as a string
DOB = input("Enter your DOB in DD-MM-YYYY formate :: ")
... | true |
2dbf8950e0e0401f7d63d8050560c09e5f16e210 | jboe10/python_practice | /Sorting_Algorithms/Insertion_Sorts/insert.py | 280 | 4.15625 | 4 | def insertion_sort(array):
for i in range(1,len(array)):
key = array[i]
follow = i -1
while follow >= 0 and key < array[follow]:
array[follow+1] = array[follow]
follow -= 1
array[follow+1] = key
array= [1,3,411,23,142,33,21,9]
insertion_sort(array)
print(array) | true |
71b0a1c14c7ce3d51fc7fbb8efcac58303efa61f | jboe10/python_practice | /Trees/Max_heap/max_heap2.py | 1,609 | 4.3125 | 4 | class node:
def __init__(self, value = None, color = "black"):
self.value = value
self.left = None
self.right = None
self.color = color
class red_black:
def __init__(self):
self.root = None
#this makes it so we dont have to worry about root/parent being empty
def insert(self, value):
if self.root... | true |
d8558d872368bce9acbce46503b5fc0f0e23d1d9 | gmcapra/Python-Data-Structures | /Array Sequences/dynamic_array_example.py | 2,089 | 4.28125 | 4 | """
--------------------------------------------------------------------------------
Dynamic Array Exercise Project
--------------------------------------------------------------------------------
Gianluca Capraro
Created: July 2019
--------------------------------------------------------------------------------
The pu... | true |
6564c454e3c628e6ac4d72af5a0d29bc5da62368 | emanmacario/dsa | /ctci-solutions/ch-08-recursion-and-dynamic-programming/01-triple-step.py | 2,071 | 4.53125 | 5 | # Triple Step: A child is running up a staircase with n steps and can hop either
# 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many
# possible ways the child can run up the stairs.
# Hints: #152, #178, #217, #237, #262, #359
# -- Solution
# Here is a general solution for climbing n steps ... | true |
0fcd282fe6957aeff00209bc387b709feb439706 | emanmacario/dsa | /ctci-solutions/ch-01-arrays-and-strings/01-is-unique.py | 449 | 4.15625 | 4 | # Implement an algorithm to determine if a string has all unique characters. What if you
# cannot use additional data structures?
# Hints: #44, #117, #732
def is_unique(string):
seen = set()
for char in string:
if char in seen:
return False
seen.add(char)
return True
def mai... | true |
8c40a3d75548b9ad23854b29281296897b64d6ea | emanmacario/dsa | /ctci-solutions/ch-01-arrays-and-strings/09-string-rotations.py | 912 | 4.59375 | 5 | # String Rotation: Assume you have a method isSubstring which checks if one word is a substring
# of another. Given two strings, sl and s2, write code to check if s2 is a rotation of s1 using only one
# call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").
# Hints: #34, #88, #104
def is_substring(s... | true |
c371018c53ce4f396ac65f2ed3738a0c4088866e | emanmacario/dsa | /epi-solutions/ch-11-searching/06-search-2d-sorted-array.py | 1,829 | 4.3125 | 4 | # Call a 2D array sorted if its rows and its columns are nondecreasing.
# For example:
# -1 2 4 4 6
# 1 5 5 9 21
# 3 6 6 9 22
# 3 6 8 10 24
# 6 8 9 12 25
# 8 10 12 13 40
# Design an algorithm that takes a 2D sorted array and a number and checks
# whether that number appears in the arra... | true |
3f0b3b2ee8f5a58f4f1fc25114c095461bce3a37 | emanmacario/dsa | /ctci-solutions/ch-04-trees-and-graphs/03-list-of-depths.py | 1,825 | 4.28125 | 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).
# Hints: #107, #123, #135
# -- Auxiliary data structures
# Definition for singly-linked list
class ListNode:
def __init_... | true |
72d54cbbf3fac238508d8d9ef2770035577768ce | emanmacario/dsa | /ctci-solutions/ch-02-linked-lists/04-partition.py | 1,831 | 4.3125 | 4 | # Partition: Write code to partition a linked list around a value x, such that all nodes less than x come
# before all nodes greater than or equal to x. If x is contained within the list, the values of x only need
# to be after the elements less than x (see below). The partition element x can appear anywhere in the
# "... | true |
6c53d466477ed42be9fd961c9d748cc004e08fd2 | pierre-ecarlat/algorithms_experiments | /leetcode_mess/q3.py | 1,130 | 4.28125 | 4 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
------------------------------
Find All Duplicates in an Array
------------------------------
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some
elements appear twice and others appear once.
Find all the elements that appear t... | true |
0e22de1ec890cf31a9ee06053a8e9e7e06e235d5 | projectPythonator/portfolio | /ProjectEuler/Python/p4.py | 1,139 | 4.125 | 4 |
def is_palindrome(num):
return (str(num) == str(num)[::-1])
def sol2(limit):
largest = 0
a = 999
lim = 100
while lim <= a:
b = 999
while a <= b:
ab = a*b
if ab < largest:
break
if is_palindrome(ab):
largest = ab
... | true |
78e7ebb88d26be732ccf0d5cdf68d1ace21449fa | JJWren/Python_UniversityStudyGroup_ConsoleApps | /pythonGraphicPrograms/drawObjectsTest.py | 941 | 4.125 | 4 | import graphics
from graphics import *
def main():
print("\n***** Graphics Test *****\n")
print("This program generates a window\nwith some shapes drawn in.\n")
# Open a graphics window
win = graphics.GraphWin('Shapes')
# Draw a red circle centered at point (100, 100) with radius 30
center = ... | true |
4fa3c4eef05f5c4bd508b40bcde7c34aab5c7f0f | gurhanPro/Interview_questions_python | /array_manipulation.py | 1,669 | 4.3125 | 4 | """ Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in your array.
For example, the length of your array of zeros
. Your list of queries... | true |
0bb193c09a34cbee9919ab598d8bcd91842bccad | Simiopolis/exercises | /reddit_dailyprogrammer/challenge_1_difficult.py | 862 | 4.125 | 4 | # Objective:
# we all know the classic "guessing game" with higher or lower prompts.
# lets do a role reversal; you create a program that will guess numbers
# between 1-100, and respond appropriately based on whether users say that
# the number is too high or too low. Try to make a program that can guess
# your num... | true |
0e6734de8f1b69456245db2093565f394b336064 | ShivaGanapathy/PascalsTriangleGenerator | /PascalsTriangle.py | 2,247 | 4.375 | 4 | '''
create a program that will result in an output of n rows of Pascal's Triangle
ex. if n is 3 the out put should look like this:
1
1 1
1 2 1
'''
def get_input():
"""
This Function handles the user input process, ensuring that the user enters an positive integer.
The Function has no arguments and returns an in... | true |
ab04240722c919c0951f3619a7743ec7e51ad9b8 | Abulero/Sorting-Algorithms | /SelectionSort.py | 422 | 4.1875 | 4 | def selection_sort(numbers):
for i in range(len(numbers)):
for index in range(len(numbers) - i):
if numbers[index + i] < numbers[i]:
swap(numbers, index + i, i)
def swap(numbers, a, b):
numbers[a], numbers[b] = numbers[b], numbers[a]
if __name__ == '__main__':
numbers ... | true |
63408a0a5e0bb8a9532957f0bacea05370a46753 | anuragpatil94/Python-Practice | /cracking-the-coding-interview/StacksAndQueues/3.3_StackOfPlates.py | 2,654 | 4.15625 | 4 | """
Stack of Plates:
Imagine a (literal) stack of plates. If the stack gets too high, it might topple.
Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold.
Implement a data structure SetOfStacks that mimics this.
SetOfStacks should be comp... | true |
e08f6a2482e6bf944979357d204e771a706a4e26 | anuragpatil94/Python-Practice | /cracking-the-coding-interview/ArraysAndStrings/CTCI_01_IsUnique.py | 738 | 4.1875 | 4 | """
Is Unique: Implement an algorithm to determine if a string has all unique characters.
What if you cannot use additional data structures?
My Solution With additional data structure
- using set to check if a duplicate character exists
"""
class Solution:
def isUnique(string):
"""
... | true |
8d5c88069762040ae079b394dd8edb7be0b4d51e | anuragpatil94/Python-Practice | /cracking-the-coding-interview/LinkedList/2.5_SumLists.py | 2,976 | 4.3125 | 4 | import sys
sys.path.insert(0, "../../")
from conceptual.linked_list import LinkedList
"""
2.5 Sum Lists: You have two numbers represented by a linked list, where each node
contains a single digit. The digits are stored in reverse order, such that
the 1's digit is at the head of the list. Write... | true |
9db68315acd436a621caa8bf8ccf8f2dd1ddfaeb | anuragpatil94/Python-Practice | /cracking-the-coding-interview/LinkedList/2.6_Palindrome.py | 1,656 | 4.375 | 4 | import sys
sys.path.insert(0, "../../")
from conceptual.linked_list import LinkedList
"""
Important
2.6: Palindrome
Implement a function to check if the linked list is the palindrome
Solution:
- Get the Middle Element in Recursion
- using the (length - 2) in the recussion which will ... | true |
f31269622691bb450c41d584b36b206670658d56 | anuragpatil94/Python-Practice | /OnlineAssessmentQuestions/N16_FindPairWithGivenSum.py | 1,166 | 4.15625 | 4 | """
Given a list of positive integers nums and an int target, return indices of the two numbers such that they add up to a target - 30.
Conditions:
You will pick exactly 2 numbers.
You cannot pick the same element twice.
If you have muliple pairs, select the pair with the largest number.
Example:
Given nums = [... | true |
4123ec6a578d0e18c1a1a983334dd43c89dab311 | anuragpatil94/Python-Practice | /interview-questions/find_nth_smallest_in_the_set.py | 2,569 | 4.125 | 4 | """
Find the Nth Order Statistic for a given array of numbers
Steps :
Find the Smallest Number -
this is straightforward O(n),
Find 2nd Smallest Number -
Brute Force - Find Minimum - swap with 1st element - then again loop the remainder to find 2nd shortest - O(n**2)
Best Possible - Have two index - 1st... | true |
83f85fdf1c3bc565f34406e38bb459000e27d864 | Luke-Callaghan23/Synonyms | /find_synonyms/scripts/clean_word.py | 554 | 4.15625 | 4 | from functools import reduce
def clean_word (word):
word = word.strip().lower() # step 1: remove excess spaces and turn to lower case
word = reduce ( # step 2: split the word on all spaces and only keep the longest one
lambda acc, word: ( # (sometimes the api will return words lik... | true |
2521f29cf2a56ef7ceab46a579f918ad465a50ec | xieqing181/Pythonwork-Chapter9 | /Admin.py | 1,818 | 4.28125 | 4 | class User():
'''save the user's first name, last name, and middle name,
also some other info, like height, weight, and username.'''
def __init__(self, first, last, height,
weight, username, middle=''):
self.first = first
self.last = last
self.height = height
self.weight = weight
self.username = username... | true |
d4c47fd2f50219fab61b8e311875e3988de33575 | toralero/PyRes | /5/errorhandling.py | 337 | 4.25 | 4 | while True:
try:
age = int(input("What is your age?: "))
except ValueError:
print("Age has to be an integer.")
print("Please answer the question again.")
print()
continue
else:
break
if age < 18:
print("You are still not an adult.")
else:
print("You a... | true |
80599480442c344e02401dc5991c1cb2862e7460 | Despaquitoe/Guisa_story | /2.py | 302 | 4.25 | 4 | # Write a program that will ask the user what their age is and then
# determine if they are old enough to vote or not and respond appropriately
ask=input("How old are you?")
elif ask >= int(18):
print=("What a little youngster")
if (18-100):
print=("Would you like to vote?")
int()
| true |
6936bac435aad77d243c975a2295281ab90e65f4 | rosemary-c/codingDojo | /python/printListType.py | 1,169 | 4.28125 | 4 | '''
Assignment: Type List
Write a program that takes a list and prints a message for each element in the list, based on that element's data type.
Your program input will always be a list. For each item in the list, test its data type.
If the item is a string, concatenate it onto a new string.
If it is a number, ad... | true |
a934712e523a820f64e266beb891d660feeb367b | sunnychemist/pylearn | /python_tutor/07_lists/rank.py | 1,119 | 4.34375 | 4 | def rank_position(list_u, x):
"""
Source https://pythontutor.ru/lessons/lists/problems/lineup/
Condition
Petya moved to another school. In a physical education lesson,
he needed to determine his place in the ranks. Help him do this.
The program receives a non-increasing sequence of natural... | true |
dfdca5d2079d4ef7bf0b00f2638511769a5c0cda | qiubite31/Leetcode | /Tree/leetcode-872.py | 1,507 | 4.28125 | 4 | """
872. Leaf-Similar Trees
Difficulty: Easy
Related Topic: Tree, Recursive
Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.
For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8).
Two binary trees are considered leaf... | true |
cbcc8e3955cecdbf3d5bdacb6a8b4cbae8b6ba6b | qiubite31/Leetcode | /Hash/leetcode-500.py | 1,268 | 4.125 | 4 | """
500. Keyboard Row
Difficulty: Easy
Related Topic: Hash Table
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.
American keyboard
Example 1:
Input: ["Hello", "Alaska", "Dad", "Peace"]
Output: ["Alaska", "Dad"... | true |
d4e3e9bbe62976988977347d81510912dd0b767f | aratik711/100-python3-programs | /92.py | 602 | 4.1875 | 4 | """
Manage a game player's High Score list.
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the thr... | true |
76c486ecc32a8632f9d39a8fc6c375dd933ae707 | aratik711/100-python3-programs | /48.py | 316 | 4.34375 | 4 | """
Define a class named Circle which can be constructed by a radius. The Circle class has a method which can compute the area.
"""
class Circle(object):
def __init__(self, radius = 0):
self.radius = radius
def area(self):
return self.radius**2*3.14
circle = Circle(5)
print(circle.area()) | true |
24477e86ca72c6bbd3285942d61766633f0fc845 | aratik711/100-python3-programs | /94.py | 1,065 | 4.3125 | 4 | """
Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime!
When cells divide, their DNA replicates too. Sometimes during this p... | true |
87346f0af31de16e7e808a7379cbc73bdd42c5d6 | JunDang/MIT-Python | /CreditCard1.py | 994 | 4.125 | 4 | '''
Monthly interest rate= (Annual interest rate) / 12.0
Minimum monthly payment = (Minimum monthly payment rate) x (Previous balance)
Monthly unpaid balance = (Previous balance) - (Minimum monthly payment)
Updated balance each month = (Monthly unpaid balance) + (Monthly interest rate x Monthly unpaid balance)
'''
def... | true |
5c1dccfbf85eb8a5f44bee2c55affd997ccec8ba | dileepachuthan/Python-Exercise | /Exercise_9.py | 1,140 | 4.21875 | 4 | Pretend that you have just opened a new savings account that earns 4 percent interest per year. The interest that you earn is paid at the end of the year, and is added
to the balance of the savings account. Write a program that begins by reading the amount of money deposited into the account from the user. Then your pr... | true |
f6276c8a2b723d2c37dbf1a3e21592a4b4d8492a | Divyansh-03/PythoN_WorK | /Denomination.py | 521 | 4.125 | 4 | ''' A cashier has currency notes of denominations 10, 50 and
100. If the amount to be withdrawn is input through the
keyboard in hundreds, find the total number of currency notes
of each denomination the cashier will have to give to the
withdrawer. '''
amount = int(input(" Enter the Total Amount in Hundreds "))
notes_... | true |
3173330493eb58230febd9caeee826a2cd2dff52 | Divyansh-03/PythoN_WorK | /distance.py | 456 | 4.40625 | 4 | ''' The distance between two cities (in km.) is input through the
keyboard. Write a program to convert and print this distance
in meters, feet, inches and centimeters. '''
dist_km = float(input("Enter distance in kilometres" ))
print(" The distance in meters is " + str(dist_km*1000.0) + " The distance in feet is "+ st... | true |
f6060dbd91f4a1e6871a97fb2db1f46be5bb56a0 | Divyansh-03/PythoN_WorK | /4company.py | 935 | 4.21875 | 4 | ''' In a company, worker efficiency is determined on the basis of
the time required for a worker to complete a particular job. If
the time taken by the worker is between 2 – 3 hours, then the
worker is said to be highly efficient. If the time required by
the worker is between 3 – 4 hours, then the worker is ordered
to ... | true |
2ca40ae8cb5255db3205a56d75f9da920f2d500a | brandonnorsworthy/ProjectEuler | /python/p004.py | 619 | 4.125 | 4 | #A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
#Find the largest palindrome made from the product of two 3-digit numbers.
foundnumber = 0
for x in reversed(range(900,1000)):
for y in reversed(range(900,1000)):
number = ... | true |
7fab1cd207ab3b2afc933d6e226c5c7ab9e78f01 | Vibhushit07/Python | /Case Studies/cs7.py | 611 | 4.40625 | 4 | '''
You are given a string that was encoded by a Caesar cipher with an unknown distance value.
The text can contain any of the printable ASCII characters.
Suggest an algorithm for cracking this code.
- Input Plain Text & its Cipher Text
- Output distance value d.
'''
def findDistance(cipherText, ... | true |
fd9f2e759e086f928e09ae35c1e089bdf8104c50 | Vibhushit07/Python | /Case Studies/cs5.py | 753 | 4.375 | 4 | '''
Write the encrypted text of each of the following words using a Caesar cipher with a distance value of 3:
a. python
b. hacker
c. wow
And then decrypt it also.
Write different scripts for encryption & decryption.
'''
def encrypt(string):
enc = ""
for i in string:
if ord(i) <... | true |
3cfb8695374c6784e4d386f865f513d545814903 | David-Guri/python | /to-do-list.py | 1,254 | 4.125 | 4 | print(' ')
print('Hi, David!')
print('Welcome back to your to-do list')
thislist = ['Learn the basics of python', 'Learn the basics of vim', 'Play with PS4', 'Take a sh*t']
print('Number of items in your list: ' + str(len(thislist)))
print('Curren... | true |
a0bb7d1e40305b400b3f64447cfc2af80c3a47a1 | achang6/wallstory | /pytuts/monkey/calc_ke.py | 503 | 4.1875 | 4 | # calculate kinetic energy
# welcome message
print('This program calculates the kinetic energy of a moving object.')
# receive mass
m_string = input('Enter the object\'s mass in kilograms: ')
# convert string input to float
m = float(m_string)
# receive velocity
v_string = input('Enter the object\'s velocity in m/s:... | true |
94c2f892a841e7e85e3b4b8668fa0c3c03aab561 | JagritiG/object_oriented_python | /15_polymorphism.py | 2,845 | 4.65625 | 5 | # Example of polymorphism
# Todo: Example of inbuilt polymorphic functions:
print(len("Python")) # len() returns length of a string
print(len([1, 2, 3, 4, 5])) # len() returns length of a list
# Todo: Example of user defined polymorphic function
def add(num1, num2, *args):
return num1 + num2 + sum(num for ... | true |
4ce07b2cd30f6087d42555e915e9369574f6dde0 | trishulg/Lectures | /Lec4/SavingsProgram.py | 548 | 4.25 | 4 | # Get information from the user ? Input
balance = float(input('How much do u want to save : '))
if balance <= 0:
print('Looks like you already have enough')
balance = 0
payment = 1
else:
payment = float(input('How much will you save each period: '))
if payment <= 0:
payment = float(input('e... | true |
66e60bf7b0d5ef02153b9ba4bb0b99e405758a45 | Latas2001/python-program | /birthday reminder.py | 721 | 4.375 | 4 | dict={}
while True:
print("_______________Birthday App________________")
print("1.Show Birthday")
print("2.Add to Birthday List")
print("3.Exit")
choice = int(input("Enter the choice: "))
if choice==1:
if len(dict.keys())==0:
print("nothing to show....")
else:
... | true |
d115b3c8fd28f43e7259473a048e960b1f65423d | shreyasingh18/HSBC-2021-WFS1-DEMOS | /python-examples/nested_list_demo.py | 361 | 4.25 | 4 | items = [[1, 4, 3], [5, 8, 9, 10]]
#above list is nested list
print(len(items))
#finding the number of items of the particular index
print(len(items[0]))
#for loop to iterate the list
for x in items:
print(x)
print("--------------")
for x in items:
for y in x:
print(y)
print(items)
#deleting the items... | true |
fc3331e287fc69733621fe8b34ad67cddc70e270 | anishmarathe007/Assignments | /bookManagement.py | 1,199 | 4.1875 | 4 | data = {}
def insertIntoBook(name,author):
if name not in data.keys():
data[name] = author
print("Book Successfully Inserted!")
else:
print("Book with the same name already exists!")
def search(name):
if name in data.keys():
print(name, "Present. Author name is : ", data[name])
else:
print(... | true |
97a6b7d3bccc444a72db5cd4fa60b184aff9468a | shotokan/web_scraping_examples | /q1/d.py | 879 | 4.6875 | 5 | def _is_multiple_of_six(number):
"""
Function utility used to check if a number is multiple of six
:param number:
:return:
"""
return (number % 6) == 0
def _is_multiple_of_seven(number):
"""
Function utility used to check if a number is multiple of seven
:param number:
:return:... | true |
5dcb94625f39b6b106041a51f63baef27ce59177 | jeremytedwards/data-structures | /src/data_structures/sort_insertion.py | 1,801 | 4.125 | 4 | # coding=utf-8
import random
import timeit
def sort_insertion(origin_list):
"""Implement insertion sort."""
if len(origin_list) == 0:
return origin_list
else:
sorted_list = [origin_list.pop(0)]
while len(origin_list) > 0:
item = origin_list.pop(0)
for index,... | true |
2683e9f5a7b57b2281df5d8b05b8245cc319660a | sudiptoshahin/pythonmachinelearningbasic | /inputs.py | 1,324 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
"""
input() and raw_input() both function take a string as
an argument and displays it as promot in shell. it waits for
the user to hit enter
for raw_input(), input line is treated as string and becomes
the value returend by the function
nput treats the typed line ... | true |
75def06a03b2dd42b7af41318c36c5a53592247f | emojipeach/euler_problems_python | /0002.py | 664 | 4.28125 | 4 | print("""Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:""")
print("""1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...""")
print("""By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the su... | true |
304bd6076896e403fd2973d669f1469b255220d4 | CrystalBRana/LabProjects2 | /q_n0_ 8.py | 299 | 4.375 | 4 | ''' Write a Python program which accepts the radius of a circle from the user and compute the area.
(area of circle =PI * r^2)'''
radius = float(input("Enter the radius of circle in centimeter:"))
area_of_circle = (3.14 * (radius**2))
print(f"The area of circle is {area_of_circle} square meter") | true |
2a0b4735c4db4ba0b831028b3a8a26c242a007f9 | CrystalBRana/LabProjects2 | /q.no.10.py | 402 | 4.1875 | 4 | # Write a python program to convert seconds to day, hour, minutes and seconds.
seconds = int(input('Insert second:'))
seconds_in_day = 60*60*24
seconds_in_hour = 60*60
seconds_in_minute = 60
days = seconds // seconds_in_day
hours = (seconds - (days * seconds_in_day))// seconds_in_hour
minutes = (seconds - (days * sec... | true |
af6475761f6aef23786189e00e99f2862639583a | SRaja001/MIT_Open | /HW/Problem_set_1.py | 2,844 | 4.25 | 4 | #Problem 0
#dob = raw_input('Please Enter your dat of birth MM/DD/YY: \n**')
#user = raw_input('Please enter your last name: \n**')
#print user, dob
###Problem 1
##
##balance = float(raw_input("Please enter the balance on your credit card: "))
##interest_rate = float(raw_input("Please enter the annual interest rate a... | true |
a8e840fc577193db202ed5af696cb221e77db59a | kaidokariste/python | /01_LearnPythonHardWay/03_raw_terminal_input.py | 499 | 4.1875 | 4 | print("How old are you"),
age = input() # raw_input from python2 was renamed input in python3
print("How tall are you"),
height = input()
print("How much do you weight"),
weight = input()
print("So you're {} old, {} tall and {} heavy.".format(age,height,weight))
# you can define input text also as variable
age = inp... | true |
3a863353a9d02e208139ed825835b60db3adee0d | iEdwinTorres/backend-baby-names-assessment | /babynames.py | 2,733 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# BabyNames python coding exercise.
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
"""
Define the extract_names() function below and change main()
to call it.
For writing regex, it's nice to inc... | true |
bb3aceaea7a1f8ef838d20a859ab58b9982c580a | flovera1/CrackingTheCodeInterview | /Python/Chapter1ArraysAndStrings/stringCompression.py | 816 | 4.34375 | 4 | '''
Implement a method to perform basic string compression using the counts of repeated characters.
For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not
become smaller than the original string, your method should return the original string.
You can assume the string has only ... | true |
079970bfa071570a912ba12d321c469e46a844ab | NedyalkoKr/Learning-Python | /Lesson 9 - Modularity/function_basics.py | 986 | 4.125 | 4 | # defining a new function
# x is the input to the function
# functions can accept one, or more or none parameters
# these parameters represent the initial data the function will use
# internaly
def square(x):
# returning the output of a function
return x * x
print(square(5))
# we can choose to bind paramete... | true |
43ce9efa69e5038b870c9bd863a26e2b4d9780fb | NedyalkoKr/Learning-Python | /Lesson 6 - Strings, Collections, and Iteration/lists.py | 922 | 4.59375 | 5 | # list is a ordered collection(sequence) of objects
# lists are mutable
# lists are iterable
# creating list object using list literal form
numbers = [1,2,3,4,5,6,7,8,9]
fruits = ["apple", "orange", "pear"]
# each list item position is map to a index that allows to reference and retrive that item
print(numbers[0])
... | true |
4c38a7789b6010f9fcd1cc16758354234c4901f1 | NedyalkoKr/Learning-Python | /Lesson 7 - Scalar Types, Operators, and Control Flow/nesting_conditionals.py | 405 | 4.28125 | 4 | h = 42
if h > 50:
print("Greater than 50")
else:
# nesting is not a bad pattern, but in python is better to flat
# than nested for readability
if h < 20:
print("Less than 20")
else:
print("Between 20 and 50")
# the same logic bu using flat structure
if h > 50:
print("Greater t... | true |
4387486343afdac38e51dd0971f9ce9637a2dd0e | luiseduardogfranca/Luis-Franca | /LP1-P1/Initial Knowledge Test/array_intersection.py | 1,370 | 4.15625 | 4 | def min_value(array):
min = array[0]
for value in array:
if value < min:
min = value
return min
# function to sort in ascending order
def sort_array(array):
new_array = []
for index in range(len(array)):
min = min_value(array)
new_array.append(min)
ar... | true |
4560924bf5c9fd07101e6cd2663c6add33352fff | luiseduardogfranca/Luis-Franca | /LP1-P1/Conditionals and Repetition Structure/playing_with_arrays.py | 1,195 | 4.15625 | 4 | def inverse_order(array):
return [array[index] for index in range(len(array) - 1, -1, -1)]
def left_shift(array):
new_array = [None] * len(array)
for index in range(len(array)):
new_array[index-1] = array[index]
return new_array
# i did it this way to learn a new way
def sort_by_decreas... | true |
00752314ecbd8f9be2862896576e36e76eaa6305 | ATHULKNAIR/PythonPrograms | /PrintSum.py | 241 | 4.15625 | 4 | # Write a program that takes three numbers and prints their sum. Every number
# is given on a separate line.
a = int(input('Enter First Number'))
b = int(input('Enter Second Number'))
c = int(input('Enter Third Number'))
print(a + b + c) | true |
6acd96fe92a6241537df088dd2df8dda02e7a6ac | rachelBurford/she_codes_python | /conditionals/dictionaries/Dictionaries_exercises/q1.py | 850 | 4.125 | 4 | prices = {
"Baby Spinach": 2.78,
"Hot Chocolate": 3.70,
"Crackers": 2.10,
"Bacon": 9.00,
"Carrots": 0.56,
"Oranges": 3.08
}
quantity = {
"Baby Spinach": 1,
"Hot Chocolate": 3,
"Crackers": 2,
"Bacon": 1,
"Carrots": 4,
"Oranges": 2
}
quantity2 = {
"Baby Spinach": 2,
... | true |
dcc907106126ba5a4491e86d9dca2aa648a365ee | vsingh1998/Code_in_place | /Lectures/Lecture4/add2numbers.py | 652 | 4.25 | 4 | """
File: add2numbers.py
--------------------
This program asks for the user inputs of two numbers and prints their sum.
"""
def main():
print("This is a program to calculate sum of two numbers.")
# ask the user to input first number
num1 = input("Enter first number: ")
# convert string into integer... | true |
34f78ebc1dd9e983bb699b85fad673b75bb318e6 | asnewton/Stack | /QueueByStack.py | 570 | 4.1875 | 4 | """ Implement Queue using Stacks """
from Stack import NewStack
class Queue:
myStack1 = NewStack()
myStack2 = NewStack()
def enQueue(self, item):
Queue.myStack1.push(item)
def deQueue(self):
while Queue.myStack1.isempty() is not True:
Queue.myStack2.push(Queue.myStack1.p... | true |
3bdaa7792f2fb8796ea50a7fa59d9204a79db3d0 | jakaprima/python-basic-minimalist | /tantangan/manipulasi_string_searching.py | 508 | 4.28125 | 4 | def LongestWord(sen):
# first we remove non alphanumeric characters from the string
# using the translate function which deletes the specified characters
sen = sen.translate(None, "~!@#$%^&*()-_+={}[]:;'<>?/,.|`")
# now we separate the string into a list of words
arr = sen.split(" ")
# the list max func... | true |
a9ca0cdcc9546f3dc38ee1f5afe01071ae2d038f | V-Marco/miscellaneous | /tkinter_bootcamp/grid.py | 420 | 4.53125 | 5 | from tkinter import *
# Create a root window
root = Tk()
# Create a label widget
myLabel1 = Label(root, text = "Hello, World!")
myLabel2 = Label(root, text = "Hi again!")
myLabel3 = Label(root, text = " ")
# Put them in the grid
# The positions are relative!
myLabel1.grid(row = 0, column = 0)
myLabel2.grid(r... | true |
bc63aacc6a2e74a5b190023f2fe991816e9cd332 | ShivaniAsokumar/problems-py | /Find_Second_Max.py | 2,532 | 4.15625 | 4 | """
! PROMPT: Find the second largest element in a given list.
* Input: Array of numbers
* Output: Second largest number
? What happens if an illegal argument is given. => Raise ValueError
* Secong largest number is smaller than max but larger than all other values.
// Brute Force Solution
* Find the maximum usi... | true |
20b94d8b7f160bb48e2371e38165ed44558046ff | namphung1998/Comp123_code | /Final/Files/Q5.py | 1,052 | 4.28125 | 4 | import turtle
# Your job in this question is to write a function named
# drawSquares. The drawSquares draws a series of squares
# each one next to the other. The drawn squares start with
# 10 pixels to a side, and get bigger by 10 until they
# reach the input max size, after which they get smaller
# until they reach 1... | true |
90987e465b35469819d8c421424500fe06dbd2de | mitcheccles/tensortrade | /tensortrade/core/clock.py | 1,184 | 4.5625 | 5 | from datetime import datetime
class Clock(object):
"""A class to track the time for a process.
Attributes
----------
start : int
The time of start for the clock.
step : int
The time of the process the clock is at currently.
Methods
-------
now(format=None)
Get... | true |
d55539e09d65135646d3a27fc82ecb7e0cc33a18 | BenjaminAage/TileTraveller | /tile_traveller_def.py | 2,707 | 4.46875 | 4 |
# https://github.com/BenjaminAage/TileTraveller/blob/master/tile_traveller_def.py
# 1. Which implementation was easier and why?
# - It was quite hard to implement program #1 (without functions), as you had to figure out
# all the factors to have the program up and running. However, the function program (#2) w... | true |
f6875ce5510fbe4dce11a13281b5b0b1784a8899 | jeowsome/Python-Adventures | /Rock-Paper-Scissors/Find positions/main.py | 473 | 4.34375 | 4 | # put your python code here
numbers = input().split(' ') # read the input then create a new list for positions
to_find = input()
to_print = []
# when "iterating over the list of numbers", append all the found occurrences
for i in range(len(numbers)):
if numbers[i] == to_find:
to_print.append(str(i... | true |
d449cdfec0e9cde9c047ed06aa6cf30360c9e108 | mauricioTechDev/daily-code-wars | /python/running-out-of-space.py | 746 | 4.15625 | 4 | # Kevin is noticing his space run out!
# Write a function that removes the spaces from the values and
# returns an array showing the space decreasing. For example,
# running this function on the array ['i', 'have','no','space']
# would produce ['i','ihave','ihaveno','ihavenospace'].
# SOLUTION W... | true |
3a5e51c219a91504012fa87e2f3db7abacd392f7 | raysmith619/Introduction-To-Programming | /exercises/prroduct.py | 664 | 4.34375 | 4 | # product.py
"""
Write a function product(factor1, factor2, factor3) that returns the
product of the values factor1, factor2, factor3.
Test it on the following:
.5, .4, .3;
1, 2, 3;
-1, -1, -1;
"""
def product(factor1, factor2, factor3):
""" Do product of 3 factors, returning the product
... | true |
f692537aac14503d8da3feecc163026fcc780f1c | raysmith619/Introduction-To-Programming | /exercises/turtle/turtle_onclick_rainbow.py | 837 | 4.4375 | 4 | # turtle_on_click_rainbow.py 27Nov2020 crs, from turtle_onclick
""" Adding color to turtle_onclick.py
Operation:
Repeat:
1. Position the mouse inside graphics screen
2. Click mouse (button one)
A line is draw to the mouse position
"""
from turtle import *
rainbow = ["red", "orange", "y... | true |
092092f0e0f92fa658a28b8a4ff6898a52868c1f | sashakrasnov/datacamp | /21-deep-learning-in-python/3-building-deep-learning-models-with-keras/03-fitting-the-model.py | 1,348 | 4.5 | 4 | '''
Fitting the model
You're at the most fun part. You'll now fit the model. Recall that the data to be used as predictive features is loaded in a NumPy matrix called predictors and the data to be predicted is stored in a NumPy matrix called target. Your model is pre-written and it has been compiled with the code from... | true |
f544c60fe5e01e1b88821505f3293bce45f8261b | sashakrasnov/datacamp | /21-deep-learning-in-python/4-fine-tuning-keras-models/06-building-your-own-digit-recognition-model.py | 2,475 | 4.5625 | 5 | '''
Building your own digit recognition model
You've reached the final exercise of the course - you now know everything you need to build an accurate model to recognize handwritten digits!
We've already done the basic manipulation of the MNIST dataset shown in the video, so you have X and y loaded and ready to model ... | true |
5a936e185653a9333474874e60db2dd78565cb30 | sashakrasnov/datacamp | /22-network-analysis-in-python-1/1-introduction-to-networks/03-specifying-a-weight-on-edges.py | 1,641 | 4.3125 | 4 | '''
Specifying a weight on edges
Weights can be added to edges in a graph, typically indicating the "strength" of an edge. In NetworkX, the weight is indicated by the 'weight' key in the metadata dictionary.
Before attempting the exercise, use the IPython Shell to access the dictionary metadata of T and explore it, f... | true |
e1b882e222d1cc893c2bcf8512372943370b71c2 | sashakrasnov/datacamp | /06-importing-data-in-python-2/3-diving-deep-into-the-twitter-api/03-load-and-explore-twitter-data.py | 1,212 | 4.53125 | 5 | '''
Load and explore your Twitter data
Now that you've got your Twitter data sitting locally in a text file, it's time to explore it! This is what you'll do in the next few interactive exercises. In this exercise, you'll read the Twitter data into a list: tweets_data.
Instructions
* Assign the filename 'tweets.txt... | true |
1575384d98d8fbab917cfe024e3686b910f42d54 | sashakrasnov/datacamp | /15-statistical-thinking-in-python-1/1-graphical-exploratory-data-analysis/05-computing-the-ecdf.py | 1,722 | 4.40625 | 4 | '''
Computing the ECDF
In this exercise, you will write a function that takes as input a 1D array of data and then returns the x and y values of the ECDF. You will use this function over and over again throughout this course and its sequel. ECDFs are among the most important plots in statistical analysis. You can writ... | true |
20eebc469dec4f8c152a61f7ea5c04b53092e976 | sashakrasnov/datacamp | /24-data-types-for-data-science/4-handling-dates-and-times/03-pieces-of-time.py | 1,804 | 4.25 | 4 | '''
Pieces of Time
When working with datetime objects, you'll often want to group them by some component of the datetime such as the month, year, day, etc. Each of these are available as attributes on an instance of a datetime object.
You're going to work with the summary of the CTA's daily ridership. It contains the... | true |
0f35c9a6a623c41d4590847e59962315672ce2b3 | sashakrasnov/datacamp | /29-statistical-simulation-in-python/2-probability-and-data-generation-process/07-driving-test.py | 2,037 | 4.65625 | 5 | '''
Driving test
Through the next exercises, we will learn how to build a data generating process (DGP) through progressively complex examples.
In this exercise, you will simulate a very simple DGP. Suppose that you are about to take a driving test tomorrow. Based on your own practice and based on data you have gathe... | true |
206f83801de4bbda63c100e3026939cf9085e7f6 | sashakrasnov/datacamp | /26-manipulating-time-series-data-in-python/1-working-with-time-series-in-pandas/06-calculating-stock-price-changes.py | 1,590 | 4.25 | 4 | '''
Calculating stock price changes
You have learned in the video how to calculate returns using current and shifted prices as input. Now you'll practice a similar calculation to calculate absolute changes from current and shifted prices, and compare the result to the function .diff().
'''
import pandas as pd
yahoo ... | true |
dbad60a48570c819043be5067ba14a0748a48fd3 | sashakrasnov/datacamp | /29-statistical-simulation-in-python/4-advanced-applications-of-simulation/01-modeling-corn-production.py | 1,494 | 4.3125 | 4 | '''
Modeling Corn Production
Suppose that you manage a small corn farm and are interested in optimizing your costs. In this exercise, we will model the production of corn.
For simplicity, let's assume that corn production depends on only two factors: rain, which you don't control, and cost, which you control. Rain is... | true |
19fb72baf7e1c430977fc551d85e516d2e87dadc | sashakrasnov/datacamp | /09-manipulating-dataframes-with-pandas/4-grouping-data/03-computing-multiple-aggregates-of-multiple.columns.py | 1,806 | 4.25 | 4 | '''
Computing multiple aggregates of multiple columns
The .agg() method can be used with a tuple or list of aggregations as input. When applying multiple aggregations on multiple columns, the aggregated DataFrame has a multi-level column index.
In this exercise, you're going to group passengers on the Titanic by 'pcl... | true |
db126fa6dca8af406e3eb64cec30bb4e302f7ef4 | sashakrasnov/datacamp | /24-data-types-for-data-science/3-meet-the-collections-module/04-safely-appending-to-a-keys-value-list.py | 1,648 | 4.75 | 5 | '''
Safely appending to a key's value list
Often when working with dictionaries, you know the data type you want to have each key be; however, some data types such as lists have to be initialized on each key before you can append to that list.
A defaultdict allows you to define what each uninitialized key will contai... | true |
0453443a2fd4382dd5faf56577be5ed76779b069 | sashakrasnov/datacamp | /08-pandas-foundations/1-data-ingestion-and-inspection/07-plotting-series-using-pandas.py | 1,935 | 4.84375 | 5 | '''
Plotting series using pandas
Data visualization is often a very effective first step in gaining a rough understanding of a data set to be analyzed. Pandas provides data visualization by both depending upon and interoperating with the matplotlib library. You will now explore some of the basic plotting mechanics wit... | true |
a8550d5ba734efaadd56fd5332aa2666f8b2fefa | sashakrasnov/datacamp | /06-importing-data-in-python-2/2-interacting-with-apis-to-import-data-from-the-web/01-loading-and-exploring-a-json.py | 924 | 4.65625 | 5 | '''
Loading and exploring a JSON
Now that you know what a JSON is, you'll load one into your Python environment and explore it yourself. Here, you'll load the JSON 'a_movie.json' into the variable json_data, which will be a dictionary. You'll then explore the JSON contents by printing the key-value pairs of json_data ... | true |
1f9b6dc325f192935d30604dae151f875e5ad35c | sashakrasnov/datacamp | /21-deep-learning-in-python/1-basics-of-deep-learning-and-neural-networks/02-the-rectified-linear-activation-function.py | 1,716 | 4.625 | 5 | '''
The Rectified Linear Activation Function
As Dan explained to you in the video, an "activation function" is a function applied at each node. It converts the node's input into some output.
The rectified linear activation function (called ReLU) has been shown to lead to very high-performance networks. This function ... | true |
8bb2983a52a9607911c0ea69f4a453fef39b45de | sashakrasnov/datacamp | /08-pandas-foundations/2-exploratory-data-analysis/09-separate-and-summarize.py | 1,569 | 4.125 | 4 | '''
Separate and summarize
Let's use population filtering to determine how the automobiles in the US differ from the global average and standard deviation. How the distribution of fuel efficiency (MPG) for the US differ from the global average and standard deviation?
In this exercise, you'll compute the means and sta... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.