blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c914ff467f6028b7a7e9d6f7c3b710a1445d15e4 | Safirah/Advent-of-Code-2020 | /day-2/part2.py | 975 | 4.125 | 4 | #!/usr/bin/env python
"""part2.py: Finds the number of passwords in input.txt that don't follow the rules. Format:
position_1-position_2 letter: password
1-3 a: abcde is valid: position 1 contains a and position 3 does not.
1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b.
2-9 c: ccccccccc is inva... | true |
17bca95271d269cf806decd0f1efafa05367146c | ycechungAI/yureka | /yureka/learn/data/bresenham.py | 1,424 | 4.125 | 4 | def get_line(start, end):
"""Modified Bresenham's Line Algorithm
Generates a list of tuples from start and end
>>> points1 = get_line((0, 0), (3, 4))
>>> points2 = get_line((3, 4), (0, 0))
>>> assert(set(points1) == set(points2))
>>> print points1
[(0, 0), (1, 1), (1, 2), (2, 3), (3, 4)]
... | true |
f712fa962c06854c9706919f63b52e6a6a6002ab | vasetousa/Python-basics | /Animal type.py | 263 | 4.21875 | 4 | animal = input()
# check and print what type animal is wit, also if it is a neither one (unknown)
if animal == "crocodile" or animal == "tortoise" or animal == "snake":
print("reptile")
elif animal == "dog":
print("mammal")
else:
print("unknown")
| true |
bc25ffa52620a3fd26e1b687452a60cb18dbf75e | Paulokens/CTI110 | /P2HW2_MealTip_PaulPierre.py | 968 | 4.375 | 4 | # Meal and Tip calculator
# 06/23/2019
# CTI-110 P2HW2 - Meal Tip calculator
# Pierre Paul
#
# Get the charge for the food.
food_charge = float(input('Enter the charge for the food: '))
# Create three variables for the tip amounts.
tip_amount1 = food_charge * 0.15
tip_amount2 = food_charge * 0.18
tip_amou... | true |
f27015948ad6042d42f278c8cbd287d46b502e93 | GaryLocke91/52167_programming_and_scripting | /bmi.py | 392 | 4.46875 | 4 | #This program calculates a person's Body Mass Index (BMI)
#Asks the user to input the weight and height values
weight = float(input("Enter weight in kilograms: "))
height = float(input("Enter hegiht in centimetres: "))
#Divides the weight by the height in metres squared
bmi = weight/((height/100)**2)
#Outputs the ca... | true |
92bc95604d982256a602ef749f090b63b4f47555 | knightscode94/python-testing | /programs/cotdclass.py | 433 | 4.28125 | 4 |
"""
Define a class named Rectangle, which can be constructed by a length and width.
The Rectangle class needs to have a method that can compute area.
Finally, write a unit test to test this method.
"""
import random
class rectangle():
def __int__(self, width, length):
self.width=width
self.length... | true |
499cccb2e57239465a929e0a2dc0db0e9d4602b7 | ivankatliarchuk/pythondatasc | /python/academy/sqlite.py | 872 | 4.1875 | 4 | import sqlite3
# create if does not exists and connect to a database
conn = sqlite3.connect('demo.db')
# create the cursor
c = conn.cursor()
# run an sql
c.execute('''CREATE TABLE users (username text, email text)''')
c.execute("INSERT INTO users VALUES ('me', 'me@mydomain.com')")
# commit at the connection level and n... | true |
0aeaa34a11aef996450483d8026fe6bdc4da6535 | ivankatliarchuk/pythondatasc | /python/main/datastructures/set/symetricdifference.py | 820 | 4.4375 | 4 | """
TASK
Given 2 sets of integers, M and N, print their difference in ascending order. The term symmetric
difference indicates values that exist in eirhter M or N but do not exist in both.
INPUT
The first line of input contains integer M.
The second line containts M space separeted integers.
The third line contains an ... | true |
b64c41f1627f672833c1998c0230d300d6790763 | OMR5221/MyPython | /Analysis/Anagram Detection Problem/anagramDetect_Sorting-LogLinear.py | 626 | 4.125 | 4 | # We can also sort each of the strings and then compare their values
# to test if the strings are anagrams
def anagramDetect_Sorting(stringA, stringB):
#Convert both immutable strings to lists
listA = list(stringA)
listB = list(stringB)
# Sort using Pythons function
listA.sort()
listB.sort()
... | true |
79a96ea2bf66f92ab3df995e2a330fd51cbae567 | OMR5221/MyPython | /Trees/BinarySearchTree.py | 2,308 | 4.125 | 4 | # BinarySearchTree: Way to map a key to a value
# Provides efficient searching by
# categorizing values as larger or smaller without
# knowing where the value is precisely placed
# Build Time: O(n)
# Search Time: O(log n)
# BST Methods:
'''
Map(): Create a new, empty map
put(key,val): Add a new key, value ... | true |
4143917f483f11fde2e83a52a829d73c62fc2fcd | OMR5221/MyPython | /Data Structures/Deque/palindrome_checker.py | 1,264 | 4.25 | 4 | # Palindrome: Word that is the same forward as it is backwards
# Examples: radar, madam, toot
# We can use a deque to get a string from the rear and from the front
# and compare to see if the strings ae the same
# If they are the same then the word is a palindrome
class Deque:
def __init__(self):
self.ite... | true |
bb8c26d9f183f83582717e8fadc247b21f3c174d | freddieaviator/my_python_excercises | /ex043/my_throw.py | 982 | 4.28125 | 4 | import math
angle = float(input("Input angle in degrees: "))
velocity = float(input("Input velocity in km/h: "))
throw_height = float(input("Input throw height in meter: "))
angle_radian = math.radians(angle)
throw_velocity = velocity/3.6
horizontal_velocity = throw_velocity * math.cos(angle_radian)
vertical_velocity... | true |
aad041babf64d755db4dad331ef0f7446a1f7527 | s-ruby/pod5_repo | /gary_brown_folder/temperture.py | 710 | 4.15625 | 4 | '''----Primitive Data Types Challenge 1: Converting temperatures----'''
# 1) coverting 100deg fahrenheit and celsius
# The resulting temperature us an integer not a float..how i know is because floats have decimal points
celsius_100 = (100-32)*5/9
print(celsius_100)
# 2)coverting 0deg fahrenheit and celsius
celsius... | true |
8407a85c075e4a560de9a9fbc2f637c79f813c1e | scottbing/SB_5410_Hwk111 | /Hwk111/python_types/venv/SB_5410_Hwk4.2.py | 2,605 | 4.15625 | 4 | import random
# finds shortest path between 2 nodes of a graph using BFS
def bfs_shortest_path(graph: dict, start: str, goal: str):
# keep track of explored nodes
explored = []
# keep track of all the paths to be checked
queue = [[start]]
# return path if start is goal
if start == goal:
... | true |
db8e97cdc0ae8faa35700bfb83502a1d8b0c4712 | Catarina607/Python-Lessons | /new_salary.py | 464 | 4.21875 | 4 |
print('----------------------------------')
print(' N E W S A L A R Y ')
print('----------------------------------')
salary = float(input('write the actual salary of the stuff: '))
n_salary = (26*salary)/100
new_salary = salary + n_salary
print(new_salary, 'is the actual salary')
print('t... | true |
e1c6c077d75f28f7e5a93cfbafce19b01586a26d | michaelvincerra/pdx_codex | /wk1/dice.py | 419 | 4.6875 | 5 | """
Program should ask the user for the number of dice they want to roll
as well as the number of sides per die.
1. Open Atom
1. Create a new file and save it as `dice.py`
1. Follow along with your instructor
"""
import random
dice = input('How many dice?')
sides = input('How may sides?')
roll = random.randint(1, 6... | true |
9faf1d8c84bdf3be3c8c47c8dd6d34832f4a2b1e | vmueller71/code-challenges | /question_marks/solution.py | 1,395 | 4.53125 | 5 | """
Write the function question_marks(testString) that accepts a string parameter,
which will contain single digit numbers, letters, and question marks,
and check if there are exactly 3 question marks between every pair of two
numbers that add up to 10.
If so, then your program should return the string true, other... | true |
844abbd605677d52a785a796f70d3290c9754cd6 | Aishwaryasaid/BasicPython | /dict.py | 901 | 4.53125 | 5 | # Dictionaries are key and value pairs
# key and value can be of any datatype
# Dictionaries are represented in {} brackets
# "key":"value"
# access the dict using dict_name["Key"]
student = {"name":"Jacob", "age":25,"course":["compsci","maths"]}
print(student["course"])
# use get method to inform user if a ke... | true |
cc0bbc28266bb25aa4822ac443fa8d371bb12399 | Akrog/project-euler | /001.py | 1,384 | 4.1875 | 4 | #!/usr/bin/env python
"""Multiples of 3 and 5
Problem 1
Published on 05 October 2001 at 06:00 pm [Server Time]
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
import sys
if (2,... | true |
7d3428fd768e5bf71b26f6e6472cf9efa8c79e8b | khyati-ghatalia/Python | /play_with_strings.py | 387 | 4.15625 | 4 | #This is my second python program
# I am playing around with string operations
#Defing a string variable
string_hello = "This is Khyatis program"
#Printing the string
print("%s" %string_hello)
#Printing the length of the string
print(len(string_hello))
#Finding the first instance of a string in a string
print(strin... | true |
962c2ccc73adc8e1a973249d4e92e8286d307bf1 | nihalgaurav/Python | /Python_Assignments/Quiz assignment/Ques4.py | 385 | 4.125 | 4 | # Ques 4. Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters.
s=raw_input()
d={ "UPPER_CASE" :0, "LOWER_CASE" :0}
for c in s:
if c.isupper():
d[ "UPPER_CASE" ]+=1
elif c.islower():
d[ "LOWER_CASE" ]+=1
else:
pass
print("UPPER CAS... | true |
b44cd8d204f25444d6b5ae9467ad90e539ace8b3 | nihalgaurav/Python | /Python_Assignments/Assignment_7/Ques1.py | 219 | 4.375 | 4 | # Ques 1. Create a function to calculate the area of a circle by taking radius from user.
r = int(input("Enter the radius of circle: "))
def area():
a = r * r * 3.14
print("\nArea of circle is : ",a)
area() | true |
ef4f49af3cb27908f9721e59222418ee63c99022 | antoshkaplus/CompetitiveProgramming | /ProjectEuler/001-050/23.py | 2,599 | 4.21875 | 4 | """
A number n is called deficient if the sum of its proper divisors
is less than n and it is called abundant if this sum exceeds n.
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16,
the smallest number that can be written as the sum of two abundant
numbers is 24. By mathematical analysis, it can be sh... | true |
cf1c83c8cabc0620b1cdd1bc8ecf971e0902806f | pgavriluk/python_problems | /reverse_string.py | 406 | 4.21875 | 4 | def reverse(string):
str_list=list(string)
length = len(string)
half = int(length/2)
for i, char in enumerate(str_list):
last_char = str_list[length-1]
str_list[length-1] = char
str_list[i] = last_char
length = length-1
if i >= half-1:
break;... | true |
c963de87cbf668a579a6de35ed4873c07b64ee90 | ramsayleung/leetcode | /600/palindromic_substring.py | 1,302 | 4.25 | 4 | '''
source: https://leetcode.com/problems/palindromic-substrings/
author: Ramsay Leung
date: 2020-03-08
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 characte... | true |
350ff920efd20882b4b138110612d4a6ad08b378 | RobertEne1989/python-hackerrank-submissions | /nested_lists_hackerrank.py | 1,312 | 4.40625 | 4 | '''
Given the names and grades for each student in a class of N students, store them in a nested list and
print the name(s) of any student(s) having the second lowest grade.
Note: If there are multiple students with the second lowest grade, order their names alphabetically and
print each name on a new line.
Ex... | true |
a89e546c4a3f3cd6027c3a46e362b23549eee2d0 | RobertEne1989/python-hackerrank-submissions | /validating_phone_numbers_hackerrank.py | 1,136 | 4.4375 | 4 | '''
Let's dive into the interesting topic of regular expressions! You are given some input, and you are required
to check whether they are valid mobile numbers.
A valid mobile number is a ten digit number starting with a 7, 8 or 9.
Concept
A valid mobile number is a ten digit number starting with a 7, 8 or 9... | true |
8d3e58e5049ef80e24a22ea00340999334358eb2 | RobertEne1989/python-hackerrank-submissions | /viral_advertising_hackerrank.py | 1,709 | 4.1875 | 4 | '''
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product,
they advertise it to exactly 5 people on social media.
On the first day, half of those 5 people (i.e.,floor(5/2)=2) like the advertisement and each shares it with 3 of
their friends. At the beginning of the sec... | true |
dfaea68c6693f63cce8638bb978077536a7dcecc | medetkhanzhaniya/Python | /w3/set.py | 2,461 | 4.71875 | 5 | """
#CREATE A SET:
thisset={"a","b","c"}
print(thisset)
ONCE A SET CREATED
YOU CANNOT CHANGE ITS ITEMS
BUT YOU CAN ADD NEW ITEMS
#SETS CANNOT HAVE 2 ITEMS WITH SAME VALUE
thisset = {"apple", "banana", "cherry"}
print("banana" in thisset)
#out:true
thisset = {"apple", "banana", "cherry"}
thisse... | true |
b17cb584cf6c78c34f6e1c7b78670fb90a9b58dd | manumuc/python | /rock-paper-scissors-lizard-spock.py | 1,905 | 4.28125 | 4 | <pre>[cc escaped="true" lang="python"]
# source: https://www.unixmen.com/rock-paper-scissors-lizard-spock-python/
#Include 'randrange' function (instead of the whole 'random' module
from random import randrange
# Setup a dictionary data structure (working with pairs efficientlyconverter = ['rock':0,'Spock':1,'pa... | true |
fb8a10f89fc38052190a480da6eeeacf88d6dd22 | govind-mukundan/playground | /python/class.py | 2,379 | 4.28125 | 4 | # Demo class to illustrate the syntax of a python class
# Illustrates inheritance, getters/setters, private and public properties
class MyParent1:
def __init__(self):
print ("Hello from " + str(self.__class__.__name__))
class MyParent2:
pass
# Inheriting from object is necessary for @property etc to wor... | true |
d3b3a2f39945050d6dd423146c794965069ead21 | jdipietro235/DailyProgramming | /GameOfThrees-239.py | 1,521 | 4.34375 | 4 |
# 2017-05-17
# Task #1
# Challenge #239, published 2015-11-02
# Game of Threes
"""
https://www.reddit.com/r/dailyprogrammer/comments/3r7wxz/20151102_challenge_239_easy_a_game_of_threes/?utm_content=title&utm_medium=browse&utm_source=reddit&utm_name=dailyprogrammer
Back in middle school, I had a peculiar way of deali... | true |
330ba20a83c20ecb7df2e616379023f74631ee2c | olutoni/pythonclass | /control_exercises/km_to_miles_control.py | 351 | 4.40625 | 4 | distance_km = input("Enter distance in kilometers: ")
if distance_km.isnumeric():
distance_km = int(distance_km)
if distance_km < 1:
print("enter a positive distance")
else:
distance_miles = distance_km/0.6214
print(f"{distance_km}km is {distance_miles} miles")
else:
print("You... | true |
924d7324d970925b0f26804bc135ffd318128745 | olutoni/pythonclass | /recursion_exercise/recursion_prime_check.py | 332 | 4.21875 | 4 | # program to check if a number is a prime number using recursion
number = int(input("enter number: "))
def is_prime(num, i=2):
if num <= 2:
return True if number == 2 else False
if num % i == 0:
return False
if i * i > num:
return True
return is_prime(num, i+1)
print(is_pri... | true |
10c70c24825c0b8ce1e9d6ceb03bd152f3d2d0c1 | slohmes/sp16-wit-python-workshops | /session 3/2d_arrays.py | 1,149 | 4.21875 | 4 | '''
Sarah Lohmeier, 3/7/16
SESSION 3: Graphics and Animation
2D ARRAYS
'''
# helper function
def matrix_print(matrix):
print '['
for i in range(len(matrix)):
line = '['
for j in range(len(matrix[i])):
line = line + str(matrix[i][j]) + ', '
line += '],'
print line
... | true |
8aa48619ba0e0741d001f061041aa944c7ee6d05 | amysimmons/CFG-Python-Spring-2018 | /01/formatting.py | 471 | 4.28125 | 4 | # STRING FORMATTING
age = 22
like = "taylor swift".title()
name = "Amy"
print "My age is {} and I like {}".format(age, like)
print "My age is 22 and I like Taylor Swift"
print "My age is {1} and I like {0}".format(age, like)
print "My age is Taylor Swift and I like 22"
print "My name is {}, my age is {} and I like... | true |
297a5886f75bde1bb4e8d1923401512848dcc53f | abhinashjain/codes | /codechef/Snakproc.py | 2,698 | 4.25 | 4 | #!/usr/bin/python
# coding: utf-8
r=int(raw_input())
for i in xrange(r):
l=int(raw_input())
str=raw_input()
ch=invalid=0
for j in str:
if((j=='T' and ch!=1) or (j=='H' and ch!=0)):
invalid=1
break
if(j=='H' and ch==0):
ch=1
if(j=='T' and ch==1... | true |
8f97da7c54be77e69733bb92efae07666c0ab421 | Didden91/PythonCourse1 | /Week 13/P4_XMLinPython.py | 1,689 | 4.25 | 4 | #To use XML in Python we have to import a library called ElementTree
import xml.etree.ElementTree as ET #The as ET is a shortcut, very useful, makes calling it a lot simpler
data = '''
<person>
<name>Chuck</name>
<phone type="intl">
+1 734 303 4456
</phone>
<email hide="yes" />
</person>'''
tree = ET.from... | true |
69940b6c1626270cf73c0fe36c2819bbba1523bd | Didden91/PythonCourse1 | /Week 11/P5_GreedyMatching.py | 929 | 4.28125 | 4 | #WARNING: GREEDY MATCHING
#Repeat characters like * and + push OUTWARD in BOTH directions (referred to as greedy) to match THE LARGEST POSSIBLE STRING
#This can make your results different to what you want.
#Example:
import re
x = 'From: Using the : character'
y = re.findall('^F.+:', x)
print (y)
#So you want to find '... | true |
9c74e24deb16d11cc0194504b4be55ea81bd1115 | Didden91/PythonCourse1 | /Week 6/6_3.py | 645 | 4.125 | 4 | def count(letter, word):
counter = 0
for search in word:
if search == letter:
counter = counter + 1
return counter
letterinput = input("Enter a letter: ")
wordinput = input("Enter a word: ")
wordinput = wordinput.strip('b ')
counter = count(letterinput, wordinput)
print(counter)
lowe... | true |
1b8b5732eeb4b7c9c767c815e5c0f2ec0676a99a | Didden91/PythonCourse1 | /Week 12/P7_HTMLParsing.py | 2,523 | 4.375 | 4 | #So now, what do we do with a webpage once we've retrieved it into our program
# We call this WEB SCRAPING, or WEB SPIDERING
# Not all website are happy to be scraped, quite a few don't want a 'robot' scraping their content
# They can ban you (account or IP) if they detect you scraping, so be careful when playing aroun... | true |
0196fbecdcaae1f917c8d17e505e2d6ca5cb8b4f | Didden91/PythonCourse1 | /Week 14/P4_Inheritance.py | 1,400 | 4.5 | 4 | # When we make a new class - we can reuse an existing class and inherit all the capabilities of an existing class
# and then add our own little bit to make our new class
#
# Another form of store and reuse
#
# Write once - reuse many times
#
# The new class (child) has all the capabilities of the old class (parent) - a... | true |
47e3ee0aa65599b23394a1b494508e0e6e1e753b | d-robert-buckley3/FSND | /Programming_Fundamentals/Use_Classes/turtle_poly.py | 402 | 4.125 | 4 | import turtle
def draw_poly(sides, size):
window = turtle.Screen()
window.bgcolor("white")
myturtle = turtle.Turtle()
myturtle.shape("classic")
myturtle.color("black")
myturtle.speed(2)
for side in range(sides):
myturtle.forward(size)
myturtle.right(360/sides)... | true |
7186b0324e96780924078e1d1e07058c1ddc1545 | SummerLyn/devcamp_2016 | /python/Nov_29_Tue/File_Reader/file_reader.py | 1,482 | 4.3125 | 4 | # This is an example on how to open a file as a read only text document
def open_file():
'''
Input: no input variables
Usage: open and read a text file
Output: return a list of words in the text file
'''
words = []
with open('constitution.html','r') as file:
#text = file.read()
#... | true |
549d05dd07db0861e05d1a748cd34ce3cc5ed303 | SummerLyn/devcamp_2016 | /python/day3/string_problem_day3.py | 395 | 4.1875 | 4 | # Take the first and last letter of the string and replace the middle part of
# the word with the lenght of every other letter.
user_input_fun = input(" Give me a fun word. >>")
#user_input_shorter = input("Enter in a shorter word. >>")
if len(user_input_fun) < 3:
print("Error!")
else:
print(user_input_fun[... | true |
1219597ac11a07ca8bbce48b6f18b61ca058052f | SummerLyn/devcamp_2016 | /python/day7/more_for_loops.py | 495 | 4.15625 | 4 | #use for range loop and then for each loop to print
word_list = ["a","b","c","d","e","f","g"]
# for each loop
for i in word_list:
print(i)
# for loop using range
for i in range(0,len(word_list)):
print(word_list[i])
#get user input
#loop through string and print value
#if value is a vowel break out of loop... | true |
2d3d01facdd8cf1951f31bd1705391b1ccb53b68 | cafeduke/learn | /Python/Advanced/maga/call_on_object.py | 1,009 | 4.28125 | 4 | ##
# The __call__() method of a class is internally invoked when an object is called, just like a function.
#
# obj(param1, param2, param3, ..., paramN)
#
# The parameters are passed to the __call__ method!
#
# Connecting calls
# ----------------
# Like anyother method __call__ can take any number of arguments and r... | true |
fc1d3ba12a5e13e8e002d503e2a5e1f9e16e4736 | RLuckom/python-graph-visualizer | /abstract_graph/Edge.py | 1,026 | 4.15625 | 4 | #!/usr/bin/env python
class Edge(object):
"""Class representing a graph edge"""
def __init__(self, from_vertex, to_vertex, weight=None):
"""Constructor
@type from_vertex: object
@param from_vertex: conventionally a string; something unambiguously
represent... | true |
7ccb83743060b18258178b414afdd1ba418acd3c | lyndsiWilliams/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 901 | 4.28125 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# TBC
# Set a base case for recur... | true |
64742533ee6dd3747a8e1945a0ae3d74dd00bee7 | rhenderson2/python1-class | /Chapter03/hw_3-5.py | 627 | 4.25 | 4 | # homework assignment section 3-5
guest_list = ["Abraham Lincoln", "President Trump", "C.S.Lewis"]
print(f"Hello {guest_list[0]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[1]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[-1]},\nYou are invited to dinner at my house.... | true |
2f84d347adabaa3c9788c2b550307e366998fc6f | RobertElias/AlgoProblemSet | /Easy/threelargestnum.py | 1,169 | 4.4375 | 4 | #Write a function that takes in an array of at least three integers
# and without sorting the input array, returns a sorted array
# of the three largest integers in the input array.
# The function should return duplicate integers if necessary; for example,
# it should return [10,10,12]for inquiry of [10,5,9,10,12].
#... | true |
060b043e11b67ad11e5ecc8dc2076dacd6efa1cf | WebSofter/lessnor | /python/1. objects and data types/types.py | 695 | 4.21875 | 4 | """
int - integer type
"""
result = 1 + 2
print(result, type(result))
"""
float - float type
"""
result = 1 + 2.0
print(result, type(result))
"""
string - string type
"""
result = '1' * 3
print(result, type(result))
"""
list - list type
"""
result = ['1','hello', 'world', 5, True]
print(result, type(result))
"""
tu... | true |
e2f04c145a4836d14f933ae04557dd6598561af2 | blfortier/cs50 | /pset6/cash.py | 1,657 | 4.1875 | 4 | from cs50 import get_float
def main():
# Prompt the user for the amount
# of change owed until a positive
# number is entered
while True:
change = get_float("Change owed: ")
if (change >= 0):
break
# Call the function that will
# print the amount of coins that
... | true |
4164c5ecc2da48210cb32028b01493a06b111873 | amymou/Python- | /masterticket.py | 2,298 | 4.34375 | 4 | SERVICE_CHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
# Outpout how many tickets are remaining using the ticket_remaining variable
# Gather the user's name and assign it to a new variable
names = input("Please provide your name: ")
# Prompt the user by name and ask how many tickets they would like
print("Hi {}... | true |
265462e6a06f4b50a87aecb72e05645d2a62d5e1 | danriti/project-euler | /problem019.py | 1,498 | 4.15625 | 4 | """ problem019.py
You are given the following information, but you may prefer to do some research
for yourself.
- 1 Jan 1900 was a Monday.
- Thirty days has September, April, June and November. All the rest have
thirty-one, Saving February alone, Which has twenty-eight, rain or shine.
And on leap years, twenty-ni... | true |
ae99ba05dfed268a96cf36014ece74a6dc8ad58c | yash1th/hackerrank | /python/strings/Capitalize!.py | 418 | 4.125 | 4 | def capitalize(string):
return ' '.join([i.capitalize() for i in string.split(' ')])
if __name__ == '__main__':
string = input()
capitalized_string = capitalize(string)
print(capitalized_string)
# s = input().split(" ") #if i use default .split() it will strip the whitespace otherwise it will only co... | true |
23b10c277a1632f5a41c15ea55f8ca3598cf43c5 | FredericoIsaac/Case-Studies | /Data_Structure_Algorithms/code-exercicies/queue/queue_linked_list.py | 1,696 | 4.28125 | 4 | class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self):
# Attribute to keep track of the first node in the linked list
self.head = None
# Attribute to keep track of the last node in the linked list
self.ta... | true |
19d88c04da25f392e92c55469f8ebac6cdb5ba1b | frostickflakes/isat252s20_03 | /python/fizzbuzz/fizzbuzz.py | 1,291 | 4.15625 | 4 | """A FizzBuzz program"""
# import necessary supporting libraries or packages
from numbers import Number
def fizz(x):
"""
Takes an input `x` and checks to see if x is a
number, and if so, also a multiple of 3.
If it is both, return 'Fizz'.
Otherwise, return the input.
"""
return 'Fizz' if isinsta... | true |
c062d016b88b589ffdccaa0175269439778a8ae3 | sahil-athia/python-data-types | /strings.py | 979 | 4.5625 | 5 | # strings can be indexed and sliced, indexing starts at 0
# example: "hello", regular index: 0, 1, 2, 3, 4, reverse index: 0, -4, -3, -2, -1
greeting = "hello"
print "hello \nworld \n", "hello \t world" # n for newline t for tab
print greeting # will say hello
print greeting[1] # will say 'e'
print greeting[-1] # will... | true |
5eea12122a9ff7e636d3e6e6d7c81eff21adaa5a | RachelKolk/Intro-Python-I | /src/lists.py | 808 | 4.3125 | 4 | # For the exercise, look up the methods and functions that are available for use
# with Python lists.
x = [1, 2, 3]
y = [8, 9, 10]
# For the following, DO NOT USE AN ASSIGNMENT (=).
# Change x so that it is [1, 2, 3, 4]
# YOUR CODE HERE
x.append(4)
print(x)
# Using y, change x so that it is [1, 2, 3, 4, 8, 9, 10]
... | true |
0f65a069cd882e3aac41649d09c1adbfe901a479 | vskemp/2019-11-function-demo | /list_intro.py | 2,910 | 4.65625 | 5 | # *******How do I define a list?
grocery_list = ["eggs", "milk", "bread"]
# *******How do I get the length of a list?
len(grocery_list)
# ******How do I access a single item in a list?
grocery_list[1]
# 'milk'
grocery_list[0]
# 'eggs'
#Python indexes start at 0
# ******How do I add stuff to a list?
grocery_list.appe... | true |
81e42c23911fce65155e1da44ca35666e507bd6e | helaahma/python | /loops_task.py | 1,296 | 4.125 | 4 | #define an empty list which will hold our dictionary
list_items= []
#While loop, and the condition is True
while True:
#User 1st input
item= input ("Please enter \"done\" when finished or another item below: \n")
# Define a conditional statement to break at "Done" input
if item == "done" or item=="Done":
break... | true |
b55dfd6fe18a15149ff4befa6199165655c60011 | mspang/sprockets | /stl/levenshtein.py | 1,949 | 4.40625 | 4 | """Module for calculating the Levenshtein distance bewtween two strings."""
def closest_candidate(target, candidates):
"""Returns the candidate that most closely matches |target|."""
return min(candidates, key=lambda candidate: distance(target, candidate))
def distance(a, b):
"""Returns the case-insensitive Le... | true |
e2064d9111bc5b9d73aeaf79eb3b248c25552b54 | ash0x0/AUC-ProgrammingLanguagePython | /Assignment.1/Qa.py | 506 | 4.3125 | 4 | """This module received three numbers from the user, computes their sum and prints the sum to the screen"""
try:
# Attempt to get input and cast to proper numeric type float
x = float(input("First number: "))
y = float(input("Second number: "))
z = float(input("Third number: "))
except ValueError:
... | true |
1ea7e928f266a8d63ec7735333632901954a1dea | ash0x0/AUC-ProgrammingLanguagePython | /Assignment.1/Qf.py | 763 | 4.15625 | 4 | """This module receives a single number input from the user for a GPA and prints a message depending on the value"""
try:
# Attempt to get input and cast to proper numeric type float
x = float(input("GPA: "))
except ValueError:
# If cast fails print error message and exit with error code
print("Invalid... | true |
179d5d73c249b74a4056eaf0a6c1f9de6f4fc892 | AmandaMoen/StartingOutWPython-Chapter5 | /bug_collector.py | 1,141 | 4.1875 | 4 | # June 8th, 2010
# CS110
# Amanda L. Moen
# 1. Bug Collector
# A bug collector collects bugs every day for seven days. Write
# a program that keeps a running total of the number of bugs
# collected during the seven days. The loop should ask for the
# number of bugs collected for each day, and when the loop is
# finis... | true |
2ebb6abe09a57a9ba5b4acdd4cf91b1a59b52545 | mkioga/17_python_Binary | /17_Binary.py | 637 | 4.375 | 4 |
# ==================
# 17_Binary.py
# ==================
# How to display binary in python
# Note that {0:>2} is for spacing. >2 means two spaces
# and on 0:>08b means 8 spaces with zeros filling the left side
# Note that adding b means to display in binary
for i in range(17):
print("{0:>2} in binary is {0:>08b... | true |
32bdfbc9a0a8a1c6dac00220d7cd5a5f6932062b | zenithude/Python-Leetcode | /h-index.py | 1,936 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
@author : zenithude
Given an array of citations (each citation is a non-negative integer) of a
researcher, write a function to compute the researcher's h-index.
According to the definition of h-index on Wikipedia: "A scientist has index
h if h of his/her N papers have at least h c... | true |
0cbefae29e6cf212a779c7da538661df56063fa5 | zenithude/Python-Leetcode | /removeAllGivenElement.py | 2,245 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: zenithude
Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.
Example:
Input: 1->2->6->3->4->5->6, val = 6
Output: 1->2->3->4->5
"""
class ListNode(object):
"""List of Nodes L... | true |
661959a1cace03d1be96a892ed6d8115c734a40f | zenithude/Python-Leetcode | /reorderList.py | 2,071 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
@author : zenithude
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You may not modify the values in the list's nodes, only nodes itself may be
changed.
Example 1:
Given 1->2->3->4, reorder it to 1->4->2->3.
Example 2:
Given 1->2->... | true |
463fa32db7284ea1088d0193b26aa64f220da509 | prasant73/python | /programs/shapes/higher_order_functions.py | 2,063 | 4.4375 | 4 | '''4. Map, Filter and Reduce
These are three functions which facilitate a functional approach to programming. We will discuss them one by one and understand their use cases.
4.1. Map
Map applies a function to all the items in an input_list. Here is the blueprint:
Blueprint
map(function_to_apply, list_of_inputs)
Most... | true |
c1cd86da9cab336059a84e6401ac97232302036c | TurbidRobin/Python | /30Days/Day 10/open_file.py | 323 | 4.15625 | 4 | #fname = "hello-world.txt"
#file_object = open(fname, "w")
#file_object.write("Hello World")
#file_object.close()
# creates a .txt file that has hello world in it
#with open(fname, "w") as file_object:
# file_object.write("Hello World Again")
fname = 'hello-world.txt'
with open (fname, 'r') as f:
print(f.read... | true |
32851ca38461cdc284e106dc600c104ac3b025d7 | bioright/Digital-Coin-Flip | /coin_flip.py | 1,231 | 4.25 | 4 | # This is a digital coin flip of Heads or Tails
import random, sys #Importing the random and sys modules that we will use
random_number = random.randint(1, 2)
choice = "" # stores user's input
result = "" # stores random output
def play_game(): # the main function that calls other function
instructions()
d... | true |
83aeea4934c224bb313c05e567c398a5e00da6d6 | monicaihli/python_course | /misc/booleans_numbers_fractions.py | 1,091 | 4.21875 | 4 | # **********************************************************************************************************************
#
# File: booleans_numbers_fractions.py
#
# Author: Monica Ihli
#
# Date: Feb 03, 2020
#
# Description: Numbers and fractions in Python. Best results: use debugging to go t... | true |
7dda75c52ab735158c9daa38fb3661284c19c98c | dillon-DL/PolynomialReggression | /PolynomialRegression/poly.py | 1,592 | 4.1875 | 4 | # Firstly the program will be using polynomial regression to pefrom prediction based on the inputs
# The inputs or variables we will be anlysing to study is the relation between the price and the size of the pizza
# Lastly the data will displayed via a graph which indicates the "non-linear" relationship between the 2... | true |
a28381495e08d45a75e21c512d06f688b9ab5dff | iwantroca/PythonNotes | /zeta.py | 2,427 | 4.46875 | 4 | ########LISTS########
# assigning the list
courses = ['History', 'Math', 'Physics', 'CompSci']
# finding length of list
print(len(courses))
# using index in list
print(courses[0])
# adding item to list
courses.append('Art')
print(courses)
# using insert to add in specific location
courses.insert(2, 'Art')
print(... | true |
f461e4886e514f6497cbe1f87d648efe3a7cf1cf | RaimbekNusi/Prime-number | /Project_prime.py | 1,146 | 4.25 | 4 | def is_prime(N):
"""
Determines whether a given positive integer is prime or not
input: N, any positive integer.
returns: True if N is prime, False otherwise.
"""
# special cases:
if N == 1:
return False
# the biggest divisor we're going to try
divisor = N // 2
... | true |
0188c28e0485e2a0ff7efe15b89e7c5286723de9 | rajesh95cs/wordgame | /wordgameplayer.py | 2,158 | 4.15625 | 4 | class Player(object):
"""
General class describing a player.
Stores the player's ID number, hand, and score.
"""
def __init__(self, idNum, hand):
"""
Initialize a player instance.
idNum: integer: 1 for player 1, 2 for player 2. Used in informational
displays in the ... | true |
1d76bf2cead6e296b7e7c37893a59a66cede9957 | Samk208/Udacity-Data-Analyst-Python | /Lesson_4_files_modules/flying_circus.py | 1,209 | 4.21875 | 4 | # You're going to create a list of the actors who appeared in the television programme Monty Python's Flying Circus.
# Write a function called create_cast_list that takes a filename as input and returns a list of actors' names. It
# will be run on the file flying_circus_cast.txt (this information was collected from im... | true |
87a54bf9f8875f2f578c0ed361b8adb924ff866c | Samk208/Udacity-Data-Analyst-Python | /Lesson_3_data_structures_loops/flying_circus_records.py | 1,018 | 4.1875 | 4 | # A regular flying circus happens twice or three times a month. For each month, information about the amount of money
# taken at each event is saved in a list, so that the amounts appear in the order in which they happened. The
# months' data is all collected in a dictionary called monthly_takings.
# For this quiz, wr... | true |
cb2a90a4869b762145f3e48160d7448ad0fda3a4 | CODE-Lab-IASTATE/MDO_course | /03_programming_with_numpy/arrays.py | 889 | 4.40625 | 4 | #Numpy tutorials
#Arrays
#Import the numpy library
import numpy as np
a = np.array([1, 2, 3])
#print the values of 'a'
print(a)
#returns the type of 'a'
print(type(a))
#returns the shape of 'a'
print(a.shape)
#prints the value of 'a'
print(a[0], a[1], a[2])
# Change an el... | true |
cb3c16cae8164f495dd73644ec16ea267f8c0814 | NickosLeondaridisMena/nleondar | /shortest.py | 1,560 | 4.375 | 4 |
# Create a program, shortest.py, that has a function
# that takes in a string argument and prints a sentence
# indicating the shortest word in that string.
# If there is more than one word print only the first.
# Your print statement should read:
# “The shortest word is x”
# Where x = the shortest word.
# The wo... | true |
7e13a6736cdae035792dec2400a1ec76e63289ce | SebasJ4679/CTI-110 | /P5T1_KilometerConverter_SebastianJohnson.py | 670 | 4.625 | 5 | # Todday i will create a program that converts kilometers to miles
# 10/27/19
# CTI-110 P5T1_KilometerConverter
# Sebastian Johnson
#
#Pseudocode
#1. Prompt the user to enter a distance in kilometers
#2. display the formula so the user knows what calculation is about to occur
#3 write a function that carri... | true |
d0de9f4a94d395499f87c7c304a70cc4e6055de2 | AkshatTodi/Machine-Learning-Algorithms | /Supervised Learning/Regression/Simple Linear Regression/simple_linear_regression.py | 1,693 | 4.46875 | 4 | # Simple Linear Regression
# Formula
# y = b0 + b1*X1
# y -> dependent variable
# X1 -> independent variable
# b0 -> Constent
# b1 -> Coefficient
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Salary_Data.csv')
# When... | true |
81d28f7e974c142d2792a4983342723fb8e7a712 | SarahMcQ/CodeWarsChallenges | /sortedDivisorsList.py | 618 | 4.1875 | 4 | def divisors(integer):
'''inputs an integer greater than 1
returns a list of all of the integer's divisor's from smallest to largest
if integer is a prime number returns '()is prime' '''
divs = []
if integer == 2:
print(integer,'is prime')
else:
for num... | true |
ef7cb3ec31fe915692c68d0d61da36bdb8004576 | jfonseca4/FonsecaCSC201-program03 | /program03-Part1.py | 1,129 | 4.375 | 4 | #Jordan Fonseca
#2.1
DNA = input(str("Enter the DNA sequence")) #asks user to input a string
DNA2 = []
for i in DNA:
if i == "A": #if DNA is A, replaces it with a T
DNA2.append("T")
if i == 'G': #if DNA is G, replaces it with a C
DNA2.append("C")
if i == "C": ... | true |
b5eb87686608cd0fc8e4215db1479bfc2e9a379b | mlm-distrib/py-practice-app | /00 - basics/08-sets.py | 515 | 4.25 | 4 |
# Set is a collection which is unordered and unindexed. No duplicate members.
myset = {"apple", "banana", "mango"}
print(myset)
for x in myset:
print(x)
print('')
print('Is banana in myset?', "banana" in myset)
myset.add('orange')
print(myset)
myset.update(["pineapple", "orange", "grapes"])
print(myset)
print('l... | true |
4cc99b2d1de0595bc2d0b6f335e7f8d1b80b906d | kannanmavila/coding-interview-questions | /quick_sort.py | 714 | 4.28125 | 4 | def r_quick_sort(array, start, end):
# Utility for swapping two elements of the array
def swap(pos1, pos2):
array[pos1], array[pos2] = array[pos2], array[pos1]
if start >= end:
return
pivot = array[start]
left = start+1
right = end
# Divide
while left - right < 1:
if array[left] > pivot:
... | true |
e177b1f2ba2fb3baaef810214a9325e1e9207342 | kannanmavila/coding-interview-questions | /reverse_string.py | 235 | 4.21875 | 4 | def reverse(string):
string = list(string)
length = len(string)
for i in xrange((length - 1) / 2 + 1):
string[i], string[length-i-1] = string[length-i-1],string[i]
return "".join(string)
print reverse("Madam, I'm Adam")
| true |
070d388659df628d00116c127f2b212c0e6033cf | kannanmavila/coding-interview-questions | /tree_from_inorder_postorder.py | 1,470 | 4.125 | 4 | class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def binary_tree(inorder, postorder):
"""Return the root node to the BST represented by the
inorder and postorder traversals.
"""
# Utility for recursively creating BST f... | true |
668f846583dadfcd5270c9e674b3271ee7381235 | kannanmavila/coding-interview-questions | /interview_cake/16_cake_knapsack.py | 1,136 | 4.25 | 4 | def max_duffel_bag_value(cakes, capacity):
"""Return the maximum value of cakes that can be
fit into a bag. There are infinitely many number
of each type of cake.
Caveats:
1. Capacity can be zero (naturally handled)
2. Weights can be zero (checked at the start)
3. A zero-weight cake can give infinite... | true |
4a46b2a0a5c8455746758351e85cbf52eaee7e72 | engineeredcurlz/Sprint-Challenge--Intro-Python | /src/oop/oop2.py | 1,535 | 4.15625 | 4 | # To the GroundVehicle class, add method drive() that returns "vroooom".
#
# Also change it so the num_wheels defaults to 4 if not specified when the
# object is constructed.
class GroundVehicle():
def __init__(self, num_wheels = 4): # only works for immutable (cant change) variables otherwise use []
self.... | true |
57170eafa6f1197f2032a809dbb0981f49b507ff | a100kpm/daily_training | /problem 0029.py | 983 | 4.1875 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Amazon.
Run-length encoding is a fast and simple method of encoding strings.
The basic idea is to represent repeated successive characters as a single count and character.
For example, the string "AAAABBBCCDAA" would be encod... | true |
003bc82579dfd89b4d1d001ee16d40d6a726da67 | a100kpm/daily_training | /problem 0207.py | 1,301 | 4.15625 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Dropbox.
Given an undirected graph G, check whether it is bipartite.
Recall that a graph is bipartite if its vertices can be divided into two independent sets,
U and V, such that no edge connects vertices of the same set.
''... | true |
0dc1cf2fcc01b34b4cf943a17ba24475df7e768a | a100kpm/daily_training | /problem 0034.py | 958 | 4.21875 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Quora.
Given a string, find the palindrome that can be made by inserting the fewest
number of characters as possible anywhere in the word. If there is more than
one palindrome of minimum length that can be made, return the l... | true |
211d0303800ef36e5c658498aa5c8ed99b3a91e8 | a100kpm/daily_training | /problem 0202.py | 671 | 4.28125 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Palantir.
Write a program that checks whether an integer is a palindrome.
For example, 121 is a palindrome, as well as 888. 678 is not a palindrome.
Do not convert the integer into a string.
'''
nbr1=121
nbr2=123454321
nbr3... | true |
2d3369c67839346d1e81cc29eda6163e1bf27080 | a100kpm/daily_training | /problem 0063.py | 1,824 | 4.15625 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Microsoft.
Given a 2D matrix of characters and a target word, write a function that returns
whether the word can be found in the matrix by going left-to-right, or up-to-down.
For example, given the following matrix:
[['F', ... | true |
f34bef76194d77d6a5e5f5891c334c33c8d7ca10 | a100kpm/daily_training | /problem 0065.py | 1,407 | 4.15625 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Amazon.
Given a N by M matrix of numbers, print out the matrix in a clockwise spiral.
For example, given the following matrix:
[[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]]
You s... | true |
4be59ab979de011b3761d0744013c0ff1ff5d9d2 | a100kpm/daily_training | /problem 0241.py | 949 | 4.3125 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Palantir.
In academia, the h-index is a metric used to calculate the impact of a researcher's papers. It is calculated as follows:
A researcher has index h if at least h of her N papers have h citations each.
If there are mu... | true |
625c3d016087f104ed463b41872b3510d000a04c | Abhishek4uh/Hacktoberfest2021_beginner | /Python3-Learn/Decorators_dsrathore1.py | 1,775 | 4.625 | 5 | #AUTHOR: DS Rathore
#Python3 Concept: Decorators in Python
#GITHUB: https://github.com/dsrathore1
# Any callable python object that is used to modify a function or a class is known as Decorators
# There are two types of decorators
# 1.) Fuction Decorators
# 2.) Class Decorators
# 1.) Nested function
# 2.) Function... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.