blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
7482d942e97a74847cbcdccf6e4809450238e845 | greenfox-velox/bizkanta | /week-04/day-03/08.py | 523 | 4.1875 | 4 | # create a 300x300 canvas.
# create a square drawing function that takes 2 parameters:
# the x and y coordinates of the square's top left corner
# and draws a 50x50 square from that point.
# draw 3 squares with that function.
from tkinter import *
root = Tk()
canvas = Canvas(root, width='300', height='300')
canvas.p... | true |
a35413038dc25063fa1bda9bf93a868010510ce9 | greenfox-velox/bizkanta | /week-03/day-02/functions/39.py | 250 | 4.1875 | 4 | names = ['Zakarias', 'Hans', 'Otto', 'Ole']
# create a function that returns the shortest string
# from a list
def shortest_str(list):
short = list[0]
for i in list:
if len(i) < len(short):
short = i
return short
print(shortest_str(names))
| true |
0c1cedbaa3a31450caae59fd00de54f21f2da412 | greenfox-velox/bizkanta | /week-04/day-04/09.py | 329 | 4.125 | 4 | # 9. Given a string, compute recursively a new string where all the
# adjacent chars are now separated by a "*".
def separated_chars_with_stars(string):
if len(string) < 2:
return string[0]
else:
return string[0] + '*' + separated_chars_with_stars(string[1:])
print(separated_chars_with_stars('... | true |
055b1173cbe0bc9a383f8863016bdf26b1285a00 | choogiesaur/codebits | /data-structures/py-trie.py | 1,350 | 4.21875 | 4 | # Implement a version of a Trie where words are terminated with '*'
# Efficient space complexity vs hashtable
# Acceptable time complexity. O(Key_Length) for insert/find
# Handle edge cases:
# - Empty String
# - Contains non alphabet characters (numbers or symbols)
# - Case sensitivity
class StarTrie:
# Each node ... | true |
406bbf1479e8c0bf119b566e4aab895ecdbc01e8 | choogiesaur/codebits | /data-structures/py-stack.py | 1,319 | 4.28125 | 4 | ### A Python implementation of a Stack data structure
class PyStack:
# Internal class for items in stack
class StackNode:
def __init__(self, val = 0, child = None):
self.val = val
self.child = child
# Check if stack has items
def is_empty(self):
return self.size() == 0
# Get number of items in stack
... | true |
7513472d24d6090efd5a3c9def621a59b41405ab | jchavez2/COEN-144-Computer-Graphics | /Jason_C_Assigment1/assignment1P2.py | 1,936 | 4.21875 | 4 | #Author: Jason Chavez
#File: assignment1P2.py
#Description: This file rasters a circle using Bresenham's algorithm.
#This is taken a step further by not only rastering the circle but also filling the circle
#The file is saved as an image and displayed using the computers perfered photo drawing software.
from PIL imp... | true |
dc9d95ec63607bec79a790a0e0e898bebe9998bc | nisarggurjar/ITE_JUNE | /ListIndex.py | 559 | 4.1875 | 4 | # Accessing List Of Items
li = ["a", 'b', 'c', 'd', 'e', 'f', 'g']
# index
print(li[2])
# Slicing
print(li[2:5]) # <LIST_NAME>[starting_index : ending_index] ==> ending_index = index(last_value) + 1
# stepping (Index Difference)
print(li[::2]) # <LIST_NAME>[starting_index : ending_index : index_difference]
# N... | true |
a714402ef8921b97870d62f24222575ba39fc5cb | Wakarende/chat | /app/main/helpers.py | 1,230 | 4.1875 | 4 | def first(iterable, default = None, condition = lambda x: True):
"""
Returns the first item in the `iterable` that
satisfies the `condition`.
If the condition is not given, returns the first item of
the iterable.
If the `default` argument is given and the iterable is empty,
or if it has no items matching ... | true |
cb8a0d965ca2b62c8b50e54621e50f524366727d | tcaserza/coding-practice | /daily_coding_problem_20.py | 1,003 | 4.125 | 4 | # Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical.
#
# For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8.
#
# In this example, assume nodes with the same value are the exact same node objects.
#
# Do this ... | true |
3b5e97f33277ee345b584501f9495e4f38c0b0e6 | tcaserza/coding-practice | /daily_coding_problem_12.py | 882 | 4.375 | 4 | # 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, 1
# 2, 1, 1
# 1, 2, 1
# 1,... | true |
4fbb7f1164e0e80689ac64a1f3a34d7e5c6f2f5b | tcaserza/coding-practice | /daily_coding_problem_18.py | 702 | 4.1875 | 4 | # Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of
# each subarray of length k.
#
# For example, given array = [10, 5, 2, 7, 8, 7] and k = 3, we should get: [10, 7, 8, 8], since:
#
# 10 = max(10, 5, 2)
# 7 = max(5, 2, 7)
# 8 = max(2, 7, 8)
# 8 = max(7, 8, 7)
... | true |
1f76f9b05ec4a73c36583154bc431bd3746f659e | cseharshit/Registration_Form_Tkinter | /registration_form.py | 2,786 | 4.28125 | 4 | '''
This program demonstrates the use of Tkinter library.
This is a simple registration form that stores the entries in an sqlite3 database
Author: Harshit Jain
'''
from tkinter import *
import sqlite3
#root is the root of the Tkinter widget
root = Tk()
#geometry is used to set the dimensions of the window
root.geom... | true |
0a121ab2cf53f4696a7ec57311ff0017549023ea | khushboo2243/Object-Oriented-Python | /Python_OOP_1.py | 1,850 | 4.46875 | 4 | #classes aallows logially grouping of data and functions in a way that's easy to resue
#and also to build upon if need be.
#data and functions asscoaited with a specific class are called attributes and methods
#mathods-> a function associated with class
class Employee: #each employee will have specific attributes... | true |
eac8dadba99e51df25d45a2a66659bdeb62ec473 | whung1/PythonExercises | /fibonacci.py | 1,570 | 4.1875 | 4 | # Need to increase recursion limit even when memoization is used if n is too large
# e.g. sys.setrecursionlimit(100000)
def fibonacci_recursive_memo(n, fib_cache={0: 0, 1: 1}):
"""Top-down implementation (recursive) with memoization, O(n^2)"""
if n < 0:
return -1
if n not in fib_cache:
f... | true |
93ef926c3ebafaf36e991d7d381f9b189e70bfea | whung1/PythonExercises | /Leetcode/Algorithms/453_minimum_moves_to_equal_array_elements.py | 1,424 | 4.15625 | 4 | """
https://leetcode.com/problems/minimum-moves-to-equal-array-elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.
Example:
Input:
[1,2,3]
Output:
3
Explanation:... | true |
0fe354cb21928d0aebc186e074b6483b8aa2d00b | trinadasgupta/BASIC-PROGRAMS-OF-PYTHON | /diamond using numbers.py | 841 | 4.3125 | 4 | # Python3 program to print diamond pattern
def display(n):
# sp stands for space
# st stands for number
sp = n // 2
st = 1
# Outer for loop for number of lines
for i in range(1, n + 1):
# Inner for loop for printing space
for j in range(1, sp + 1):
print (" ", end = ' ')
#... | true |
a74e1b0117319af55c10e7c7952a07228664481b | S-EmreCat/GlobalAIHubPythonHomework | /HomeWork2.py | 500 | 4.125 | 4 | # -*- coding: utf-8 -*-
first_name=input("Please enter your FirstName: ")
last_name=input("Please enter your last name: ")
age=int(input("Please enter your age: "))
date_of_birth=int(input("Please enter date of birth year: "))
User_Info=[first_name,last_name,age,date_of_birth]
if User_Info[2]<18:
print("You cant ... | true |
004d7e7459f43bf5ac8f37d56342df192e1a862e | Susaposa/Homwork_game- | /solutions/2_functions.py | 1,202 | 4.125 | 4 | # REMINDER: Only do one challenge at a time! Save and test after every one.
print('Challenge 1 -------------')
# Challenge 1:
# Write the code to "invoke" the function named challenge_1
def challenge_1():
print('Hello Functional World!')
challenge_1()
print('Challenge 2 -------------')
# Challenge 3:
# Uncommen... | true |
4513babc8ea339c4ba1b9d02fe360b9ad431cb3a | kszabova/lyrics-analysis | /lyrics_analysis/song.py | 939 | 4.34375 | 4 | class Song:
"""
Object containing the data about a single song.
"""
def __init__(self,
lyrics,
genre,
artist,
title):
self._lyrics = lyrics
self._genre = genre
self._artist = artist
self._title = title
... | true |
eafd2e749b9261a9c78f78e6459846a19094a786 | VedantK2007/Turtle-Events | /main.py | 2,842 | 4.34375 | 4 | print("In this project, there are 4 different patterns which can be drawn, and all can be drawn by the click of one key on a keyboard. If you press the 'a' key on your keyboard, a white pattern consisting of triangles will be drawn. Or, if you press the 'b' key on your keyboard, an orange pattern consisting of squares ... | true |
5eb61a6e224d6a447c211b2561f8fa07b1864c38 | lyh71709/03_Rock_Paper_Scissors | /03_RPS_comparisons.py | 1,742 | 4.1875 | 4 | # RPS Component 3 - Compare the user's action to the computer's randomly generated action and see if the user won or not
valid = False
action = ["Rock", "Paper", "Scissors"]
while valid == False:
chosen_action = input("What are you going to do (Rock/Paper/Scissors)? ").lower()
cpu_action = "rock"
# Rock ... | true |
ced55ee757f946247dfa6712bd1357c303fbc8e1 | jayanta-banik/prep | /python/queuestack.py | 703 | 4.125 | 4 | import Queue
'''
# Using Array to form a QUEUE
>>> from collections import deque
>>> queue = deque(["Eric", "John", "Michael"])
>>> queue.append("Terry") # Terry arrives
>>> queue.append("Graham") # Graham arrives
>>> queue.popleft() # The first to arrive now leaves
'Eric'
>>> queue.... | true |
5bce167313c249ba3ae12cb62787711b2d42d07c | dsrlabs/PCC | /CH 5/5_1_ConditionalTests.py | 775 | 4.34375 | 4 | print()
color = 'black' #The color black is assigned to variable named color
print("Is color == 'black'? I predict True.") #Here, the equality sign is used to determine if the value on each side of the operator matches.
print(color == 'black') #Here the result of the equality prediction is printed
print("\nIs color =... | true |
1228d627795969c4325f56aec74d589468da8e51 | dsrlabs/PCC | /CH 8/8_8_UserAlbum.py | 615 | 4.15625 | 4 | print()
def make_album(artist_name, album_title):
"""Return a dictionary with the album information"""
album_info = {'artist_name' : artist_name.title(), 'album' : album_title.title()}
return album_info
print("\nPlease enter the artist name:")
print("Please enter the album title:")
print("[enter 'q' at any... | true |
1d86f145ce68ca28fb615b990f72b4ddde489415 | dsrlabs/PCC | /CH 8/8_7_album.py | 540 | 4.1875 | 4 | # Thus block of code calls a function using a default
# an f-string is used.
print()
def make_album(name, album_title, tracks =''):
"""Return a dictionary with the album information"""
album_info = {'artist_name' : name.title(), 'album' : album_title.title()}
if tracks:
album_info['tracks'] = tracks... | true |
3d177f31578123ad01d5733c178fbd81d89adcdd | PMiskew/Coding_Activities_Python | /Activity 1 - Console Activity/ConsoleFormulaStage1.py | 621 | 4.625 | 5 | #In this stage we will make a simple program that takes in
#values from the user and outputs the resulting calculation
#Some chnage
print("Volume of a Cylinder Formula: ")
name = input("Please input your name: ")
print("The volume of a cylinder is")
print("V = (1/3)*pi*r\u00b2")
#Input
radius = input("Input radius(... | true |
93deaa3d236efa015c0525e1328be94642630492 | edunzer/MIS285_PYTHON_PROGRAMMING | /WEEK 3/3.5.py | 1,278 | 4.21875 | 4 | # Shipping charges
def lbs(weight):
if weight <= 2:
cost = weight * 1.50
print("Your package will cost: $",cost)
elif weight >= 2 and weight <= 6:
cost = weight * 3.00
print("Your package will cost: $",cost)
elif weight >= 6 and weight <= 10:
cost = weight * 4.00
... | true |
8294cf5fb457523f714f4bfd345756d282ed54f6 | svetlmorozova/typing_distance | /typing_distance/distance.py | 1,094 | 4.3125 | 4 | from math import sqrt
import click
from typing_distance.utils import KEYBOARDS
@click.command()
@click.option('-s', '--string', help='Input string', prompt='string')
@click.option('-kb', '--keyboard', help='What keyboard to use',
type=click.Choice(['MAC'], case_sensitive=False), default='MAC')
@click.... | true |
4ffe1b31fbdc21fc2dec484ff36470b9ac842e0f | NisAdkar/Python_progs | /Python Programs/WhileLoop.py | 1,724 | 4.4375 | 4 | """
1.While Loop Basics
a.create a while loop that prints out a string 5 times (should not use a break statement)
b.create a while loop that appends 1, 2, and 3 to an empty string and prints that string
c.print the list you created in step 1.b.
2.while/else and break statements
a.create a while loop that does the... | true |
51bf1f588e2230dbf128dba5439dfd7ff0ac4680 | sonisparky/Ride-in-Python-3 | /4.1 Decision Making.py | 1,824 | 4.4375 | 4 | #Python 3 - Decision Making
#3.1 Python If Statements
'''if test expression:
statement(s)'''
'''a = 10
if a == 10:
print("hello Python")
# If the number is positive, we print an appropriate message
num = 3
if num > 0:
print(num, "is a positive number.")
print("This is always printed.")
... | true |
0b701cf8b1945f9b0a29cf2398776368a2919c03 | Aravindkumar-Rajendran/Python-codebook | /Fibonacci series check.py | 1,123 | 4.25 | 4 | ```python
''' It's a python program to find a list of integers is a part of fibonacci series'''
#Function to Check the first number in Fibonacci sequence
def chkFib(n):
a=0;b=1;c=a+b
while (c<=n):
if(n==c):
return True
a=b;b=c;c=a+b
return False
#Function to check the list in ... | true |
8ba50e3abc4f884b876a4ddd9c7a216d33fb443e | AbelWeldaregay/CPU-Temperatures | /piecewise_linear_interpolation.py | 2,286 | 4.34375 | 4 | import sys
from typing import (List, TextIO)
def compute_slope(x1: int, y1: int, x2: int, y2: int) -> float:
"""
Computes the slope of two given points
Formula:
m = rise / run -> change in y / change in x
Args:
x1: X value of the first point
y1: Y value of the first point
x2: X value of second point
y2: ... | true |
e1dd2e0f656d266fb8d469943a169daa11f8bbc6 | Jtoliveira/Codewars | /Python/listFiltering.py | 557 | 4.25 | 4 | """
In this kata you will create a function that takes a list of non-negative integers and
strings and returns a new list with the strings filtered out.
"""
def filter_list(l):
result = []
#letters = "abcdefghijklmnopqrstuwvxyz"
for item in l:
if type(item) == int or type(item) == float:
... | true |
d92355f8065ef618216326ef8da15cd5d5d171b2 | omariba/Python_Stff | /oop/gar.py | 2,875 | 4.1875 | 4 | """
THE REMOTE GARAGE DOOR
You just got a new garage door installed.
Your son (obviously when you are not home) is having a lot of fun playing with the remote clicker,
opening and closing the door, scaring your pet dog Siba and annoying the neighbors.
The clicker is a one-button remote that works like this:
If the door... | true |
a32e9f1ed7b0de2069df756e27bf264763f66f89 | Ntare-Katarebe/ICS3U-Unit4-07-Python-Loop_If_Statement | /loop_if_statement.py | 392 | 4.28125 | 4 | #!/usr/bin/env python3
# Created by: Ntare Katarebe
# Created on: May 2021
# This program prints the RGB
# with numbers inputted from the user
def main():
# This function prints the RGB
# process & output
for num in range(1001, 2000 + 2):
if num % 5 == 0:
print(num - 1)
el... | true |
6ddaba1a37e239c325bfd313d4f20ef5f0079c9a | pranay573-dev/PythonScripting | /Python_Lists.py | 1,447 | 4.3125 | 4 | '''
#################################Python Collections (Arrays)###############################################
There are four collection data types in the Python programming language:
bytes and bytearray: bytes are immutable(Unchangable) and bytearray is mutable(changable):::::[]
List is a collection which is ordered... | true |
29b440e1130521cb7fdc12a381a215b2725c90fa | aggiewb/scc-web-dev-f19 | /ict110/3.5_coffee_shop_order.py | 578 | 4.21875 | 4 | '''
This is a program that calculates the cost of an order at a coffee shop.
Aggie Wheeler Bateman
10/10/19
'''
COFFEE_PER_POUND = 10.50 #dollars
def main():
print("Welcome to Coffee Inc. order calculation system. This system will calcute the cost of an order.")
print()
orderAmount = f... | true |
000fec743dd12b9254000e20af4d3b38f6d4e28c | aggiewb/scc-web-dev-f19 | /ict110/itc110_midterm_gas_mileage.py | 600 | 4.28125 | 4 | '''
This is a program to calculate the gas mileage for your car based off of the
total miles traveled and the gallons of gas used for that distance.
Aggie Wheeler Bateman
11/6/19
'''
def getMiles():
miles = int(input("Please enter the total amount of miles traveled: "))
return miles
def getGas():
gas = ... | true |
930cd2911cb85cb7036434b242538e75a3f6e9ac | aggiewb/scc-web-dev-f19 | /ict110/enter_read_file.py | 607 | 4.125 | 4 | '''
This is a program a program that allows a user to enter data that is
written to a text file and will read the file.
Aggie Wheeler Bateman
10/17/19
'''
from tkinter.filedialog import askopenfilename
def main():
print("Hi! I am Text, and I will allow you to enter a text file, and I will read the file.")
p... | true |
44d93bddb7c00d2cc12e9203f52083a25cf05bb8 | ryanyb/Charlotte_CS | /gettingStarted.py | 1,952 | 4.6875 | 5 |
# This is a python file! Woo! It'll introduce printing and variable declaration.
# If you open it in a text editor like VS Code it should look nifty and like
# well, a bunch of text.
# As you can see, all of this stuff is written without the computer doing anything about it
# These are things called comme... | true |
32b051aab1979bdbfebd0a416184a735eb8e298a | ProngleBot/my-stuff | /Python/scripts/Weird calculator.py | 849 | 4.21875 | 4 | try:
x = int(input('enter first number here: '))
y = int(input('enter second number here: '))
operators = ['+','-','*', '/']
operator = input(f'Do you want to add, multiply, subtract or divide these numbers? use {operators}')
def add(x, y):
result = x + y
return result
def subtr... | true |
dc2a08d86e16079ae334445d83ce45fa77c27c79 | TareqJudehGithub/higher-lower-game | /main.py | 2,274 | 4.125 | 4 | from replit import clear
from random import choice
from time import sleep
from art import logo, vs, game_over_logo
from game_data import data
def restart_game():
game_over = False
while game_over == False:
restart = input("Restart game? (y/n) ")
if restart == "y":
# Clear screen between rounds:
... | true |
60c9b68333f9a33ca526e156e0947db767f69892 | ianneyens/Ch.03_Input_Output | /3.0_Jedi_Training.py | 1,461 | 4.65625 | 5 | # Sign your name:Ian Neyens
# In all the short programs below, do a good job communicating with your end user!
# 1.) Write a program that asks someone for their name and then prints a greeting that uses their name.
"""
print()
name = str(input("What is your name?:"))
print()
print("Hello", name)
'''
# 2. Write a prog... | true |
d30a8339678effc870e6dc5ad82917d1282acff9 | Laikovski/codewars_lessons | /6kyu/Convert_string_to_camel_case.py | 796 | 4.625 | 5 | """
Complete the method/function so that it converts dash/underscore delimited words into camel casing.
The first word within the output should be capitalized only if the original word was capitalized
(known as Upper Camel Case, also often referred to as Pascal case).
Examples
"the-stealth-warrior" gets converted to "... | true |
eaa974e6367967cadc5b6faa9944fbaaa760557f | Laikovski/codewars_lessons | /6kyu/Longest_Palindrome.py | 511 | 4.28125 | 4 | # Longest Palindrome
#
# Find the length of the longest substring in the given string s that is the same in reverse.
#
# As an example, if the input was “I like racecars that go fast”, the substring (racecar) length would be 7.
#
# If the length of the input string is 0, the return value must be 0.
# Example:
#
# "a" -... | true |
cd4a14aa502abbcba0519428a684b01be17c0427 | Laikovski/codewars_lessons | /6kyu/New_Cashier_Does_Not_Know.py | 1,292 | 4.28125 | 4 | # Some new cashiers started to work at your restaurant.
#
# They are good at taking orders, but they don't know how to capitalize words, or use a space bar!
#
# All the orders they create look something like this:
#
# "milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"
#
# The kitchen staff are threatenin... | true |
aecd95cb9a29890136688bffeb3d378dc70574fd | bryandeagle/practice-python | /03 Less Than Ten.py | 648 | 4.34375 | 4 | """
Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list
that areless than 5.
Extras:
1. Instead of printing the elements one by one, make a new list that has all
the elements less than 5 from this list in it and print o... | true |
6f9a10bbf9d0064cc111e7be3a9ed458fc615e46 | bryandeagle/practice-python | /18 Cows And Bulls.py | 1,358 | 4.375 | 4 | """
Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit that the user guessed correctly in the correct place, they
have a “cow”. For every digit the user guessed correctly in the w... | true |
2fec0f04fce0558c8f4a2d9ff8ced1f36c8b2c14 | bryandeagle/practice-python | /06 String Lists.py | 406 | 4.4375 | 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.)
"""
string = input('Give me a string:').lower()
palindrome = True
for i in range(int(len(string)/2)):
if string[i] != string[-i-1]:
palindrome = Fa... | true |
2f12138956586c72818de4c13b73eb04e0e0d9fb | stybik/python_hundred | /programs/27_print_dict.py | 309 | 4.21875 | 4 | # Define a function which can generate a dictionary where the keys are numbers
# between 1 and 20 (both included) and the values are square of keys.
# The function should just print the values only.
numbers = int(raw_input("Enter a number: "))
dic = {n: n**2 for n in range(1, numbers)}
print dic.values()
| true |
646f89a757e6406543bec77dab04d9f61f97308d | stybik/python_hundred | /programs/10_whitespace.py | 342 | 4.125 | 4 | # Write a program that accepts a sequence of whitespace
# separated words as input and prints the words after
# removing all duplicate words and sorting them
# alphanumerically.
string = "Hello world, I am the boss boss the world should fear!"
words = string.split(" ")
print ("The answer is: ")
print (" ".join(sorte... | true |
ddcc1201c4fdd399c98f67689fc6a90cc5677069 | stybik/python_hundred | /programs/6_formula.py | 480 | 4.15625 | 4 | # Write a program that calculates and prints the value according to the given formula:
# Q = Square root of [(2 * C * D)/H]
# Following are the fixed values of C and H:
# C is 50. H is 30.
# D is the variable whose values should be input to your program in a comma-separated sequence.
import math
c = 50
h = 30
val = [... | true |
2f86621b953186c71e491a3fd164c96deca3b7f2 | stybik/python_hundred | /programs/21_robot.py | 1,045 | 4.53125 | 5 | # 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 numbers after the direction are steps. Please write a program to compute the dist... | true |
61585cbf2848306932b35664530ba2ba925d1f22 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_3/jparshle@bu.edu_hw_3_8_1.py | 1,687 | 4.3125 | 4 | """
Joey Parshley
MET CS 521 O2
30 MAR 2018
hw_3_8_1
Description: Write a program that prompts the user to enter a Social Security
number in the format ddd-dd-dddd, where d is a digit. The program displays
Valid SSN for a correct Social Security number or Invalid SSN otherwise.
"""
def ssn_val... | true |
30b1452a33dc76783e68a00f0a2a329acb1402a9 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_2_3.py | 774 | 4.40625 | 4 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_2_3
Write a program that reads a number in feet, converts it to meters, and
displays the result.
One foot is 0.305 meters.
"""
# Greet the user and prompt them for a measurement in feet
print("\nThis program will read a measurement in feet from ... | true |
2a4854737b37f2659e6b11ca4dd1e91fd0162448 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_3_1.py | 2,292 | 4.53125 | 5 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_3_1
Write a program that prompts the user to enter the length from the center of
a pentagon to a vertex and computes the area of the pentagon
"""
# import the math module to use sin and pi
import math
# Contstants to be used in functions
# used to c... | true |
be808b86dd30bf6983fa13f28a5feba15ef6efce | puneet4840/Data-Structure-and-Algorithms | /Queue in Python/1 - Creating Queue using python List.py | 1,889 | 4.25 | 4 | # Queue is the ordered collection of items which follows the FIFO (First In First Out) rule.
## Insertion is done at rear end of the queue and Deletion is done at front end of the queue.
print()
class Queue():
def __init__(self):
self.size=int(input("\nEnter the size of the Queue: "))
self.que=lis... | true |
9467799833a6c78fc4097870f8ec7c917f45ca68 | puneet4840/Data-Structure-and-Algorithms | /Stack in Python/3 - Reverse a string using stack.py | 571 | 4.1875 | 4 | # Reverse a string using stack.
# We first push the string into stack and pop the string from the stack.
# Hence, string would be reversed.
print()
class Stack():
def __init__(self):
self.stk=list()
self.str=input("Enter a string: ")
def Push(self):
for chr in self.str:
se... | true |
79b5b14d8006fc6ee9598d4bfc46518289510fe4 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/2 - Doubly Linked List/4 - Insertion before specific node.py | 2,390 | 4.25 | 4 | # Inserting a node before a specific node in the linked list.
print()
class Node():
def __init__(self,data):
self.prev=None
self.data=data
self.next=None
class Linked_list():
def __init__(self):
self.start=None
def insert_node(self,data):
temp=Node(data)
if... | true |
1292d9ae7544923786c98b67c4c2c426314f3cac | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Binary Search using python.py | 798 | 4.125 | 4 | # Binary Search using Python.
# It takes o(logn) time to execute the algorithm.
l1=list()
size=int(input("Enter the size of list: "))
for i in range(size):
l1.append(int(input(f"\nEnter element {i+1}: ")))
l1.sort()
def Binary_Search(l1,data,low,high):
if(low>high):
return False
else:
... | true |
d03538d4dca196e6fda1d7508233a8f9ce2852a6 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/5 - Queue using Linked LIst/12 - Queue using Linked lIst.py | 1,436 | 4.1875 | 4 | # Implementing Queue using Linked list.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linkd_list():
def __init__(self):
self.start=None
def Insert_at_end(self,data):
temp=Node(data)
if self.start==None:
self.start=te... | true |
9a46984cc1655739334a16a11f1f252dc20cdd91 | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Print numbers from 1 to 10 in a way when number is odd add 1 ,when even subtract 1.py | 393 | 4.3125 | 4 | # Program to print the numbers from 1 to 10 in such a way that when number is odd add 1 to it and,
# when number is even subtract 1 from it.
print()
def even(n):
if n<=10:
if n%2==0:
print(n-1,end=' ')
n+=1
odd(n)
def odd(n):
if n<=10:
if n%2!=0:
... | true |
fa0bf4de5631301d3ee23a655a62980dde419eab | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/1 - Singly Linked List/2 - Creating linked list.py | 1,266 | 4.21875 | 4 | # Linked List is the collection of nodes which randomly stores in the memory.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linked_List():
def __init__(self):
self.start=None
def Insert_Node(self,data):
temp=Node(data)
if self.s... | true |
e565859face5705525c10fe91e6e9e5111088773 | stuartses/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 1,552 | 4.53125 | 5 | #!/usr/bin/python3
"""1. Divide a matrix
This module divides all elements of a matrix in a number
Corresponds to Task 1.
Holberton School
Foundations - Higher-level programming - Python
By Stuart Echeverry
"""
def matrix_divided(matrix, div):
"""Function that divides all elements of a matrix in a number
Args... | true |
b00edcdc40657f72d82766fd72da4de8d4b7c8cc | stuartses/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 699 | 4.125 | 4 | #!/usr/bin/python3
"""0. Integers addition
This module adds two input integer numbers.
Corresponds to Task 0.
Holberton School
Foundations - Higher-level programming - Python
By Stuart Echeverry
"""
def add_integer(a, b=98):
"""Functions that adds two integers
Args:
a (int): first argument. Could ... | true |
4ff3c3cd3009d5a9984928b54a89748b7792bec5 | MyrPasko/python-test-course | /lesson11.py | 567 | 4.25 | 4 | # String formatting
name = 'Johny'
age = 32
title = 'Sony'
price = 100
print('My name is ' + name + ' and I\'m ' + str(age) + ' old.')
print('My name is %(name)s and I\'m %(age)d old.' % {'name': name, 'age': age})
print('My name is %s and I\'m %d old. %s' % (name, age, name))
print('Title: %s, price: %.2f' % ('Sony'... | true |
e23e20632d635370cf05b8e1f6c0079cf1e173c3 | FedoseevAlex/algorithms | /tests/insert_sorting_test.py | 1,750 | 4.1875 | 4 | #!/usr/bin/env python3.8
from unittest import TestCase
from random import shuffle
from algorithms.insert_sorting import increase_sort, decrease_sort
class InsertionSortTest(TestCase):
"""
Test for insertion sorting functions
"""
def test_increasing_sort_static(self):
"""
Testing ins... | true |
29847749ede6139ce34c257e2aed969f03a0bd13 | srikanthpragada/PYTHON_03_AUG_2021 | /demo/libdemo/list_customers_2.py | 1,097 | 4.125 | 4 | def isvalidmobile(s):
"""
Checks whether the given string is a valid mobile number.
A valid mobile number is consisting of 10 digits
:param s: String to test
:return: True or False
"""
return s.isdigit() and len(s) == 10
def isvalidname(s):
"""
Checks whether the given name contai... | true |
30e0997cb7359cd6f14b98717c68d409c6f68aec | dalexach/holbertonschool-machine_learning | /supervised_learning/0x04-error_analysis/1-sensitivity.py | 684 | 4.3125 | 4 | #!/usr/bin/env python3
"""
Sensitivity
"""
import numpy as np
def sensitivity(confusion):
"""
Function that calculates the sensitivity for each class
in a confusion matrix
Arguments:
- confusion: is a confusion numpy.ndarray of shape (classes, classes)
where row indices represe... | true |
e62b085add02d42761f087761eeccfe1c55b53d4 | dalexach/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/4-moving_average.py | 608 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Moving average
"""
def moving_average(data, beta):
"""
Function that calculates the weighted moving average of a data set:
Arguments:
- data (list): is the list of data to calculate the moving average of
- beta (list): is the weight used for the moving average
Retu... | true |
b01b43fb042dd2345fd2778fd4c75418b95b7a97 | dalexach/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/1-normalize.py | 621 | 4.28125 | 4 | #!/usr/bin/env python3
"""
Normalize
"""
import numpy as np
def normalize(X, m, s):
"""
Function that normalizes (standardizes) a matrix
Arguments:
- X: is the numpy.ndarray of shape (d, nx) to normalize
* d is the number of data points
* nx is the number of features
- m: is a ... | true |
2e7755488ee4f5f74d8120d2d10ef04b0446c37b | Wet1988/ds-algo | /algorithms/sorting/quick_sort.py | 1,132 | 4.21875 | 4 | import random
def quick_sort(s, lower=0, upper=None):
"""Sorts a list of numbers in-place using quick-sort.
Args:
s: A list containing numbers.
lower: lower bound (inclusive) of s to be sorted.
upper: upper bound (inclusive) of s to be sorted.
Returns:
s
"""
if upper is... | true |
6d5fa9841aaed33cade266f564debefbd97e82a0 | JustinCee/tkinter-handout | /handout exercise.py | 1,103 | 4.375 | 4 | # this is to import the tkinter module
from tkinter import *
# this function is to add the numbers
def add_numbers():
r = int(e1.get())+int(e2.get())
label_text.set(r)
def clear():
e1.delete(0)
e2.delete(0)
root = Tk()
# the below is the size of the window
root.geometry("600x200")
root.title("Justin... | true |
84e78624aa3c0171d05b430576946cad18360fdf | BC-CSCI-1102-S19-TTh3/example_code | /week10/dictionarydemo.py | 507 | 4.40625 | 4 | # instantiating a dictionary
mydictionary = {}
# adding key-value pairs to a dictionary
mydictionary["dog"] = 2
mydictionary["cat"] = 17
mydictionary["hamster"] = 1
mydictionary["houseplant"] = 5
# getting a value using a key
mycatcount = mydictionary["cat"]
# looping through keys in a dictionary
for k in mydiction... | true |
3df5c17e536ddf072745ff1dca3aae6a7f265c51 | llamington/COSC121 | /lab_8_5.py | 1,783 | 4.34375 | 4 | """A program to read a CSV file of rainfalls and print the totals
for each month.
"""
from os.path import isfile as is_valid_file
def sum_rainfall(month, num_days, columns):
"""sums rainfall"""
total_rainfall = 0
for col in columns[2:2 + num_days]:
total_rainfall += float(col)
return month... | true |
cdf618d95d1d4e99aeccf6e67df08a96a7f812a7 | RSnoad/Python-Problems | /Problem 7.py | 588 | 4.125 | 4 | # Find the 10,001st prime number
from math import sqrt
# Function to find the nth prime in list using the isPrime function below.
def nthPrime(n):
i = 2
primeList = []
while len(primeList) < n:
if isPrime(i):
primeList.append(i)
i += 1
print(primeList[-1])
# Brute force m... | true |
685452c53ea915107f3f2a2ec2ef020a1702f132 | isaac-friedman/lphw | /ex20-2.py | 1,661 | 4.6875 | 5 | ####
#This file combines what we've learned about functionwas with what we've
#learned about files to show you how they can work together. It also
#sneaks in some more info about files which you may or may not know depending
#on if you did the study drills.
####
from sys import argv
#In some of my versions of the stud... | true |
21e7a38cfa5194e6b321693cbe24008421ff0974 | isaac-friedman/lphw | /ex13-3_calc.py | 1,129 | 4.6875 | 5 | ####
#More work with argv
#This time we will use argv to collect two operands and then use raw input to
#ask for an arithmetic operation to perform on them. Effectively, we've just
#made a basic calculator
####
from sys import argv
####
#See how we aren't checking to make sure the arguments are numbers? That is a
... | true |
d1c8dbc2a8c9ba6edff5ff330a826997c5c019dc | isaac-friedman/lphw | /ex15.py | 1,390 | 4.5 | 4 | ####
#This script prints a specified file to the screen. More specifically, it
#prints to something called "standard output" which is almost always the screen
#but could be something else. For now, think of 'print' as 'printing to the
#screen' and 'standard output' or 'stdio' etc as "the screen." It's easier and
#pret... | true |
209880bc58394e1b26637a150f957699452642e9 | gabcruzm/Basis-Python-Projects | /loops/loop_through.py | 493 | 4.40625 | 4 | #Loop through a string with For
def run():
# name = input("Write your name: ")
# for letter in name: #For letters in the name it will print each letter in each loop.
# #letter is the variable that will represent each character in each repetition in the for loop. The characters are taken from the name w... | true |
e471cb0845e9550d954db99e807ac0adebd115c0 | maimoneb/dsp | /python/q8_parsing.py | 1,295 | 4.3125 | 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 t... | true |
72e7171a13387c6fcd77caf8c2c3b03ddf82c155 | pratikv06/python-tkinter | /Entry.py | 520 | 4.1875 | 4 | from tkinter import *
root = Tk()
# Define a function for button4 to perform
def myClick():
msg = "Hello, " + e.get() + "..."
myLabel = Label(root, text=msg)
myLabel.pack()
# Create a entry i.e. input area
# setting width of the entry
# changing border width of the entry
e = Entry(root, widt... | true |
21cae5cdc5b43d27e62d161e20d46712ae3d7282 | mdelite/Exercism | /python/guidos-gorgeous-lasagna/lasagna.py | 1,467 | 4.34375 | 4 | """Functions used in preparing Guido's gorgeous lasagna.
Learn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum
"""
EXPECTED_BAKE_TIME = 40
PREPARATION_TIME = 2
def bake_time_remaining(elapsed_bake_time):
"""Calculate the bake time remaining.
:param elapsed_bak... | true |
1216602668067d9a17e4dd59c896d8fe2250be54 | sssmrd/pythonassignment | /38.py | 238 | 4.28125 | 4 | #program to add member(s) in a set.
l=input("Enter some elements=").split();
s=set(l);
print(s)
c=int(input("How many elements to enter="))
for i in range(0,c):
n=input("Enter the element to be added in set=")
s.add(n);
print(s) | true |
55b8617e66a268c69ef5e2e14861dcc494034b11 | edwardyulin/sit_project | /sit_il/utils/moving_average.py | 623 | 4.15625 | 4 | import numpy as np
def moving_average(data: np.ndarray, window_size: int) -> np.ndarray:
"""Return the moving average of the elements in a 1-D array.
Args:
data (numpy.ndarray): Input 1-D array.
window_size (int): The size of sliding window.
Returns:
numpy.ndarray: Moving average... | true |
b5aa438957ab34145e3e8228f28ffddc91251e80 | joshisujay1996/OOP-and-Design-Pattern | /oop/employee_basic.py | 1,049 | 4.3125 | 4 | """
Basic OOD Example
In python everything is derived from a class and they have their own methods, like List, tuple, int, float, etc
Everything is an Object in PY and they have there own methods and attributes
we create instance out of the list class or tuple or etc
pop, append,__str__, remove are methods of th list... | true |
5b0d75ecbaebe98998a91200d2cb95d667a7d8d6 | dhobson21/python-practice | /practice.py | 1,794 | 4.1875 | 4 | # 11/19/19--------------------------------------------------------------------------------
"""Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known ... | true |
5654828bd965177fc7ef341aecaf1fb897e59a1e | weekswm/cs162p_week8_lab8 | /Car.py | 1,291 | 4.25 | 4 | #Car class
class Car:
'''Creates a class Car
attributes: make, color, and year
'''
def __init__(self, make = 'Ford', color = 'black', year = 1910):
'''Creates a car with the provided make, color, year.
Defaults to Ford black 1910.
'''
self.make = make
self.color =... | true |
2034276de5f99ed60e9ab3fd0d3e8d667c3e5ba0 | mugwch01/Trie | /Mugwagwa_Trie_DS.py | 2,267 | 4.21875 | 4 | #My name is Charles Mugwagwa. This is an implementation of a Trie data structure.
class Trie:
def __init__(self):
self.start = None
def insert(self, item):
self.start = Trie.__insert(self.start, item+"$")
def __contains__(self,item):
return Trie.__contains(self.sta... | true |
c1940693fd3eface908ff33ad53698b00bccba0a | patrickbucher/python-crash-course | /ch07/pizza-toppings.py | 294 | 4.125 | 4 | prompt = 'Which topping would you like to add to your pizza?'
prompt += '\nType "quit" when you are finished. '
topping = ''
active = True
while active:
topping = input(prompt)
if topping == 'quit':
active = False
else:
print(f'I will add {topping} to your pizza.')
| true |
05a6e73545aba94442b52eb8cfcced8225292cad | qmisky/python_fishc | /3-3 斐波那契数列-递归.py | 372 | 4.21875 | 4 | def factorial(x):
if x==1:
return 1
elif x==2:
return 1
elif x>2:
result=int(factorial(x-1))+int(factorial(x-2))
return result
elif x<0:
print ("WRONG NUMBER!")
number=int(input("please enter a positive number:"))
result=factorial(number)
print("the %d'th mont... | true |
c3fbdb921f822e4d6ebfeeeb8c11459af4f8af50 | jasonwsvt/Python-Projects | /db_sub.py | 1,389 | 4.375 | 4 | """
Use Python 3 and the sqlite3 module.
Database requires 2 fields: an auto-increment primary integer field and a field with the data type “string.”
Read from fileList and determine only the files from the list which end with a “.txt” file extension.
Add those file names from the list ending with “.txt” file extension... | true |
c526f0b569465e0e1a3cd10674793bff1debd6bf | luzap/intro_to_cs | /cs013/lab.py | 1,389 | 4.21875 | 4 | import random
import helpers
#
# Each of the following functions have an arbitrary return value. Your
# job is to edit the functions to return the correct value. You'll
# know it's correct because when you run test.py, the program will
# print "PASS" followed by the function name.
#
# Any code you add outside of these... | true |
ecddeb829aa78cd91843859c3e72093580f00279 | Antrikshhii17/myPythonProjects | /DataStructure_Algorithm/Count_occurrences.py | 485 | 4.28125 | 4 | """ Program to count number of occurrences of each element in a list.
Asked in Precisely interview for Software Engineer-I """
def count_occurrences(ourlist):
# return dict((i, ourlist.count(i)) for i in ourlist) # List comprehension approach
dicx = {}
for j in ourlist:
dicx.__setite... | true |
1838b979bbf1c1b6ee4f1e872367325f2e3ea6da | Antrikshhii17/myPythonProjects | /DataStructure_Algorithm/Bubble_sort.py | 516 | 4.3125 | 4 | """ Bubble sort. Time complexity-
Worst case = O(n^2) , when the array is in descending order.
Average case = O(n^2) , when the array is jumbled.
Best case = O(n) , when the array is already sorted. """
def bubblesort(list):
for i in range(len(list)):
for j in range(len(list) - i - 1):
... | true |
aba880ab4100a7c30c4b9fe8dbc5fd52da08a225 | vkhalaim/pythonLearning | /tceh/lection2/list_task_2.py | 359 | 4.15625 | 4 | objectList = ["Pokemon", "Digimon", "Dragon", "Cat", "Dog"]
# first method
for i in objectList:
print("Element of list -> " + i + "[" + str(objectList.index(i)) + "]"
+ "(in square braces index of element)")
# enumarate
print("-------------------")
for index, element in enumerate(objectList):
print(... | true |
94a22ec4cf15613bf3ccce939d29bf6ba89f4a51 | J-Gottschalk-NZ/Random_String_generator | /main.py | 721 | 4.21875 | 4 | import string
import random
# Function to check string length is an integer that is > 0
def intcheck(question):
error = "Please enter an integer that is more than 0 \n"
valid = False
while not valid:
try:
response = int(input(question))
if response < 1:
print(error)
else... | true |
07c883f8fc0c761e210688b095c5c0e0d5cd82c8 | MMGroesbeck/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 2,097 | 4.1875 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
elements = len(arrA) + len(arrB)
merged_arr = [0] * elements
# Your code here
i = 0
a = 0
b = 0
while i < elements:
if a >= len(arrA):
merged_arr[i] = arrB[b]
b += 1
... | true |
a6079ca9dd18ad71ea9a3aee7159e14985c90d63 | serereg/homework-repository | /homeworks/homework7/hw2.py | 2,154 | 4.3125 | 4 | """
Given two strings. Return if they are equal when both are typed into
empty text editors. # means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Examples:
Input: s = "ab#c", t = "ad#c"
Output: True
# Both s and t become "ac".
Input: s = "a##c", t = ... | true |
e10d7fa1b2457d129396d35cc6885d03f4dee095 | serereg/homework-repository | /homeworks/homework4/task_1_read_file.py | 1,784 | 4.1875 | 4 | """
Write a function that gets file path as an argument.
Read the first line of the file.
If first line is a number return true if number in an interval [1, 3)*
and false otherwise.
In case of any error, a ValueError should be thrown.
Write a test for that function using pytest library.
You should create files require... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.