blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
98442c545f269213e63e8a6f966c01db056c21f5 | Moiseser/pythontutorial | /ex3.py | 562 | 4.375 | 4 | print "I will now count my chickens:"
print 'Hens' , 25+30/6
print 'Roosters', 100-25 * 3 % 4
print 'What is 4 % 3' , 4 % 3
print 'Now I will count my eggs:'
print 3 + 2 +1 -5 +4 % 2 -1 /4 + 6
print '1 divide by 4' , 1/4
print '1.0 dive by 4.0' , 1.0/4.0
print 'It is true that 3+2 < 5 - 7 ?'
print 3 + 2 < 5 - 7
... | true |
1f13b414cb94ff7e57a9a2a41ac470e41dfd52ba | dongjulongpy/hackerrank_python | /Strings/find_a_string.py | 385 | 4.1875 | 4 | def count_substring(string, sub_string):
string_list = list()
length = len(sub_string)
for i in range(len(string)-length+1):
string_list.append(string[i:i+length])
return string_list.count(sub_string)
if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()
... | true |
76265670bce143a07b85821de09bab6355a40e92 | LisaLen/code-challenge | /interview_cake_chals/find_rotation_point.py | 1,661 | 4.125 | 4 | '''I opened up a dictionary to a page in the middle and started flipping through,
looking for words I didn't know. I put each word I didn't know at increasing
indices in a huge list I created in memory. When I reached the end of the
dictionary, I started from the beginning and did the same thing until I reached
the ... | true |
0b98b66200151b0dc6bd322824f2d53b37e2329c | LisaLen/code-challenge | /primes/primes.py | 927 | 4.28125 | 4 | """Return count number of prime numbers, starting at 2.
For example::
>>> is_prime(3)
True
>>> is_prime(24)
False
>>> primes(0)
[]
>>> primes(1)
[2]
>>> primes(5)
[2, 3, 5, 7, 11]
"""
def is_prime(number):
assert number >= 0
if number < 2:
return False
... | true |
1c627ef942bc3401647b955fda0cd4a9139e6e57 | iliakur/python-experiments | /test_strformat.py | 1,311 | 4.125 | 4 | """12/08/2016 my colleague Leela reported getting a weird error.
She was trying to perform an equivalent of the following string interpolation:
`" a {0}, b {1}".format(some_dict["key"], ["key2"])`
She had forgotten to type `some_dict` for the second argument of `format`.
However the error she got was unrelated to tha... | true |
e50d72ab79c96789a88454a52ceb0c54985130e9 | Lusarom/progAvanzada | /ejercicio38.py | 825 | 4.5 | 4 | #Exercise 38: Month Name to Number of Days
#The length of a month varies from 28 to 31 days. In this exercise you will create
#a program that reads the name of a month from the user as a string. Then your
#program should display the number of days in that month. Display “28 or 29 days”
#for February so that leap years... | true |
beeea37473e0c78c74d28ca618548df2fab1cf0b | Lusarom/progAvanzada | /ejercicio40.py | 766 | 4.5 | 4 | #Exercise 40: Name that Triangle
#A triangle can be classified based on the lengths of its sides as equilateral, isosceles
#or scalene. All 3 sides of an equilateral triangle have the same length. An isosceles
#triangle has two sides that are the same length, and a third side that is a different
#length. If all of the... | true |
32799865345f5c901d665edadf4cc0904cbaff3d | DJBlom/Python | /CS1101/Unit_7/Discussion.py | 1,141 | 4.65625 | 5 | """ This is a program to demonstrate how tuples can be usefull loops over lists and dictionaries. """
def listZip():
st = 'Code'
li = [0, 1, 2, 3]
print('Zip function demo.')
t = zip(li, st)
for i, j in t:
print(i, j... | true |
4a2455564ea6478e6ea519a97befc90cc8a3aed2 | nimkha/IN4110 | /assignment3/wc.py | 1,391 | 4.46875 | 4 | #!/usr/bin/env python
import sys
def count_words(file_name):
"""
Takes file name and calculates number of words in file
:param file_name:
:return: number of words in file
"""
file = open(file_name)
number_of_words = 0
for word in file.read().split():
number_of_words += 1
... | true |
3626f86acddcde796092a53d014f8f50137ace0a | prasannatuladhar/30DaysOfPython | /day17.py | 1,685 | 4.375 | 4 | """
1) Create a function that accepts any number of numbers as positional arguments and prints the sum of those numbers. Remember that we can use the sum function to add the values in an iterable.
2) Create a function that accepts any number of positional and keyword arguments, and that prints them back to the user. Y... | true |
35d7c42f4c010a1e13be3938b4f5a9853ac1be3b | prasannatuladhar/30DaysOfPython | /day16.py | 1,224 | 4.5625 | 5 | """
1) Use the sort method to put the following list in alphabetical order with regards to the students' names:
students = [
{"name": "Hannah", "grade_average": 83},
{"name": "Charlie", "grade_average": 91},
{"name": "Peter", "grade_average": 85},
{"name": "Rachel", "grade_average": 79},
{"name": "Lauren", "grade... | true |
a6b674c546b274b86005d37f47214a4395906407 | alexeysorok/Udemy_Python_2019_YouRa | /Basics/03_string.py | 927 | 4.28125 | 4 | greeting = "Hello!"
first_name = "Jack"
last_name = "White"
print(greeting + ' ' + first_name + ' ' + last_name)
print(len(greeting)) # длина
print(greeting[-1])
print(greeting[2:5])
print(greeting[::-1]) # перевернуть строку
print(greeting.upper())
print(greeting.lower())
print(greeting.split()) # разделяет по проб... | true |
2baf17cc2c72406fcc1f3b089a986727cfd25230 | ztnewman/python_morsels | /circle.py | 619 | 4.21875 | 4 | #!/usr/bin/env python3
import math
class Circle:
def __init__(self,radius=1):
if radius < 1:
raise ValueError('A very specific bad thing happened')
self.radius = radius
def __str__(self):
return "Circle("+str(self.radius)+")"
def __repr__(self):
return "... | true |
52b40ae26017b13d5f259c7790c95987186e71bd | erinszabo/260week_5 | /main.py | 2,301 | 4.34375 | 4 | """
Chapter 6 in Runestone Exercises:
2, 3 - Do the recursive search without slicing. 5, 6, 7, 15, 16
"""
if __name__ == '__main__':
print("")
print("")
print("2) Use the binary search functions given in the text (recursive and iterative). Generate a random, "
"ordered list of integers and do a ... | true |
1aba5ddb6b34e4f6ee1a0d11f74a20de7cf975c8 | tannazjahanshahi/tamrinpy | /tamrin3.py | 1,151 | 4.3125 | 4 | # # for i in range(6):
# # for j in range(i):
# # print ('* ', end="")
# # print('')
# # for i in range(6,0,-1):
# # for j in range(i):
# # print('* ', end="")
# # print('')
# numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] # Declaring the tuple
# cnt_odd=0
# odd_list=[]
# cnt_even=0
# even_list=... | true |
2eeee06b978d55b99a68eeffa12eb62a127ee0c3 | LinhPhanNgoc/LinhPhanNgoc | /page_63_project_09.py | 614 | 4.21875 | 4 | """
Author: Phan Ngoc Linh
Date: 02/09/2021
Problem:
Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles.
Use the following approximations:
• A kilometer represents 1/10,000 of the distance between the North Pole and the equator.
• There ar... | true |
b4f79d10f725f9ab9120f67282f4d34726f60430 | hafizur-r/Python | /week_2/Problem2_5.py | 1,324 | 4.40625 | 4 | """
Problem 2_5:
Let's do a small simulation. Suppose that you rolled a die repeatedly. Each
time that you roll the die you get a integer from 1 to 6, the number of pips
on the die. Use random.randint(a,b) to simulate rolling a die 10 times and
printout the 10 outcomes. The function random.randint(a,b) will
gen... | true |
34e659a741a9be2903e86f40143d58e38623fa5b | hafizur-r/Python | /week_3/Problem3_4.py | 1,400 | 4.34375 | 4 | #%%
"""
Problem 3_4:
Write a function that is complementary to the one in the previous problem that
will convert a date such as June 17, 2016 into the format 6/17/2016. I
suggest that you use a dictionary to convert from the name of the month to the
number of the month. For example months = {"January":1, "Febru... | true |
885164b1fd52886a7d065fd8cdadf1b7b15d9d57 | yanjun91/Python100DaysCodeBootcamp | /Day 9/blind-auction-start/main.py | 978 | 4.15625 | 4 | from replit import clear
from art import logo
#HINT: You can call clear() to clear the output in the console.
print(logo)
print("Welcome to the secret auction program.")
continue_bid = True
bidders = []
while continue_bid:
name = input("What is your name?: ")
bid = int(input("What's your bid?: $"))
# Store... | true |
a196a7540550ffb301675dbc5138757faabf422a | MaGo1981/MITx6.00.1x | /MidtermExam/Sandbox-ExtraProblems-NotGraded/Problem9.py | 928 | 4.59375 | 5 | '''
Problem 9
1 point possible (ungraded)
Write a function to flatten a list. The list contains other lists, strings, or ints.
For example, [[1,'a',['cat'],2],[[[3]],'dog'],4,5] is flattened into [1,'a','cat',2,3,'dog',4,5]
def flatten(aList):
'''
'''
aList: a list
Returns a copy of aList, which is a flatten... | true |
f665521d39d777428e35e4c66706e0ccf5eed10d | camitt/PracticePython_org | /PP_Exercise_1.py | 1,175 | 4.28125 | 4 | from datetime import date
# Exercise 1
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Extras:
#
# 1. Add on to the previous program by asking the user for another number and printing out that m... | true |
f60727bc1404c6a3631e4a9b158d847abe44afef | AnkyXCoder/PythonWorkspace | /practice.py | 939 | 4.53125 | 5 | # Strings
first_name = "Ankit"
last_name = "Modi"
print(first_name)
print(last_name)
full_name = first_name + last_name
print(full_name)
# printing name with spaces
full_name = first_name + ' ' + last_name
print(full_name)
# OR you can print it like this also
# with no difference
print(first_name + ' ' + last_nam... | true |
43491586c77d23d9aba8416dd658cc7bf795f917 | AnkyXCoder/PythonWorkspace | /Object Oriented Programming/Abstraction.py | 1,463 | 4.5625 | 5 | # Create a class and constructors
# Abstraction
# create an object
class PersonalCharacter:
# global attribute
_membership = True
# constructor
def __init__(self, name = 'anonymous', age = 0, strength = 100): # dunder method
"""This is a constructor using __init__ which is called a duncder meth... | true |
180c54cc32d9d18b773f9a91e734b19f254c5014 | AnkyXCoder/PythonWorkspace | /python basics/dictionary.py | 2,859 | 4.3125 | 4 | # Dictionary
# data structure that stores data in terms of keys and values as pairs
# list is a sorted data structure, list of people in queue
# dictionary has no order, list of a persons belongings in wardrobe
user2 = dict(name = "Johny")
print(user2)
# another way of creating dictionary
dictionary = {
# immu... | true |
81982a4ea086b205b116518aa20113f130b6d0d8 | AnkyXCoder/PythonWorkspace | /Object Oriented Programming/Modifying_Dunder_Methods.py | 1,175 | 4.75 | 5 | # Whenever an Object is created and instantiated, it gest access to all the basic Dunder Methods available to it as per Python
# Programming Language.
# By defining the Dunder Method in the Class Encapsulation, the access to Dunder Methods are modified.
class SuperList(list): # Defining SuperList as the Subclass of t... | true |
45c8680dc29404c7cd53bf30445d9c821705c9d4 | zhjohn925/niu_algorithm | /S03_Interpolation_search.py | 1,573 | 4.5625 | 5 | # Interpolation search can be particularly useful in scenarios where the data being searched is uniformly
# distributed and has a large range.
# For example:
# Large Data Sets: If you have a large data set and the elements are uniformly distributed, interpolation search
# can provide faster search times compared to b... | true |
20c2f4cf45a6a501895565d2f40273263d77430c | zhjohn925/niu_algorithm | /L20_Bucket_Sort.py | 2,347 | 4.1875 | 4 | # Bucket Sort is a linear-time sorting algorithm on average when the input elements are uniformly
# distributed across the range.
# It is commonly used when the input is uniformly distributed over a range or when the range of values
# is relatively small compared to the input size.
def bucket_sort(arr):
# Crea... | true |
f8ca4890c4833c2d752a3dcf14dc404089e7c85a | Aka-Ikenga/Daily-Coding-Problems | /swap_even_odd.py | 527 | 4.21875 | 4 | """Good morning! Here's your coding interview problem for today.
This problem was asked by Cisco.
Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, the 3rd and 4th bit should be swapped, and so on.
For example, 10101010 should be 01010101. 11100010 should be 11010001... | true |
a26239a775b14953e7dfe6c922bbf7a95b7e6a69 | juliangyurov/js-code | /matrix.py | 1,170 | 4.71875 | 5 | # Python3 program to find the sum
# of each row and column of a matrix
# import numpy library as np alias
import numpy as np
# Get the size m and n
m , n = 3, 3
# Function to calculate sum of each row
def row_sum(arr) :
sum = 0
print("\nFinding Sum of each row:\n")
# finding the row sum
for i in ra... | true |
64fefed9d00b683cbbcc88668ed7d17baef8dd57 | elizabethgulsby/python101 | /the_basics.py | 2,376 | 4.25 | 4 | # print "Liz Gulsby"
# name = "Liz Gulsby"
# name = "Liz " + "Gulsby"
# fortyTwo = 40 + 2;
# print fortyTwo
# fortyTwo = 84 / 2;
# print fortyTwo;
# array...psyche! Lists (in Python)
animals = ['wolf', 'giraffe', 'hippo'];
print animals
print animals[0]
print animals[-1] # gets the last element - hippo, here
animals... | true |
f4d5d91147e0a5749f7570a2fd85133fd4fcddaf | down-dive/python-practice | /maxNum.py | 596 | 4.3125 | 4 | # Max Num
# In this activity you will be writing code to create a function that returns the largest number present in a given array.
# Instructions
# - Return the largest number present in the given `arr` array.
# - e.g. given the following array:
arr = [1, 17, 23, 5, 6];
# - The following number should ... | true |
cbc3fe3f32e2879d6594aef7746f7007dceb2743 | Cwagne17/WordCloud-Generator | /WordCloud.py | 2,114 | 4.1875 | 4 | # Word Cloud
#
# This script recieves a text input of any length, strips it of the punctuation,
# and transforms the words into a random word cloud based on the frequency of the word
# count in the text.
#
# To try it - on ln20 change the .txt file to the path which youd... | true |
0c05275b5642bdfaa6db3f433c2983c9f9f74c70 | klivingston22/tutorials | /stingzz.py | 465 | 4.15625 | 4 | str = 'this is string example....wow!!!'
print str.capitalize() #simply capitalises the first letter
sub = 'i'
print str.count (sub, 4, 40) # this should output 2 as 'i' appears twice
sub = 'wow'
print str.count(sub) # this should output 1 as 'wow' only appears once
print len(str) # this should output 33 as th... | true |
cd728160534e09d7cb8adee8b4bebaaf81d083a3 | shivanikarnwal/Python-Programming-Essentials-Rice-University | /week2-functions/local-variables.py | 853 | 4.1875 | 4 | """
Demonstration of parameters and variables within functions.
"""
def fahrenheit_to_celsius(fahrenheit):
"""
Return celsius temperature that corresponds to fahrenheit
temperature input.
"""
offset = 32
multiplier = 5 / 9
celsius = (fahrenheit - offset) * multiplier
print("... | true |
824d7672f35bf799e5ce0914c29bfed54805866d | siddeshshewde/Competitive_Programming_v2 | /Daily Coding Problem/Solutions/problem002.py | 1,075 | 4.1875 | 4 | """
This problem was asked by Uber.
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If ... | true |
725fd29a6a090a89a375b345965e88b4bbb173d8 | DanishKhan14/DumbCoder | /Python/Arrays/bestTimeToBuySellStock.py | 581 | 4.3125 | 4 | """
Max profit that we can get in a day is determined by the minimum prices in previous days.
For example, if we have prices array [3,2,5,8,1] we can calculate the min prices array [3,2,2,2,1]
and get the difference in our max profit array [0,0,3,6,0]. We can see clearly the max profit is 6,
which is buy from the index... | true |
280a5cbb31989e73535ff4b77dc9f727ca36dd8a | ktb702/AutomateTheBoringStuff | /sum.py | 854 | 4.15625 | 4 | # PROBLEM STATEMENT
# If we list all the natural numbers between 1 and 10 (not including 1 or 10) that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Write code using a language of your choice that will find the sum of all the multiples of 3 or 5 between 1 and 1000 (not including... | true |
37f59db3e5bb8925c6913bf7f309c6e375da0069 | gerardoxia/CRACKING-THE-CODING | /1.8.py | 636 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def isSubstring(str1,str2):
length1=len(str1)
length2=len(str2)
check=True
if length1>length2: return False
for index2 in range(length2-length1+1):
index=index2-1
for index1 in range(length1):
index=index+1
if s... | true |
31339c4dfd1287b66e689816a8f2ba69b4ceb88f | katherine-davis/katherine-davis.github.io | /day 12.py | 1,525 | 4.15625 | 4 | ###########################################################################
#********************************--day 12--********************************
##Write a function called initials
##it to take in three perameters
## first name
## last name
## and middle name
## and then return their initials... | true |
3f70f8f5a551e0daebf6ef8f8b083fd552bff472 | qzlgithub/MathAdventuresWithPython | /ex1.2CircleOfSquares.py | 303 | 4.15625 | 4 | # Write and run a function that draws 60 squares, turning right 5 degrees after each square. Use a loop!
from turtle import *
shape('turtle')
speed(0)
def createSquares():
for j in range(4):
forward(100)
right(90)
for j in range(60):
createSquares()
right(5)
| true |
6333f91ccd0c372887a2367b29e3fbbb0a2b0d9c | AlexOfTheWired/cs114 | /FinalProject/Final_Project.py | 2,346 | 4.125 | 4 | """
Final Project Proposal()
Create a cash register program.
- On initialize the user sets amount of Bills and Coins in register
(starting bank amount)
- Set Sales Tax
- sales_tax = 2.3%
- Then print Register status:
- Amount of Coins and Bills
- Total cash amount
Render Transaction:
(S... | true |
d60c724b32214d29b29a8cc0bf2b1fd47b82f3be | Environmental-Informatics/python-learning-the-basics-Gautam6-asmita | /Second attempt_Exercise3.3.py | 1,009 | 4.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Created on 2020-01-16 by Asmita Gautam
Assignment 01: Python - Learning the Basics
Think Python Chapter 3: Exercise 3.3
Modified to add header and comments for resubmission on 2020-03-04
"""
"""
While considering th each rows of the grid we can see 2 patters of the row... | true |
df1ee3a21892feab3d619c813550c104e702370a | fantastic-4/Sudoku | /src/Parser/validator.py | 2,874 | 4.15625 | 4 | class Validator:
def __init__(self):
self.digits = "123456789"
self.rows = "ABCDEFGHI"
def validate_values(self,grid):
'''Function to validate the values on grid given.
Return True if their values are numeric or False if their not.'''
full_line=""
... | true |
bb521b8932abe5d21f01a144b5c384caa32daf2e | FelixFelicis555/Data-Structure-And-Algorithms | /GeeksForGeeks/Sorting/Bubble_Sort/bubble_sort.py | 436 | 4.125 | 4 | def bubbleSort(list,n):
for i in range(0,n-1):
for j in range(0,n-i-1):
if list[j]>list[j+1]:
#swap
temp=list[j]
list[j]=list[j+1]
list[j+1]=temp
print("Sorted Array : ",end=' ')
print(list)
def main():
list=[]
print("Enter the numbers in the list(Enter x to stop): ")
while True:
num=inpu... | true |
7c9aae80093542f3b41713cdffcf3fb093407be8 | jancal/jan2048python | /plot_ols.py | 2,296 | 4.34375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=========================================================
Linear Regression Example
=========================================================
This example uses the only the first feature of the `diabetes` dataset, in
order to illustrate a two-dimensional plot of this regre... | true |
2535cb0e40bc6cfdec4510b6d264a9a7f8a711c8 | rachaelthormann/Project-Euler-Python | /Problem3.py | 701 | 4.21875 | 4 | """
File name: Problem3.py
Description: This program will find the largest prime factor
of the number 600851475143.
Author: Rachael Thormann
Date Created: 3/21/2016
Date Last Modified: 3/21/2016
Python Version: 3.4
"""
def largest_prime_factor(num):
"""Finds the largest prime factor."""
i = 2
#... | true |
3b5e0d1bf01b242fac32661aba45c6d6a0983f6c | kalnaasan/university | /Programmieren 1/PRG1/Übungen/Übung_06/Alnaasan_Kaddour_0016285_3.py | 1,390 | 4.125 | 4 | """ This script is the solution of Exercise Sheet No.4 - Task 3 and 4 """
__author__ = "0016285: Kaddour Alnaasan"
__credits__ = """If you would like to thank somebody
i.e. an other student for her code or leave it out"""
__email__ = "qaduralnaasan@gmail.com"
def length_list(text):
length = len(tex... | true |
a58af9f6b048d0aa853c45a59689da0bc8abea76 | olugboyegaonimole/python | /a_simple_game.py | 2,907 | 4.4375 | 4 |
#A SIMPLE GAME
class Football():
class_name=''
description='' #THIS IS THE INITIAL VALUE OF THE PROPERTY
objects={}
#1. WHEN A SETTER IS USED, YOU MUST ASSIGN AN INITIAL VALUE TO THE PROPERTY
#2. HERE FOR EXAMPLE, THE ASSIGNMENT TAKES PLACE WHEN THE PROPERTY IS DEFINED AS A CLASS ATTRIBUTE
... | true |
02f2947e9e98e73e640aa8a46cf21878ee94bcc8 | pawnwithn0name/Python3EssentialTraining | /GUI/5.event-hangling.py | 728 | 4.1875 | 4 | '''
After the root window loads on the system, it waits for the occurence of some event. These events can be button clicks, motion of the mouse, button release, etc. These events are handled by defining functions that are executed in case an event occurs.
'''
from tkinter import *
def handler1():
print('White')
de... | true |
95d4f71e7e6a505afc4f3156a3cb57d64077db6d | pawnwithn0name/Python3EssentialTraining | /02 Quick Start/forloop.py | 338 | 4.4375 | 4 | #!/usr/bin/python3
# read the lines from the file
fh = open('lines.txt')
for line in fh.readlines():
# Print statement 'end' argument in Python 3 allows overriding the end-of-line character which
# defaults to '\n'. Each line in the file already has a carriage return so the end-of-line is not needed.
print... | true |
e28e734decc6a09e159ce7105997df8d2bb1f437 | dvishwajith/shortnoteCPP | /languages/python/algorithms/graphs/bfs/bfs.py | 998 | 4.25 | 4 | #!/usr/bin/env python3
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
from collections import deque
print("bfs first method. Using deque as a FIFO because list pop(0) is O(N)")
def BFS(graph, start):
node_fifo = deque([]) #using deque becaus... | true |
7cd2eef61cd8036e0e78001a306b0737f7d9e191 | EfimT/pands-problems-2020 | /homework 2.py | 266 | 4.21875 | 4 | # Write a program that asks a user to input
# a string and outputs every second letter in reverse order.
sentence = (input("Enter a string : "))
sentence = sentence [::-1]
print ("Heres is you're string reversed and every second letter is:", sentence[::2]) | true |
95af810ee907a31e305afca8e4f7413807b82213 | BT-WEBDEV/Volcano-Web-Map | /script.py | 1,674 | 4.25 | 4 | #folium - lets us generate a map within python
#pandas - lets us read the csv file containing volcano locations.
import folium
import pandas
#dataframe variable will let us read the txt file.
df=pandas.read_csv("Volcanoes.txt")
#map variable - this creates our map object.
map=folium.Map(location=[df['LAT'... | true |
74bde0e83f315810c5a80032527d31780d6e7200 | DavidLohrentz/LearnPy3HardWay | /ex3.py | 946 | 4.5 | 4 | # print the following text
print("I will now count my chickens:")
# print Hens and add 25 + (30/6)
print("Hens", 25 + 30.0/6)
# print Roosters calc the following
print("Roosters", 100 - 25.0 * 3 % 4)
# print this text
print("Now I will count the eggs:")
# print the following calc total
print(3.0 + 2 + 1 - 5 ... | true |
e9578f654f6e9e0c8f2d9a450bb7010814a36230 | DavidLohrentz/LearnPy3HardWay | /ex15.py | 740 | 4.375 | 4 | # get the argv module ready
# from sys import argv
# tell argv what to do with the command line input
#script, filename = argv
# define txt; mode r is read only
# save filename text to txt variable
# txt = open(filename, mode = 'r')
# put in a blank line at the top
print("\n")
# print a string with filename va... | true |
288b48493795a69feb81d2da83d2239c977344c4 | jiyifan2009/calculator | /main.py | 891 | 4.25 | 4 | #Calculator
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 = int(input("What's the first number?: "))
for symb... | true |
13ac170d8fa2a582b5bd2c045142f4f7973e6509 | yuenliou/leetcode | /lcof/06-cong-wei-dao-tou-da-yin-lian-biao-lcof.py | 1,923 | 4.1875 | 4 | #!/usr/local/bin/python3.7
# -*- coding: utf-8 -*-
from typing import List
from datatype.list_node import ListNode, MyListNode
def reversePrint(head: ListNode) -> List[int]:
return reversePrint(head.next) + [head.val] if head else []
def reversePrint3(head: ListNode) -> List[int]:
list = []
def reverse(h... | true |
e6eae9ba50431852dd588b56dc975cabe2be8a98 | 73nko/daily-interview | /Python/matrix-spiral-print.py | 2,042 | 4.1875 | 4 | ###
# 13-12-2020
# Hi, here's your problem today. This problem was recently asked by Amazon:
# You are given a 2D array of integers. Print out the clockwise spiral traversal of the matrix.
# Example:
# grid = [[1, 2, 3, 4, 5],
# [6, 7, 8, 9, 10],
# [11, 12, 13, 14, 15],
# [16, 17, 18, 19... | true |
b628c6fcf630b12388ea72c75bec610993c7fa25 | 73nko/daily-interview | /Python/cal-angle.py | 1,087 | 4.34375 | 4 | ###
# 16-01-2021
# Hi, here's your problem today. This problem was recently asked by Microsoft:
#
# Given a time in the format of hour and minute, calculate the angle of the hour and minute hand on a clock.
###
###
# SOLUTION
# This is primarily breaking down the problem into a formula.
# It is more tricky than algori... | true |
e0c4b786df476a43bb9210912fdc1df62cfe6601 | 73nko/daily-interview | /Python/falling-dominoes.py | 1,465 | 4.125 | 4 | ###
# 05-12-2020
# Hi, here's your problem today. This problem was recently asked by Twitter:
# Given a string with the initial condition of dominoes, where:
# . represents that the domino is standing still
# L represents that the domino is falling to the left side
# R represents that the domino is falling to the rig... | true |
b870fbb7bf5c9ecdefd05971e372aa1242a17113 | ismailft/Data-Structures-Algorithms | /LinkedLists/LinkedList.py | 746 | 4.21875 | 4 | #Implementation of a linked list:
class Node(object):
def __init__(self, data):
self.Data = data
self.next = None
self.prev = None
class LinkedList(object):
def __init__(self):
self.head = None
print("Linked List Created!")
def addNode(self, data):
node = No... | true |
87a1288436eeb85f7d485ee347c254da06855fd6 | loveplay1983/daily_python | /python_module_with_example/Text/str_cap.py | 543 | 4.1875 | 4 | # Manually accomplish the same functionality of string.capwords()
# separate text first then use a temp list add each part of the text in which each text has already been convert to captalized by for loop, then use join() to combine all together
# import string
text = 'hello world'
def captalize(text):
text_sep =... | true |
01882010d5ec0d5fab6e89804a09fe05c3fb1a58 | WitheredGryphon/witheredgryphon.github.io | /python/HackerRank/Regex/detect_the_email_addresses.py | 936 | 4.15625 | 4 | '''
You will be provided with a block of text, spanning not more than hundred lines.
Your task is to find the unique e-mail addresses present in the text.
You could use Regular Expressions to simplify your task.
And remember that the "@" sign can be used for a variety of purposes!
Input Format
The first line conta... | true |
11bbb77f4b587d8863076daafee3138f29241f13 | WitheredGryphon/witheredgryphon.github.io | /python/Code Wars/count_the_smiley_faces.py | 1,457 | 4.125 | 4 | '''
Description:
Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.
Rules for a smiling face:
-Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
-A smiley face can have a nose but it does not have to. Valid charact... | true |
bb2d4ac961ebd2e517cc2e29ebcc47011e420027 | ruvvet/File-Rename | /Rename.py | 2,862 | 4.125 | 4 | # BATCH FILE RENAMER PROGRAM
# Rename all files within a folder using the folder name, a specified name, or last modified date as the prefix.
import os
import glob
import sys
import time
def main():
# Input the directory with all files.
# Returns all files in the folder and the # of files in the fol... | true |
f5c6213aac0f6d02789e29dd82d82b3054b7e69b | rishabhjhaveri10/Linear-Regression | /linear_regression_scipy.py | 2,337 | 4.4375 | 4 | #This code has its inspiration from Data Science and Machine Learning with Python course by Frank Kane on www.udemy.com.
import numpy as np
from matplotlib import pyplot as plt
from scipy import stats
#Model 1
#Generating page speeds randomly with a mean of 3, standard deviation of 0.5 and for 1000 people.
pa... | true |
0778ccfd4830cb34d032acaf51f4dfd764f07cb3 | marlonrenzo/A01054879_1510_assignments | /A3/character.py | 1,300 | 4.34375 | 4 | def get_character_name():
"""
Inquire the user to provide a name.
:return: a string
"""
name = input("What is your name?").capitalize()
print(f"Nice to meet you {name}\n")
return name
def create_character() -> dict:
"""
Create a dictionary including attributes to associate to a ch... | true |
0a571afe9dc8d96a68d51d74efbd9af73adeb66c | marlonrenzo/A01054879_1510_assignments | /A4/Question_3.py | 1,371 | 4.34375 | 4 | import doctest
def dijkstra(colours: list) -> None:
"""
Sort the colours into a pattern resembling dutch flag.
Capitalize all letters except for strings starting with 'b' in order to sort the way we need to.
:param colours: a list
:precondition: colours must be a non-empty list
:post conditi... | true |
cf9a22378eb8cb4bd42f5821b51ccf9123c32e4d | Saketh1196/Programming | /Python/Weather Measurement.py | 367 | 4.21875 | 4 | Temp=float(input("Enter the temperature in Fahrenheit: "))
Celsius=(5/9)*(Temp-32)
print("The temperature in Celsius is: ",Celsius)
while True:
if Celsius>30:
print("The Weather is too hot. Please take care")
elif Celsius<10:
print("The Weather is too Cold. Wear Warm Clothes")
else:
... | true |
5cbf031344cab3889dfa61b44b9739befd5abd29 | Sumanth-Sam-ig/pythoncode | /sum of square and cube of series.py | 762 | 4.21875 | 4 | print ('Enter the number n')
a=int(input())
print('Enter the number of the mathematical operation required')
print ('')
print(""" 1 - Sum of the numbers till n
2 - sum of the squares of the numbers
3 -sum of the cubes of the numbers """)
print('\n')
b=int(input())
if b>3:
print('invalid entery'... | true |
76ad14efd7fd787c72dd439f54eb6fc21fd0bb57 | Anancha/Inventing-Phoenix-Getting-to-know-Raspberry-PI-Pico | /1) Blink code for Raspberry PI Pico.py | 734 | 4.125 | 4 | #Code created by Inventing Phoenix
#1 FEB 2021
from machine import Pin # For accessing these pins using the Pin class of the machine module
import time # Time module helps in creating delays
led= Pin(25,Pin.OUT) # The Pin is assigned and the mode of the pin is set in this command
while True: # While T... | true |
9eb18156516741b7e836d6aedfb9305a1b8a8c18 | andy-j-block/COVID_Web_Scraper | /helper_files/get_todays_date.py | 400 | 4.28125 | 4 |
from datetime import date
def get_todays_date():
###################
#
# This function gets today's current day and month values for later use in
# the program.
#
###################
todays_date = str(date.today())
current_day = todays_date.split('-')[2]
cur... | true |
b82235bfdb9c233787b1f791e34f293cf739c8dd | Yixuan-Lee/LeetCode | /algorithms/src/Ex_987_vertical_order_traversal_of_a_binary_tree/group_share_jiangyh_dfs.py | 1,229 | 4.1875 | 4 | """
DFS method
Time complexity:
Space complexity: O(N)
"""
import collections
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def verticalTrave... | true |
eb0ab4d39ecbda17d7a3903c3825eeb435da3d4a | mozahid1/Easy-Calculator | /Easy_to_Calculate.py | 1,155 | 4.1875 | 4 |
# This function adds two numbers
def add(x,y):
return x + y
# This function subtracts two numbers
def subtract(x,y):
return x - y
# This function multiplies two numbers
def multiply(x,y):
return x * y
# This function divides two numbers
def divide(x,y):
return x / y
print("Select... | true |
ba6b894681b78a1023760739eb2a1731b9aa8965 | Neveon/python-algorithms | /binary_search/binary_search_intro.py | 1,102 | 4.25 | 4 | # Iterative Binary Search
def binary_search_iterative(data, target):
# array is already sorted - we split the array in half to find if the target is
# in the upper half or lower half of the already sorted array
low = 0
high = len(data) - 1
while low <= high:
mid = (low + high) // 2
print('Indices: lo... | true |
e9d5d74c5d6667f525866164554d59d515737a31 | makennamartin97/python-algorithms | /ninjainheritence.py | 1,677 | 4.4375 | 4 | # As you can see, peons have limited abilities. They only have default health
# point of 100 and can't attack but can only takeDamage.
# Imagine that you wanted to create a new class called Warrior. You want
# warrior to have everything that a Peon has. You also want the warrior to
# do everything that a Peon can d... | true |
965fe9cd22babe11276fc0efaf1fd5389498fb0e | makennamartin97/python-algorithms | /sorts/bubblesort.py | 541 | 4.25 | 4 | # bubble sort
# It is a comparison-based algorithm in which each pair of adjacent elements
# is compared and the elements are swapped if they are not in order.
def bubblesort(list):
# Swap the elements to arrange in order
for i in range(len(list)-1,0,-1): # start stop step
for j in range(i):
... | true |
68530451a07c82d1a0c553bf6535fd0dbdf8f95f | makennamartin97/python-algorithms | /stutteringfxn.py | 508 | 4.125 | 4 | # Write a function that stutters a word as if someone is struggling to read it.
# The first two letters are repeated twice with an ellipsis ... and space after
# each, and then the word is pronounced with a question mark ?.
# stutter("incredible") ➞ "in... in... incredible?"
# stutter("enthusiastic") ➞ "en... en...... | true |
df1eba0e96c7a622d0a7f9140d2480e83e930847 | makennamartin97/python-algorithms | /sorts/mergesort.py | 922 | 4.28125 | 4 | # merge sort
# Merge sort first divides the array into equal halves and then combines
# them in a sorted manner.
unsortedlist = [64, 34, 25, 12, 22, 11, 90]
def mergesort(unsortedlist):
if len(unsortedlist) <= 1:
return unsortedlist
# find middle pt and divide it
mid = len(unsortedlist) //2
lef... | true |
be4114feb5e61f82d58686aa757adea9a93f8296 | makennamartin97/python-algorithms | /factorial.py | 315 | 4.375 | 4 | # Create a function that takes an integer and returns the factorial of that
# integer. That is, the integer multiplied by all positive lower integers.
# factorial(3) ➞ 6
# factorial(5) ➞ 120
# factorial(13) ➞ 6227020800
def factorial(num):
if num < 2:
return num
else:
return factorial(num-1) * num | true |
3def48fa48e7add42ed31186c7d15327a554d68e | samuel-navarro/calendar | /date_parser.py | 1,080 | 4.46875 | 4 | import yearinfo
def date_str_to_tuple(date_string: str):
"""
Calculates a date tuple (day, month, year) from a date string in the format dd.mm.yyyy
:param date_string: Date string with the form dd.mm.yyyy
:return: The date tuple with three integers if the parsing was successful, None otherwise
"""... | true |
09d69fb7eb61eefa361141d80f8572862de9090a | atulasati/scripts_lab_test | /user_crud/PROG1326_Lab7_VotreNom.py | 2,104 | 4.1875 | 4 | import getpass
class User(object):
""" Defined user object.
create user object passing params - name, city, phone
Args:
name (str, mandatory): user name, to be provide during the user creation
city (str, mandatory): user city, to be provide during the user creation
"""
def __init__(self, name, city, pho... | true |
3b77508b910db0d8b6781964d76f25389c9597f6 | vaibhavtwr/patterns-and-quiz | /python/kmtom.py | 496 | 4.21875 | 4 | #Python Program to Convert Kilometers to Miles
ch=int(input("enter 1 for change in kilometers to miles \n enter 2 for change in miles to kilometers"))
if (ch==1):
n=int(input("enter the distance in kilometers"))
m=0.621371*n
txt="you distance in kilometer {} and in miles {}"
print(txt.format(n,m))
elif (ch==2) :
... | true |
1178bb0800c6b294a4462d3e08813f772341b721 | dklickman/pyInitial | /Lab 8/workspace2.py | 982 | 4.28125 | 4 |
num_date = input("Please enter a date in mm/dd/yy format: ")
# Create variables to check against the month conditions
# and convert to an integer so we can math on it
month_check = int(num_date[0:2])
day_check = int(num_date[3:5])
year_first_value = (int(num_date[6]))
year_second_value = (int(num_date[7]))
y... | true |
9cf3a51ee95373998a0f10b48714147b82a795e2 | dklickman/pyInitial | /Lab 7/Notes/7.7 Returning a List from a Function.py | 973 | 4.375 | 4 | # This program uses a function to create a list
# The function returns a reference to the list
def main():
# Get a list with values stored in it
numbers = get_values()
# Display the values in the list
print("The numbers are", numbers)
# The get_values() function gets a series of numbers
... | true |
e14f317d78a45ecac9a946cb0448c79a986f62e6 | dklickman/pyInitial | /Lab 7/Notes/7.7 Working with Lists and Files Part D2 reading numbers to a file.py | 856 | 4.1875 | 4 | # While reading numbers from a file into a list; convert the number
# stored as a string back into an integer so math can be performed
# This program reads numbers from a file into a list
def main():
# Open the file
infile = open('numberlist.txt', 'r')
# Read the file's content into a list
... | true |
83e550b09a6b39a2ea66387520f1134f451d97ac | Adrian-Jablonski/python-exercises | /Guess_A_Number/Guess_A_Number.py | 1,243 | 4.15625 | 4 | import random
secret_number = random.randint(1, 10)
guesses_left = 5
game_over = False
print("I am thinking of a number between 1 and 10")
print("You have ", guesses_left, " guesses left.")
while game_over == False:
guess = int(input("What's the number? "))
if guess == secret_number:
print("Yes! Yo... | true |
e5e378fabf26fec9c650ba4d624ac2720a8bbdb8 | nehayd/pizza-deliveries | /main.py | 985 | 4.1875 | 4 | # 🚨 Don't change the code below 👇
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
add_cheese = input("Do you want extra cheese? Y or N ")
# 🚨 Don't change the code above 👆
#Write your code below this line ... | true |
8ee2de89c9697171cbd18ff19855e37e320b3d19 | VasudevJaiswal/Python-Quistions-CP | /If-Elif-Else/02 - Test/02.py | 842 | 4.15625 | 4 | # Write a program to accept the cost price of a bike and display the road tax to be paid according to the following criteria :
# Cost price (in Rs) Tax
# > 100000 15 %
# > 50000 and <= 100000 ... | true |
45a80c99c1943ffe147270995fff4fe2eb827d4f | akhilnair111/100DaysOfCode | /Week1/String Slicing.py | 542 | 4.125 | 4 | """ Copeland’s Corporate Company also wants to update how they generate temporary passwords for new employees.
Write a function called password_generator that takes two inputs, first_name and last_name and then concatenate the last three letters of each and returns them as a string. """
first_name = "Reiko"
last_name... | true |
3be4dc6f769698dc958ceeed3e6dc4c50deda0f2 | akhilnair111/100DaysOfCode | /Week2/Delete a Key using dictionaries.py | 1,131 | 4.15625 | 4 | """ 1.
You are designing the video game Big Rock Adventure. We have provided a dictionary of items that are in the player’s inventory which add points to their health meter. In one line, add the corresponding value of the key "stamina grains" to the health_points variable and remove the item "stamina grains" from the ... | true |
6bb25eb72442be16fde69b5bba6cccfafd93010b | akhilnair111/100DaysOfCode | /Week3/part_of_speech.py | 2,399 | 4.15625 | 4 | """ . Import wordnet and Counter
from nltk.corpus import wordnet
from collections import Counter
wordnet is a database that we use for contextualizing words
Counter is a container that stores elements as dictionary keys
2. Get synonyms
Inside of our function, we use the wordnet.synsets() function to get a set of synony... | true |
40a07ac8623ec825f9262ff5bb2839076ca5885a | luismelendez94/holbertonschool-higher_level_programming | /0x06-python-classes/3-square.py | 486 | 4.3125 | 4 | #!/usr/bin/python3
"""This is the class Square"""
class Square:
"""Compute the area of the square"""
def __init__(self, size=0):
"""Initialize variable size"""
try:
self.__size = size
if size < 0:
raise ValueError("size must be >= 0")
except Ty... | true |
944a48e3b0f0714cab53057649706393df849e5e | luismelendez94/holbertonschool-higher_level_programming | /0x06-python-classes/5-square.py | 1,003 | 4.375 | 4 | #!/usr/bin/python3
"""This is the class Square"""
class Square:
"""Print a square"""
def __init__(self, size=0):
"""Initialize variable size"""
self.__size = size
def area(self):
"""Compute the area size of a square"""
return self.__size ** 2
@property
def size... | true |
bae61c16ce9f880b3b0041b229e69deee721f74f | luismelendez94/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 445 | 4.3125 | 4 | #!/usr/bin/python3
"""Function that make an integer addition
Verifies if it is an integer and if float,
converts it to integer
"""
def add_integer(a, b=98):
"""Function that adds 2 integers"""
if not isinstance(a, int) and not isinstance(a, float):
raise TypeError("a must be an integer")
if not ... | true |
f71e1facae36061727ccd6673297ab8da0a09bbf | cjoelfoster/pythagorean-triple-finder | /pythagorean-triples.py | 2,349 | 4.625 | 5 | #! /usr/bin/env python3.6
## Find all pythagorean triples within a specified range of values
# 1) input a value, 'z'
# 2) find all pythagorean triples such that x^2 + y^2 = z^2, 0<=x<=z, 0<=y<=z
# 3) return the list of triples in ordered by increasing z, x, y
# 4) future development: include a lower bound for 'z' suc... | true |
ea644a40d55c45f5698fac5f0ec3148aceac4101 | Gelitan/IwanskiATLS1300 | /Animating with Turtles/PC02_20200131_Iwanski.py | 2,797 | 4.40625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 31 09:41:11 2020
@author: analiseiwanski
"""
#========
#PC02-Animating with Turtles
#Analise Iwanski
#200131
#
#This code creates an abstract animation of tangent circles with radii based on the fibonacci sequence, then creates a red and blue
#opp... | true |
9f68fc23bba9abef83216264a9233d696495f81f | coflin/Intrusion-Detection-System | /shaktimaan/bashmenu/HiddenPython | 893 | 4.4375 | 4 | #!/usr/bin/python
import os
#Code for searching the hidden files in the given directory
path=raw_input("Enter the path : ")
print("---------------------------------------------")
def hiddenFile(path):
for root,dirs,files in os.walk(path,topdown=False): #looping through the directory '.' means current working director... | true |
1ef857b41c9d6449388b6026d28487716534fdd6 | quezada-raul-9060/CS161_Final_Project | /CS161_project/Brick_class.py | 1,048 | 4.15625 | 4 | class theBrick(object):
"""
Created a class for the brick.
The class is for a brick/rectangle created.
Will make a hitbox for the brick.
"""
def __init__(self, x, y, width, height):
"""
Sets variables for the brick.
This code gives the specifics of the bric... | true |
e68f3a6816d2008674f8fe1f67f1fab62c97a619 | HoaiHoai/btvn-vuthithuhoai | /Assignment1/2.py | 320 | 4.15625 | 4 | import math #library needed to use method acos
pi = math.acos(-1) #get pi value 3.1459265359 (arc cosine of -1 = pi)
radius = float(input("Radius? ")) #read input 'radius' from user
area = radius ** 2 * pi #calculate area r^2*pi
print("Area = %.2f" % area) #print out with 2 numbers after decimal point | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.