blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c42cbd069f0767ddf4080718265b98ae6c5a8c98 | viktapas/AlgoCasts_Python_JS | /exercises/fizzbuzz/index.py | 772 | 4.5625 | 5 | # --- Directions
# Write a program that console logs the numbers
# from 1 to n. But for multiples of three print
# 'fizz' instead of the number and for the multiples
# of five print 'buzz'. For numbers which are multiples
# of both three and five print 'fizzbuzz'.
# --- Example
# fizzBuzz(5);
# 1
# 2
# fizz
# ... | false |
8e616784d502fdcb9f874d394e8129137aaec025 | yungjas/Python-Practice | /even.py | 315 | 4.28125 | 4 | #Qn: Given a string, display only those characters which are present at an even index number.
def print_even_chars(str_input):
for i in range(0, len(str_input), 2):
print(str_input[i])
text = "pynative"
print("Original string is " + text)
print("Printing only even index chars")
print_even_chars(text) | true |
83655407a288aa3d7c0192bc936e40eaaee5e22e | not-so-daily-practice/top-80-interview-algorithms | /strings_and_arrays/reverse_array_except_special.py | 554 | 4.15625 | 4 | def reverse_except_special(arr):
"""
Given an array, reverse it without changing the positions of special characters
:param arr: array to reverse
:return: reversed array
"""
arr = list(arr)
left = 0
right = len(arr) - 1
while left < right:
if not arr[left].isalpha():
... | true |
1ce26ff860b909d7f61db0e82b957103bc70519b | akshitsarin/python-files | /singlylinkedlistfinal.py | 1,587 | 4.34375 | 4 | # singly linked list final
class Node:
def __init__(self, data):
self.data = data # Assign data
self.next = None # Initialize next as null
class LinkedList:
def __init__(self):
self.head = None # initialise head
def push(self, new_data):
new_node = Node(new_data)
... | true |
0cce8f2b81b2b0956c2fb2dca7444a352684d6b2 | supvolume/codewars_solution | /5kyu/move_zeros.py | 389 | 4.125 | 4 | """ solution for Moving Zeros To The End challenge
move zero to the end of the array"""
def move_zeros(array):
no_zero = []
zero = []
for a in array:
if a == "0":
no_zero.append(a)
elif (str(a) == "0.0" or str(a) == "0" or a == 0) and str(a) != "False":
zero.append(a... | false |
68863a0fd52ddce4d306749ee22ca4e81cde8ba3 | provishalk/Python | /Linked List/LinkedList.py | 1,701 | 4.15625 | 4 | class LinkedList:
head = None
class Node:
def __init__(self, x):
self.value = x
self.next = None
def insert(self,value):
toAdd = self.Node(value)
if self.head == None:
self.head = toAdd
return
temp = self.head
while temp... | true |
76f9c27e3ddcc3afc6e800a05882ff649f7d1ac2 | tristan1049/Dungeon-for-the-Bored | /Illustrations.py | 2,859 | 4.15625 | 4 | def dice1():
"""
Purpose: To make an illustration for the 1-side of a die
Output: List of each row in drawing
"""
rv = [" _______ ",
"| |",
"| * |",
"| |",
"|_______|"]
return rv
def dice2():
"""
Purpose: To make an illustratio... | false |
ba7cb756981686727f4c3c2722b3ac59fbf9d608 | yossibaruch/learn_python | /learn_python_the_hard_way/ex3.py | 855 | 4.34375 | 4 | # print some output
print "I will now count my chickens:"
# order of math
print "Hens", 25+30/6
# order of math
print "Roosters", 100-25*3%4
# print something
print "Now I will count the eggs:"
# math order, first multiply/div then add/sub, also what / and % do
print 3+2+1-5+4%2-1/4+6
# print something
print... | true |
ece25778d428f34d312ed89566a52d317d4c3bf5 | yossibaruch/learn_python | /non-programmers/13-braces.py | 1,447 | 4.3125 | 4 | import string
print("""
# Iterate on characters from string
# Find opening braces and "remember" them in order
# Find closing braces and make sure it fits the last opening braces
# If "yes", forget last opening braces
# If "no", return False
# If memory of opening braces is not empty - return F... | true |
4dbef496f2b1a7f6a40083bb1851101865b2a8f0 | Muscularbeaver301/WebdevelopmentSmartNinja201703 | /Kursprojekte/Kursprogramm/examples/VehicleManager.py | 1,723 | 4.15625 | 4 | class Vehicle(object):
def __init__(self, brand, model, km, service_date):
self.brand = brand
self.model = model
self.km = km
self.service_date = service_date
def show(self):
print "{} {} {} {}".format(self.brand, self.model, self.km, self.service_date)
if __name__ == ... | true |
bfadef36e211fb74bc5191806e7e20577889683e | JayWebz/PythonExercises | /final/project3 - EmployeeDbCRUDapp/emp.py | 1,513 | 4.25 | 4 | class Employee:
"""employee is an object that creates and manipulates data about a particular employee such as calculating pay, printing employee info, ."""
# Initialize attributes
def __init__(self, firstName, lastName, employeeID, status, payRate):
self.firstName = firstName
self.lastName = lastName
self.e... | true |
5c8978b9860f2cba173eafa34cc0315bd0fe7a12 | JayWebz/PythonExercises | /Module3/project4 - EpactCalc/hw3extraCredit.py | 1,264 | 4.40625 | 4 | #! /usr/bin/python
# Exercise No. extra credit
# File Name: hw3extraCredit.py
# Programmer: Jon Weber
# Date: Sept. 10, 2017
#
# Problem Statement: Write a user-friendly program that
# prompts the user for a 4-digit year and then outputs the value of the Gregorian epact for that year
#
# Overall Plan... | true |
cd446e7ed3da381d0ad861dfebed7769a61ac211 | JayWebz/PythonExercises | /Module4/project2 - CalcSumGUI/hw4project2.py | 2,298 | 4.5 | 4 | #! /usr/bin/python
# Exercise No. 2
# File Name: hw4project2.py
# Programmer: Jon Weber
# Date: Sept. 17, 2017
#
# Problem Statement: Create a Graphical User Interface
# for a program that calculates sum and product of three numbers.
#
# Overall Plan:
# 1. Create a window for objects and print welcome... | true |
35621ed7d9d2dfdae93b1fba45b942a3a668efac | JayWebz/PythonExercises | /final/project3 - EmployeeDbCRUDapp/record.py | 1,308 | 4.3125 | 4 | class Employee:
"""employee is an object that creates and manipulates data about a particular employee such as calculating pay, printing employee info, ."""
# Initialize attributes
def __init__(self, firstName, lastName, employeeID, status, payRate):
self.firstName = firstName
self.lastName = lastName
self.e... | true |
48df7ef8f1638b25aa1c405fa7f941792d5d6029 | Slackd/python_learning | /PY4E/05-iterations.py | 665 | 4.28125 | 4 | #! /usr/bin/python3
# Write another program that prompts for a list of
# numbers as above and at the end prints out both the maximum
# and minimum of the numbers instead of the average.
userNums = input("Enter Numbers Separated by spaces: ")
inputNums = userNums.split()
for i in range(len(inputNums)):
inputNum... | true |
91a712961cbd6bfd8c8ec3de6629d178d6e0b62e | Slackd/python_learning | /First/if_else.py | 616 | 4.34375 | 4 | is_male = False
is_tall = True
if is_male and is_tall:
print("You are a tall male")
elif is_male and not (is_tall):
print("you are a short male")
elif not (is_male) and is_tall:
print("you are not a male, but are tall")
else:
print("you are neither male not tall or both")
num1 = input("Enter 1st N... | true |
86d1bd41d5682d09eaa8356a0dcde8c978b11210 | Voidivi/Python-1 | /Pig Latin Translator.py | 1,847 | 4.40625 | 4 | #!/usr/bin/env python3
# Assignment Week 6 - Pig Latin Translator
# Author: Lyssette Williams
# global values for the program
ay = 'ay'
way = 'way'
vowels = ['a','e', 'i', 'o', 'u']
punctuations = '''!()-[];:'",<>./?@#$%^&*_~'''
# decided to add some formatting stuff to make it more readable
def display():... | true |
f5b22ec6f30c9d286bc75a37f5001c493abe6b58 | Maria-Lasiuta/geegs_girls_lab3 | /ex3(3).py | 363 | 4.15625 | 4 | #Calculate number of distinct characters in a string using a for loop.
def unique_count(word):
k=list()
b = word.split()
b = ''.join(b)
for x in b:
if x not in k:
k.append(x)
return len(k)
enter=input()
print('унікальних символів:',unique_count(enter))
... | true |
2cb3cf3b87d0068c7291eb80c7be10675218e57d | Maria-Lasiuta/geegs_girls_lab3 | /lab 3/5(3).py | 376 | 4.15625 | 4 | #Check if the number is prime
def is_prime(n):
if n > 1:
for i in range(2, (int(n/2)+1)):
if n%i == 0:
return f'{n} is not a prime number'
else:
return f'{n} is a prime nummber'
else:
return f'{n} is a prime number'
n = in... | false |
4ae76eeee25d37e786eda9fea0dc14163c77a8fa | epotyom/interview_prepare | /coding/sorts/quicksort.py | 1,154 | 4.28125 | 4 | def sort(data):
"""
Quicksort function
Arguments:
data(list): list of numbers to sort
"""
sortIteration(data, 0, len(data)-1)
def sortIteration(data, first, last):
"""
Iteration of quicksort
Arguments:
data(list): list to be sorted
first(int): first element of iteration
last(int): l... | true |
820dca361b752699d098b0d9b59615971ecdc524 | yohannabittan/iterative_hasher | /iterative_hasher.py | 2,778 | 4.3125 | 4 | #written by Yohann Abittan
#this program uses hashlib to either produce hashes which have been hashed iteratively a given number of times
#or to test wether a given hash matches a password after a number of iterations of hashing
import hashlib
def encryptMd5(initial):
encrypted = hashlib.md5()
encrypt... | true |
1817ccf74ed79881b17d5e029cffa926ee282e93 | chrismvelez97/GuideToPython | /techniques/exceptions/value_error.py | 989 | 4.625 | 5 | # How to handle the value error
'''
The value error is when your
program is expecting a certain
value type back such as a number
or a string and you get the other.
For example, we'll be using a
calculator that can add, but
get a value error if we type letters
in place of numbers.
The following is ... | true |
6dfde392607bfe8accf5baa0e097e7ee838717da | chrismvelez97/GuideToPython | /techniques/files/storingData/saving_user_data.py | 730 | 4.1875 | 4 | # How to save user data
'''
Using the json.dump() and json.load()
techniques we just learned about, we
can actually save user data to be
used at a later time.
'''
import json
username = input("Hello! What is your name?\n\n")
path = "/home/chrismvelez/Desktop/GuideToPython3/techniques/files/s... | true |
64c2d50ebe0d127df0170b3834507467c89340d0 | chrismvelez97/GuideToPython | /data_types/dictionaries.py | 1,541 | 4.90625 | 5 | # How to use dictionaries
'''
Dictionaries are special forms of containers that do NOT have indices. They
can start off empty and have values added later
Instead, they have key and value pairs. To access a value you use the key.
The keys must be strings, and the values can hold anything f... | true |
f837053b00cd472b1097c4f4e72e4e7b053e0100 | chrismvelez97/GuideToPython | /techniques/classes/default_modifying_attributes.py | 1,751 | 4.625 | 5 | # Default values and Modifying attributes
class Character():
"""
This class will model a character in a videogame
to show the different things we can do with classes.
"""
def __init__(self, name):
'''
You can see we have attributes we didn't require
in ... | true |
080d28c6f1467abf777e76ac49a786b0e0055333 | chrismvelez97/GuideToPython | /techniques/functions/built_in_functions/sum.py | 478 | 4.15625 | 4 | # How to use the sum() function
'''
The sum() function adds all the numbers up from a list of numbers.
Note that for min, max, and sum, you can only do them on lists full of numbers.
also it is not a method attached to the number datatype which is why it is in
the techniques folder instead o... | true |
97a8074488d0ee8e03d0f1ba2e3ed725c0820691 | chrismvelez97/GuideToPython | /techniques/functions/built_in_functions/range.py | 1,471 | 4.90625 | 5 | # How to use range in python
'''
So after looking over this I really debated with myself if I should
put this under method or techniques and I ended up putting it here because,
the function doesn't execute if not in conjunction with a for loop, hence it
being a technique.
The range(start, en... | true |
38c5fa3b7f2798b48e0aaab62bf319f18ff2c8f9 | chrismvelez97/GuideToPython | /techniques/loops/looping_dictionaries.py | 995 | 4.5 | 4 | # How to loop Dictionaries
'''
You can loop through dictionaries but it should be noted that they will not
come out in any specific order because are not ordered by indices
'''
dictionary = {
"words": {
"penultimate": "The second to last item in a group.",
"ultimate": "The... | true |
a5d24fbee492882a3802ab5a147d333a937494b2 | pratishhegde/rosalind | /problems/fibd/fibd.py | 1,184 | 4.125 | 4 | # -*- coding: utf-8 -*-
'''
Recall the definition of the Fibonacci numbers from “Rabbits and Recurrence
Relations”, which followed the recurrence relation Fn=Fn−1+Fn−2 and assumed that
each pair of rabbits reaches maturity in one month and produces a single pair of
offspring (one male, one female) each subsequent mon... | true |
7ac4527ba233e39bf952a56b069e4a2f5ff4418c | Wamique-DS/my_world | /Some Basic Program in Python...py | 1,650 | 4.1875 | 4 |
# coding: utf-8
# In[3]:
# prgogarm to find Area of circle
radius=eval(input("Enter the radius of circle ")) # eval takes any value either integer or float
# calculate area
area=radius*radius*3.14
# Display result
print("Area of circle of radius", radius,"is",round(area,2))
# In[8]:
# Program to find area of... | true |
901bfe55f38adb6702d4ce85ef8473b0a6e7da4d | kunzhang1110/COMP9021-Principles-of-Programming | /Quiz/Quiz 6/quiz_6.py | 2,804 | 4.1875 | 4 | # Defines two classes, Point() and Triangle().
# An object for the second class is created by passing named arguments,
# point_1, point_2 and point_3, to its constructor.
# Such an object can be modified by changing one point, two or three points
# thanks to the function change_point_or_points().
# At any stage, the ob... | true |
667e34fb89fc133969d6649bb218c3c0c40adaa5 | Maria61/test_script | /2020-08-03/test1.py | 272 | 4.34375 | 4 | # 注释:“:”后缩进的语句视为代码块;python大小写敏感
# a = 100
# if a >= 0:
# print(a)
# else:
# print(-a)
#
# print('I\'m \"OK\"')
#
# print('I\'m OK')
#
# print(r'\\\t\\\ ')
# print('T \t i \n m')
print('''asdf
jlkl
... werwqre
... d''') | false |
c159ab3cb87d420b584ca54d07397f7942600269 | ridolenai/Day_Trip_Generator | /DayTripGenerator.py | 2,583 | 4.15625 | 4 | import random
destinations = ["Disney World", "Oktoberfest", "Crawfish Festival", "Mawmaw's House"]
restaurants = ["Applebee's", "Schnitzel Emporium", "Pizza Hut", "Sullivan's"]
transportation = ['Car', 'Bicycle', '4-wheeler', 'Yee Yee Truck']
entertainment = ['Miley Cyrus Concert', 'Chainsaw Juggler', 'Sock Manufactu... | true |
c21d9ce87e81316c8dc18ea15f4228cb04152e8b | ashutosh-qa/PythonTesting | /PythonBasics/First.py | 509 | 4.28125 | 4 | # To print anything
print("This is first Pyhton program")
# How to define variable in python
a = 3
print(a)
# How to define String
Str="Ashutosh"
print(Str)
# Other examples
x, y, z = 5, 8.3, "Test"
print(x, y, z)
# to print different data types - use format method
print ("{} {}".format("Value is:", x))
# How to k... | true |
04f373e0bb32fc3a4f4e9d77e1fc83fe368803f2 | Dame-ui/Algorithms | /bubblesort.py | 797 | 4.375 | 4 |
def bubble_sort(list_of_numbers):
for i in range(len(list_of_numbers)): #run N times, where N is number of elements in a list
# Last i elements are already in place
# It starts at 1 so we can access the previous element
for j in range(1, len(list_of_numbers) - i): # N-i elements
... | true |
c44dc53c8c6aea407e29c934b9559c752a9e0216 | thinhld80/python3 | /python3-17/python3-17.py | 1,695 | 4.3125 | 4 | #Functions in depth
#No Arguments
def test():
print('Normal function')
print('\r\n------ No Arguments')
test()
#Positional and Keyword Arguments
def message(name,msg,age):
print(f'Hello {name}, {msg}, you are {age} years old')
print('\r\n------ Positional and Keyword Arguments')
message('Bryan', 'good morni... | true |
8bc9cb211ce9780e5d76303f4869eac4aa0d87bb | thinhld80/python3 | /python3-48/python3-48.py | 2,113 | 4.375 | 4 | #Queues and Futures
#Getting values from a thread
#This is a problem for future me
"""
Queues is like leaving a message
A Future is used for synchronizing program execution
in some concurrent programming languages. They describe an
object that acts as a proxy for a result that is initially unknown,
usually because... | true |
34953844e759a37f2b697a345c7ed870d6098e3e | thinhld80/python3 | /python3-4/python3-4.py | 685 | 4.15625 | 4 | #Numbers - int float complex
#int
iVal = 34
print(f'iVal = {iVal}')
#float
fVal = 3.14
print(f'fVal = {fVal}')
import sys
print(sys.float_info) # https://docs.python.org/3/library/sys.html#sys.float_info
#complex - complex([real[, imag]])
cVal = 3 +6j
print(f'cVal = {cVal}')
cVal = complex(5,3)
print(f'cVal = {cVal}... | false |
0cdafb79c9df477474722c851deb8c28efe02905 | thinhld80/python3 | /python3-32/python3-32.py | 1,055 | 4.15625 | 4 | #Multiple Inheritance
#Inherit from multiple classes at the same time
#Vehical class
class Vehical:
speed = 0
def drive(self,speed):
self.speed = speed
print('Driving')
def stop(self):
self.speed = 0
print('Stopped')
def display(self):
print(f'Driving at {self... | true |
8579d3e9933115a259e8bebe517ec51b6ae95f1c | loganmcampbell/CSCE-3193 | /Homework[7]/my_cipher2.py | 2,896 | 4.25 | 4 | import functioncipyer
# START HERE : ENTER A THE KEYWORD TO CIPHER AND UPPERCASE IT
word = input("Enter keyword for encrpyt: ")
while (word == ""):
word = input("Enter keyword for encrpyt: ")
print("w o r d : ", word)
word = word.upper()
original = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
original = " ".join(original... | false |
8ed8c49a7b826f676b6987a6cb1fb583fefa8d52 | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_02_ciclos_01/06.py | 339 | 4.125 | 4 | numero_ingresado = int(input('Ingrese un número, programa finaliza con un -1: '))
suma = 0
while numero_ingresado != -1:
suma = suma + numero_ingresado
numero_ingresado = int(input('Ingrese un número, programa finaliza con un -1: '))
if numero_ingresado == -1:
print('Programa finalizado')
print(f'Sum... | false |
bf0d3e56763cca5dc8024581746ab9eafcb6313b | sandeepmaity09/python_practice | /tuple.py | 354 | 4.59375 | 5 | #!/usr/bin/python3
empty=() # creating tuple
print(type(empty))
empty=tuple() # creation tuple
print(type(empty))
empty="hello", # <---- note trailing comma for create a tuple with only one item
print(empty)
empty=23,34,'heelo' # to create tuple
x,y,z=empty # sequence unpacking of tuple
print(type(x... | true |
975eb35f2c500489c4e0e78f54cebb3fadb49242 | sandeepmaity09/python_practice | /data_structure/disjoint2.py | 254 | 4.125 | 4 | #!/usr/bin/python3
#Running time algorithm = O(n) power 2
def disjoint2(A,B,C):
"""Return True if there is no element common to all three lists."""
for a in A:
for b in B:
if a==b:
for c in C:
if a==c:
return False
return True
| true |
4589b0d8e9c31882841896cec8b077769cb58257 | JohnnySheng/learn_python | /others/foods.py | 567 | 4.15625 | 4 | my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
my_foods.append('cannoli')
friend_foods.append('ice_cream')
print("My favorite foods are:")
print(my_foods)
print("\nMy friend's favorite foods are:")
print(friend_foods)
print("The first three items in the list are: ")
print(my_foods[0:3])
pr... | false |
ca0592b5430cca0b075845b1f9a33690ff7cbbdb | Floozutter/project-euler | /python/p004.py | 1,723 | 4.34375 | 4 | """
Project Euler - Problem 4
"Find the largest palindrome made from the product of two 3-digit numbers."
"""
from heapq import merge
from typing import Iterable
def palindromic(s: str) -> bool:
"""
Checks whether a string is a palindrome.
"""
size = len(s)
for i in range(size // 2):
if s... | true |
8056f057bd8fa11a7dfc6e8f41731d37be7dfbba | TrWesche/ca_sorts | /ca_bubblesort.py | 491 | 4.21875 | 4 | nums = [5, 2, 9, 1, 5, 6]
# Define swap() below:
def swap(arr, index_1, index_2):
# pass
temp = arr[index_1]
arr[index_1] = arr[index_2]
arr[index_2] = temp
def bubble_sort(arr):
for el in arr:
for index in range(len(arr) - 1):
if arr[index] > arr[index + 1]:
sw... | false |
f9b80902340fda78db2016b2e7b4d77984f5ba7f | LuisPatino92/holbertonschool-higher_level_programming | /0x06-python-classes/4-square.py | 1,177 | 4.5625 | 5 | #!/usr/bin/python3
""" This module has the definition of a Square class"""
class Square:
""" Model of a square """
def __init__(self, size=0):
""" Constructor for Square Method
Args:
size (int): Is the size of the instance, 0 by default.
"""
if not isinst... | true |
d098fa93e1def3706732bd290518efe0296b17ae | prathameshkurunkar7/Python_Projects | /Final Capstone Project/FindCostOfTile.py | 388 | 4.21875 | 4 | def find_cost(cost_per_tile, w, h):
"""
Return the total cost of tile to cover
WxH floor
"""
return cost_per_tile * (w * h)
w, h = (int(x) for x in input("Enter W and H : ").split())
cost_tile = float(input("Enter the cost per tile : "))
print(
"Total cost of tile to cover WxH floor... | true |
2a60f5343b27fe587437abf1b972bbe9e7e04285 | dougBelcher/Scripts | /temperature.6.3.py | 674 | 4.375 | 4 | # 6.3 - Challenge: Convert Temperatures
def convert_cel_to_far(temp_cel):
"""Return the Celsius temp converted to Fahrenheit"""
temp_far = temp_cel * (9 / 5) + 32
return temp_far
def convert_far_to_cel(temp_far):
"""Return the Fahrenheit temp converted to Celsius"""
temp_cel = (temp_far - 32) * ... | false |
4fb378146c4b8c716dfd3b87c0bd3ca8caedbeb4 | ticotheps/Algorithms | /stock_prices/stock_prices.py | 2,711 | 4.375 | 4 | #!/usr/bin/python3
#---------------Understanding the Problem---------------
# Objective: Find the largest positive difference between two numbers in a
# list of 'stock prices'.
# Expected Input: a list of stock prices.
# Example: [1050, 270, 1540, 3800, 2]
# Expected Output: an integer representin... | true |
55b20ca41e543233e4fb7ba479ac3093a8b3b07d | Mauricio-Fortune/Python-Projects | /randturtle.py | 1,964 | 4.25 | 4 | # Mauricio Fortune Panizo
# COP 2930
# Python turtle with random number
# 09/10/12
import turtle
import random
#what do they want to draw
shape = (input("Do you want a rectangle, triangle, or both?\n"))
turtle.pencolor("violet")
turtle.fillcolor("blue")
#Rectangle
if shape == "rectangle" or shape == "Rectangle" or ... | true |
3c757e0e0ab2e6b6a48b8f0cc4e4a4b2360afb36 | SarveshMohan89/Python-Projects | /grade.py | 580 | 4.375 | 4 | score = input("Enter Score: ")
try:
score=float(score)
except:
print("Enter a valid value")
quit()
if score >=0.9:
print("A")
elif score >=0.8:
print("B")
elif score >=0.7:
print("C")
elif score >=0.6:
print("D")
elif score <0.6:
print("F")
# Write a program ... | true |
8d5b7d048e87d6fdd6fc7e7c09f60a2d3b17439e | SarveshMohan89/Python-Projects | /Pay.py | 564 | 4.28125 | 4 | hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter Rate:")
r= float(rate)
if h <= 40:
pay = h * r
elif h > 40:
pay = 40*r + (h-40)*r*1.5
print (pay)
#Write a program to prompt the user for hours and rate per hour using input to compute gross pay.Pay the hourly rate for the hours up to 4... | true |
cb0cd132a4af328cb1007a0ece0b6f6935f5c240 | cinxdy/Python_practice | /Python_Workbook/B08.py | 534 | 4.1875 | 4 | num1 = int(input('number 1?'))
num2 = int(input('number 2?'))
num3 = int(input('number 3?'))
if num1==num2 or num2==num3 or num1==num3 :
print('condition1 satisfied')
if (num1>50 and num2>50) or (num2>50 and num3>50) or (num1>50 and num3>50) :
print('condition2 satisfied')
if num1+num2 == num3 or num2+num3 == ... | false |
fa757a907024fabdf8c6eca41cb99a5ad539fd6f | pBouillon/codesignal | /arcade/intro/3_Exploring_the_Waters/palindromeRearranging.py | 757 | 4.25 | 4 | """
Given a string, find out if its characters can be rearranged to form a palindrome.
Example
For inputString = "aabb", the output should be
palindromeRearranging(inputString) = true.
We can rearrange "aabb" to make "abba", which is a palindrome.
Input/Output
[execution time limit] 4 seconds (py3)
[input... | true |
46e7b658c7f7d1e5cbe22662800a9eedf480148a | pBouillon/codesignal | /arcade/python/1_Slithering_in_Strings/Convert_Tabs.py | 1,221 | 4.28125 | 4 | """
You found an awesome customizable Python IDE that has
almost everything you'd like to see in your working environment.
However, after a couple days of coding you discover that there is
one important feature that this IDE lacks: it cannot convert
tabs to spaces. Luckily, the IDE is easily customizable, so you
d... | true |
d9dafdd492d3d28036bae95508f9bc80582eca24 | pBouillon/codesignal | /arcade/the_core/2_Corner_of_0s_and_1s/Mirror_Bits.py | 505 | 4.1875 | 4 | """
Reverse the order of the bits in a given integer.
Example
For a = 97, the output should be
mirrorBits(a) = 67.
97 equals to 1100001 in binary, which is 1000011 after
mirroring, and that is 67 in base 10.
For a = 8, the output should be
mirrorBits(a) = 1.
Input/Output
[execution time... | true |
bcf2fee9bf1b50855607e2b748080ad319468f7b | pBouillon/codesignal | /arcade/intro/9_Eruption_of_Light/Is_MAC48_Address.py | 1,343 | 4.53125 | 5 | """
A media access control address (MAC address) is a unique identifier
assigned to network interfaces for communications on the physical
network segment.
The standard (IEEE 802) format for printing MAC-48 addresses in
human-friendly form is six groups of two hexadecimal digits
(0 to 9 or A to F), separated by hyp... | true |
c17719db8ae21f8174e7a4526c9f0e71eb92d32a | pBouillon/codesignal | /arcade/python/5_Fumbling_In_Functionnal/Fix_Result.py | 1,332 | 4.125 | 4 | """
Your teacher asked you to implement a function that calculates
the Answer to the Ultimate Question of Life, the Universe, and
Everything and returns it as an array of integers. After several
hours of hardcore coding you managed to write such a function,
and it produced a quite reasonable result. However, when y... | true |
d93215df09999419db4bab6bc4f8eb39b2aeb127 | pBouillon/codesignal | /arcade/python/6_Caravan_of_Collections/Unique_Characters.py | 939 | 4.28125 | 4 | """
You need to compress a large document that consists of a
small number of different characters. To choose the best
encoding algorithm, you would like to look closely at the
characters that comprise this document.
Given a document, return an array of all unique characters
that appear in it sorted by their ASCII ... | true |
c74785827938751410f2ca78676c167697e02ce5 | digitalcourtney87/lpthw | /ex3.py | 972 | 4.625 | 5 | # prints the string "I will now count my chickens:"
print("I will now count my chickens:")
# prints hens and roosters and the calculation after each string
print("Hens", 25 + 30 / 6)
print("Roosters", 100 - 25 * 3 % 4)
# prints the string "I wil now count my eggs"
print("I will now count my eggs:")
# prints the calc... | true |
f64c77c65741ef75db8bab6200a1714c05ac954e | jamincen/Python3X_Daily_question | /24_simple_operation_of_strings.py | 1,390 | 4.5 | 4 | """
字符串的三种表达方式
. single quotes '
. double quotes "
. three quotes ''' # multi-line string
"""
## 拼接字符串的方式
a = 'hello'
b = 'world'
print(a + ' ' + b)
print(a, b)
print('%s %s' % (a, b)) # 推荐,效率高
print('hello''world')
print('{}{}'.format(a, b)) # 推荐,效率高
print(''.join(['h... | false |
2c6fb80d74f7c752c451cb1d28c91fa8767de50e | RuggeroPiazza/rock_paper_scissors | /rockPaperScissors.py | 1,998 | 4.15625 | 4 | import random
"""
This program execute a given number of runs of
'Rock, Paper, Scissors' game and returns stats about it.
"""
choices = ['paper', 'rock', 'scissors']
winning = [('paper', 'rock'), ('rock', 'scissors'), ('scissors', 'paper')]
def run():
"""INPUT: no input.
OUTPUT: string.
The functi... | true |
0cd51399d1c1d5e08cdc522da22e7b0ab4aaa4d2 | manasmdg3/python | /F2CTemperature.py | 601 | 4.28125 | 4 | #Fahrenheit to Celcius Temperature
def c2fConverter():
temp = float(input("\nEnter Temperature in Celcius: "))
print(str(temp)+" degree Celcius in Fahrenheit is: "+"{:.2f}".format((9*temp)/5+32))
def f2cConverter():
temp = float(input("\nEnter Temperature in Fahrenheit: "))
print(str(temp)+" degree Fahr... | false |
9aff11cc554d9567141f292091d60eea7e47473c | renegadevi/hour-calculator | /main.py | 2,678 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Hour Calculator
Quickly made hour calculator for 24h day clock to prevent the need of relying
on a website for simple time calculations. Does the work; enter timestamps,
shows results in a table of elapsed time and total hours.
"""
import datetime
import sys
import ... | true |
c0da82154044bc19c0417101c83f80c25c3b160e | PdxCodeGuild/Programming102 | /resources/example_lessons/unit_2/grading_with_functions.py | 1,633 | 4.25 | 4 | import random # for randint()
#### add this function if there's time
"""# return True if the number is between 1 and 100
# return False otherwise
def get_modifier(score):
'''
return a grade modifier based on a score
'''
# isolate the ones digit of the score with % 10
ones = score % 10
modifier... | true |
0fb9823e4724afbace1b7b392876fc3d6661f933 | pramodchahar/Python_A_2_Z | /lists/slices.py | 540 | 4.5625 | 5 | ###########################
# Slicing of List
###########################
# makes new lists using slices or parts of original lists
# list_name[start:end:step]
#sort of similar to range(start,end,step size)
num_list=[11,22,33,44,55,66,77,88,99]
print(num_list[3:])
print(num_list[5:])
print(num_list[-1:])
pri... | true |
2eb5d6e96aa9cc6b08b66e5724bb3b2bb7fc9960 | Javenkm/Functions-Basic-2 | /functions_basic2.py | 2,376 | 4.28125 | 4 | # 1. Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element).
# Example: cuntdown(5) should return [5, 4, 3, 2, 1].
def countDown(num):
list = []
for x in range(num, -1, -1):
list.app... | true |
4e0730d471146edd5bb196ff536c023e67eb5453 | akash123456-hub/hello.py | /vns2.py | 836 | 4.15625 | 4 | '''
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[-4:-1])
'''
'''
class Dog:
# Class Variable
animal = 'dog'
# The init method or constructor
def __init__(self, breed, color):
# Instance Variable
self.breed = bre... | true |
9421a2ef16ebab41bc62af119d3a39013ae06099 | clementeqp/Python_Clemen | /09-In_Not.py | 383 | 4.3125 | 4 | # con una lista
trabajadores=["Laura", "Manolo", "Jorge", "Teresa"]
if "Manolo" in trabajadores:
print("Manolo esta en la lista")
else:
print("Manolo no esta en la lista")
# con un string
trabajadores2="Laura", "Manolo", "Jorge", "Teresa"
if "Manolo" not in trabajadores2:
print("Man... | false |
1cfd08df97ae7e4228ec082f096432bb2beee189 | Brokenshire/codewars-projects | /Python/six_kyu/in_array.py | 1,066 | 4.28125 | 4 | # Python solution for 'Which are in?' codewars question.
# Level: 6 kyu
# Tags: REFACTORING, ARRAYS, SEARCH, ALGORITHMS, LISTS, DATA STRUCTURES, and STRINGS.
# Author: Jack Brokenshire
# Date: 11/06/2020
import unittest
from re import search
def in_array(array1, array2):
"""
Finds which words within array1 a... | true |
850ef1bc3215064426abed63def8de9a52fd8cc4 | Brokenshire/codewars-projects | /Python/six_kyu/likes.py | 1,552 | 4.375 | 4 | # Python solution for 'Who likes it?' codewars question.
# Level: 6 kyu
# Tags: Fundamentals, Formatting, Algorithms, and Strings.
# Author: Jack Brokenshire
# Date: 19/02/2020
import unittest
def likes(names):
"""
You probably know the "like" system from Facebook and other pages. People can "like" blog post... | true |
a6c9f153e08a44a65cd9cd314229b7b18a7a60f6 | Brokenshire/codewars-projects | /Python/seven_kyu/find.py | 636 | 4.53125 | 5 | # Python solution for 'Sum of all the multiples of 3 or 5' codewars question.
# Level: 7 kyu
# Tags: FUNDAMENTALS.
# Author: Jack Brokenshire
# Date: 18/05/2020
import unittest
def find(n):
"""
Finds the sum of all multiples of 3 and 5 of an integer.
:param n: an integer value.
:return: the sum of al... | true |
f66d99f8800f29f0da719a02ca7df5666637ff11 | Brokenshire/codewars-projects | /Python/seven_kyu/square_digits.py | 891 | 4.4375 | 4 | # Python solution for 'Simple Pig Latin' codewars question.
# Level: 7 kyu
# Tags: Fundamentals, Mathematics, Algorithms, and Numbers
# Author: Jack Brokenshire
# Date: 11/02/2020
import unittest
def square_digits(num):
"""
Welcome. In this kata, you are asked to square every digit of a number.
For examp... | true |
19937ad4042fe640d47bc40486434f0a2fd86c3e | Brokenshire/codewars-projects | /Python/four_kyu/permutations.py | 962 | 4.1875 | 4 | # Python solution for 'Permutations' codewars question.
# Level: 4 kyu
# Tags: ALGORITHMS, PERMUTATIONS, and STRINGS.
# Author: Jack Brokenshire
# Date: 13/05/2020
import unittest
import itertools
def permutations(string):
"""
Create all permutations of an input string and remove duplicates, if present. This... | true |
e48a8a7273db7f74a15710e01769a58535e3fdcd | Brokenshire/codewars-projects | /Python/seven_kyu/in_asc_order.py | 1,046 | 4.125 | 4 | # Python solution for "Are the numbers in order?" codewars question.
# Level: 7 kyu
# Tags: ALGORITHMS, FUNDAMENTALS, MATHEMATICS, NUMBERS, CONTROL FLOW, BASIC LANGUAGE FEATURES, and OPTIMIZATION.
# Author: Jack Brokenshire
# Date: 06/04/2020
import unittest
def in_asc_order(arr):
"""
Determines if the given... | true |
cf815b0af79820535c15167786267ec93245cfc2 | Brokenshire/codewars-projects | /Python/six_kyu/count_smileys.py | 1,811 | 4.21875 | 4 | # Python solution for 'Count the smiley faces!' codewars question.
# Level: 6 kyu
# Tags: Fundamentals, Regular Expressions, Declarative Programming, Advanced Language Features, and Strings.
# Author: Jack Brokenshire
# Date: 06/02/2020
import unittest
def count_smileys(arr):
"""
Given an array (arr) as an a... | true |
a5746557d0b41917a459998bc393246117f4ba40 | Brokenshire/codewars-projects | /Python/eight_kyu/reversed_string.py | 725 | 4.15625 | 4 | # Python solution for 'Reversed Strings' codewars question.
# Level: 8 kyu
# Tags: FUNDAMENTALS and STRINGS.
# Author: Jack Brokenshire
# Date: 27/06/2020
import unittest
def solution(string):
"""
Complete the solution so that it reverses the string passed into it.
:param string: a string value.
:ret... | true |
ffa315450ca504e52aa8d42b1a66e75bc8273040 | Brokenshire/codewars-projects | /Python/seven_kyu/reverse_letter.py | 880 | 4.25 | 4 | # Python solution for 'Simple Fun #176: Reverse Letter' codewars question.
# Level: 7 kyu
# Tags: FUNDAMENTALS.
# Author: Jack Brokenshire
# Date: 03/05/2020
import unittest
def reverse_letter(string):
"""
Given a string str, reverse it omitting all non-alphabetic characters.
:param string: a string valu... | true |
3187a208fd79756ce2f348354e0439249a5d786a | Brokenshire/codewars-projects | /Python/six_kyu/find_missing_number.py | 991 | 4.21875 | 4 | # Python solution for 'Number Zoo Patrol' codewars question.
# Level: 6 kyu
# Tags: ALGORITHMS, PERFORMANCE, MATHEMATICS, and NUMBERS.
# Author: Jack Brokenshire
# Date: 09/05/2020
import unittest
def find_missing_number(numbers):
"""
akes a shuffled list of unique numbers from 1 to n with one element missin... | true |
2227299998c5819a79b6ad295b37d46e55ad626f | Brokenshire/codewars-projects | /Python/seven_kyu/odd_or_even.py | 972 | 4.46875 | 4 | # Python solution for 'Odd or Even?' codewars question.
# Level: 7 kyu
# Tags: Fundamentals, Arithmetic, Mathematics, Algorithms, Numbers, and Arrays.
# Author: Jack Brokenshire
# Date: 15/02/2020
import unittest
def odd_or_even(arr):
"""
Given a list of numbers, determine whether the sum of its elements is ... | true |
a77599b1b182804ef47d14662e3e4a6f8640af86 | Brokenshire/codewars-projects | /Python/seven_kyu/get_count.py | 806 | 4.1875 | 4 | # Python solution for 'Vowel Count' codewars question.
# Level: 7 kyu
# Tags: Fundamentals, Strings, and Utilities
# Author: Jack Brokenshire
# Date: 09/02/2020
import unittest
def get_count(inputStr):
"""
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, and u as vowe... | true |
bca58d3cfb38f49d0c0a227539eb638498ae5e31 | Brokenshire/codewars-projects | /Python/seven_kyu/convert_my_dollars.py | 2,708 | 4.3125 | 4 | # Python solution for "Currency Conversion" codewars question.
# Level: 7 kyu
# Tags: FUNDAMENTALS, MATHEMATICS, ALGORITHMS, NUMBERS, and ALGEBRA.
# Author: Jack Brokenshire
# Date: 05/04/2020
import unittest
CONVERSION_RATES = {
"Argentinian Peso": 10,
"Armenian Dram": 478,
"Bangladeshi Taka": 1010010,
"Cro... | false |
4c1ef91c4464eb933dfeb493523e27d408a89b30 | Brokenshire/codewars-projects | /Python/seven_kyu/even_chars.py | 1,045 | 4.5 | 4 | # Python solution for 'Return a string's even characters.' codewars question.
# Level: 7 kyu
# Tags: FUNDAMENTALS, STRING, AND SARRAYS.
# Author: Jack Brokenshire
# Date: 16/08/2020
import unittest
def even_chars(st):
"""
Finds all the even characters in a string.
:param st: string value.
:return: a ... | true |
1790d87e28600368578483b8c0511619df107563 | Brokenshire/codewars-projects | /Python/seven_kyu/get_middle.py | 1,284 | 4.15625 | 4 | # Python solution for 'Get the Middle Character' codewars question.
# Level: 7 kyu
# Tags: Fundamentals, and Strings
# Author: Jack Brokenshire
# Date: 10/02/2020
import unittest
def get_middle(s):
"""
You are going to be given a word. Your job is to return the middle character of the word. If the word's len... | true |
204d75a486784b74f705a51a2edc7f5989d5b554 | Brokenshire/codewars-projects | /Python/five_kyu/sum_pairs.py | 1,845 | 4.1875 | 4 | # Python solution for "Sum of Pairs" codewars question.
# Level: 5 kyu
# Tags: FUNDAMENTALS, PARSING, ALGORITHMS, STRINGS, MEMOIZATION, DESIGN PATTERNS, and DESIGN PRINCIPLES.
# Author: Jack Brokenshire
# Date: 08/04/2020
import unittest
def sum_pairs(ints, s):
"""
Finds the first pairs to equal the integer ... | true |
0f702ff15d1d5b9145082f6402c50e7a282d49a8 | Brokenshire/codewars-projects | /Python/eight_kyu/make_negative.py | 714 | 4.21875 | 4 | # Python solution for 'Return Negative' codewars question.
# Level: 8 kyu
# Tags: FUNDAMENTALS and NUMBERS.
# Author: Jack Brokenshire
# Date: 11/04/2020
import unittest
def make_negative(number):
"""
Make a given number negative.
:param number: an integer value.
:return: the integer as a negative nu... | true |
8ce90fd19cf8df52af008dac2f8c61ad9054b3fb | Brokenshire/codewars-projects | /Python/five_kyu/pig_it.py | 880 | 4.21875 | 4 | # Python solution for 'Square Every Digit' codewars question.
# Level: 5 kyu
# Tags: Algorithms
# Author: Jack Brokenshire
# Date: 11/02/2020
import unittest
def pig_it(text):
"""
Move the first letter of each word to the end of it, then add "ay" to the end of the word.
Leave punctuation marks untouched.... | true |
5696eedb1fce1317b7e599a1a3d82c11ed318297 | Brokenshire/codewars-projects | /Python/eight_kyu/bool_to_word.py | 767 | 4.1875 | 4 | # Python solution for 'Convert boolean values to strings 'Yes' or 'No'.' codewars question.
# Level: 8 kyu
# Tags: FUNDAMENTALS, BOOLEAN, and SBEST PRACTICES.
# Author: Jack Brokenshire
# Date: 01/05/2020
import unittest
def bool_to_word(boolean):
"""
Complete the method that takes a boolean value and return... | true |
cfa7febef65c5683971080f1119d2734c91dc229 | thekuldeep07/SDE-SHEET | /majority element.py | 745 | 4.15625 | 4 | # Question :- find the majority element i.e which appear more than n//2 times
# method1:- using two nested loops
# o(n2)
# method2:- using hashmap
# O(n)
# mrthod 3 :- using moore voting algorithm
def findMajority(nums):
maj_index=0
count=0
for i in range(len(nums)):
if nums[i]== nums[maj_index... | true |
d85fc53158e06d73441712a6401b59bf3dd3ebf8 | VicSanNun/DeterminantePython | /main.py | 2,944 | 4.1875 | 4 | #@author: Victor Nunes
#Estudante de Fsica e Engenharia
#Calcular Determinante de Matrizes bsicas
#v.1.0 - 13/05/2018 00:20
#Definindo Funes para Calcular o Determinante
#Ordem 2
def ordem_2(a11, a12, a21, a22):
det = ((a11*a22)-(a21*a12))
return det
#Ordem 3
def ordem_3(a11, a12, a13, a21, a22, a23, a31, a32,... | false |
b1d3f6edbe21e683f6e8596c56ad8a8b0a288ded | Zizo001/Random-Password-Generator | /RandomPasswordGenerator.py | 1,798 | 4.34375 | 4 | """
Author: Zeyad E
Description: random password generator that uses characters, numbers, and symbols
Last Modified: 6/9/2021
"""
import random
import string
import pyperclip #external library used to copy/paste to clipboard
def randomPassword(length):
characters = string.ascii_letters + string.dig... | true |
54bab2af89fe1cb539ebafc3777a39971492d69b | stoltzmaniac/data_munger | /basics.py | 1,293 | 4.40625 | 4 | def mean(data: list) -> float:
"""
Calculates the arithmetic mean of a list of numeric values
:param data: list of numeric values
:return: float
"""
data_mean = sum(data) / len(data)
return data_mean
def variance(data: list) -> float:
"""
Calculates the variance of a list of numeri... | true |
47355faeb3b11b5eed30d09453b463dd564ce36c | carlocamurri/NeuralNetworksKarpathyTutorial | /neural_network_practice.py | 2,065 | 4.40625 | 4 | # Simplified version of multiplication gate to return the output or the gradient of the input variables
def multiply_gate(a, b, dx=1, backwards_pass=False):
if not backwards_pass:
return a * b
else:
da = b * dx
db = a * dx
return da, db
def add_gate(a, b, dx=1, backwards_pass=F... | true |
0676e98b993097962e0014a31daabedc5c1939f5 | rsinger86/software-testing-udacity | /lessons/luhns_algorithm.py | 1,351 | 4.34375 | 4 |
# concise definition of the Luhn checksum:
#
# "For a card with an even number of digits, double every odd numbered
# digit and subtract 9 if the product is greater than 9. Add up all
# the even digits as well as the doubled-odd digits, and the result
# must be a multiple of 10 or it's not a valid card. If the card ... | true |
15054803c30ba692946895d90db8d16ac202c84b | Jefferson-Oliveira1/python | /03_ receber_dados_client.py | 1,143 | 4.34375 | 4 | """
Receber Dados Do Client
input() -> Todo Dado Recebido Via Input e do tipo String
Em Python Stinng e Tudo que Estiver entre:
- Aspas Simples
- Aspas Duplas:
- Aspas Simples Triplas:
- Aspas Duplas Triplas:
Exemplos:
- aspas Simples -> 'Anjolina Jolie'
- aspas duplas -> "Anjolina Jolie"
- aspas Simples tiplas -> '... | false |
9d6e83cb10bca31436fd3a1dc0d7941b29a205eb | Saikat2019/Python3-oop | /5magic_dunder.py | 1,116 | 4.25 | 4 | #magic methods - emulate some built-in methods in python
#implement operator overloding
#dunder means double'_' -- __add__() it's a dunder method
#you can change some special methods , like for __add__
#we define add in our way ... in line 32
class Employee:
num_of_emps = 0
raise_amount = 1.04
def __init__(self, f... | false |
090d2c08fc310eec386602a8686fa8694265967e | alfredleo/ProjectEuler | /problem1.py | 2,667 | 4.5 | 4 | import unittest
from utils import performance
def multiplesof3and5(to):
"""
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.
https://projecteuler.net/problem=1
"... | true |
42997cc7da8ef79ab952c1594a30f878aa649ad0 | purusoth-lw/Python | /10.operator.py | 897 | 4.3125 | 4 | """
Operator:
=========
1.arithmatic Operator
2.Relational Operator
3.Logical Operator
4.Bitwise Operator
5.Assignent Operator
6.Special OPerator
1.arithmatic Operator:
=====================
(+) ----> Addition
(-) ----> Subtraction
(*) ----> Multiplication
(/) ----> Division
(//) ----> Floor ... | false |
80b595700516c71fce8cb9a27d205d18e4a793d1 | Vanzcoder/HackerRankChallenges-Python- | /List_Comprehensions.py | 1,655 | 4.375 | 4 | """
Let's learn about list comprehensions!
You are given three integers X,Y and Z representing the dimensions of a cuboid along with an integer N.
You have to print a list of all possible coordinates given by (i,j,k) on a 3D grid
where the sum of i + j + k is not equal to N.
Here, 0 <= i <= X; 0 <= j <= Y, 0 <= k <= Z
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.