blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ec61070b91028fe626d24645c354dea9364199be | ramanathanaspires/learn-python | /basic/ep13_iterators_comprehensions_genfunc_genexp/generator_expressions.py | 223 | 4.125 | 4 | double = (x * 2 for x in range(10))
print("Double:", next(double))
print("Double:", next(double))
print("Double:", next(double))
print("Double:", next(double))
print("Double:", next(double))
for num in double:
print(num) | true |
dc2ab7aa13e66dfd39cf9f523e4a0a7320326f51 | ramanathanaspires/learn-python | /basic/ep4_string_functions/acronym_generator.py | 287 | 4.21875 | 4 | # Ask for a string
string = "Random Access Memory"
ACR = ""
# Convert the string to uppercase
string = string.upper()
# Convert the string into a list
string = string.split()
# Cycle through the list
for i in string:
# Get the 1st letter of the word
print(i[0], end="")
print() | true |
f7d3deda15f5fa65cb0dfbfce4d9cba884c3eb6c | IamP5/Python---Loops | /Question3.py | 354 | 4.28125 | 4 | """ Make a program that receive a float number "n". If the number is greater than 157, print "Goal Achieved" and break the loop.
Else, print "Insufficient" and read a new number "n". You should read at most 5 numbers """
for i in range(5):
i = float(input())
if i > 157:
print("Goal Achieved")
break
... | true |
44252d3a22878ea2f3f669d944f73e2992d627cf | amirobin/prime | /home_study/missing2.py | 324 | 4.125 | 4 | def find_missing(list1,list2):
missingout = 0
if len(list1) > len(list2):
longer_list = list1
shorter_list = list2
else:
longer_list = list2
shorter_list = list1
for val in longer_list:
if val not in shorter_list:
missingout = val
print missingout
find_missing([1,6,7,8,9],[1,6,8... | true |
4b3a5c066c3f2417a58c4318f9119aeaf5bd916f | mbreault/python | /algorithms/check_permutations.py | 618 | 4.1875 | 4 | ## given two strings check if one is a permutation of the other
## method 1 using built-in python list methods
def sorted_chars(s):
## sort characters in a string
return sorted(set(s))
def check_permutation(a,b):
if a == b:
return True
elif len(a) != len(b):
return False
els... | true |
1f92c8e71474d67e720967c544bca4fa1b9ba8dd | ajayvenkat10/Competitive | /slidingwindow.py | 1,657 | 4.4375 | 4 | # Python3 program to find the smallest
# window containing
# all characters of a pattern
from collections import defaultdict
MAX_CHARS = 256
# Function to find smallest window
# containing
# all distinct characters
def findSubString(str):
n = len(str)
# Count all distinct characters.
dist_count = len(set([x fo... | true |
bd2737365d163236c1640be6973584bd194e48ea | dstada/Python | /test2.py | 1,230 | 4.28125 | 4 | """
Tests whether a matrix is a magic square.
If it is, prints its magic number.
INPUT INSTRUCTIONS: Either just press
"Submit" or enter EACH ROW IN A NEW LINE.
Separate entries by comma and/or space.
Example 1:
1, 2, 3
4, 5, 6
7, 8, 9
Example 2:
7 12 1 14
2 13 8 11
16 3 10 5
9 6 15 4
"""
import numpy as np
def is... | true |
94fb53db05943459330902864360926149c3d610 | dstada/Python | /Is that an IP address.py | 1,384 | 4.21875 | 4 | """Is That an IP Address?
Given a string as input, create a program to evaluate whether or not it is a valid IPv4 address.
A valid IP address should be in the form of: a.b.c.d where a, b, c and d are integer values ranging from 0 to 255 inclusive.
For example:
127.0.0.1 - valid
127.255.255.255 - valid
257.0.0.1 - in... | true |
0bc0a586aca6cc1a7d1a02df1b898a753b40f893 | dstada/Python | /[Challenge] Prime Strings.py | 950 | 4.1875 | 4 | """Prime Strings
A String is called prime if it can't be constructed by concatenating multiple (more than one) equal strings.
For example:
"abac" is prime, but "xyxy" is not ("xyxy" = "xy" + "xy").
Implement a program which outputs whether a given string is prime.
Examples
Input: "xyxy"
Output: "not prime"
Input: ... | true |
eb38f1c9a63f9d009a1236af993ecdfd08bc0672 | dstada/Python | /rgb to hex.py | 1,437 | 4.5 | 4 | """
RGB to HEX Converter
RGB colors are represented as triplets of numbers in the range of 0-255, representing the red, green and blue components
of the resulting color.
Each RGB color has a corresponding hexadecimal value, which is expressed as a six-digit combination of numbers
and letters and starts with the # sig... | true |
d4df46d410ba8a5da505b799aa070dbc651fb258 | AbinayaDevarajan/google_interview_preparation | /dynamic_programming/fibonacci.py | 937 | 4.1875 | 4 |
import timeit
"""
Top down approach by using the recursion:
"""
def fibonacci(input):
if input ==0:
return 1
elif input ==1:
return 1
else:
return fibonacci(input-1) + fibonacci(input -2 )
"""
memoization usage of cache
"""
def fibonacci_memo(input, cache=None):
if input =... | true |
1cddccfcd681221093b1a367335b5fa41c1c6271 | victoire4/Some-few-basic-codes-to-solve-the-problem | /3.The Longest word.py | 583 | 4.375 | 4 | def longest(N): # We define the function
A = N.split(' ') # A is a list. Each element of A is one word of N
L = 0 # Initialisation of the size for the comparison
for i in range(0,len(A)):
if (len(A[i]) > L):
W= A[i]
L = len(A[i]) ... | true |
6fe7e5516c8a1b0052f41b8f944151b971e840e0 | MillicentMal/alx-higher_level_programming-1 | /0x07-python-test_driven_development/0-add_integer.py | 533 | 4.15625 | 4 | #!/usr/bin/python3
"""
This is the "0-add_integer" module.
The 0-add_integer module supplies one function, add_integer().
"""
def add_integer(a, b=98):
"""My addition function
Args: a: first integer b: second integer
Returns: The return value. a + b """
if (a is None or (not isinstance(a, int) and ... | true |
8287ac8f2d458302a9de577d017bace013f74246 | Mauricio-KND/holbertonschool-higher_level_programming | /0x06-python-classes/6-square.py | 2,904 | 4.46875 | 4 | #!/usr/bin/python3
"""Module that creates an empty square."""
class Square:
__size = 0
"""Square with value."""
def __init__(self, size=0, position=(0, 0)):
"""Initialize square with size and position."""
if not isinstance(size, int):
raise TypeError("size must be an integer")
... | true |
1b9ed4be63989a054f4c3866ef9fa35c4927c1ac | livneniv/python | /week 2/assn2.py | 446 | 4.1875 | 4 | #Write a program to prompt the user for hours and rate per hour to compute gross pay
user_name=raw_input('Hi Sir, Whats your name? ')
work_hours=raw_input('and how many hours have you been working? ')
work_hours=float(work_hours) #converts type from string to float
rate=raw_input('pardon me for asking, but how much do... | true |
9c695f5445161a76936e72ac336a9253d9113541 | s4git21/Two-Pointers-1 | /Problem-1.py | 1,086 | 4.15625 | 4 | """
Approach:
1) if you were to sort the first and last flag, your middle flag is automatically sorted
2) use two pointers to keep track of the sorted indices for 0 and 2
3) you'd need to have a 3rd pointer to make comparisons from left to right
4) swap elements at 3rd moving pointer with either left/right pointer if 0... | true |
50bc005b9baea7ad7e64f4ec4f95149c94ab2b0c | grogsy/python_exercises | /csc232 proj/encrypt.py | 2,898 | 4.28125 | 4 | import random
import string
import sys
symbols = list(string.printable)[:94]
def encrypt(text):
"""Add three chars after every char in the plaintext(fuzz)
After, substitue these chars with their hex equivalent(hexify)
input: string sentence
returns: string
>>> encrypt('secret message')
... | true |
2f0fbbe6d72d54c7ca98ed12821a1b12e59a2313 | grogsy/python_exercises | /datastructures/merge_sort.py | 768 | 4.1875 | 4 | def merge_sort(arr):
if len(arr) <= 1:
return arr
left = []
right = []
midpoint = len(arr) // 2
for i, element in enumerate(arr):
if i < midpoint:
left.append(element)
else:
right.append(element)
left = merge_sort(left)
right = merge_sort... | true |
34445e45fd10f8a252f743c9410099857c8ca96d | kiksnahamz/python-fundamentals | /creating_dictionary.py | 1,040 | 4.75 | 5 | #Creating a dictionary from a list of tuples
'''
Creating a list of tuples which we name "users"
'''
users = [
(0, "Bob", "password"),
(1, "Rolf", "bob123"),
(2, "Jose", "longp4assword"),
(3, "username", "1234"),
]
'''
we are transcribing the data from users into a dictionaries. The fir... | true |
46104a9824c0c549577b73a45c048bc7009936ca | rsheftel/raccoon | /raccoon/sort_utils.py | 1,828 | 4.15625 | 4 | """
Utility functions for sorting and dealing with sorted Series and DataFrames
"""
from bisect import bisect_left, bisect_right
def sorted_exists(values, x):
"""
For list, values, returns the insert position for item x and whether the item already exists in the list. This
allows one function call to ret... | true |
115a859802940f367926d1487f65bb874e075d41 | xatlasm/python-crash-course | /chap4/4-10.py | 267 | 4.25 | 4 | #Slices
cubes = [cube**3 for cube in range(1,11)]
print(cubes)
print("The first three items in the list are: ")
print(cubes[:3])
print("Three items from the middle of the list are: ")
print(cubes[3:6])
print("The last three items in the list are: ")
print(cubes[-3:]) | true |
16bd7425b8d794c6ccdb22fbb12d1f764c4ccd7e | Jayoung-Yun/test_python_scripts | /repeating_with_loop.py | 903 | 4.28125 | 4 | word = 'lead'
print word[0]
print word[1]
print word[2]
print word[3]
print '========================'
word = 'oxygen'
for char in word:
print char # space is necessar!
length = 0
for vowel in 'aeiou' :
length = length +1
print (' In loop : There are'), length, ('vowels')
print ('There are'), length, ('vowe... | true |
9d10008f588fe46246752758f08b27d66cde8ba8 | leonardlan/myTools | /python/list_tools.py | 936 | 4.28125 | 4 | '''Useful functions for lists.'''
from collections import Counter
def print_duplicates(my_list, ignore_case=False):
'''Print duplicates in list.
Args:
my_list (list): List of items to find duplicates in.
ignore_case (bool): If True, case-insensitive when finding duplicates.
Returns:
... | true |
389ec37fa582b3d379b01d13b3f9aa44265dd922 | cvhs-cs-2017/sem2-exam1-jman7150 | /Encrypt.py | 1,703 | 4.34375 | 4 | """
Write a code that will remove vowels from a string and run it for the sentence:
'Computer Science Makes the World go round but it doesn't make the world round itself!'
Print the save the result as the variable = NoVowels
"""
def NoVowels(AnyString):
newString = ""
for ch in AnyString:
if ord(ch) ... | true |
a7181fd0ddfc4fba1b653e06e05c34d917690dbb | JoshuaMeza/ProgramacionEstructurada | /Unidad 3-Funciones/Ejercicio43.py | 2,972 | 4.21875 | 4 | """
Author Joshua Immanuel Meza Magana
Version 1.0
Program who count how many positive and negative numbers are on N numbers, 0 break the count.
"""
#Functions
def specifyNumbers():
"""
It gets the N numbers that we will count.
Args:
_N (int): Value of the number of numbers
Returns:... | true |
cf56c17dc4d5d912013ef55466911dee5e042fda | ainnes84/DATA520_HW_Notes | /Get_Weekday.py | 692 | 4.71875 | 5 | def get_weekday(current_weekday, days_ahead): # or day_current, days_ahead
""" (int, int) -> int
Return which day of the week it will be days_ahead days from
current_weekday.
current_weekday is the current day of the week and is in the
range 1-7, indicating whether today is Sunday (... | true |
babb5f609272132392a4e6b6f7fa4209f62ac2d5 | ainnes84/DATA520_HW_Notes | /file_editor.py | 1,719 | 4.21875 | 4 | import os.path
def file_editor(writefile):
while os.path.isfile(writefile):
rename = input('The file exists. Do you want to rename the file? (y/n)')
if rename == 'y':
print ('I will rename the ' + writefile + ' file.')
filename = input('Please give new file name (In .txt for... | true |
ea313897b6a0b264b0f492b6275dc3d7d8c0ad2b | ainnes84/DATA520_HW_Notes | /count_duplicates.py | 507 | 4.25 | 4 | def count_duplicates(dictionary):
""" (dict) -> int
Return the number of values that appear two or more times.
>>> count_duplicates({'A': 1, 'B': 2, 'C': 1, 'D': 3, 'E': 1})
1
"""
duplicates = 0
values = list(dictionary.values())
for item in values:
if values.count(item) >= 2... | true |
87d9533f914f4a0cb9c25fbe838a45acd24b303c | kenny2892/RedditProfileSaver-C-Sharp | /Database/sqlite_helper.py | 1,467 | 4.21875 | 4 | import sqlite3
from sqlite3 import Error
# Source for how to use Sqlite in Python: https://www.sqlitetutorial.net/sqlite-python/
def create_connection(db_file):
""" create a database connection to the SQLite database
specified by db_file
:param db_file: database file
:return: Connection object or N... | true |
20cff6b03d5d7d2cb34b24adc911f05701fb190f | ritasonak/Python-Samples | /Pluralsight/Fundamentals/Docstring_Demo.py | 470 | 4.125 | 4 | """Retrieve and print words from a URL
"""
import urllib2
def fetch_words(url):
"""Fetch a list of words from URL.
:param
url: The URL of a UTF-8 text document.
:return:
A list of strings containing the words from the document.
"""
story = urllib2.urlopen(url)
story_words = [... | true |
4f7140f2b36c772bee6f83d865e7fa2205c06979 | kmerchan/holbertonschool-interview | /0x1C-island_perimeter/0-island_perimeter.py | 2,591 | 4.28125 | 4 | #!/usr/bin/python3
"""
Defines function to calculate the perimeter of an island
represented by a list of list of ints
"""
def island_perimeter(grid):
"""
Calculates the perimeter of an island represented by a list of list of ints
parameters:
grid [list of list of ints]: represents the island & su... | true |
b1e36c377de098bebae5361b8bb64df364612c22 | ASHWINIBAMBALE/Calculator | /calculator.py | 818 | 4.15625 | 4 | def add(n1,n2):
return n1+n2
def subtract(n1,n2):
return n1-n2
def multiply(n1,n2):
return n1*n2
def divide(n1,n2):
return n1/n2
operations={
"+":add,
"-":subtract,
"*":multiply,
"/":divide
}
def calculator():
num1=float(input("Enter the first number:"))... | true |
926051d16f0ca8e3a19d98e8460c9ed27ea19700 | ehedaoo/Practice-Python | /Basic28.py | 412 | 4.1875 | 4 | # Write a Python program to print out a set
# containing all the colors from color_list_1 which are not present in color_list_2.
# Test Data :
# color_list_1 = set(["White", "Black", "Red"])
# color_list_2 = set(["Red", "Green"])
# Expected Output :
# {'Black', 'White'}
color_list_1 = set(["White", "Black", "Red"])
co... | true |
9b9912a3790e0af2a0fb1dc0ece3afcd3e5e990f | ehedaoo/Practice-Python | /Basic4.py | 212 | 4.28125 | 4 | # Write a Python program which accepts the user's first and last name
# and print them in reverse order with a space between them.
name = input("Enter your name please: ")
if len(name) > 0:
print(name[::-1]) | true |
8331b70e425b25d1cf4f1f8a08bfd316b4af4978 | ehedaoo/Practice-Python | /Basic3.py | 254 | 4.40625 | 4 | # Write a Python program which accepts the radius of a circle from the user and compute the area.
import math
radius = int(input("Enter the radius of the circle: "))
area1 = math.pi * pow(radius, 2)
print(area1)
area2 = math.pi * radius**2
print(area2) | true |
7352122a917e1228a98fdb984a84c1852852b3e6 | ehedaoo/Practice-Python | /Basic35.py | 552 | 4.3125 | 4 | # Write a Python program to add two objects if both objects are an integer type.
def add_numbers(a, b):
if not (isinstance(a, int) and isinstance(b, int)):
raise TypeError("Inputs must be integers")
return a + b
obj1 = int(input("Enter an integer 1: "))
obj2 = int(input("Enter an integer 2: "))
print... | true |
8e4912c44b713408b18770aa1599ecdc4b120c14 | azrap/python-rest-heroku-deploy | /test.py | 762 | 4.34375 | 4 | import sqlite3
connection = sqlite3.connect('data.db')
cursor = connection.cursor()
create_table = "CREATE TABLE users (id int, username text, password text)"
cursor.execute(create_table)
# must be a tuple
user = (1, 'jose', "superpass")
# the ? signifies parameters we'll insert
# must insert tuple with the... | true |
5cb40df0d005df2a3c0caf071285b30911b6a0d2 | dduong7/dduong7-_pcc_cis012_homework | /Module 4/mathematical.py | 951 | 4.375 | 4 | # Create two variables (you pick the name) that have an integer value of 25,000,000 but one uses underscores as a
# thousand separator and the other doesn't.
var_int = 25000000
varr_int = 25_000_000
# Print out each variable using an f string with the following format "<Var Name>: <Var Value>" where <Var Name> is
# r... | true |
573c91766b1ece833891767b7c6a7ef7ae306398 | joew1994/isc-work | /python/tuples.py | 543 | 4.15625 | 4 | #a TUPLE = a sequence like a list, except it can not be modified once created
# created using normal brackets instead of square brackets
#but still index with square brackets
#emunerate function = produces index and values in pairs.
#question 1
t = (1,)
print t
print t[-1]
tup = range(100, 200)
print tup
tup2 =... | true |
6eccdf6c93349b1885f911e2a863bc95e39f07d3 | sdrsnadkry/pythonAssignments | /Functions/7.py | 361 | 4.28125 | 4 | def count(string):
upperCount = 0
lowerCount = 0
for l in string:
if l.isupper():
upperCount += 1
elif l.islower():
lowerCount += 1
else:
pass
print("Upper string Count: ", upperCount,
"\nLower String Count: ", lowerCount)
string =... | true |
8e9d4540f197553ce8ee741201507c04075b4bd2 | danijar/training-py | /tree_traversal.py | 1,945 | 4.34375 | 4 | from tree import Node, example_tree
def traverse_depth_first(root):
"""
Recursively traverse the tree in order using depth first search.
"""
if root.left:
yield from traverse_depth_first(root.left)
yield root.value
if root.right:
yield from traverse_depth_first(root.right)
de... | true |
fa1c5da5d10b4a3b1e1a5b39301ad98c11294a89 | danijar/training-py | /digits_up_to.py | 2,656 | 4.25 | 4 | def digits(number):
"""Generator to iterate over the digits of a number from right to left."""
while number > 0:
yield number % 10
number //= 10
def count_digits_upto(the_number, the_digit):
"""Count the amount of digits d occuring in the numbers from 0 to n
with runtime complexity of ... | true |
75005f329735e2d241747d7d2cda7b06d6e30c94 | crystalDf/Automate-the-Boring-Stuff-with-Python-Chapter-01-Python-Basics | /MathOperators.py | 258 | 4.1875 | 4 | # ** Exponent
print(2 ** 3)
# % Modulus/remainder
print(22 % 8)
# // Integer division/ oored quotient
print(22 // 8)
# when the * operator is used on one string value and one integer value,
# it becomes the string replication operator.
print('Alice' * 5)
| true |
078d077ae95661565d3e657a19a8496b07a033e0 | jcburnworth1/Python_Programming | /computer_science/towers_of_hanoi_stacks/towers_of_hanoi_script.py | 2,841 | 4.3125 | 4 | ## Towers of Hanoi - CodeAcademy
from computer_science.towers_of_hanoi_stacks.stack import Stack
## Start the game
print("\nLet's play Towers of Hanoi!!")
# Create the Stacks
stacks = []
left_stack = Stack("Left")
middle_stack = Stack("Middle")
right_stack = Stack("Right")
## Add each individual stack in a large list... | true |
b85a5495b451c01f5c992521c88e0514eb4be948 | jcburnworth1/Python_Programming | /basic_python/scrabble_functions.py | 2,600 | 4.28125 | 4 | ## Scrabble - CodeAcademy
## Initial Variables
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z"]
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4,
1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
## Combin... | true |
baf1c9013f89e4e73e46ec3bac27f915ca6fb3fd | redi-vinogradov/leetcode | /rotate_array.py | 398 | 4.1875 | 4 | def rotate(nums, k):
""" The trick is that we are moving not just each value but slice of array
to it's new position by calculating value of modulus remainder
"""
k = k % len(nums)
if k == 0:
return
nums[:k], nums[k:] = nums[-k:], nums[:-k]
print(nums)
def main():
nums = [1,2,3,... | true |
e2c2a407cb7422c4529db7131b41aee5f065c027 | aragaomateus/PointOfService | /Main.py | 1,576 | 4.15625 | 4 | ''' Creating the restaurant pos program in python'''
from Table import Table
# Function for initializing the table objects assingning a number to it.
def initiateTables():
tablesGrid = [Table(i) for i in range(21)]
return tablesGrid
# Function for printing the floor map when needed.
def printTables(tables):
... | true |
487e4a3fdbb30210d7a0faad073437bc88eb6892 | m120402/maule | /server.py | 1,859 | 4.15625 | 4 | import socket
# Tutorial came from:
# https://pythonprogramming.net/sockets-tutorial-python-3/
# create the socket
# AF_INET == ipv4
# SOCK_STREAM == TCP
# The s variable is our TCP/IP socket.
# The AF_INET is in reference to th family or domain, it means ipv4, as opposed to ipv6 with AF_INET6.
# The SOCK_STREAM ... | true |
4b6a42ff50842c497db16d19844b41ca8a23de27 | huangsam/ultimate-python | /ultimatepython/classes/basic_class.py | 2,673 | 4.625 | 5 | """
A class is made up of methods and state. This allows code and data to be
combined as one logical entity. This module defines a basic car class,
creates a car instance and uses it for demonstration purposes.
"""
from inspect import isfunction, ismethod, signature
class Car:
"""Basic definition of a car.
W... | true |
1233b07fb7e52520645d588af089fee900483281 | huangsam/ultimate-python | /ultimatepython/syntax/loop.py | 2,727 | 4.4375 | 4 | """
Loops are to expressions as multiplication is to addition. They help us
run the same code many times until a certain condition is not met. This
module shows how to use the for-loop and while-loop, and also shows how
`continue` and `break` give us precise control over a loop's lifecycle.
Note that for-else and whil... | true |
5191ec83e749d9e838e1984665e9a250069bcf84 | Yanaigaf/NextPy-Coursework | /nextpy1.1.py | 982 | 4.25 | 4 | import functools
# 1.0 - write a oneliner function that attaches a symbol to every element of an iterable
# and prints all elements as a single string
def combine_coins(symbol, gen):
return ", ".join(map(lambda x: symbol + str(x), gen))
print(combine_coins('$', range(5)))
# 1.1.2 - write a oneliner function t... | true |
2fa430c5e0cee76e4e9a8beecbbb4f63a2530739 | cmhuang0328/hackerrank-python | /introduction/2-python-if-else.py | 588 | 4.125 | 4 | #! /usr/bin/env python3
'''
Task
Given an integer, , perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of to , print Not Weird
If n is even and in the inclusive range of to , print Weird
If n is even and greater than , print Not Weird
Input Format
A single li... | true |
2bbd8eeb959c2eb53dfe860f1b835df62ad3a131 | Archana-SK/python_tutorials | /Handling_Files/_file_handling.py | 2,036 | 4.21875 | 4 | # File Objects
# r ---> Read Only, w ---> Write Only, a ---> Append, r+ ---> Read and Write
# Reading file without using Context manager
f = open('read.txt', 'r')
f_contents = f.read()
print(f_contents)
f.close()
# Reading file Using Context Manager (No need to close the file explicitly when file is opened using con... | true |
10beb77fb6294dcb65c43870f26d86efae24096e | AndreiKorzhun/CS50x | /pset7_SQL/houses/roster.py | 870 | 4.125 | 4 | import cs50
import csv
from sys import argv, exit
# open database for SQLite
db = cs50.SQL("sqlite:///students.db")
def main():
# checking the number of input arguments in the terminal
if len(argv) != 2:
print(f"Usage: python {argv[0]} 'name of a house'")
exit(1)
# sample of students of... | true |
f2f35bd0fa2e0a0bde87df9ca4274f8e1124ef37 | remycloyd/projects | /python Programs/miningRobots.py | 1,247 | 4.125 | 4 | # You are starting an asteroid mining mission with a single harvester robot. That robot is capable of mining one gram of mineral per day.
# It also has the ability to clone itself by constructing another harvester robot.
# That new robot becomes available for use the next day and can be involved in the mining process o... | true |
b671e84a60e0ca80d31d0d502ada7307005ed206 | Nickbonat22/CIS210 | /p51_binaryr.py | 2,722 | 4.25 | 4 | '''
Binary Encoding and Decoding Recursively
CIS 210 F17 Project 5, Part 1
Author: Nicholas Bonat
Credits:
Convert a non-negative integer to binary recursively and prints it. Then
converts back to decimal form and prints the value.
'''
import doctest
def dtob(n):
'''(int) -> str
Function dtob takes non-n... | true |
878ad2087a24100fce96b6cf80feb543fae809f1 | gordwilling/data-structures-and-algorithms | /unscramble-computer-science-problems/Task4.py | 1,297 | 4.25 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
from operator import itemgetter
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 4:... | true |
b848295a1ae8ed1915d00addf29610a1f218c167 | Hosen-Rabby/Learn-Python-The-Hard-Way | /access tuple items.py | 413 | 4.4375 | 4 | print("Can Access Tuple Items-by referring to the index number, inside square brackets")
thistuple = ("kat", "Gari", "toy","Laptop","TV")
print(thistuple[2])
print("Negative Indexing")
print("refers to the last item -",thistuple[-1])
print("refers to the 2nd last item -",thistuple[-2])
print("Range of Indexes... | true |
0065eda3217c9a30b9d1950134dc7ee2e32cecff | nathanbrand12/training | /src/LCM.py | 681 | 4.15625 | 4 | # def lcm(x, y):
# if x > y:
# greater = x
# else:
# greater = y
# while(True):
# if((greater % x == 0) and (greater % y == 0)):
# lcm = greater
# break
# greater += 1
# return lcm
#
# num1 = float(input("Input first number: "))
# num2 = float(input("Input secon... | true |
7f2fc6389628f4d74de363e5cea3327d3041bf39 | ankitbansal2101/data-structures | /queue.py | 1,731 | 4.1875 | 4 | #fifo(first in first out)
#using list
q=[]
q.insert(0,"a")
q.insert(0,"b")
q.insert(0,"c")
q.pop()
#using deque
from collections import deque
q=deque()
q.appendleft("a")
q.appendleft("b")
q.appendleft("c")
q.pop()
#using inbuilt queue
# Initializing a queue
q = Queue(maxsize = 3)
# qsize() give the maxsize
#... | true |
6d7c431c0d4d2d4938f1f939fe4f3b19096bdee5 | karinsasaki/Python_ML_projects | /guess_number_game/build/lib/guess_number_game/guess_number.py | 2,850 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 8 12:56:50 2020
@author: sasaki
"""
import random
import guess_number_game.utils as utils
#class Chosen:
# """Class of the chosen number.
#
# min_bound (int>=0): minimum bound of range the program can choose a number from. Default is 0.
# ... | true |
4f88343db2cd456fa3930da1b2ee0cf0d8793be1 | TARUNJANGIR/FSDP_2019 | /DAY2/Hands_On_1.py | 383 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 4 16:51:39 2019
@author: HP
"""
# Create a list of number from 1 to 20 using range function.
# Using the slicing concept print all the even and odd numbers from the list
our_list = list(range(21))
print (type(our_list))
print (our_list)
print ('even numbers>')
print (... | true |
2453dad75840fdb875fb6be8b330afa77c70e60d | KhairulIzwan/Python-for-Everybody | /Values and Types/Exercise/3/main.py | 732 | 4.6875 | 5 | #!/usr/bin/env python3
"""
Assume that we execute the following assignment statements:
width = 17
height = 12.0
For each of the following expressions, write the value of the expression and the type (of the value of the expression).
1. width//2
2. width/2.0
3. height/3
4. 1 + 2 \* 5
"""
#
width = 17
height = 12.0... | true |
40517f70d8c803ea2ed1184d6428d47b896d38b7 | michaelamican/python_starter_projects | /Python_Fundamentals/Functions_Basic_II.py | 1,511 | 4.3125 | 4 | #Countdown - Create a function that accepts a number as an input. Return a new array that counts down by one, from the number (as arrays 'zero'th element) down to 0 (as the last element). For example countDown(5) should return [5,4,3,2,1,0].
def count_down(int):
i = int
while i >= 0:
print(i)
i -=... | true |
5e3d78e715d03ac40400cc9ae33bf35b396be8bb | Ylfcynn/Python_Practice | /Python/TensorFlow/data_format.py | 1,397 | 4.125 | 4 | """
Deep Learning Using TensorFlow: Introduction to the TensorFlow library
An exercise with Matt Hemmingsen
A subfield of machine learning, inspired by the structure and function of the brain,
often called artificial neural networks.
Deep learning can solve broader problems without specifically defining each feature... | true |
423d2342360be47f1af94b4c9388a286dcc2235d | Ylfcynn/Python_Practice | /Python/atm-interface/atm_interface.py | 2,739 | 4.3125 | 4 | """
This is a menu for accessing a user's account. Logic is located in account.py
"""
from account import Account
import pychalk
acct = Account # pep484 annotations
USER_ACCOUNTS = dict() # Refactor this. If it stays global, UPPERCASE!
def user_menu(account):
"""
Displays a menu of user opt... | true |
f56fbddeba596cb59d85c15de2aa5145769c2eb7 | Ylfcynn/Python_Practice | /credit.py | 1,799 | 4.375 | 4 | """
Goal
Write a function which returns whether a string containing a credit card number is valid as a boolean.
Write as many sub-functions as necessary to solve the problem.
Write doctests for each function.
--------------------
Instructions
1. Slice off the last digit. That is the **check digit**.
2. Reverse the ... | true |
dfd12c2fa65c0f412c9eb6d14003ee4b21447697 | Ylfcynn/Python_Practice | /hammer.py | 1,655 | 4.1875 | 4 | """
Write a function that returns the meal for any given hour of the day.
Breakfast: 7AM - 9AM
Lunch: 12PM - 2PM
Dinner: 7PM - 9PM
Hammer: 10PM - 4AM
>>> meal(7)
'Breakfast time.'
>>> meal(13)
'Lunch time.'
>>> meal(20)
'Dinner time.'
>>> meal(21)
'No meal scheduled at this time.'
>>> meal(0)
'Hammer time.'
>>> meal(... | true |
7486275b192534951ab95cecd52e752faa2d4e03 | VakinduPhilliam/Python_Data_Mapping | /Python_List_Comprehensions.py | 495 | 4.125 | 4 | # Python Data Structures List Comprehensions
# List comprehensions provide a concise way to create lists.
# Common applications are to make new lists where each element is the result
# of some operations applied to each member of another sequence or iterable,
# or to create a subsequence of those elements that s... | true |
1e5a4bbcf9b1a60bb2a882e12d2d02d49797c272 | VakinduPhilliam/Python_Data_Mapping | /Python_List_Comprehensions (Example).py | 847 | 4.375 | 4 | # Python Data Structures List Comprehensions
# List comprehensions provide a concise way to create lists.
# Common applications are to make new lists where each element is the result
# of some operations applied to each member of another sequence or iterable,
# or to create a subsequence of those elements that s... | true |
d7c3c6c4a14ffb9b23f57fcfbab464a35963b7f5 | nealorven/Python-Crash-Course | /1_Chapter_Basics/7_While_cycles/Exercises/7_3_multiples_of_10.py | 324 | 4.21875 | 4 | number = input("Enter a multiple of 10: ")
number = int(number)
if number % 10 == 0:
print(f"\nThe number {str(number)} is multiple.")
else:
print(f"\nThe number {str(number)} not multiple.")
# Enter a multiple of 10: 101
# The number 101 not multiple.
# Enter a multiple of 10: 110
# The number 110 is multip... | true |
bac7551316b9025f88671c580126d591119d2b62 | nealorven/Python-Crash-Course | /1_Chapter_Basics/5_if_Operator/Exercises/Interactive/2_for_if_else.py | 406 | 4.28125 | 4 | names = {
'robert green':'robertgreen@gmail.com',
'neal orven':'nealorven@gmail.com',
'alen frojer':'alenfrojer@gmail.com',
'bob eron':'boberon@gmail.com'
}
name_search = input("Write your username to search for a mailing address: ")
for name, mail in names.items():
if name_search in name:
... | true |
17cc17340c7e0144ec4abf5d80c4675d873cde3c | webAnatoly/learning_python | /fromPythonBook/uniquewords1.py | 641 | 4.125 | 4 | #!/usr/bin/env python3.4
'''
Here is a program from a study book that I'm reading.
The programm lists every word and the
number of times it occurs in alphabetical order for all the files listed on the
command line:
'''
import string
import sys
words = {}
strip = string.whitespace + string.punctuation + string.digits + ... | true |
c0dad9e3f04b628492da4feec32e5f97ac6be3e9 | ash301/kuchbhi | /leap.py | 734 | 4.4375 | 4 | #take the year as input
def function(year):
leap = False
if(year%4 == 0):
if(year%100 == 0):
if(year%400 == 0):
leap = True
else:
leap = True
return leap
year = int(input("Enter the Year : "))
print function(year)
#Documentation taken from url:
#https://support.microsoft.com/en-in/kb/21401... | true |
cf46bee5eb0a3ba95addb4a25960331c39003d81 | 3mRoshdy/Learning-Python | /09_generators.py | 472 | 4.28125 | 4 | # Generators are simple functions which return an iterable set of items, one at a time, in a special way.
# Using 'yield' keyword for generating Fibonacci
def fib():
a,b = 1,1
while 1:
yield a
a, b = b, b + a
# testing code
import types
if type(fib()) == types.GeneratorType:
print("Good, Th... | true |
790d755e7834ad0e9a081d74a4b087c6e656466e | ikarek-one/zoom-decoder | /zoomChatDecoderVer2.py | 2,619 | 4.125 | 4 |
print("Decoding Zoom chat .txt-s")
print("Enter the name (or path) of your .txt file!")
print("Examples: myFile.txt OR C:/Documents/meeting_saved_chat.txt")
fileName = input("Name of file: \n")
if(fileName == ""):
fileName = "meeting_saved_chat.txt"
print("\nEnter 'save' if you want to save your file. T... | true |
4c9eaad51acdfb0bdaa4d9c9faa6a2a4435ff63d | G3Code-CS/Intro-Python-I | /src/14_cal.py | 2,176 | 4.53125 | 5 | """
The Python standard library's 'calendar' module allows you to
render a calendar to your terminal.
https://docs.python.org/3.6/library/calendar.html
Write a program that accepts user input of the form
`14_cal.py month [year]`
and does the following:
- If the user doesn't specify any input, your program should
... | true |
cef0c723b7f0ad7212ea8fbd5c80af1a8b039635 | tgaye/Learn_Python_the_Hard_Way | /ex11.py | 668 | 4.21875 | 4 | # ex.11 User Inputs
print('How old are you?', end=' ')
age = input()
print('How tall are you?', end=' ')
height = input()
print('How much do you weigh (lbs?)?', end=' ') # imperial system bc im an ignorant American.
weight = input()
print(f'So, you\'re {age} old, {height} tall and {weight} lbs heavy'.format(age, hei... | true |
9f7abd5a59f1514adb0be406e8dc20bb3ce2ba18 | hello-lily/learngit | /pytest/ex18.py | 683 | 4.21875 | 4 | # this one is like your scripts with argv
def print_two ( *args):
arg1,arg2 =args
print ("arg1: %r, arg2: %r" % (arg1, arg2))
#ok, that *args is actually pointless, we can just do this
# so what is*args? means a lot of strings
def print_two_again(arg1, arg2):
print ("arg1: %s, arg2: %s" % (arg1, arg2))
# %r the... | true |
343d8ddec7f5d12ce721c94b2c9dd96e53930147 | vchatchai/bootcamp-ai | /week1/tuple-cheat-sheet.py | 882 | 4.78125 | 5 | # %%
"""
- By convention, we generally use tuple for different datatypes
and list for similar datatypes
- Since tuple are immutable, then iteration througth tuple
is faster than with list!!!
- Tuple that contain immutables elements can be used as key for a
dictionary. With list, this is NOT possible.
- If you have... | true |
6778b4cadbf8b1530bc949cf7903dafdc4c07edc | jdfdoyley/python_list | /python_list.py | 998 | 4.5 | 4 | # Create a list
# =============
# A list of integers
numbers = [1, 2, 3, 4, 5]
# A list of Strings
names = ["Josephine", "Jess", "Marsha", "Krystal"]
# A list of mixed type
employee = [
"Jessie", "Lewis", 30, (1761, "S Military Hwy", "Norfolk", "VA", 23502),
True
]
# An empty list
empty_list = []
# The lis... | true |
92854e6164be7f96190de56031e29ce0bd43ec1a | lef17004/Daily-Coding-Challenges | /8:17-9:3 2020/reverse_list.py | 951 | 4.59375 | 5 | ###############################################################################
"""
Reverse List
8/19/2021
Time Complexity: O(n)
Description: Write function that reverses a list, preferably in place.
"""
###############################################################################
def reverse_list(list,... | true |
76cd6f0dd04037b7e085da5d0a7f5d556345a567 | lef17004/Daily-Coding-Challenges | /8:17-9:3 2020/bubble_sort.py | 1,197 | 4.21875 | 4 |
###############################################################################
"""
Bubble Sort
8/17/2021
Time Complexity: O(n^2)
Description: Starting from the beginning of the list, compare every adjacent
pair, swap their position if they are not in the right order (the latter one is
smaller than the former one).... | true |
9d73704305095fe1886f53493f503cf7dfb7ac2e | sraakesh95github/Python-Course | /Homeworks/Homework 1/hw1_1.py | 898 | 4.4375 | 4 | import sys
import math
# Program to calculate the time taken for a ball to drop from a height for a given initial velocity
#Set a constant value for acceleration due to gravity
g = 9.81;
#Get the height from which the ball is dropped
s = int(input("Enter height : "));
#Check for the height range
if s<10 or s>1000 :
... | true |
b147b2c96fc928a21f25f9b5901be7a4fa88845d | DiamondGo/leetcode | /python/SortColors.py | 1,588 | 4.125 | 4 | '''
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
Note:
You are not suppose to use the libr... | true |
3e2505c4409bfbe19aef3a9d3dd29d8d4eca1ea5 | DiamondGo/leetcode | /python/SlidingWindowMaximum.py | 1,300 | 4.125 | 4 | '''
Created on 20160511
@author: Kenneth Tse
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
For example,
Given nums = [1,3,-1,-3... | true |
af01fe43f281513beb6503b91fabc6d900e38489 | yosoydead/recursive-stuff | /visualising recursion/bla.py | 753 | 4.53125 | 5 | from turtle import *
t = Turtle()
wind = Screen()
#i use penup so that when the turtle is repositioned, it doesn't draw any lines
t.penup()
#starting position
t.setposition(-300,-300)
#make the turtle draw again
t.pendown()
#this is for speed test
t.speed(9)
#the method needs a turtle object to use to draw things... | true |
f1e606e96dbea769da2adb4d543e5bd6b3a64c37 | AlDBanda/Python-Functions | /main.py | 2,177 | 4.46875 | 4 | #def greet():
# return "Hello Alfred"
#print(greet())
#============================
'''
Function with parameters
'''
#def greet(name):
# '''
# Greets a person passed in as argumrnt name: a name of a person to greet
# '''
# return f"Hello {name}, Good morning"
#print(greet("Felix"))
#print(greet("Arlo"))... | true |
a62e16ff90361d0e60103355fe85838c54c611c9 | simgroenewald/NumericalDataType | /Numbers.py | 876 | 4.34375 | 4 | # Compulsory Task 1
Num1 = input("Enter your first number:")# Allows user to input their first number and saves it as variable number1
Num2 = input("Enter your second number:")# Allows user to enter their second number and saves it as variable number2
Num3 = input("Enter your third number:") # Allows the user to ent... | true |
137ed3c9089d953574204d65fad08722db04a813 | GayathriAmarneni/Training | /Programs/nToThePowern.py | 239 | 4.375 | 4 | # Program to calculate n to the power n.
base = int(input("Enter a base number: "))
result = 1
counter = 0
while counter < base:
result = result * base
counter = counter + 1
print(base, "to the power of", base, "is", result)
| true |
4d13a1c0cddb9ab162b99df61875359b3617ad91 | GayathriAmarneni/Training | /Programs/mToThePowern.py | 270 | 4.375 | 4 | #Program to calculate m to the power n.
base = int(input("Enter base number: "))
exponent = int(input("Enter exponent number: "))
result = 1
for exponent in range(0, exponent + 1, 1):
result = result * base
print(base, "to the power of", exponent, "is", result) | true |
6c1f1f2b78af6e4989c6bf0ebf8677e992e9e70e | datadiskpfv/basics1 | /printing.py | 874 | 4.21875 | 4 | print('Hello World')
print(1 + 2)
print(7 * 6)
print()
print("The End")
print("Python's strings are easy to use")
print('We can even include "quotes" in strings')
print("hello" + " world")
# using variables
greeting = "Hello"
name = "Paul"
print(greeting + name)
print(greeting + ' ' + name)
#greeting = 'Hello'
#name ... | true |
fdda56b607a15772990151abdc4a5d93a1bdcada | datadiskpfv/basics1 | /sets.py | 1,719 | 4.40625 | 4 | # sets are mutable objects (unless you use a frozen set)
# there is no ordering
farm_animals = {"sheep", "cow", "hen"}
print(farm_animals)
wild_animals = set(["lion", "tiger", "panther", "elephant", "hare"])
print(wild_animals)
wild_animals.add("horse")
wild_animals.add("ant")
print(wild_animals)
# you can also use... | true |
0cd37577dcd53530aaeb1988110fb141dfac3a24 | sutclifm0850/cti110 | /P4HW1_Sutcliffe.py | 313 | 4.15625 | 4 | #P4HW1
#Distance Travveled
#Sutcliffe
#March 25, 2018
speed = float(input('What is the speed of the vehicle in mph?'))
time = int(input('How many hours has it traveled?'))
print('Hour','\tDistance Traveled')
for Hour in range(1, time + 1 ):
distance = speed * Hour
print(Hour,'\t',distance)
| true |
61d7528d11582fa50ee89b4e44a420f4e2e025ee | AthaG/Kata-Tasks | /6kyu/MultiplesOf3Or5_6kyu.py | 715 | 4.25 | 4 | '''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.
Finish the solution so that it returns the sum of all the multiples of 3 or 5 below
the number passed in.
Note: If the number is a multiple of both 3 and 5, only count it once. Als... | true |
c43b4fcbd1989400e3bf9d78e1b9d319ebb5ffa9 | AthaG/Kata-Tasks | /6kyu/FindTheOrderBreaker_6kyu.py | 1,373 | 4.25 | 4 | '''In this kata, you have an integer array which was ordered by ascending except one
number.
For Example: [1,2,3,4,17,5,6,7,8]
For Example: [19,27,33,34,112,578,116,170,800]
You need to figure out the first breaker. Breaker is the item, when removed from
sequence, sequence becomes ordered by ascending.
For Example... | true |
326e404d03568049e1667422f555773ecb2c1cd7 | AthaG/Kata-Tasks | /6kyu/VasyaClerk_6kyu.py | 1,295 | 4.15625 | 4 | '''The new "Avengers" movie has just been released! There are a lot of people at the
cinema box office standing in a huge line. Each of them has a single 100, 50 or 25
dollar bill. An "Avengers" ticket costs 25 dollars.
Vasya is currently working as a clerk. He wants to sell a ticket to every single person
in this l... | true |
50bfe95cf2fe7023477c7d1905f33b8ba556d552 | AthaG/Kata-Tasks | /5kyu/Rot13_5kyu.py | 1,258 | 4.75 | 5 | '''ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.
Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or special characters included in the string, they... | true |
dc3a319dc4cef21360ac1c9a61f93b39205ee072 | Tanveer132/Python-basics | /FST_04_dict.py | 765 | 4.375 | 4 | #--------------DICTIONARY--------------
# It is an important datatype used in machine learning
#key:value
d={1:"Tanveer", 2:"Akshay" ,3:"Shaheem",1:"Kiran"}
#print dictionary
print(d)
#print type of d
print(type(d))
#access the dictionary using key value
print(d[3])
#update the dictionary
d[4]="Snjana"
print(d)... | true |
f82fd283e547e2a829e7a5027b17d87c867a05e2 | EmIErO/Programming-Puzzles | /inverse_captcha_part_2.py | 821 | 4.15625 | 4 | # Program reviews a sequence of digits (a txt file)
# and find the sum of all digits that match the digit halfway around in the list.
import inverse_captcha
def add_matching_digits(list_of_digits):
"""Calculates the sum of all digits that match the digit halfway around the circular list."""
half_of_list =... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.