blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
154cf1ad66e4d8fab9b523676935b615ef831d3d | arun-p12/project-euler | /p0001_p0050/p0038.py | 2,093 | 4.125 | 4 | '''
192 x 1 = 192 ; 192 x 2 = 384 ; 192 x 3 576
str(192) + str(384) + str(576) = '192384576' which is a 1-9 pandigital number.
What is the largest 1 to 9 pandigital 9-digit number that can be formed as the
concatenated product of an integer with (2, ... , n) digits?
Essentially n > 1 to rule out 918273645 (formed by... | true |
4cbef49ee1fd1c6b4a15eae4d2dee12be49475a8 | arun-p12/project-euler | /p0001_p0050/p0017.py | 2,376 | 4.125 | 4 | '''
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then
there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words,
how many letters would be used? Ignore spaces
'''
def number_letter_count(number=1000):
... | true |
c891fec31546ed93374bc833e0bb4870c7e3e188 | rmrodge/python_practice | /format_floating_point_in_string.py | 800 | 4.4375 | 4 | # Floating point number is required in programming for generating fractional numbers,
# and sometimes it requires formatting the floating-point number for programming purposes.
# There are many ways to exist in python to format the floating-point number.
# String formatting and string interpolation are used in the f... | true |
b82b3928481d538244ec70a34fecb0b7ed761f3c | Jeff-ust/D002-2019 | /L2/L2Q6v1.py | 1,387 | 4.375 | 4 | #L2 Q6: Banana Guessing game
#Step 1: Import necessary modules
import random
#Step 2: Welcome Message
print('''Welcome to the Banana Guessing Game
Dave hid some bananas. Your task is to find out the number of bananas he hid.''')
#Step 3: Choose a random number between 1-100
n = random.randint(1,100)
print ("s... | true |
fbf0406858a0b3cdb529472d4642b2acea5fa3d2 | shouryacool/StringSlicing.py | /02_ strings Slicing.py | 820 | 4.34375 | 4 | # greeting="Good Morning,"
# name="Harry"
# print(type(name))
# # Concatining Two Strings
# c=greeting+name
# print(c)
name="HarryIsGood"
# Performing Slicing
print(name[0:3])
print(name [:5]) #is Same as [0:4]
print(name [:4]) #is Same as [0:4]
print(name [0:]) #is Same as [0:4]
print(name [-5:-1]) # is ... | true |
d8f89c6f971a5378300db593da07310ed7dfa31d | AlexanderIvanofff/Python-OOP | /defending classes/programmer.py | 2,311 | 4.375 | 4 | # Create a class called Programmer. Upon initialization it should receive name (string), language (string),
# skills (integer). The class should have two methods:
# - watch_course(course_name, language, skills_earned)
# o If the programmer's language is the equal to the one on the course increase his skills with the... | true |
6847b974bfa860f4dcec26f502a5b7c6c307e7e8 | learn-co-curriculum/cssi-4.8-subway-functions-lab | /subway_functions.py | 1,870 | 4.625 | 5 | # A subway story
# You hop on the subway at Union Square. As you are waiting for the train you
# take a look at the subway map. The map is about 21 inches wide and 35 inches
# tall. Let's write a function to return the area of the map:
def map_size(width, height):
map_area = width * height
return "The map is %... | true |
1c832205ec93dc322ab47ed90c339a9d81441282 | nyu-cds/asn264_assignment3 | /product_spark.py | 590 | 4.1875 | 4 | '''
Aditi Nair
May 7 2017
Assignment 3, Problem 2
This program creates an RDD containing the numbers from 1 to 1000,
and then uses the fold method and mul operator to multiply them all together.
'''
from pyspark import SparkContext
from operator import mul
def main():
#Create instance of SparkContext
sc = Spark... | true |
9723db9bc6f9d411d0ae62f525c33a410af9f529 | george-ognyanov-kolev/Learn-Python-Hard-Way | /44.ex44.py | 981 | 4.15625 | 4 | #inheritance vs composition
print('1. Actions on the child imply an action on the parent.\n')
class Parent1(object):
def implicit(self):
print('PARENT implicit()')
class Child1(Parent1):
pass
dad1 = Parent1()
son1 = Child1()
dad1.implicit()
son1.implicit()
print('2. Actions on the child overr... | true |
e5663cb79ea48d897aacc4350443c713dee27d5e | jejakobsen/IN1910 | /week1/e4.py | 773 | 4.15625 | 4 | """
Write a function factorize that takes in an integer $n$, and
returns the prime-factorization of that number as a list.
For example factorize(18) should return [2, 3, 3] and factorize(23)
should return [23], because 23 is a prime. Test your function by factorizing a 6-digit number.
"""
def get_primes(n):
numb... | true |
8e1f774d2d8748ae9f0a7707208ebf6e77ca8f7a | Yousab/parallel-bubble-sort-mpi | /bubble_sort.py | 981 | 4.1875 | 4 | import numpy as np
import time
#Bubble sort algorithm
def bubble_sort(nums):
# We set swapped to True so the loop looks runs at least once
swapped = True
while swapped:
swapped = False
for i in range(len(nums) - 1):
if nums[i] > nums[i + 1]:
# Swap the elements
... | true |
0791a754b6620486dd07026672d3e27dd533da7f | helpmoeny/pythoncode | /Python_labs/lab09/warmup1.py | 2,104 | 4.34375 | 4 | ##
## Demonstrate some of the operations of the Deck and Card classes
##
import cards
# Seed the random number generator to a specific value so every execution
# of the program uses the same sequence of random numbers (for testing).
import random
random.seed( 25 )
# Create a deck of cards
my_deck = cards.Deck()
... | true |
4983ce5f51d32706025dead611acdbfdea92594c | Ramtrap/lpthw | /ex16.py | 1,284 | 4.125 | 4 | from sys import argv
print "ex16.py\n"
script, filename = argv
print "We're going to erase %r." % filename
print "If you don't want that, hit CTRL-C (^C)."
print "If you do want that, hit RETURN."
raw_input("?")
print "Opening the file..."
target = open(filename, 'w')
print "Truncating the file. G... | true |
ef3e1712df8cf28034c6ab2fc8d3fd46b4683783 | shivsun/pythonappsources | /Exercises/Integers/accessing elements in the list with messages.py | 1,294 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 21:09:17 2020
@author: bpoli
"""
#Accessing Elements in a List
#Lists are ordered collections, so you can access any element in a list by
#telling Python the position, or index, of the item desired. To access an element
#in a list, write the name of the list followed... | true |
0b111a4e7f476a46248db5680d9c0ab9d1aebc1d | miffymon/Python-Learning | /ex06.py | 1,210 | 4.40625 | 4 |
#Python function pulls the value although its not announced anywhere else
#string in a string 1
x = "There are %d types of people." % 10
#naming variable
binary = "binary"
#naming variable
do_not = "don't"
#assigning sentence to variable and calling other assigned variables
#string in a string 2
y = "Those who know %... | true |
f533dddb9e2ba1ecb1d1a7b0a4a6ceb20976d022 | ferisso/phytonexercises | /exercise7.py | 893 | 4.21875 | 4 | # Question:
# Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j.
# Note: i=0,1.., X-1; j=0,1,¡Y-1.
# Example
# Suppose the following inputs are given to the program:
# 3,5
# Then, the output of the progra... | true |
5cf93df98db5fb6fe7444fffbbd1fa79559607cd | lavalio/ChamplainVRSpecialist-PythonAlgorithms | /Week4/Class1/Homework.py | 1,080 | 4.25 | 4 | #Create a list of numbers, randomly assigned.
#Scan the list and display several values:The minimum, the maximum, count and average
#Don`t use the “min”, “max”, “len ” and “sum” functions
#1. Len : gives the number of elements in array.
#2. Min, max: Gives the highest highestor lowest number in the array.
#3. Sum: A... | true |
e8cf2f63f38c417981c670689bbb649ccb1f296d | annikaslund/python_practice | /python-fundamentals/04-number_compare/number_compare.py | 301 | 4.15625 | 4 | def number_compare(num1, num2):
""" takes in two numbers and returns a string
indicating how the numbers compare to each other. """
if num1 > num2:
return "First is greater"
elif num2 > num1:
return "Second is greater"
else:
return "Numbers are equal" | true |
91e08c304bdf2dcade4f00ad513711d7cadde116 | annikaslund/python_practice | /python-fundamentals/18-sum_even_values/sum_even_values.py | 235 | 4.15625 | 4 | def sum_even_values(li):
""" sums even values in list and returns sum """
total = 0
for num in li:
if num % 2 == 0:
total += num
return total
# return sum([num for num in li if num % 2 == 0]) | true |
4a5ffb428059845f0761201c602942bb964f0e55 | 19doughertyjoseph/josephdougherty-python | /TurtleProject/Turtle Project.py | 939 | 4.125 | 4 | import turtle
turtle.setup(width=750, height=750)
pen = turtle.Pen()
pen.speed(200)
black_color = (0.0, 0.0, 0.0)
white_color = (1.0, 1.0, 1.0)
red_color = (1.0, 0.0, 0.0)
green_color = (0.0, 1.0, 0.0)
blue_color = (0.0, 0.0, 1.0)
def basicLine():
moveTo(-50, 0)
pen.forward(100)
#The origin on the screen ... | true |
0ed3044556e7faa1464a480dbe0550b2a22e20c5 | leobyeon/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 360 | 4.28125 | 4 | #!/usr/bin/python3
def append_write(filename="", text=""):
"""
appends a string at the end of a text file
and returns the number of chars added
"""
charCount = 0
with open(filename, "a+", encoding="utf-8") as myFile:
for i in text:
charCount += 1
myFile.write(i)
... | true |
828a52fcf979bb4c8dc3793babbfcf41a71efa2b | Nipuncp/lyceaum | /lpthw/ex3.py | 479 | 4.25 | 4 | print ("I'll now count my chickens")
print ("Hens:", 25 +30 / 6)
print ("Roosters", 100-25 *3%4)
print ("I'll now count the eggs:")
print (3 +2 + 1 - 5 + 4 % 2-1 % 4 + 6)
print ("Is it true that 3 + 2 < 5 - 7")
print (3 + 2 < 5 -7)
print ("What is 3 + 2", 3 + 2)
print ("What is 5 - 7", 5 - 7)
print ("THat is why, it is... | true |
fefe99ae80decc1c40885d81430a651ddbcd3541 | anupam-newgen/my-python-doodling | /calculator.py | 281 | 4.15625 | 4 | print('Add 2 with 2 = ', (2 + 2))
print('Subtract 2 from 2 = ', (2 - 2))
print('Multiply 2 with 2 = ', (2 * 2))
print('2 raise to the power 2 = ', (2 ** 2))
print('2 divide by 2 = ', (2 / 2))
# This is a comment.
# You can use above concept to solve complex equations as well.
| true |
4df2e2270df04452ca0403b08547f2bebad70504 | selva86/python | /exercises/concept/guidos-gorgeous-lasagna/.meta/exemplar.py | 1,640 | 4.28125 | 4 | # time the lasagna should be in the oven according to the cookbook.
EXPECTED_BAKE_TIME = 40
PREPARATION_TIME = 2
def bake_time_remaining(elapsed_bake_time):
"""Calculate the bake time remaining.
:param elapsed_bake_time: int baking time already elapsed
:return: int remaining bake time (in minutes) derived ... | true |
0a7def488ed51a9d0b3e3a1a5ccc8a29efa89a23 | selva86/python | /exercises/concept/little-sisters-vocab/.meta/exemplar.py | 1,648 | 4.3125 | 4 | def add_prefix_un(word):
"""
:param word: str of a root word
:return: str of root word with un prefix
This function takes `word` as a parameter and
returns a new word with an 'un' prefix.
"""
return 'un' + word
def make_word_groups(vocab_words):
"""
:param vocab_words: list of... | true |
3db5a554acc92051d4ec7a544a4c922fcad49309 | PradipH31/Python-Crash-Course | /Chapter_9_Classes/C2_Inheritance.py | 1,094 | 4.5625 | 5 | #!./ENV/bin/python
# ----------------------------------------------------------------
# Inheritance
class Car():
"""Class for a car"""
def __init__(self, model, year):
"""Initialize the car"""
self.model = model
self.year = year
def get_desc_name(self):
"""Get the descrip... | true |
c684cf0f8d15e4e684b2668eaf0bfadd8b30306a | PradipH31/Python-Crash-Course | /Chapter_9_Classes/C1_Book.py | 959 | 4.4375 | 4 | #!./ENV/bin/python
# ----------------------------------------------------------------
# # Classes
class Book():
"""Class for a book"""
def __init__(self, name, year):
"""Initialize the book with name and year"""
self.name = name
self.year = year
def get_name(self):
"""Ret... | true |
9a76041b4f7465fc6061ed4ee3efb65899a258db | alexugalek/tasks_solved_via_python | /HW1/upper_lower_symbols.py | 374 | 4.46875 | 4 | # Task - Count all Upper latin chars and Lower latin chars in the string
test_string = input('Enter string: ')
lower_chars = upper_chars = 0
for char in test_string:
if 'a' <= char <= 'z':
lower_chars += 1
elif 'A' <= char <= 'Z':
upper_chars += 1
print(f'Numbers of lower chars is: {lower_chars}... | true |
fea598032ae2a1c7676e6b0286d2fae1362bdfa3 | alexugalek/tasks_solved_via_python | /HW1/task_5.py | 418 | 4.40625 | 4 | def add_binary(a, b):
"""Instructions
Implement a function that adds two numbers together
and returns their sum in binary. The conversion can
be done before, or after the addition.
The binary number returned should be a string.
"""
return bin(a + b)[2:]
if __name__ == '__main__':
a = ... | true |
6889e39e73935e704d91c750b3a13edb36133afc | alexugalek/tasks_solved_via_python | /HW1/task_23.py | 1,327 | 4.4375 | 4 | def longest_slide_down(pyramid):
"""Instructions
Imagine that you have a pyramid built of numbers,
like this one here:
3
7 4
2 4 6
8 5 9 3
Here comes the task...
Let's say that the 'slide down' is a sum of consecutive
numbers from the top to the bottom of the pyramid. As
... | true |
a5306511c39e1a2bd0e3077f86df25e6e47f2dc6 | firozsujan/pythonBasics | /Lists.py | 1,629 | 4.1875 | 4 | # Task 9 # HakarRank # Lists
# https://www.hackerrank.com/challenges/python-lists/problem
def proceessStatement(insertStatement, list):
if insertStatement[0] == 'insert': return insert(insertStatement, list)
elif insertStatement[0] == 'print': return printList(insertStatement, list)
elif insertStatement... | true |
86b3488e679b6e34d43d0be6e219a6f01761b3e1 | firozsujan/pythonBasics | /StringFormatting.py | 655 | 4.125 | 4 | # Task # HackerRank # String Formatting
# https://www.hackerrank.com/challenges/python-string-formatting/problem
def print_formatted(number):
width = len(bin(number)[1:])
printString = ''
for i in range(1, number+1):
for base in 'doXb':
if base == 'd':
width = len(bin(nu... | true |
87324442d3dabfdcae8ef4bbea84f21f1586d663 | drdiek/Hippocampome | /Python/dir_swc_labels/lib/menu/select_processing.py | 1,109 | 4.125 | 4 | def select_processing_function():
reply = ''
# main loop to display menu choices and accept input
# terminates when user chooses to exit
while (not reply):
try:
print("\033c"); # clear screen
## display menu ##
print 'Please select ... | true |
f46893c5784cc16ad9c4bcaf19d47a126e1f02a5 | Granbark/supreme-system | /binary_tree.py | 1,080 | 4.125 | 4 | class Node():
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class BST():
def __init__(self):
self.root = None
def addNode(self, value):
return Node(value) #returns a Node, see class
def addBST(self, node, number): #node = current node, number is what yo... | true |
6a5cf3421133b39a0108430efee4d3c9ba51933f | megnicd/programming-for-big-data_CA05 | /CA05_PartB_MeganMcDonnell.py | 2,112 | 4.1875 | 4 | #iterator
def city_generator():
yield("Konstanz")
yield("Zurich")
yield("Schaffhausen")
yield("Stuttgart")
x = city_generator()
print x.next()
print x.next()
print x.next()
print x.next()
#print x.next() #there isnt a 5th element so you get a stopiteration error
print "\n"
citie... | true |
2d3fb98cd2c98c632c60fc9da686b6567c1ea68d | jaimedaniels94/100daysofcode | /day2/tip-calculator.py | 402 | 4.15625 | 4 | print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What percentage tip would you like to give? 10, 12, or 15? "))
split = int(input("How many people will split the bill? "))
bill_with_tip = tip / 100 * bill + bill
bill_per_person = bill_with_tip / split
final_am... | true |
2b47e8987cc92f9069fa12915030329d764cf032 | tomahim/project-euler | /python_solutions/problem3.py | 780 | 4.125 | 4 | from python_solutions.utils import timing
@timing
def compute_largest_prime_factor(value: int):
denominator = 2
while denominator < value:
disivion_result = value / denominator
if disivion_result.is_integer():
value = disivion_result
else:
denominator += 1
r... | true |
c70b8b6d2966f6620ad280ca6cabd29bac4cadc1 | Harrywekesa/Sqlite-database | /using_place_holders.py | 562 | 4.1875 | 4 | import sqlite3
#Get personal data from the user aand insert it into a tuple
First_name = input("Enter your first name: ")
Last_name = input("Enter your last name: ")
Age = input("Enter your age: ")
personal_data = (First_name, Last_name, Age)
#Execute insert statement for supplied personal data
with sqlite3.connect("... | true |
b720f24465dda89e7ff7e6dd6f0fdde60fdb297d | vpreethamkashyap/plinux | /7-Python/3.py | 1,594 | 4.21875 | 4 | #!/usr/bin/python3
import sys
import time
import shutil
import os
import subprocess
print ("\nThis Python script help you to understand Types of Operator \r\n")
print ("Python language supports the following types of operators. \r\n")
print ("Arithmetic Operators \r\n")
print ("Comparison (Relational) Operators \r\n... | true |
db59ee60efb684c780262407c276487760cca73c | RoshaniPatel10994/ITCS1140---Python- | /Array/Practice/Beginin array in lecture.py | 1,815 | 4.5 | 4 | # Create a program that will allow the user to keep track of snowfall over the course 5 months.
# The program will ask what the snowfall was for each week of each month ans produce a total number
# of inches and average. It will also print out the snowfall values and list the highest amount of snow and the lowest amo... | true |
c3869c3a16815c7934e88768d75ee77a4bcc207d | RoshaniPatel10994/ITCS1140---Python- | /Quiz's/quiz 5/LookingForDatesPython.py | 1,479 | 4.40625 | 4 | #Looking For Dates Program
#Written by: Betsy Jenaway
#Date: July 31, 2012
#This program will load an array of names and an array of dates. It will then
#ask the user for a name. The program will then look for the user in the list.
#If the name is found in the list the user will get a message telling them
#... | true |
c4a91a468b3c96852d1365870230b15433f8007c | RoshaniPatel10994/ITCS1140---Python- | /Quiz's/quiz 2/chips.py | 989 | 4.15625 | 4 | # Roshani Patel
# 2/10/20
# Chips
# This program Calculate the cost of an order of chips.
# Display program that will ask user how many bags of chips they want to buy.
#In addition ask the user what size of bag.
#If the bag is 8 oz the cost is 1.29 dollar if the bag is 16 oz then the cost is 3.59 dollars.
#If ... | true |
a95bdaa18d1b88eb8d178998f6af8f1066939c81 | Lin-HsiaoJu/StanCode-Project | /stanCode Project/Wheather Master/weather_master.py | 1,463 | 4.34375 | 4 | """
File: weather_master.py
Name: Jeffrey.Lin 2020/07
-----------------------
This program should implement a console program
that asks weather data from user to compute the
average, highest, lowest, cold days among the inputs.
Output format should match what is shown in the sample
run in the Assignment 2 Handout.
"""... | true |
92e0031f054add61799cd4bfcd81a835e705af0d | ruthvika-mohan/python_scripts- | /merge_yearly_data.py | 1,002 | 4.125 | 4 | # Import required modules
# Glob module finds all the pathnames matching a specified pattern
# Pandas required to do merge operation
# chdir() method in Python used to change the current working directory to specified path.
from os import chdir
from glob import glob
import pandas as pdlib
# Move to the path t... | true |
a29e29d8f4e58d67a3d7cf38132b587cb8c27822 | dinulade101/ECE322Testing | /command/cancelBookingCommand.py | 2,224 | 4.3125 | 4 | '''
This file deals with all the commands to allow the user to cancel bookings.
It will initially display all the user's bookings. Then the user will select
the number of the booking displayed to cancel. The row of the booking in the db
will be removed. The member who's booking was canceled will get an automated messag... | true |
3735f2e08803537b4f8c1ba5fa4ad92e6109e16b | Jacalin/Algorithms | /Python/hash_pyramid.py | 661 | 4.5 | 4 | '''
Implement a program that prints out a double half-pyramid of a specified height, per the below.
The num must be between 1 - 23.
Height: 4
# #
## ##
### ###
#### ####
'''
def hash_pyramid():
# request user input, must be num bewtween 1 - 23
n = int(input("please type in a number between 1 - 23:... | true |
31fc3087cab6005638007c911291d6c23ae293ee | kyledavv/lpthw | /ex24.py | 1,725 | 4.125 | 4 | print("Let's practice everything.")
print('You\'d need to know \'bout escapes with \\ that do:')
print('\n newlines and \t tabs.')
poem = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere the... | true |
aa673ad99e3adc6a02d9e49a1c7d6b9d82ad2d2d | rawswift/python-collections | /tuple/cli-basic-tuple.py | 467 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# create tuple
a = ("one", "two", "three")
# print 'em
print a
# how many node/element we have?
print len(a) # 3
# print using format
print "Counting %s, %s, %s..." % a
# iterate
for x in a:
print x
# print value from specific index
print a[1] # 'two'
# create an... | true |
05dbf2f6923071eccad18dc65d97a3e0baab3333 | schlangens/Python_Shopping_List | /shopping_list.py | 632 | 4.375 | 4 | # MAKE sure to run this as python3 - input function can cause issues - Read the comments
# make a list to hold onto our items
shopping_list = []
# print out instruction on how to use the app
print('What should we get at the store?')
print("Enter 'DONE' to stop adding items.")
while True:
# ask for new items
... | true |
ed5c9669052efef4d7003952c0a7f20437c5109d | alma-frankenstein/Rosalind | /RNA.py | 284 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#Transcribing DNA to RNA
#Given: A DNA string t
#Return: The transcribed RNA string of t
.
filename = 'rosalind_rna.txt'
with open(filename) as file_object:
contents = file_object.read()
rna = contents.replace('T', 'U')
print(rna)
| true |
6a8203f812ccc5b829b20e7698246d8c327ac3af | dudejadeep3/python | /Tutorial_Freecodecamp/11_conditionals.py | 530 | 4.34375 | 4 | # if statement
is_male = True
is_tall = False
if is_male and is_tall:
print("You are a tall male.")
elif is_male and not is_tall:
print("You are a short male")
elif not is_male and is_tall:
print("You are not a male but tall")
else:
print("You are not male and not tall")
def max_num(num1, num2, num3)... | true |
dbfd05d60911bf8141c1bf910cad8229915e420a | dudejadeep3/python | /Tutorial_Freecodecamp/06_input.py | 467 | 4.25 | 4 | # Getting the input from the users
name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello " + name + "! You are "+age)
# Building a basic calculator
num1 = input("Enter a number:")
num2 = input("Enter another number:")
result = float(num1) + float(num2); # we could use int() but it will remov... | true |
cf717c597321786c758d22056fd1c90eb8d4b175 | lima-oscar/GTx-CS1301xIV-Computing-in-Python-IV-Objects-Algorithms | /Chapter 5.1_Objects/Burrito5.py | 1,764 | 4.46875 | 4 | #In this exercise, you won't edit any of your code from the
#Burrito class. Instead, you're just going to write a
#function to use instances of the Burrito class. You don't
#actually have to copy/paste your previous code here if you
#don't want to, although you'll need to if you want to write
#some test code at the bot... | true |
09c67cc5a452e5af7021221d589c49e17f37d7b6 | panhboth111/AI-CODES | /pandas/4.py | 394 | 4.34375 | 4 | #Question: Write a Pandas program to compare the elements of the two Pandas Series.
import pandas as pd
ds1 = pd.Series([2, 4, 6, 8, 10])
ds2 = pd.Series([1, 3, 5, 7, 10])
print("Series1:")
print(ds1)
print("Series2:")
print(ds2)
print("Compare the elements of the said Series:")
print("Equals:")
print(ds1 == ds2)
prin... | true |
2bf7cbe5bcecf17ebaf46be2f5420ebbde0163b0 | panhboth111/AI-CODES | /pandas/16.py | 530 | 4.28125 | 4 | """Question: Write a Pandas program to get the items of a given series not present in another given series.
Sample Output:
Original Series:
sr1:
0 1
1 2
2 3
3 4
4 5
dtype: int64
sr2:
0 2
1 4
2 6
3 8
4 10
dtype: int64
Items of sr1 not present in sr2:
0 1
2 3
4 5
dtype: int64 """
import pandas as pd
sr1 = pd.Series([1,... | true |
e133ba7d9f305a476985d6d2659aefb7b91ddb51 | MariinoS/projectEuler | /problem1.py | 571 | 4.125 | 4 | # Project Euler: Problem 1 Source Code. By MariinoS. 5th Feb 2016.
"""
# task: 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.
#
# My Solution:
"""
list = ran... | true |
2834050573db40f828573a3a5e88137c4851382e | P-RASHMI/Python-programs | /Functional pgms/QuadraticRoots.py | 979 | 4.3125 | 4 | '''
@Author: Rashmi
@Date: 2021-09-17 19:10:01
@Last Modified by: Rashmi
@Last Modified time: 2021-09-17 19:36:03
@Title : A program that takes a,d,c from quadratic equation and print the roots”
'''
import math
def deriveroots(a,b,c):
"""to calculate roots of quadratic equation
parameter : a,b,c
ret... | true |
2af7aa31f51f43d8d4cdaaaf245833f3c215e9cf | P-RASHMI/Python-programs | /Logicalprogram/gambler.py | 1,715 | 4.3125 | 4 | '''
@Author: Rashmi
@Date: 2021-09-18 23:10
@Last Modified by: Rashmi
@Last Modified time: 2021-09-19 2:17
@Title : Simulates a gambler who start with $stake and place fair $1 bets until
he/she goes broke (i.e. has no money) or reach $goal. Keeps track of the number of
times he/she wins and the number of bets he/she m... | true |
65d56039fe3688d16aeb6737fbcd105df044155a | pranshulrastogi/karumanchi | /doubleLL.py | 2,884 | 4.40625 | 4 | '''
implement double linked list
'''
class Node:
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
class doubleLL:
def __init__(self):
self.head = None
# insertion in double linked list
def insert(self,data,pos=-1):
assert pos >... | true |
0765b7bc193f7bc799aa0b713b32b9c97ce7b3eb | maheshganee/python-data | /13file operation.py | 2,798 | 4.65625 | 5 | """
file operation:python comes with an inbuilt open method which is used to work with text files
//the text files can operated in three operation modes they are
read
write
append
//open method takes atleast one parameter and atmost two parameters
//first parameter represents the file name along with full path and sec... | true |
1e171d3183670dd0bac6ab179a3b7c13c42f834c | rronakk/python_execises | /day.py | 2,705 | 4.5 | 4 | print "Enter Your birth date in following format : yyyy/mm/dd "
birthDate = raw_input('>')
print" Enter current date in following format : yyyy/mm/dd "
currentDate = raw_input('>')
birth_year, birth_month, birth_day = birthDate.split("/")
current_year, current_month, current_day = currentDate.split("/")
year1 = int(b... | true |
f9baac6271366884fbb8caaf201ccb6b4e53e254 | sunilmummadi/Trees-3 | /symmetricTree.py | 1,608 | 4.21875 | 4 | # Leetcode 101. Symmetric Tree
# Time Complexity : O(n) where n is the number of the nodes in the tree
# Space Complexity : O(h) where h is the height of the tree
# Did this code successfully run on Leetcode : Yes
# Any problem you faced while coding this : No
# Approach: To check for symmetry of a tree, check if ... | true |
4e1bc4ed86486ee94c63f439d96d7f663df5587c | mcfarland422/python101 | /loops.py | 277 | 4.21875 | 4 | print "Loops file"
# A for loop expects a starting point, and an ending point.
# The ending poin (in range) is non-inclusive, meaning, it will stop when it gets there
# i (below) is going to be the number of the loop it's on
for i in range(1,10):
if (i == 5):
print
| true |
4df919c2b292cf09bf210ea8337023dea1c63bbf | Rosswell/CS_Exercises | /linked_list_manipulation.py | 2,673 | 4.15625 | 4 | '''Prompt:
You have simple linked list that specifies paths through a graph. For example; [(node1, node2), (node2, node3)]
node 1 connects to node 2 and node 2 connects to node 3. Write a program that traverses the list and breaks any cycles.
So if node 1 links to both node 2 and node 2374, one link should be broken a... | true |
41585c6dca2b0c40fbdd86fecbedecfa663e306a | Shadow-Arc/Eleusis | /hex-to-dec.py | 1,119 | 4.25 | 4 | #!/usr/bin/python
#TSAlvey, 30/09/2019
#This program will take one or two base 16 hexadecimal values, show the decimal
#strings and display summations of subtraction, addition and XOR.
# initializing string
test_string1 = input("Enter a base 16 Hexadecimal:")
test_string2 = input("Enter additional Hexadecimals, else... | true |
50d3d8fe9a65b183a05d23919c255b71378c7af5 | alejandrox1/CS | /documentation/sphinx/intro/triangle-project/trianglelib/shape.py | 2,095 | 4.6875 | 5 | """Use the triangle class to represent triangles."""
from math import sqrt
class Triangle(object):
"""A triangle is a three-sided polygon."""
def __init__(self, a, b, c):
"""Create a triangle with sides of lengths `a`, `b`, and `c`.
Raises `ValueError` if the three length values provided can... | true |
5e4c5593c59e8218630172dd9690da00c7d8fc1c | CostaNathan/ProjectsFCC | /Python 101/While and for loops.py | 1,090 | 4.46875 | 4 | ## while specify a condition that will be run repeatedly until the false condition
## while loops always checks the condition prior to running the loop
i = 1
while i <= 10:
print(i)
i += 1
print("Done with loop")
## for variable 'in' collection to look over:
## the defined variable will change each iteratio... | true |
959aae8e60bcc42ea90447dc296262c791e18d8c | CostaNathan/ProjectsFCC | /Python 101/Try & Except.py | 298 | 4.21875 | 4 | ## try/except blocks are used to respond to the user something when an error occur
## best practice to use except with specific errors
try:
number = int(input("Enter a number: "))
print(number)
except ZeroDivisionError as err:
print(err)
except ValueError:
input("Invalid input") | true |
df3955f45591745ac7c20b87d71d01a16f774cf1 | OlivierParpaillon/Contest | /code_and_algo/Xmas.py | 1,504 | 4.21875 | 4 | # -*- coding:utf-8 -*
"""
Contest project 1 : Christmas Tree part.1
Olivier PARPAILLON
Iliass RAMI
17/12/2020
python 3.7.7
"""
# Python program to generate branch christmas tree. We split the tree in 3 branches.
# We generate the first branch of the christmas tree : branch1.
# We will use the same... | true |
23bd8f9abc8622a7fba3ec85097241eacd9f3713 | DLLJ0711/friday_assignments | /fizz_buzz.py | 1,486 | 4.21875 | 4 | # Small: add_func(1, 2) --> outputs: __
# More Complex: add_func(500, 999) --> outputs: __
# Edge Cases: add_func() or add_func(null) or add_func(undefined) --> outputs: ___
# Take a user's input for a number, and then print out all of the numbers from 1 to that number.
#startFrom = int(input('Start From (... | true |
27908f6c8668a493e416fc1857ac8fa49e7bb255 | s3rvac/talks | /2017-03-07-Introduction-to-Python/examples/22-point.py | 353 | 4.25 | 4 | from math import sqrt
class Point:
"""Representation of a point in 2D space."""
def __init__(self, x, y):
self.x = x
self.y = y
def distance(self, other):
return sqrt((other.x - self.x) ** 2 +
(other.y - self.y) ** 2)
a = Point(1, 2)
b = Point(3, 4)
print(a.di... | true |
7baaca13abcd7fc98fd5d9b78de0bc62557f4b83 | s3rvac/talks | /2020-03-26-Python-Object-Model/examples/dynamic-layout.py | 666 | 4.34375 | 4 | # Object in Python do not have a fixed layout.
class X:
def __init__(self, a):
self.a = a
x = X(1)
print(x.a) # 1
# For example, we can add new attributes to objects:
x.b = 5
print(x.b) # 5
# Or even new methods into a class:
X.foo = lambda self: 10
print(x.foo()) # 10
# Or even changing base classes d... | true |
42b39efbe438ae62a818b8487aedeb5d71d4cf58 | lafleur82/python | /Final/do_math.py | 1,022 | 4.3125 | 4 | import random
def do_math():
"""Using the random module, create a program that, first, generates two positive one-digit numbers and then displays
a question to the user incorporating those numbers, e.g. “What is the sum of x and y?”. Ensure your program conducts
error-checking on the answer and notifies ... | true |
074f936e918b85a0b3ed669bb60f0d02d7a790db | daniel-reich/ubiquitous-fiesta | /PLdJr4S9LoKHHjDJC_22.py | 909 | 4.3125 | 4 |
# 1-> find if cube is full or not, by checking len of cube vs len of current row.
# 2-> calculate the missing parts in current row, by deducting the longest len of row vs current row.
# 3-> if we have missing parts return it.
# 4-> if we don't have missing parts, but our len of cube is smaller than our longest r... | true |
2950192f84c4b16ace89e832e95300b7b58db078 | daniel-reich/ubiquitous-fiesta | /ZdnwC3PsXPQTdTiKf_6.py | 241 | 4.21875 | 4 |
def calculator(num1, operator, num2):
if operator=='+':
return num1+num2
if operator=='-':
return num1-num2
if operator=='*':
return num1*num2
if operator=='/':
return "Can't divide by 0!" if num2==0 else num1/num2
| true |
7e8131e9fa9aaf0b419635a8f06519d48571a49d | daniel-reich/ubiquitous-fiesta | /ZwmfET5azpvBTWoQT_9.py | 245 | 4.1875 | 4 |
def valid_word_nest(word, nest):
while True:
if word not in nest and nest != '' or nest.count(word) == 2:
return False
nest = nest.replace(word,'')
if word == nest or nest == '':
return True
| true |
b7b5dc1ec31ac738b6ed4ef5f0bf7d383bc54fb2 | daniel-reich/ubiquitous-fiesta | /MvtxpxtFDrzEtA9k5_13.py | 496 | 4.15625 | 4 |
def palindrome_descendant(n):
'''
Returns True if the digits in n or its descendants down to 2 digits derived
as above are.
'''
str_n = str(n)
if str_n == str_n[::-1] and len(str_n) != 1:
return True
if len(str_n) % 2 == 1:
return False # Cannot produce a full set of... | true |
b2cea9d9a6e9442f4ff3877a211ea24b8072d821 | daniel-reich/ubiquitous-fiesta | /hzs9hZXpgYdGM3iwB_18.py | 244 | 4.15625 | 4 |
def alternating_caps(txt):
result, toggle = '', True
for letter in txt:
if not letter.isalpha():
result += letter
continue
result += letter.upper() if toggle else letter.lower()
toggle = not toggle
return result
| true |
48d9d502b12feb2a2c6c637cc5050d353a6e45d0 | daniel-reich/ubiquitous-fiesta | /tgd8bCn8QtrqL4sdy_2.py | 776 | 4.15625 | 4 |
def minesweeper(grid):
'''
Returns updated grid to show how many mines surround any '?' cells, as
per the instructions.
'''
def mines(grid, i, j):
'''
Returns a count of mines surrounding grid[i][j] where a mine is
identified as a '#'
'''
count = 0
lo... | true |
17608253348421e9e8efeceef37697702b9e49b2 | daniel-reich/ubiquitous-fiesta | /FSRLWWcvPRRdnuDpv_1.py | 1,371 | 4.25 | 4 |
def time_to_eat(current_time):
#Converted hours to minutes to make comparison easier
breakfast = 420;
lunch = 720;
dinner = 1140;
full_day = 1440;
#Determines if it's morning or night
morning = True;
if (current_time.find('p.m') != -1):
morning = False;
#Splits the time from the A.M/P.M C... | true |
f2cb2449e31eac8a7f3001a503cf34bb953440db | daniel-reich/ubiquitous-fiesta | /NNhkGocuPMcryW7GP_6.py | 598 | 4.21875 | 4 |
import math
def square_areas_difference(r):
# Calculate diameter
d = r * 2
# Larger square area is the diameter of the incircle squared
lgArea = d * d
# Use the diameter of the circle as the hypotenuse of the smaller
# square when cut in half to find the edges length
# When the legs are equal length (b... | true |
2163c89bda23d7bb9c02adc2729b3b678a695785 | daniel-reich/ubiquitous-fiesta | /gJSkZgCahFmCmQj3C_21.py | 276 | 4.125 | 4 |
def de_nest(lst):
l = lst[0] #Define 'l' so a while loop can be used
while isinstance(l,list): #repeat until l is not a list
l = l[0]
#This is a neat little trick in recursion, you can keep diving
#into list by just taking the 0 index of itself!
return l
| true |
701687d9659a7c7e4373ed7159096bf1b1f18a85 | daniel-reich/ubiquitous-fiesta | /QuxCNBLcGJReCawjz_7.py | 696 | 4.28125 | 4 |
def palindrome_type(n):
decimal = list(str(n)) == list(str(n))[::-1] # assess whether the number is the same read forward and backward
binary = list(str(bin(n)))[2:] == list(str(bin(n)))[2:][::-1] # assess whether the binary form of the number is the same read forward and backward
if((decimal) and (binary)): #... | true |
13a03a6d6d627d8f0c36bb4b295a9b89cd8dd36e | lavakiller123/python-1 | /mtable | 333 | 4.125 | 4 | #!/usr/bin/env python3
import colors as c
print(c.clear + c.blue + 'Mmmmm, multiplication tables.')
print('Which number?')
number = input('> ' + c.green)
print('table for ' + number)
for multiplier in range(1,13):
product = int(number) * multiplier
form = '{} x {} = {}'
print(form.format(number,multiplie... | true |
177034604e43405fc616b4ea8c4017f96e8bacea | aliasghar33345/Python-Assignment | /Assignment_5/ASSIGNMENT_5.py | 2,975 | 4.4375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
"""
Answer # 1
Write a Python function to calculate the factorial of a number (a non-negative
integer). The function accepts the number as an argument.
"""
def factorial(n):
num = 1
while n > 0:
num *= n
n -= 1
return num
print(factori... | true |
7a5bf78bc03f1008220e365be65e95273686d56f | erik-kvale/HackerRank | /CrackingTheCodingInterview/arrays_left_rotation.py | 2,412 | 4.4375 | 4 | """
------------------
Problem Statement
------------------
A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. FOr example,
if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2]. Given an array of n
integers... | true |
756347df8759c2befdb80feabcb255431be085d8 | saiyampy/currencyconverter_rs-into-dollars | /main.py | 898 | 4.28125 | 4 | print("Welcome to rupees into dollar and dollar into rupees converter")
print("press 1 for rupees into dollar:")
print("press 2 for dollar into rupees:")
try:#it will try the code
choice = int(input("Enter your choice:\n"))
except Exception as e:#This will only shown when the above code raises error
print("You... | true |
2d6ceb13782c1aa23f2f1c9dce160b7cb51cb5f3 | nguya580/python_fall20_anh | /week_02/week02_submission/week02_exercise_scrapbook.py | 2,398 | 4.15625 | 4 | # %% codecell
# Exercise 2
# Print the first 10 natural numbers using a loop
# Expected output:
# 0
# 1
# 2
# 3
# 4
# 5
# 6
# 7
# 8
# 9
# 10
x = 0
while x <= 10:
print(x)
x += 1
# %% codecell
# Exercise 3:
# Execute the loop in exercise 1 and print the message Done! after
# Expected output:
# 0
# 1
# 2
# 3... | true |
471bb7458f78b94190321bdcbaa0dce295cdb3f9 | contactpunit/python_sample_exercises | /ds/ds/mul_table.py | 1,088 | 4.21875 | 4 | class MultiplicationTable:
def __init__(self, length):
"""Create a 2D self._table of (x, y) coordinates and
their calculations (form of caching)"""
self.length = length
self._table = {
(i, j): i * j
for i in range(1, length + 1)
for j in range(... | true |
c06217c63dd9a7d955ae6f2545773486d84158b0 | Iliya-Yeriskin/Learning-Path | /Python/Exercise/Mid Exercise/4.py | 266 | 4.40625 | 4 | '''
4. Write a Python program to accept a filename from the user and print the extension of that.
Sample filename : abc.java
Output : java
'''
file=input("Please enter a file full name: ")
type=file.split(".")
print("Your file type is: " + repr(type[-1]))
| true |
0d19a4381c7c94180999bc78613aecdf65cf04a0 | Iliya-Yeriskin/Learning-Path | /Python/Projects/Rolling Cubes.py | 2,517 | 4.1875 | 4 | '''
Cube project:
receive an input of player money
every game costs 3₪
every round we will roll 2 cubes,
1.if cubes are the same player wins 100₪
2.if the cubes are the same and both are "6" player wins 1000₪
3.if the cubes different but cube 2 = 2 player wins 40₪
4.if the cubes different but cube 1 = 1 player ... | true |
5736199cbc797c8ae7d2cc6d8fc09da59023d5e2 | Iliya-Yeriskin/Learning-Path | /Python/Exercise/Mid Exercise/10.py | 306 | 4.3125 | 4 | '''
10. Write a Python program to create a dictionary from a string. Note: Track the count of the letters from the string.
Sample string : 'Net4U'
Expected output: {'N': 1, 'e': 1, 't': 2, '4': 1, 'U': 1}
'''
word=input("Please enter a word: ")
dict={i:word.count(i) for i in word}
print(dict)
| true |
03a72365c3d05751de58a9e973736dd925ea6bb2 | Stefan1502/Practice-Python | /exercise 13.py | 684 | 4.5 | 4 | #Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
#Take this opportunity to think about how you can use functions.
#Make sure to ask the user to enter the number of numbers in the sequence to generate.
#(Hint: The Fibonnaci seqence is a sequence of numbers where the n... | true |
252901028a8feadeb4070b57ff330d2c2751757c | Stefan1502/Practice-Python | /exercise 9.py | 894 | 4.21875 | 4 | #Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right.
#(Hint: remember to use the user input lessons from the very first exercise)
#Extras: Keep the game going until the user types “exit” Keep track of h... | true |
b831314d05f1b2a996e687d3f43f046ef46eab0d | Stefan1502/Practice-Python | /exercise 28.py | 421 | 4.375 | 4 | # Implement a function that takes as input three variables, and returns the largest of the three.
# Do this without using the Python max() function!
# The goal of this exercise is to think about some internals that Python normally takes care of for us.
# All you need is some variables and if statements!
... | true |
d0fdd8537fc6e96de145f6c409cc166699a51ee1 | ericrommel/codenation_python_web | /Week01/Chapter04/Exercises/ex_4-10.py | 1,171 | 4.34375 | 4 | # Extend your program above. Draw five stars, but between each, pick up the pen, move forward by 350 units, turn right
# by 144, put the pen down, and draw the next star. You’ll get something like this:
#
# _images/five_stars.png
#
# What would it look like if you didn’t pick up the pen?
import turtle
def make_wind... | true |
7fcd55b167623ad4139ebe7d9eab75f958c78fb2 | ericrommel/codenation_python_web | /Week01/Chapter04/Exercises/ex_4-09.py | 694 | 4.53125 | 5 | # Write a void function to draw a star, where the length of each side is 100 units. (Hint: You should turn the turtle
# by 144 degrees at each point.)
#
# _images/star.png
import turtle
def make_window(color="lightgreen", title="Exercise"):
win = turtle.Screen()
win.bgcolor(color)
win.title(title)
... | true |
f4aeba34d229b94abb230c2d9607b8f39570fede | ericrommel/codenation_python_web | /Week01/Chapter03/Exercises/ex_3-06.py | 871 | 4.3125 | 4 | # Use for loops to make a turtle draw these regular polygons (regular means all sides the same lengths, all angles the same):
# An equilateral triangle
# A square
# A hexagon (six sides)
# An octagon (eight sides)
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
wn.title("Exercise 6")
tria... | true |
bd0d86565d9a8380c8ede6fc6a36249d4b134ffb | arabindamahato/personal_python_program | /risagrud/function/actual_argument/default_argument.py | 690 | 4.5625 | 5 | ''' In default argument the function contain already a arguments. if we give any veriable
at the time of function calling then it takes explicitely . If we dont give any arguments then
the function receives the default arguments'''
'''Sometimes we can provide default values for our positional arguments. '''
def wish(... | true |
90aba704a0cf75e1359c3585d1986dbb7a5b826d | arabindamahato/personal_python_program | /programming_class_akshaysir/find_last_digit.py | 353 | 4.28125 | 4 | print('To find the last digit of any number')
n=int(input('Enter your no : '))
o=n%10
print('The last digit of {} is {}'.format(n,o))
#To find last digit of a given no without using modulas and arithmatic operator
print('To find last digit of a given no')
n=(input('Enter your no : '))
o=n[-1]
p=int(o)
print('The las... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.