blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
96b0f6d10c1b6f643defb23f2bdebdeeb837724e | npmitchell/lepm | /lepm/timing.py | 1,458 | 4.125 | 4 | from timeit import default_timer as timer
import sys
'''Custom functions for handling timing of function execution
'''
def timefunc(func, *args, **kwargs):
"""Time a function.
Parameters
----------
func : function
the function to time, which accepts arguments *args and **kwargs. Note that th... | true |
774c287a0ea1908c42f418aa51f463d670b642bb | RickXie747/UNSW-18S1-COMP9021- | /Quiz6/Quiz6_2.py | 2,687 | 4.28125 | 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 method change_point_or_points().
# At any stage, the obje... | true |
984b94a305bd42c760dd5f405b2927c57f9f0f6f | Sheersha-jain/Tree | /all-path-tree.py | 1,053 | 4.15625 | 4 | # print all the path from root to leaf of binary tree.
class Root:
def __init__(self, value):
self.left = None
self.right = None
self.key = value
def printpath(parent_node):
path = []
printpathtrail(parent_node, path, 0)
def printpathtrail(parent_node, path, path_length):
if p... | true |
8c60e441224076c52b1f182a17e2ee954c548202 | ChristopherSClosser/code-katas | /src/mult_3_5.py | 437 | 4.25 | 4 | """Kata: Multiples of 3 and 5.
List all the natural numbers that are multiples of 3 or 5.
- **URL**: [challenge url](https://www.codewars.com/kata/multiples-of-3-and-5)
#1 Best Practices Solution by zyxwhut & others
def solution(number):
return sum(x for x in range(number) if x % 3 == 0 or x % 5 == 0)
"""
def... | true |
0730da36901113cda49d40fe551035a4d19acb0d | i-me-you/m.i.t-600-answers | /6.0001/ps1/ps1b.py | 1,453 | 4.15625 | 4 | #mit-introduction to computer science and programming using python 6.0001
#problem set 1 B answer
"""Writeaprogramtocalculatehowmanymonthsitwilltakeyoutosaveupenoughmoneyforadown payment.
given the following parameters"""
total_cost = float(input('Total cost of \'your\' dream home: '))
portion_down_payment = 0.25 ... | true |
50e3e44bb7e2e70dde071f52df95693520e52de4 | hamziqureshi/Python-Basics | /Question_21.py | 1,113 | 4.71875 | 5 | '''
#----------------------------------------#
Question 21
Level 3
Question£º
A robot moves in a plane starting from the original point (0,0).
The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps.
The trace of robot movement is shown as the following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
¡
The nu... | true |
3464504993ebc5ba1e867cf5d5da3651d30b6494 | hamziqureshi/Python-Basics | /Question_4.py | 523 | 4.3125 | 4 | #----------------------------------------#
#Question 4
#Level 1
#Question:
#Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number.
#Suppose the following input is supplied to the program:
#34,67,55,33,12,98
#Then, the output... | true |
90de55f3670f9243af00a1cd28ddcf817e8a599c | edmondyuen917/Track | /JsonTest.py | 2,112 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 19 12:30:13 2021
@author: edmond
"""
# Python program to demonstrate
# Conversion of JSON data to
# dictionary
# importing the module
import json
import csv
import os
import sys
# Opening JSON file
def ReadConfig(filename):
try:
if not os.path.isfile(fi... | true |
8e8f98a3f0be7c9add7eb7de0d399ce361592e45 | oaldri/comp110-21f-workspace | /lessons/dictionaries.py | 1,155 | 4.46875 | 4 | """Demonstrations of dictionary capabilities."""
# Declaring the type of a dictionary
schools: dict[str, int]
# Initialize to an empty dictionary
schools = dict()
# Set a key-value pairing in the dictionary
schools["UNC"] = 19_400
schools["Duke"] = 6_717
schools["NCSU"] = 26_150
# Print a dictionary literal rep... | true |
2108814f7ae442e47380ef996381c37582a89e03 | Fjohnpaul/RFID-Project | /SQL/DatabaseWSQL.py | 1,968 | 4.1875 | 4 | import sqlite3
# Testing Ground for MySqlLite https://www.youtube.com/watch?v=byHcYRpMgI4
#Connect to database
conn = sqlite3.connect("customer.db") ## This will create a table or find one
#create a cursor
pointerCursor = conn.cursor()
#_-------------------------------------------------------------------------------... | true |
6376ccd7faf07f9f9b6b576b0df7b8ba573a9ca9 | Hopeguy/1FA661-Introduction-to-Python-for-Physicists-and-Engineers | /lab-2.py | 2,453 | 4.40625 | 4 | import numpy as np
import math
#Question 1
my_arr = np.array([1,2,3,4])
print(my_arr[1])
print(my_arr[1:3])
my_arr[1] = 6
my_arr[2:3] = 42
my_arr = np.array([[1,2,3],[1,2,3]])
print(my_arr[1,2])
"""
first arg is the row, and second is the collum, or you can see it as
the first argument gives you the element in th... | true |
d72455c89c3314203c416239c9e0e577404a7286 | rasmuskkilp/python_basics | /homework_python_1.py | 1,048 | 4.28125 | 4 | # declare some strings
# prompt user for his/her name
prompt_name = input('what is your name?')
# Save it to some variables with good names
name_1 = prompt_name
# prompt the user for some random number between 0 - 99
prompt_num = input('enter number between 0-99')
# store it in a variable called: user_chosen_num
user... | true |
4a3e18bca56c35d118923a1aa02ed15d1b9dc7e4 | SarahStamps/Assignment-2 | /code.py | 2,119 | 4.3125 | 4 | import numpy as np
import math as m
import matplotlib.pyplot as plt
"""
Make sure you make this module as modular as you can.
That is add as many functions as you can.
1) Have a main function
2) A function to capture user input, this could be inside your "main" function
3) A function to calculate the projectile motion
... | true |
9e62fc7fbc9ec80c0ae251a9e6f70c8b36f0caa8 | EoghanDelaney/Problem-Sets | /begins-width-t.py | 809 | 4.15625 | 4 | # For this problem I used the Python documentation http://strftime.org/
# Once datetime can determine the day of the week in string format the rest is straightforward
import time
from datetime import datetime
date = datetime.now() # using datetime get today's date
day = date.strftime("%A") # get the day of the week ... | true |
9d77d1f4910685ef00b65283d9b618a7511f9429 | khanmaster/python_dev | /01_python_dev/06_OOP/04_OOP_four_pillars/animal.py | 945 | 4.59375 | 5 | # creating Animal class
class Animal:
# __init__ to declare attributes
def __init__(self):
self.alive = True
self.spine = True
self.alive = True
self.lungs = True
# create methods of our animal
def breathe(self):
return "keep breathing to stay alive"
# crea... | true |
b6e035f8b953e317d719ab2432393f2b213358c5 | subahan983/Basic-programs-in-python | /Object Oriented Programming/Constructor.py | 371 | 4.40625 | 4 | # This program shows the use of constructor without any parameters.
class MyClass:
def __init__(self):
print('I am in constructor')
def hello(self):
print('I am in hello method')
obj = MyClass() # Creating an object reference to MyClass class which invokes the default constructor.
obj.hello() # Ca... | true |
c814d8780ffa5dfc6647b98b4e19f000967a5866 | IkeyBenz/InterviewProblems | /linked_list_problems.py | 640 | 4.28125 | 4 | from rotate_linked_list import LinkedList
def middle_from_linked_list(lst: LinkedList):
'''
Given a singly linked list, finds the middle value in the list
'''
middle = len(lst) // 2
for index, val in enumerate(lst):
if index == middle:
return val
if __name__ == '__main__'... | true |
f6dbc972c0411551baddca50e1f4614eb64e3ef1 | RZaga09/practicepython | /31.py | 1,291 | 4.28125 | 4 | # Let’s say the word the player has to guess is “EVAPORATE”.
# For this exercise, write the logic that asks a player to guess a letter and
# displays letters in the clue word that were guessed correctly.
# For now, let the player guess an infinite number of times until they get the entire word.
# As a bonus, keep t... | true |
361f466ae1ba3516331eb2be91fd345599e3f7b8 | RZaga09/practicepython | /6.py | 300 | 4.28125 | 4 | # Ask the user for a string and print out whether this string is a palindrome or not.
# (A palindrome is a string that reads the same forwards and backwards.)
print('Type a word')
word = input()
c = ([i for i in word])
d = list(reversed(c))
print('Palindrome') if d == c else print('Not')
| true |
8b9e0ca6cba1fd44a050a5addf04defef958cd67 | SwagatikaM/python | /arrays.py | 364 | 4.125 | 4 | numbers = [2, 4, 6, 1, 8, 9, 22, 54, 5, 3]
numbers.sort()
print(numbers[-1])
max = numbers[0]
for number in numbers:
if number > max:
max = number
print(max)
#Matrix in Python - 2D array
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
print(matrix[0][1])
for row in matrix... | true |
c75bdb64a75593edb993866273a9ff4e47c8b442 | daiyomiura/study_python | /editor/tutorial/numpy/numpy_tutorial.py | 2,418 | 4.53125 | 5 | # Basic data Types
# Numbers
x = 3
print(type(x)) # Prints "<class 'int'>"
print(x) # Prints "3"
print(x + 1) # Addition: prints "2"
print(x - 1) # Subtraction: prints "2"
print(x * 2) # Multiplication: prints "6"
print(x ** 2) # Exponentiation: prints "9"
x += 1
print(x) # Prints "4"
y = 2.5
prin... | true |
3cd09eb6a5fffe3d41f0398a7386921ff6b1a2aa | AKippins/Olivia-Asteris-Tutoring | /Lesson 7/leap_year.py | 1,396 | 4.4375 | 4 | # Write a function which decides if any year entered from the keyboard is a leap year.
# Write a main function which takes the year from the user and calls the function,
# outputting the results to the user.
# When we get a problem
# Break the problem down.
# We get more managable pieces
# Get it into terms we can ... | true |
14621287b75601be3d7940f16ba8fb033194b790 | memermaid/code_in_place | /KhansoleAcademy/khansole_academy.py | 760 | 4.25 | 4 | """
Program randomly generates a simple addition problem for the user
until the user has gotten 3 problems correct in a row.
"""
import random
def main():
correct = 0
while correct != 3:
num1 = random.randint(1, 100)
num2 = random.randint(1, 100)
total = num1 + num2
print("What... | true |
39f3e4ca6d3552d9973a5a8e1145d5835c3a959b | brianshukwit/mind-palace | /python/practice_section/Vowel Replace.py | 398 | 4.1875 | 4 | # Vowel Replace
def translate(phrase):
translation = ""
for vowel in phrase:
if vowel.lower() in "aeiou":
if vowel.isupper():
translation = translation + "X"
else:
translation = translation + "x"
else:
translation = translation... | true |
bf54becd482780326318177d66150b2b463bed11 | rohitmi0023/cs_programs | /sort/insertion_sort/insertion_sort.py | 1,017 | 4.46875 | 4 | def insertion_sort_func(lists):
# n - 1 iterations starting from the 1 index i.e. 2nd element
for i in range(1, len(lists)):
# Picked up card to be the key
key = lists[i]
j = i - 1
# i - 1 iterations till the key is greater
while j >= 0 and key < lists[j]:
# ... | true |
2e63dfa75f3246438e7360a9973b60a3f7b497e0 | erdodule/pytasks | /task5.py | 217 | 4.1875 | 4 | print("Input your height: ")
height_ft = int(input("Feet: "))
height_inch = int(input("Inches: "))
height_inch += height_ft * 12
height_cm = round(height_inch * 2.54, 1)
print("Your height is : %d cm." % height_cm)
| true |
eed40b347d7a715004ea8835d8c830803673b55b | shubhomedia/Learn_Python | /functions/nested_function.py | 356 | 4.125 | 4 | #nested function
def add(x,y,z): # simple function
sum = x + y + z
return sum
#nested function
def outer(a):
def nested(b):
return b * a;
a = nested(a)
return a
print(outer(10))
# nested function like loop
def f(a):
def g(b):
def h(c):
return a * b * c
retur... | true |
f3337e74454542e570b2a4076288ac2502cca3dd | shubhomedia/Learn_Python | /format_method.py | 488 | 4.28125 | 4 | # print somethings and using format method.
print("Today I Had {0} cups of {1}".format(2,"coffee"))
print("prices: ({x},{y},{z})".format(x = 10,y = 1.50, z = 5))
print("The {vehicle} had {0} crashes in {1} months".format(5,6, vehicle = 'car'))
print('{:<20}'.format("text")) # create space after text
print('{:>20}'.for... | true |
8c09e38d84223d70888b71b53794c418ce475a9e | CodingGuruInTraining/2905_Lab_1_Simple_Game | /Part_1_Guess_Number.py | 949 | 4.15625 | 4 | # This program runs a simple guessing game.
# Import random library
import random
def main():
# Gets a random number between 1 and 10
randomNumber = random.randint(1, 10)
# Displays introduction message and instruction
print("Greetings! Pick a number, any number ")
print("between 1 and 10.")
... | true |
f0478e2c331842b6994d4c10fcb3e16ce1bfa201 | sagelga/prepro59-python | /24_ChangeSpeedUnit.py | 332 | 4.34375 | 4 | """This program will convert m/s into different unit of speed"""
def converter():
"""This should work"""
speed = float(input())
print("%.4f" %(speed * 3.2808) + " foot per second.")
print("%.4f" %(speed * 2.2369) + " miles per hour.")
print("%.4f" %(speed * 3.6000) + " kilometer per hour.")
c... | true |
f058403b1d87563cfbb22a85c0e6c5c5ab350670 | dshapiro1dev/RuCoBo | /src/examples/loops/PizzaShop.py | 2,280 | 4.40625 | 4 | # Make an application that keeps building a pizza order until the person says quit
# Create lists with common yes & no responses
yes = ['y', 'yes', 'yeah', 'please', 'okay', 'absolutely']
no = ['n', 'no', 'nope', 'never', 'please no']
done = ['all done', 'quit', 'nothing', 'no more', 'stop', 'no', 'none', 'done']
# Cr... | true |
44226989b0c45fbde02f81ed968032401bb30864 | dshapiro1dev/RuCoBo | /src/examples/loops/SandwichShop.py | 769 | 4.1875 | 4 | # Make a list of sandwiches that can be ordered with a quanity, have a random flow of orders until exhausted
from random import choice
# Create a list of sandwiches that are available, with a quantity for each
sandwiches = {'turkey': 5, 'blt': 5, 'meatball': 5, 'veggie': 5, 'italian': 5}
print("The deli is open & tak... | true |
2fde6515a4576929b0d26bf44695af803752f23e | lukasbasista/Daily-coding-problem | /012/main.py | 1,140 | 4.375 | 4 | """
This problem was asked by Amazon.
There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function
that returns the number of unique ways you can climb the staircase. The order of the steps matters.
For example, if N is 4, then there are 5 unique ways:
1, 1, 1,... | true |
eccae2e9512884fe5ede94d2d1741696c2a0feb9 | ejrach/exercises-mosh | /Project-GuessingGame.py | 474 | 4.125 | 4 | secret_number = 9
tries = 0
guess_limit = 3
#while loops can have else blocks
while tries < guess_limit:
guessed_number = int(input('Enter your guess: '))
tries += 1
if guessed_number == secret_number:
print("You win!")
break
#this runs if the while loop finishes without a break happening. ... | true |
0c341450dc9108bf7b1ddb90320170e0988f9150 | ejrach/exercises-mosh | /2DLists.py | 346 | 4.125 | 4 | #[
# 1 2 3
# 4 5 6
# 7 8 9
# ]
# 2D lists
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
#to access the first row, second column (item with value of 2)
print(matrix[0][1])
# to modify that value
matrix[0][1] = 20
print(matrix[0][1])
# to print the items in a 2D list
for row in matrix:
for item in r... | true |
1f99fd8d47fedffaff9d145440897677a5da27f7 | sarozzx/Python_practice_2 | /10.py | 577 | 4.34375 | 4 | # Write a function that takes camel-cased strings (i.e.
# ThisIsCamelCased), and converts them to snake case (i.e.
# this_is_camel_cased). Modify the function by adding an argument,
# separator, so it will also convert to the kebab case
# (i.e.this-is-camel-case) as well.
def change_cam(str):
str1=str[0].lower()
... | true |
f838b0055927daaf601553dc97838df244874f83 | Chrybear/CSC-310-HW1 | /HW1 problem 2.py | 923 | 4.21875 | 4 | # Homework problem #2
# setting up the funtion to check if the sequence of int values has a pair whose product is odd.
# I am assuming that, in the event a sinlge int is entered, it should return "False" since there is no
# pair with which to test with.
def isodd(nums): #main function to test if it is odd
last... | true |
b95d96973ee0a20295f4d733786ebba1b230d450 | swang2000/BinaryTree | /Onesibling.py | 1,255 | 4.25 | 4 | '''
Print all nodes that don’t have sibling
2.1
Given a Binary Tree, print all nodes that don’t have a sibling (a sibling is a node that has same parent. In a Binary
Tree, there can be at most one sibling). Root should not be printed as root cannot have a sibling.
For example, the output should be “4 5 6” for the foll... | true |
aab31341d17d79236fdd421d0c51447f2d9f08f0 | swang2000/BinaryTree | /MiniBTdepth.py | 783 | 4.125 | 4 | '''
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from root node down to the nearest leaf node.
'''
import CdataS.BianrySearchTree as BST
def miniBTdepth(bt):
if bt == None:
return 0
if bt.left_child == None and bt.right_child == None:
... | true |
d2ef2fba24ef60c79c5efc51335cfd0b9a8aefc0 | muditabysani/Linked-List-1 | /Problem1.py | 1,396 | 4.125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseList1(self, head):
# Time Complexity : O(n) where n is the number of elements in the array
# Space Complexity : O(n) because we are storing the entire li... | true |
18dd46c324550c461a3b8fbf9b66a17d34fbe00f | divs17/1BM17CS133 | /even.py | 536 | 4.15625 | 4 |
numbers = []
n = int(input("Enter number of elements: \t"))
for i in range(1, n+1):
allElements = int(input("Enter element:"))
numbers.append(allElements)
print("all the elements ", numbers)
even_lst=[]
for j in numbers:
if j % 2 == 0:
even_lst.append(j)
print("even elements ", eve... | true |
b8fad9b81c4cb91c929c5541eee8753c22bbb6dd | praveenmathew/Python_Scripts | /Mini_Project_1.py | 425 | 4.21875 | 4 | #Based on challenges put up by https://www.teclado.com/30-days-of-python/python-30-day-3-project
#Simple script to read, calculate data with minimal arithmetic and display to output.
name = input("Please enter employee name: ").strip().title()
hourly_wage = float(input("Please enter hourly_wage: "))
work_hours = flo... | true |
7a57a87ea88d1ef21c0925c63cbea5e492ccfdc5 | AkhileshPandeyji/Python_All | /Python_Basics/Python_listcomp_generators.py | 1,544 | 4.40625 | 4 | # list comprehensions : [expression]
# Are lists that are loaded and retrieved whole once at a time and then executed.
# They contain sequential data that follows some rule.
xyz = [i for i in range(10)]
print(xyz)
print(type(xyz))
# Generators : (expression)
# types:generator variable ,generator function
# Are lists ... | true |
5d8ff7c96d5a30133fc831978736661f524540c7 | AkhileshPandeyji/Python_All | /Python_Basics/PythonVariables.py | 722 | 4.25 | 4 | #printing to the console
print("Hello World!!")
#Numerical Variables
num1 = -34 #int
num2 = 23.04 #float/double
num3 = (34+23)-24 #expressional value
num4 = 23+45j #complex no
print(num1,num2,num3,num4)
#string Variables
string1 = "Akhilesh Pandey"
string2 = string1
string3 = string1+" "+ string2
#character variable... | true |
66f0216a5edae920f79833bd710ae11c7771efe9 | hitesh091/Interactive_PyGames | /Guess the number.py | 2,687 | 4.21875 | 4 |
#==========To run, click the link below================#
########################################################
http://www.codeskulptor.org/#user29_gahmhlJRV57Hnja.py
########################################################
# template for "Guess the number" mini-project
# input will come from buttons and an input... | true |
a4ad8c133db07113449d53de801f18a5e60dfaf4 | Amatuer-/Test | /MSDS/Partition.py | 2,011 | 4.125 | 4 | def swap(a, i, j):
assert 0 <= i < len(a), f'accessing index {i} beyond end of array {len(a)}'
assert 0 <= j < len(a), f'accessing index {j} beyond end of array {len(a)}'
a[i], a[j] = a[j], a[i]
def simplePartition(a, pivot):
# print(pivot)
n = len(a)
i = -1
j = 0
for j in range(n-1):
... | true |
33d79b2be6141fe735856e48f0326f3a3985410d | Krithip/Project97 | /Project97.py | 486 | 4.375 | 4 | import random
number = random.randint(1, 10)
chances = 3
print("guess a number between 1 to 10")
while chances>0:
guess = int(input("enter your guess"))
if(guess == number):
print("Congratulations! You guessed correctly!")
break
elif guess<number:
print("Your guess was wron... | true |
6106000262c8c27de6702c31b99f56de5f3b51eb | BLINDICY/hello-world | /Sample.py 9.py | 898 | 4.375 | 4 | '''
build a calculator that provides the
amount of miles per gallon
miles per gallon = miles driven/gallons used
'''
print("This program calculates mpg.")
miles_driven = float(input("Enter miles driven:"))
gallons_used = float(input("Enter gallons used:"))
mpg = miles_driven / gallons_used
print("Your mi... | true |
72a4de9fb48040ec09c2462995f5d2b23787e4c2 | solouniverse/Python | /B2BSWE/Patterns/Prog_Number_Columns.py | 285 | 4.15625 | 4 | n = int(input("Enter no of test runs: "))
while n > 0:
rows = int(input("Enter no of rows: "))
columns = int(input("Enter no of columns: "))
for row in range(1, rows+1):
for col in range(1, columns+1):
print(col, end=" ")
print()
n = n - 1 | true |
9e3b9f1020c13c8227c0e73824b0ca82e40ec692 | pavel-prykhodko96/source | /Python/CrashCourse/Chapter7/7_4_to_7_7.py | 660 | 4.15625 | 4 | #7_4
# ~ toppings = []
# ~ while True:
# ~ topping = input('Please add the topping to the pizza: ')
# ~ if topping != 'quit':
# ~ toppings.append(topping)
# ~ print("Your pizza consists of: ")
# ~ for value in toppings:
# ~ print(" " + value)
# ~ else:
# ~ bre... | true |
57adfacdab7cfcf5e3bc2a9daeed3e5dc053dcd9 | ayazhemani/hackerrank-py | /python2/implementation/sequenceEquation/sequenceEquation.py | 727 | 4.15625 | 4 | """Solution for HackerRank challenge: Sequence Equation
"""
def sequence_equation(seq):
"""Given a set of numbers, return the second index lookup
(index of index) of the range of the sequence.
Args:
seq (int[]): Initial sequence of numbers
Returns:
int[]: Second index array of sequenc... | true |
36d954c35eabba69f32f92161814abd1048918c7 | CRTC-Computer-Engineering/CRTC-Python-Examples | /CodeHS/6/4/9/Temperature-Converter-Travis.py | 609 | 4.28125 | 4 | # Write your function for converting Celsius to Fahrenheit here.
# Make sure to include a comment at the top that says what
# each function does!
def convert_celsius_to_fahrenheit(num):
return float((num - 32) / 1.8)
# Now write your function for converting Fahrenheit to Celsius.
def convert_fahrenheit_to_celsiu... | true |
1ec63bcdda5d67149c28e27954daddc5cf92ffa4 | CRTC-Computer-Engineering/CRTC-Python-Examples | /CodeHS/3/5/9/Recipe-Joe.py | 1,245 | 4.25 | 4 | """
This program made by Joe S
"""
servings = -1 # Set the servings to a null value
shopping_list = ["mixed greens", "blueberries", "walnuts"] # Create a list of all the things we need to shop for
object_list = [] # Create an empty list where we will store objects
class ingredient(): # This class defines the ingredi... | true |
04c6c639cc9d4d637624d7908d924755b3583223 | JacobRuter/RockPaperScissors | /RockPaperScissors/RockPaperScissors.py | 967 | 4.1875 | 4 | import random;
play = True;
over = False;
choices = ['rock', 'paper', 'scissors'];
Userchoice = input() #Variable to take in user input
print ("My choice is ", Userchoice)
Computerchoice = choices[random.randint(0, 2)]
print ("The computer choose ", Computerchoice)
while (play == True):
if Userchoice == 'rock' :
... | true |
93bcaa902b4ecd7145c644255e0c4cb2773d2def | Mahii143/python-workshop | /CO4 questions/q no 10.py | 594 | 4.46875 | 4 | ''' Q10: You must implement the function ''appendStringToFile'' which accepts two string values F and S.
F represents a filename and S represents a string. The program must open the file F
and append the string S with the existing content.
'''
#function defined to append user input string into an existing file
def app... | true |
4f66a7f53d1cb9f4ca033bed66d6acae5093009f | Ankitapalle/Basic_python_projects | /gp_btw_dates.py | 409 | 4.15625 | 4 | """Write a Python program to calculate number of days between two dates.
Sample dates : (2014, 7, 2), (2014, 7, 11)
Expected output : 9 days"""
from datetime import date
n = int(input("Enter date"))
a = int(input("Enter month"))
b = int(input("Enter year"))
c = int(input("Enter date"))
d = int(input("Enter month"))... | true |
ec70323d0512171030f9ab08e660a5cfb76ca41a | Ankitapalle/Basic_python_projects | /Examination_schedule.py | 404 | 4.125 | 4 | """Write a Python program to display the examination schedule. (extract the date from exam_st_date).
exam_st_date = (11, 12, 2014)
Sample Output : The examination will start from : 11 / 12 / 2014"""
date = int(input("Enter the date - "))
month = int(input("Enter the month - "))
year = int(input("Enter the year - "))
... | true |
f06c60a554755dcfbe2be586435232ffc4f1024b | antondelchev/For-Loop---More-Exercises | /04. Grades.py | 1,189 | 4.125 | 4 | students_attended = int(input())
students_b_grade = 0
students_c_grade = 0
students_d_grade = 0
students_f_grade = 0
grades_total = 0
for i in range(1, students_attended + 1):
grade = float(input())
if grade < 3.0:
students_f_grade += 1
grades_total += grade
elif 3 <= grade ... | true |
04a5ace1194b9db6a3a8ea58ca650626b782ff9d | jlehenbauer/python-projects-public | /codesignal/is_tandem_repeat.py | 1,688 | 4.15625 | 4 | '''
Easy
Codewriting
300
Determine whether the given string can be obtained by one concatenation of some string to itself.
Example
For inputString = "tandemtandem", the output should be
isTandemRepeat(inputString) = true;
For inputString = "qqq", the output should be
isTandemRepeat(inputString) = false;
For inputS... | true |
16fa3cf6ec4321de8975fb0851e2e2aee5edfe41 | SrikanthGoli/data-structures-algorithms | /algorithms/binary_search.py | 808 | 4.1875 | 4 |
# Binary Search - O(logN)
def binarySearch_recursive(key, input, left, right):
"""Searches the given element recursively"""
if right >= left:
mid = (left+right)//2
if input[mid] == key:
return mid
elif key < input[mid]:
return binarySearch_recursive(key, inpu... | true |
3f424498d47958d4364e9eb0d01aca776f14295e | CSCD01/team_14-project | /pandas_demo/netflix-example.py | 1,659 | 4.1875 | 4 | import pandas as pd
from functools import reduce
import os
# author: Dax Patel
# script to analyze netflix data
# for given list of actors and actresses, we use
# pandas to extract and manipulate data to compare
# different stars' presence on Netflix per year
# data source: https://www.kaggle.com/shivamb/netflix-shows... | true |
44703d92c60a9d908b23321761753c8d528ff612 | Isaac-Newt/python-learning | /Pre College/Scripts/Games/battleship_2.py | 1,456 | 4.34375 | 4 | from random import randint
# Create "board" list
board = []
# Create board layout
for x in range(5):
board.append(["0"] * 5)
# Prints the board
def print_board(board):
for row in board:
print " ".join(row)
# Begin the game
print "Let's play Battleship!"
print_board(board)
# Choose rando... | true |
46a3d854709790ed430be3b8682c6c89997b1418 | NdeyJobe/games | /batteryship.py | 2,443 | 4.21875 | 4 | """In this project I will build a simplified, one-player version of the classic board game Battleship!
In this version of the game, there will be a single ship hidden in a random location on a 5x5 grid.
The player will have 10 guesses to try to sink the ship."""
from random import randint
from time import sleep
bo... | true |
53472c77a29981867a423bdde548904235b8a3bb | estraviz/pybites-exercises | /251_Introducing_Pandas_Series/series.py | 1,462 | 4.1875 | 4 | """
Bite 251. Introducing Pandas Series
"""
import string
import pandas as pd
def basic_series() -> pd.Series:
"""Create a pandas Series containing the values 1, 2, 3, 4, 5
Don't worry about the indexes for now.
The name of the series should be 'Fred'
"""
return pd.Series([1, 2, 3, 4, 5], name='... | true |
b1fba1d30c2f5c5b71191eee152dcfc3d4ee9cb7 | evans-osinaike/Introduction-to-Python-Programming | /password_generator.py | 1,131 | 4.125 | 4 | # TODO: First import the `random` module
import random as r
# We begin with an empty `word_list`
word_file = "word_list.txt"
word_list = []
# We fill up the word_list from the `word_list.txt` file
with open(word_file,'r') as words:
for line in words:
# remove white space and make everything lowercase
word = line... | true |
c10a647cfdd8ae8f692af04ca3aac8c81cf22c39 | MrDrewShep/Python_fundamentals | /review_of_fundamentals.py | 2,372 | 4.125 | 4 |
# Want to edit items? LIST
# Strict set of sequence? TUPLE
# Want everything to be unique? SET
# List
# CRUD
my_list = [2, 4, 3] # create
first_item = my_list[0] # read
#nested_item = my_list[0][2] # read within a nested list
my_slice = my_list[-2::] # returns last 2
print(my_slice)
my_slice = my_list[::-1]... | true |
0bbd2ccf66e4e1a33d41ad0e1c96bd1e2bc2044c | rohansharma777/Python_Assignments | /Assignment_1/prog1.py | 220 | 4.1875 | 4 | length=int(input("Enter length of the rectangle.: "))
breadth=int(input("Enter the breadth of rectangle.: "))
print("Area = ",length*breadth)
if length==breadth:
print("Voila ! The rectangle turned out to be a square") | true |
a003c4b9b3af81122a59ca84db3ec0313e96fa82 | trinbar/coding-challenges | /Arrays-Lists-Hashmaps/reverse_words.py | 795 | 4.5625 | 5 | """
Your team is scrambling to decipher a recent message, worried it's a plot to
break into a major European National Cake Vault. The message has been mostly
deciphered, but all the words are backward! Your colleagues have handed off the
last step to you.
Write a function reverse_words() that takes a message as a l... | true |
0ab4f79aa27f74ea5566b6b30803fc0d0ed59314 | Gor-Ren/firecode.io | /src/python/level_1/flip_vertical_axis.py | 547 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 5 17:25:05 2017
@author: Gor-Ren
"""
def flip_vertical_axis(matrix):
"""Flips a matrix across the vertical axis.
A matrix in the form of a list of lists, where each sublist represents a row
is flipped across its vertical centre line.
Args:
mat... | true |
3fb5016f0e77f75183d13e44165b51a2b6180061 | Gor-Ren/firecode.io | /src/python/level_3/excel_column_name_to_number.py | 2,202 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 16 17:27:33 2017
@author: Gor-Ren
"""
def excel_column_name_to_number(column_title):
"""Translate an Excel column reference from letter(s) to a number.
Excel column references may be expressed as letters, e.g. 'A', 'D', 'AZ'.
These have a corresponding nume... | true |
02f6857e57fb6f179c8d27752c9509a467306825 | ewong8/ewong8.github.io | /Assignments/Assignment 2/cis122-assign02-pythagorean.py | 1,048 | 4.53125 | 5 | '''
CIS 122 Summer 2020 Assignment 2
Author: Ethan Wong
Description: Defining a function to use the Pythagorean Theorem
References: https://www.rapidtables.com/calc/math/pythagorean-calculator.html;
http://mathforum.org/dr.math/faq/faq.pythagorean.html;
https://docs.python.org/3/library/math.html
'''
# Question... | true |
bf98bb43200c617963007656c9a184eb39052fac | natemccoy/pyintro | /simplemodule.py | 1,714 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This is a simple module example. It has a few functions and some data.
You can import this module if you are in the same directory by doing:
import simplemodule
The functions and data variables declared in this file can then be used by
typing:
simp... | true |
9d1ee27a62cf1d1054016c5fad6a03d633f692f8 | wduncan21/Challenges | /leetcode/algo/647. Palindromic Substrings.py | 960 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 9 22:54:12 2017
@author: Mr.Wang
Given a string, your task is to count how many palindromic substrings in this
string.
The substrings with different start indexes or end indexes are counted as
different substrings even they consist of same characters.
Example 1:
Inp... | true |
2105fba30872c0d1526e936ca9930752978d3438 | Mansi149/Python | /43 Radio.py | 1,631 | 4.25 | 4 | """
PROBLEM 43
Write a program to print the output of the following poblem statement :-
Characteristics | Functionality
---------------------------------------
color |
brand |
ACPower |
headphone |
|
power_led | power_switch ( O... | true |
265467a34a8798b1c02127c5f74c07fa2729e3d0 | webclinic017/New-Osama-Python | /Completed code/Education fees.py | 1,837 | 4.125 | 4 | """
A program for calculating the total amount deposited in the bank to cover the school
expenses completely throughout the school years, and the remainder is zero after the end of the
school years
"""
# (ver 1) account money and check it (12-2-2020 by Osama)
n1 = int(input('What is the value of the annual school expe... | true |
6edb8f4a11829c755da100e7e5bb99b5cf964120 | machinelearningdeveloper/aoc_2016 | /01/directions.py | 2,092 | 4.125 | 4 | import re
def load_directions(filename):
"""Load directions from a file."""
with open(filename) as f:
return [direction.strip().strip(',') for direction
in f.readline().strip().split()]
def turn(orientation, direction):
"""Given an orientation on the compass
and a direction (... | true |
cd10774a38f1a95e31fee570b7e91c4a50567682 | hackoregon/civicu-pythonii-summer-2017 | /student-work/cassandradelieto/Building Classes/working_with_classes.py | 1,521 | 4.25 | 4 | <<<<<<< HEAD
#Make the class have at least three attributes in its __init__ method and at least one method that
#combines two of these attributes in some way.
class MealPreparation:
people_min = 1
def __init__(self, people, pans, ingredients):
self.people = people
self.pans = pans
self... | true |
fb1ecb5dd3b5fc9d74345dd46aed919cbb00b018 | hackoregon/civicu-pythonii-summer-2017 | /student-work/sambeck/week_1/group_challenge/names_challenge.py | 2,095 | 4.125 | 4 | """
The goal of this challenge is to create a function that will take a list of
names and a bin size and then shuffle those names and return them in a
list of lists where the length of the inner lists matches the bin size.
For example calling the function with a list of names and the size of 2 should return
a lis... | true |
e911f43a2c731b07a59b0b39fa80cb2a8a2c91f8 | sydneykuhn/ICS3U-Unit4-05-Python-Sum-Loop | /loop_sum.py | 864 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Sydney Kuhn
# Created on: Oct 2020
# This program calculates the sum of positive numbers
def main():
# this function is a loop
total = 0
# input
number_amount_as_string = input(
"How many numbers would you like to add together : "
)
# process & o... | true |
ead9dad89cb04fb1ae14fc07902e59979907f069 | akshxrx/Translator-Eng-Ben- | /main.py | 2,142 | 4.21875 | 4 | #!/usr/bin/python3
'''
This program is from p. 81 Figure 5.9 "Translating text (badly)" of
our Gutag textbook.
You can use it as a starter program for assignment 2.
The output from the program is:
--------------------------------------
Input: I drink good red wine, and eat bread.
Output: Je bois "good" rouge ... | true |
9de7998ff8e5726574d7f7ab1dab0f290c46fe9e | gracepfohl/SIPPartnerAssignments | /DrawShapes.py | 978 | 4.84375 | 5 | from turtle import * #imports entire turtle library already created
import math
# Name your Turtle.
### Write your code below:
#this draws a square
#how do i loop this to user input? Helpppppppppp
def Draw_Shape(num_sides): #num_sides=argument and parameter
# Set Up your screen and starting positio... | true |
149b10ab41f0b765a8f1b08e71237842e39696a2 | MarsBighead/mustang | /Python/hackerrank/primality.py | 363 | 4.125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the primality function below.
def primality(n):
if n < 2: return "Not prime"
for i in range(2,int(math.sqrt(n))+1):
if n % i == 0:
return "Not prime"
return "Prime"
if __name__ == '__main__':
n = 12
... | true |
7a6e51fe2379f4ed34fb57ef67a56b190c5e8812 | Sidhus234/Python-Dev-Course | /Codes/Session 3/Session 3 - Python Basics - List.py | 2,433 | 4.21875 | 4 | # List is ordered sequence of objects
li = [1,2,3,4,5]
li2 = ['a', 'b',' c', 'd']
li3 = ['a', 1,2,'apple', 'True']
# Data Structure: Way to organise information
amazon_cart = ['notebooks', 'sunglasses']
amazon_cart[0]
amazon_cart[1]
amazon_cart[3]
# List Slicing
amazon_cart = [
'notebooks',
... | true |
bfa9b44b9b9a7956c589f77ebc3a8b92b5320dce | s-torn/labb1 | /labb1.py | 607 | 4.375 | 4 | import math
print('Welcome to volume calculator!')
while True:
choice=input('Would you like to calculate the volume of a cube or a tetrahedon? \nType C or T, or leave empty to exit program.\n')
if choice=='':
break
elif choice=='c' or choice=='C':
cube=float(input('Enter cube side length in ... | true |
341a65b2b92441adeacbcbb3f4400c3ab77fe6e0 | andrewrowland1/RowlandAS-Yr12ComputerScience | /ACS Programming Task/06InputValidation.py | 638 | 4.15625 | 4 | #program that asks the user for a number between 1 and 10 and then outputs the times table for that number
i_Number = int(input("Please input a number between 1 and 10"))
#Check if number is between 1 and 10
if i_Number != 99:
while i_Number < 1 or i_Number > 10:
i_Number = int(input("Please input a number ... | true |
ff76cd187b2c26456106f5ba2a8970013af9eb74 | andrewrowland1/RowlandAS-Yr12ComputerScience | /ACS Programming Task/09SecondsAnyone.py | 411 | 4.21875 | 4 | #program that takes in the hours, minutes and seconds then outputs the total number of seconds
hours = int(input("Please input the number of hours"))
minutes = int(input("Please input the number of minutes"))
seconds = int(input("Please input the number of seconds"))
HoursToSeconds = hours * 3600
MinutesToSeconds = mi... | true |
554e9317cfd3620297958628dce7ef56caac344a | wufei74/lpthw | /ex6.py | 1,381 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 9 13:54:00 2020
@author: WufeiNewPC
"""
types_of_people = 10 #Variable
x = f"There are {types_of_people} types of people." #x is a string that includes our previous variable, also a string
binary = "binary"
do_not = "don't"
y = f"Those who know {binary} ... | true |
b88b313638cf463e78e950263daaa4c23bba3b2d | shilab/Courses | /multiplication.py | 505 | 4.15625 | 4 | #!/usr/bin/python
# An algorithm for multiplication
def multiplication (x, y):
# Input: Two integers x and y with y >= 0
# Output: The product of x and y
if y == 0:
return 0
z = multiplication (x, y // 2)
# z = multiplication (x, y >> 1) # right shift by 1 : divide by 2
if y % 2... | true |
9e6728a6064f89921a5c26423f8f2051fb2593fe | tbindi/hackerrank | /utopian_tree.py | 1,018 | 4.5 | 4 | '''
The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian tree sapling is planted at the onset of the spring. Its height is 1 met... | true |
0e7189bbd5e6781322ae078966ef9c64c6851204 | tbindi/hackerrank | /quick_sort.py | 844 | 4.25 | 4 | '''
The previous challenges covered Insertion Sort, which is a simple and intuitive sorting algorithm. Insertion Sort has a running time of O(N2) which isn't fast enough for most purposes. Instead, sorting in the real-world is done with faster algorithms like Quicksort, which will be covered in the challenges that foll... | true |
5441eaec30a4f9966171b2b26e7f7e870c0f0e74 | akash20aeccse123/Python | /divisible_by_five_or_eleven.py | 230 | 4.1875 | 4 | n=int(input("Enter any Number:"))
if(n%5==0):
print("Number is Divisible by 5, SuccessFully.")
elif(n%11==0):
print("Number is Divisible by 11,SuccessFully.")
else:
print("Number is Not Divisible by 5 and 11.")
| true |
6cb577bb9f1277a3e98080727afcff35db97b025 | akash20aeccse123/Python | /area_rectangle.py | 226 | 4.4375 | 4 | '''3.program to obtain length and breadth of a rectangle and
calculate its area.'''
length=float(input("Enter lenght:"))
breadth=float(input("Enter breadth:"))
area=(length*breadth)
print("Area of rectangle=",area)
| true |
52f3269cac3ef4832f981628020b565ecdb05172 | Michaelnstrauss/Byte | /inclass2_6/n_class26.py | 305 | 4.28125 | 4 | #!/usr/bin/env python3
value = int(input('Give me a number: '))
if value > 100:
print("That's a big number")
if value % 2 == 0:
print('Also it is even')
else:
print('Also it is odd')
elif value > 10:
print("That's not too small")
else:
print("That's a small number")
| true |
5efda9d85ecbfef3e4e521181b23ddf1046a6d76 | Karlasalome/python-challenge | /HW2_python/PyPoll/python hw.py | 1,827 | 4.25 | 4 | #import csv file and The total number of months included in the dataset
import csv
input_File ="C:\\Users\\KarlaSalome\\Desktop\\COLNYC201904DATA3\\homework\\03-Python\\Instructions\\PyBank\\Resources\\budget_data.csv"
totalMonths = 0
totalRev = 0
pastRev = 0
highestIncRev = 0
lowestDecRev = 0
#create lists to store r... | true |
c6c0641c14295c9b795233455a1f79250d03d9e4 | Robert-Rutherford/learning-Python | /practiceProblems/oopCalculator.py | 664 | 4.15625 | 4 | # Simple OOP Calculator
# site: https://edabit.com/challenge/ta8GBizBNbRGo5iC6
# Create methods for the Calculator class that can do the following:
#
# Add two numbers.
# Subtract two numbers.
# Multiply two numbers.
# Divide two numbers.
class Calculator:
def add(self, num1, num2):
return num1 + num2
... | true |
a7904035e3f200c5f393d63c968de180ae99d2d3 | Robert-Rutherford/learning-Python | /practiceProblems/fullnameAndEmail.py | 1,105 | 4.40625 | 4 | # Fullname and Email
# site: https://edabit.com/challenge/gB7nt6WzZy8TymCah
# Create the instance attributes fullname and email in the Employee class. Given a person's first and last names:
#
# Form the fullname by simply joining the first and last name together, separated by a space.
# Form the email by joining the fi... | true |
7f09d7d596c934a8956121ddfff2bffe38da293a | stewartstout/dsp | /python/q8_parsing.py | 1,240 | 4.40625 | 4 | #The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program to... | true |
09909b7ab1b60f5c575816e734fb6e78276d8051 | 4OKEEB90/COM404 | /1-basics/03-decision/01-if/bot.py | 357 | 4.28125 | 4 | #Ask what kind of book this is.
print("What type of book is this?")
#define the variable "book" as a string variable to be input by the user.
book = str(input())
#If statement to give a specific response to "adventure" books
if book == "adventure":
print("I like adventure books!")
#A print statement to end the proc... | true |
c7583dca55e506efd68867b022ccc79b0d98fc45 | chaoswork/leetcode | /036.ValidSudoku.py | 1,972 | 4.25 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author: Chao Huang (huangchao.cpp@gmail.com)
Date: Wed Feb 21 12:11:45 2018
Brief: https://leetcode.com/problems/valid-sudoku/description/
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.
The Sudoku board could be partially filled, where empty... | true |
7baeb5e08cdf3b2ad91af050c37defa4d78fa4cc | BibhushaSapkota/pyhtonlabwork | /programming/dragon.py | 273 | 4.34375 | 4 | # write a program to print sum of three numbers
firstnumber=float(input("enter first number"))
secondnumber=float(input("enter second number"))
thirdnumber=float(input("enter third number"))
sum=firstnumber+secondnumber+thirdnumber
print("the sum of three number is" ,sum)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.