blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
8026ce987b2ed319dee7faf702c82772be01e708 | dzhonapp/python_programs | /Loops/averageRainfall.py | 1,003 | 4.375 | 4 | '''Write a program that uses nested loops to collect data and calculate the average rainfall
over a period of years. The program should first ask for the number of years. The outer loop
will iterate once for each year. The inner loop will iterate twelve times, once for each month.
Each iteration of the inner loop will ... | true |
94b675bb81acbb2d07829c4180920a36bb601b8b | dzhonapp/python_programs | /Basics/Celsius to Fahreneit Temperature Converter.py | 429 | 4.25 | 4 | '''9. Celsius to Fahrenheit Temperature Converter
Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula
is as follows:
F =9/5C+32
The program should ask the user to enter a temperature in Celsius, and then display the
temperature converted to Fahrenheit.
'''
fahreneit= int(input('... | true |
8d0ae7668e921e6e0047c1143cfbcdbf56f701a6 | dzhonapp/python_programs | /functions/milesPerGallon.py | 507 | 4.34375 | 4 | '''Miles-per-Gallon
A car’s miles-per-gallon (MPG) can be calculated with the following formula:
MPG = Miles driven / Gallons of gas used
Write a program that asks the user for the number of miles driven and the gallons of gas
used. It should calculate the car’s MPG and display the result.
'''
def mpgCalculate():
... | true |
ebec474eb20cfa6f338595a9bccf23b95a541dfd | dzhonapp/python_programs | /Loops/oceanLevels.py | 382 | 4.3125 | 4 | '''
Assuming the ocean’s level is currently rising at about 1.6 millimeters per year, create an
application that displays the number of millimeters that the ocean will have risen each year
for the next 25 years.
'''
millimeters=1.6
for years in range(25):
print("Year #", years+1)
print('Millimeters risen so far... | true |
7780f37587dc6bc07109b72911dc720f332268ad | garimadawar/LearnPython | /DynamicAvg.py | 262 | 4.1875 | 4 | print("Calculate the sum and average of two numbers")
number1 = float(input("Enter the first number"))
number2 = float(input("Enter the second number"))
print("the sum equals to " , number1 + number2)
print("average equals to " , (number1 + number2) / 2)
| true |
c1fa73caced9e5aeafe0e282ae88e6cb5c58a7fd | justinhinckfoot/Galvanize | /github/Unit 1 Exercise.py | 1,662 | 4.34375 | 4 | # Unit 1 Checkpoint
# Challenge 1
# Write a script that takes two user inputted numbers
# and prints "The first number is larger." or
# "The second number is larger." depending on which is larger.
# If the numbers are equal print "The two numbers are equal."
first = int(input('Enter first test value: '))
second = int... | true |
95350d0995ec53e75601c3db0010b9da7ce90ebe | ricek/lpthw | /ex11/ex11-1.py | 265 | 4.40625 | 4 | # Prompt the user to enter their name
# end='' arg tells print function to not end the line
print("First Name:", end=' ')
first = input()
print("Last Name:", end=' ')
last = input()
# Prints out formatted string with the given input
print(f"Hello {first} {last}")
| true |
9013585a902e8aa2384f162b4a8c25e730429778 | arossholm/Py_Prep | /egg_problem.py | 1,347 | 4.125 | 4 | # A Dynamic Programming based Python Program for the Egg Dropping Puzzle
# http://www.geeksforgeeks.org/dynamic-programming-set-11-egg-dropping-puzzle/
INT_MAX = 32767
def eggDrop(n, k):
# A 2D table where entery eggFloor[i][j] will represent minimum
# number of trials needed for i eggs and j floors.
eggFl... | true |
b073e30fb0c7b43e61845de6a0cb50ea6fe1d4f0 | Benature/Computational-Physics-Course-Code | /chp9/随机数/布朗运动1d.py | 1,082 | 4.25 | 4 | # 参考答案
# random walk,随机行走
import matplotlib.pyplot as plt
import random as rd
# %matplotlib inline
nsteps = 100 # input('number of steps in walk -> ')
nwalks = 100 # input('number of random walks -> ') 粒子数
seed = 10 # input('random number seed -> ')
rd.seed(seed)
steps = range(nsteps)
xrms = [0.0] * nsteps # mean ... | true |
0bb48e09dcbde0d8d604075bf650e9f2c42e9570 | jezzicrux/Python-Alumni-Course | /Excercises/inclass9_16.py | 508 | 4.28125 | 4 | #Making a function the adds three number and divdes by 3. (Pretty much average)
#This the function to get the average of the three numbers
avg = 0
def average(x,y,z):
avg=(x+y+z)/3
print(f"The average the three numbers is {avg}.")
def getting_numbs():
print ("Please enter your first number")
x = int(in... | true |
ef1b85d6df36bc6b251b94edd51c27c019bc63ec | jezzicrux/Python-Alumni-Course | /Excercises/triangle.py | 992 | 4.25 | 4 | def main():
print(f"Welcome to the triangle finder program")
print(f"Please enter 3 values for each side.")
print(f"Enter in value for side 1")
side1 = int(input(">> "))
print(f"Enter in value for side 2")
side2 = int(input(">> "))
print(f"Enter in value for side 3")
side3 = int(input(">... | true |
17a546db017b9abc0b1853b1df5137167e6fb795 | jezzicrux/Python-Alumni-Course | /Excercises/HW1.py | 837 | 4.34375 | 4 | #a message stating it going to count the number on chickens
print("I will now count my chickens:")
#number of hens
print("Hens", 25 + 30 / 6)
#number of roosters
print("Roosters", 100 - 25 * 3 % 4)
#a message counting the number of eggs
print("Now I will count the eggs:")
#The math for calculating the number of eggs
pr... | true |
fb8125f73e2825f92d99ac10951cf857e8be7239 | jaredmckay17/DataStructuresAlgorithmsPractice | /binary_search.py | 1,120 | 4.125 | 4 | # Non-recrusive implementation
def binary_search(input_array, value):
first = 0
last = len(input_array) - 1
while first <= last:
midpoint = (first + last) // 2
if input_array[midpoint] == value:
return midpoint
else:
if value < input_array[midpoint]:
last ... | true |
f791702e716e22da1327780cbc9e272648b5c2b8 | justinmyersdata/ProjectEuler | /7_Project_Euler.py | 607 | 4.25 | 4 |
def isprime(x):
'''Returns True if x is prime and false if x is composite'''
if x == 1:
return False
elif x == 2:
return True
elif x % 2 == 0:
return False
else:
for y in range(3,int(x**(1/2))+1,2):
if x % y == 0: ... | true |
ab65d41474186820587e216e5c91617621b599c2 | amitshipra/PyExercism | /recursion/examples.py | 743 | 4.28125 | 4 | __author__ = 'agupt15'
# Source: http://www.python-course.eu/python3_recursive_functions.php
#
#
#
#
# ## Example 1
#
# Write a recursive Python function that returns the sum of the first n integers.
###
def rec_add(num):
if num == 1:
return 1
return num + rec_add(num - 1)
print(rec_add(10))
### ... | true |
5bea9d32a0f174543c3d734002f8e856d6ac6279 | gurkiratsandhu/Assignment_Daily | /assignment7 (1).py | 1,521 | 4.15625 | 4 | #(Q.1)- Create a function to calculate the area of a circle by taking radius from user.
def area():
pi = 3.14
radius = float(input("enter radius: "))
area = pi*radius**2
print("Area of a circle = ",area)
area()
#(Q.2)- Write a function “perfect()” that determines if parameter number is a perfect number.
#Us... | true |
8263b10b5c958eb40ebc8c67a4aafecf5b18a6f8 | rhysJD/CC1404_Practicals | /Prac 2/exceptions_demo.py | 785 | 4.21875 | 4 | """
CP1404 - Practical 2
Rhys Donaldson
"""
try:
numerator = int(input("Enter the numerator: "))
denominator = int(input("Enter the denominator: "))
while denominator == 0:
denominator = int(input("Denominator cannot be zero. PLease enter a new number: "))
fraction = numerator / denominator
... | true |
685f5b4ead65493c2689d479df91bbc9af93aa0c | kiwi-33/Programming_1_practicals | /p12-13/p12p3(+pseudo).py | 639 | 4.28125 | 4 | '''define function for getting approx square root
prompt for input and convert to float
check if greater than 0
call function with (input, self selected tolerance)
else print message'''
def sq(number, epsilon):
root = 0.0
step = epsilon**2
while abs(number-root**2) >= epsilon and root <= number:
ro... | true |
ddb2f13ed4d056934a51cdc65a58aa3c7eabe411 | kiwi-33/Programming_1_practicals | /p14-15/p15p3.py | 568 | 4.1875 | 4 | '''define the function
prompt for input
enter while loop:
enter for loop, limit = input:
print statement that shows progression towards the base case and calls function
prompt for input'''
def series(x):
if x == 0:
return 13
elif x == 1:
return 8
else:
return((series... | true |
68390cc2272a00e24b578960ba52c76c1a3265e4 | Kadus90/CS50 | /pset6/mario/less/mario.py | 899 | 4.21875 | 4 | from cs50 import get_int
def main():
# Get an integer between 1 - 8
height = get_positive_int("Height: ")
# Print bricks
print_bricks(height)
def get_positive_int(prompt):
# Use get_int to get an integer from the user
n = get_int(prompt)
# While not in the proper range
while n < 1 or... | true |
ccb9824ec5d7ffeeb123b86914383d174eb63e03 | alcoccoque/Homeworks | /hw5/ylwrbxsn-python_online_task_5_exercise_2/task_5_ex_2.py | 692 | 4.5625 | 5 | """
Task05_2
Create function arithm_progression_product, which outputs the product of multiplying elements of arithmetic progression sequence.
The function requires 3 parameters:
1. initial element of progression - a1
2. progression step - t
3. number of elements in arithmetic progression sequence - n
Example,
... | true |
a0716844aecf22b76731ae339ea52037ba170bb9 | alcoccoque/Homeworks | /hw10/ylwrbxsn-python_online_task_10_exercise_3/task_10_ex_3.py | 2,102 | 4.375 | 4 | """
File `data/students.csv` stores information about students in CSV format.
This file contains the student’s names, age and average mark.
1. Implement a function get_top_performers which receives file path and
returns names of top performer students.
Example:
def get_top_performers(file_path, number_of_top_st... | true |
28c998e30f41f350345d22934294b93fda8f3dc2 | alcoccoque/Homeworks | /hw9/ylwrbxsn-python_online_task_9_exercise_4/task_9_ex_4.py | 2,094 | 4.28125 | 4 | """
Implement a bunch of functions which receive a changeable number of strings and return next
parameters:
1) characters that appear in all strings
2) characters that appear in at least one string
3) characters that appear at least in two strings
Note: raise ValueError if there are less than two strings
4) ch... | true |
d5b3eb35448994bbe027230cf715f633e3bbef90 | alcoccoque/Homeworks | /hw4/ylwrbxsn-python_online_task_4_exercise_8/task_4_ex_8.py | 638 | 4.1875 | 4 | """
Task 04-Task 1.8
Implement a function which takes a list of elements and returns a list of tuples containing pairs of this elements.
Pairs should be formed as in the example. If there is only one element in the list return `None`
instead.
Using zip() is prohibited.
Examples:
>>> get_pairs([1, 2, 3, 8, 9])
... | true |
0039bfc1dae3f74a8116973fade7541d37435561 | mandypepe/py_data | /spark_querin_dataset.py | 1,071 | 4.1875 | 4 | # First we need to import the following Row class
from pyspark.sql import SQLContext, Row
# Create a RDD peopleAge,
# when this is done the RDD will
# be partitioned into three partitions
peopleAge = sc.textFile("examples/src/main/resources/people.txt")
# Since name and age are separated by a comma let's split them
par... | true |
2a51577b5291d2667e285d799a1cb47d0dec5c88 | lunawarrior/python_book | /Exercises/6/1_turn_clockwise.py | 721 | 4.28125 | 4 |
'''
This is the first exercise in chapter 6:
The four compass points can be abbreviated by single-letter strings as “N”, “E”, “S”, and “W”.
Write a function turn_clockwise that takes one of these four compass points as its parameter,
and returns the next compass point in the clockwise direction. Here are some tests... | true |
b735e871863e7f2fe735293b21f01ea0158bb9d5 | quydau35/quydau35.github.io | /ds/chunk_6/python_modules.py | 2,618 | 4.53125 | 5 | """
# Python Modules\n
What is a Module?\n
Consider a module to be the same as a code library.\n
A file containing a set of functions you want to include in your application.\n
# Create a Module\n
To create a module just save the code you want in a file with the file extension ```.py```:\n
```
# Save this code in a ... | true |
fa096dffbef3c9578b693c3b2c07014a53b94ec6 | sandycamilo/SPD1.4 | /Complexity_Analysis/merge_lists.py | 1,027 | 4.125 | 4 | # Merge two sorted linked lists and return it as a new list.
# The new list should be made by splicing together the nodes of the first two lists.
# Input: 1->2->4, 1->3->4
#Create a new linked list:
# Output: 1->1->2->3->4->4
# O(1)
class Solution(object):
def mergeTwoLists(self, l1, l2):
head = ListN... | true |
e85c5ae1101d7e3e25ccd570231e3e04e5e32d74 | JLtheking/cpy5python | /practical03/q1_display_reverse.py | 899 | 4.3125 | 4 | # Filename: q1_display_reverse.py
# Author: Justin Leow
# Created: 19/2/2013
# Modified: 22/2/2013
# Description: Displays an integer in reverse order
##Input a positive integer: 5627631
##1367265
##Input a positive integer: nope
##Input is not an integer. Utilizing default value of 6593
##3956
##Input a positive inte... | true |
bf920db934db1952d9c741ce8e8335a47dae2d0f | JLtheking/cpy5python | /08_OOP/bankaccount.py | 2,339 | 4.3125 | 4 | #bankaccount.py
class Account():
'''Bank account class'''
def __init__(self,account_no,balance):
'''constructor method'''
#double underscore makes it a hidden private attribute
self.__account_no = account_no
self.__balance = balance
def get_account_no(self):
'''accessor method to retrieve account no'... | true |
73b2fa58628caf0682ba2fbcca4d44c25662c460 | JLtheking/cpy5python | /practical01/q1_fahrenheit_to_celsius.py | 634 | 4.25 | 4 | # Filename: q1_fahrenheit_to_celsius.py
# Author: Justin Leow
# Created: 22/1/2013
# Modified: 22/1/2013
# Description: Program which converts an input of temperature in farenheit to an
# output in celcius
# main
while(True):
#get user input farenheit
fInput = input(["Input temperature in farenh... | true |
af47a62770895f3239b6a0505b1cce9509a903ad | mmutiso/digital-factory | /darts.py | 773 | 4.28125 | 4 | import math
def square(val):
return math.pow(val,2)
def score(x, y):
'''
Give a score given X and Y co-ordinates
Rules
X range -10,10
Y range -10, 10
The problem is finding the radius of the circle created by a given point x,y
then compare if the point is inside the circle using pythag... | true |
d239595956f2ebdd76d628be8aae6892ba43e352 | Andeleisha/dicts-restaurant-ratings | /ratings.py | 1,534 | 4.15625 | 4 | """Restaurant rating lister."""
# put your code here
def build_dict_restaurants(filename, dictionary):
"""Takes a file and creates a dictionary of restaurants as keys and ratings as values"""
with open(filename) as restaurant_ratings:
for line in restaurant_ratings:
line = line.strip()
line = line.split(... | true |
f12370d769339351a1e01eb6189c6e45914fbd67 | sukritishah15/DS-Algo-Point | /Python/armstrong_number.py | 585 | 4.1875 | 4 | n = int(input())
l = len(str(n))
s = 0
temp = n
while temp > 0:
s += (temp%10) ** l
temp //= 10
if n == s:
print("Armstrong number")
else:
print("Not an armstrong number")
'''
Check whether a number entered by the user is Armstrong or not.
A positive integer of n digits is called an Armstrong Number ... | true |
ec34d801bf68c970a600d37ae6cc5a6e04fee1f6 | sukritishah15/DS-Algo-Point | /Python/majority_element.py | 733 | 4.375 | 4 | # Python problem to find majority element in an array.
def majorityElement(nums, n):
nums.sort()
for i in range(0, n):
if(i+int(n/2)) < n and nums[i] == nums[i+int(n/2)]:
return nums[i]
return None
n = int(input("Enter the total number of elements\n"))
print('Enter a list of '+str(n)... | true |
c1d8ba9a81d785d6a77de20d075150f371825ba7 | sukritishah15/DS-Algo-Point | /Python/automorphic.py | 423 | 4.125 | 4 | # Automorphic Number: The last digits of thr square of the number is equal to the digit itself
n=int(input("Enter the number: "))
sq= n**2
l=len(str(n))
ld=sq%pow(10,l)
if (ld==n):
print("Automorphic Number")
else:
print("Not a automorphic number")
"""
I/O
Enter the number: 25
Automorphic Numbe... | true |
ccfe5912c428bbaf377448c3b4961ce2d3c4e838 | sukritishah15/DS-Algo-Point | /Python/inordder.py | 608 | 4.28125 | 4 | class Node:
def __init__(self,key):
self.left = None
self.right = None
self.val = key
def printInorder(root):
if root:
printInorder(root.left)
print(root.val),
printInorder(root.right)
root = Node(1)
root.left = Node(2)
root.right = N... | true |
00d927ab9488e3d8954720d71ee8272394f99739 | sukritishah15/DS-Algo-Point | /Python/harmonic.py | 372 | 4.3125 | 4 | # Sum of harmonic series
def sumHarmonic(n):
i = 1
sum = 0.0
for i in range(1, n+1):
sum = sum + 1/i;
return sum;
n = int(input("First term :"))
print("Sum of the Harmonic Series :", sumHarmonic(n))
""""
Example:
First term :
6
Sum of the Harmonic Series : 2.4499999999999997
.........
Time... | true |
aabf2577bd44425c702d6a670ba21dcef79c4aa0 | dboldt7/PRG105 | /Banana revised.py | 1,207 | 4.21875 | 4 | """"
Banana Bread Recipe:
2 cups of flour
1 teaspoon of baking soda
0.25 teaspoons of salt
0.5 cups of butter
0.75 cups of brown sugar
2 eggs
2.33 bananas
Recipe produces 12 servings of bread
Write a program that asks the user how many servings they want
Program displays the ingredients needed to make the ... | true |
c3920afa242227c20a26747c5903249ca2fb2687 | AliMazhar110/Python-Projects | /Guess-a-number/main.py | 1,575 | 4.1875 | 4 | #Number Guessing Game Objectives:
from art import logo
import random
from os import system
# Include an ASCII art logo.
# Allow the player to submit a guess for a number between 1 and 100.
# Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer.
# If they got the answ... | true |
233d0067b828c7d7a12c6fd0d7c8e5f2f3d5476a | Elyseum/python-crash-course | /ch9/car.py | 1,512 | 4.25 | 4 | """ Modifying class state """
class Car():
""" Simple car """
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptive_name(self):
""" Formatting a descriptive name """
long_na... | true |
f21caae41042f33a4a60ea9ebcc8211b85d62bd2 | jormao/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/3-say_my_name.py | 939 | 4.4375 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
This module have a function that prints My name is <first name> <last name>
prototype: def say_my_name(first_name, last_name=""):
"""
def say_my_name(first_name, last_name=""):
""" function that prints My name is <first name> <last name>
first_name and last_nam... | true |
48af3a3a7920e8b0fc67cca325cc3d1305db77d1 | PureWater100/DATA-690-WANG | /ass_2/ass2.py | 1,413 | 4.21875 | 4 | # python file for assignment 2
# code from the jupyter notebook
user_inputs = []
MAX_TRY = 11
for i in range(1, MAX_TRY):
while True:
try:
user_input = input("Please enter an integer:")
in_input = int(user_input)
break
except:
print("Please retry (... | true |
5c3e03c9ec8a0c41e68d542f959098169adf612f | selvendiranj-zz/python-tutorial | /hello-world/exceptions.py | 2,018 | 4.3125 | 4 | """
Python provides two very important features to handle any unexpected error in your Python programs
and to add debugging capabilities in them
Exception Handling
Assertions
"""
def KelvinToFahrenheit(Temperature):
assert (Temperature >= 0), "Colder than absolute zero!"
return ((Temperature - 273) * 1.8) +... | true |
c16a4d2cb51863a144f5a9e33c46467620b8abd9 | LogSigma/unipy | /docstring.py | 916 | 4.5 | 4 | def func(*args, **kwargs):
"""
Summary
This function splits an Iterable into the given size of multiple chunks.
The items of An iterable should be the same type.
Parameters
----------
iterable: Iterable
An Iterable to split.
how: {'equal', 'remaining'}
The method to sp... | true |
9d07ce046e2c46a928da07c2d6578f7e91d1df9b | kristinamb15/cracking-the-coding-interview | /1_ArraysStrings/1.4.py | 1,286 | 4.15625 | 4 | # 1.4 Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome.
# The palindrome does not need to be limited to just dictionary words.
# You can ignore casing and non-letter characters.
import unittest
# Solution 1
# O(N)
def palindrome_perm(mystring):
mystring = my... | true |
616067b46918e0940fcf1805d8e3ae12ab0bbf2f | ShehabAhmedSayem/Rosalind-Chapterwise | /Chapter 1/ba1a.py | 691 | 4.15625 | 4 | # Problem Name: Compute the Number of Times a Pattern Appears in a Text
def read_input_from_file(file_name):
with open(file_name, 'r') as file:
string = file.readline().strip()
pattern = file.readline().strip()
return string, pattern
def occurrence(string, pattern):
"""
string... | true |
864401be5d0d0ba69503da811f67cebe37edbaa4 | Mustafa-Filiz/HackerRank--Edabit--CodeWars | /Codewars_12_ROT13.py | 1,234 | 4.65625 | 5 | # ROT13
"""
ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.
Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or special characters included in the str... | true |
d8ad0945acb41da09f474325b940b6b289bd91ad | newemailjdm/intro_python | /121515/conditional.py | 337 | 4.21875 | 4 |
first_name = input("What's your first name")
name_length = len(first_name)
if name_length > 10:
print("That's a long name!")
elif name_length > 3:
print("Nice, that's a name of medium length.")
elif name_length == 3:
print("That's a short name.")
else:
print("Are you sure those aren't ... | true |
83a1611d3673951ca106228ea3b28e55c97a85b1 | AnkurPokhrel8/LinkedList | /LinkedList.py | 2,012 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Ankur Pokhrel
"""
class Node: # Node class
def __init__(self, data):
self.data = data
self.next = None
class LinkedList: # Linkedlist class
def __init__(self):
self.head = None
def addNode(... | true |
6243bfacd386b76e0bf1fb38183e40bba96c48d9 | jmason86/python_convenience_functions | /lat_lon_to_position_angle.py | 982 | 4.1875 | 4 | import numpy as np
def lat_lon_to_position_angle(latitude, longitude):
"""Function to translate heliocentric coordinates (latitude, longitude) into position angle
Written by Alysha Reinard and James Paul Mason.
Inputs:
longitude [float]: The east/west coordinate
latitude [float]: The nort... | true |
94418a9660befad407049a9b6b6c3e3708c3e394 | LogicPenguins/BeginnerPython | /Udemy Course/HW Funcs & Methods/exer3.py | 444 | 4.375 | 4 | # Write a Python function that accepts a string and calculates the number of upper case
# and lowercase letters.
def case_info(string):
num_upper = 0
num_lower = 0
for char in string:
if char.islower():
num_lower += 1
elif char.isupper():
num_upper += 1
print(f'U... | true |
d79574835a4f1924c0d5fc4160cb3e31788aba42 | madhuri-bh/DSC-assignmentsML-AI | /Python1.py | 572 | 4.25 | 4 | movieEntered = input("Enter a movie")
thriller=["Dark","Mindhunter","Parasite","Inception","Insidious","Interstellar","Prison Break","MoneyHeist","War","Jack Ryan"]
comedy=["Friends","3 Idiots","Brooklyn 99","How I Met Your Mother","Rick And Morty","The Big Bang Theory","TheOffice","Space Force"]
movieEntered = movi... | true |
6c8326308e4df9e5a607376b8ccf1c68a1ba6478 | sushtend/100-days-of-ml-code | /code/basic python/13.5 guessing game.py | 361 | 4.1875 | 4 | Guess_count=1
guess=9
print("+++++ This program lets you guess the secret number +++++")
while Guess_count<=3:
num = int(input("Gues the number: "))
if guess==num:
print("Correct")
#exit()
break
Guess_count+=1
# Else for while loop evaluates after completion of all loops without brt... | true |
a957102ba9b196c13b102ecdf02e81ed94796a8b | sushtend/100-days-of-ml-code | /code/basic python in depth/21 sets.py | 1,367 | 4.5 | 4 | # https://realpython.com/python-sets/
#
numbers = [1, 2, 3, 4]
first = set(numbers)
second = {1, 5}
print(first | second) # Uniion
print(first & second) # Intersection
print(first - second) # Differece
print(first ^ second) # semantic difference. Items in either a or b but not both
# ----------------------------... | true |
635a67a18e9542866a68fc362ecc2941069da6e1 | jinm808/Python_Crash_Course | /chapter_4_working_w_lists/pracs.py | 1,661 | 4.5625 | 5 | '''
4-1: Pizzas
Think of at least three kinds of your favorite pizza.
Store these pizza names in a list, and then use a for loop to print the name of each pizza.
Modify your for loop to print a sentence using the name of the pizza instead of printing just the name of the pizza.
For each pizza you should have one lin... | true |
cab02298ed5b609d152d734f11416bf9442792f8 | jinm808/Python_Crash_Course | /chapter_8_functions/user_album.py | 712 | 4.21875 | 4 | def make_album(artist_name, album_title, tracks = 0):
"""Build a dictionary describing a music album."""
album_dict = {
'artist' : artist_name.title(),
'album' : album_title.title()
}
if tracks:
album_dict['tracks'] = tracks
return album_dict
print("Enter 'q' at any time to stop.")
while True:... | true |
2fc1a9a57b5e8713e1fd8b231289656d1838e32c | wandingz/daily-coding-problem | /daily_coding_problem61.py | 1,695 | 4.28125 | 4 | '''
This problem was asked by Google.
Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y.
Do this faster than the naive method of repeated multiplication.
For example, pow(2, 10) should return 1024.
'''
class Solution:
def powNaive(self, a, b)... | true |
5503d10bbcf8a15a7e6e4d4e1becb769f87839d1 | glemvik/Knowit_julekalender2017 | /Luke11.py | 2,087 | 4.375 | 4 | # -*- coding: utf-8 -*-
from time import time
from math import sqrt
def mirptall(primes):
"""
Returns all positive 'mirptall' smaller than 'number', where 'mirptall' are
primes which are also primes when the digits are reversed without being
palindromes.
"""
# INITIALIZE
... | true |
db545519dc14cf85b7b0a0b7c146974958756205 | pipa0979/barbell-squats | /Singly Linked List/Insertion/LL-Insertion-end.py | 1,746 | 4.28125 | 4 | # Purpose - to add node to the end of the list.
class Node(object):
def __init__(self, val):
self.data = val
self.next = None
class LinkedList(object):
# Head, Tail in a new LL will point to None
def __init__(self):
self.head = None
self.tail = None
... | true |
8d90eb725e1b93cafb1f814f531052d52f7db673 | emcguirk/atbs | /Chapter 7/strongPass.py | 573 | 4.1875 | 4 | import re
import pyperclip
# Regexes for each requirement:
hasLower = re.compile(r'[a-z]')
hasUpper = re.compile(r'[A-Z]')
hasNumber = re.compile(r'[0-9]')
def isStrong(pwd):
assert type(pwd) == str
lower = hasLower.findall(pwd)
upper = hasUpper.findall(pwd)
number = hasNumber.findall(pwd)
if len(lower) < 1 or l... | true |
f242ca44b241f49b69bd857d106747af2bcf5e2c | mattdrake/pdxcodeguild | /python/fizz_buzz.py | 757 | 4.1875 | 4 | __author__ = 'drake'
#reques input from user for any number
question = input("Enter a number. ")
#created variable for incrementing input from user
num = -1
#create loop to count from zero to user input number
while question > num:
#incrementing by one
num += 1
#test if number is a multiple of both 3 and 4 not in... | true |
742e5d7916310d6be17299e6d47c40c901498635 | kebron88/essential_libraries_assignment | /question11.py | 941 | 4.21875 | 4 | import numpy as np
import pandas as pd
#Do not import any other libraries
"""
Suppose you have created a regression model to predict some quantity. Write a function that takes 2 numpy arrays that both have the same length, y and y_pred.
The function should return the loss between the predicted and the actual values wh... | true |
69ba98a8c14e62037d3016662fc7d6e571187c67 | LukeG-dev/CIS-2348 | /homework1/3.18.py | 888 | 4.21875 | 4 | # Luke Gilin
import math
wall_H = float(input("Enter wall height (feet):\n"))
wall_W = float(input("Enter wall width (feet):\n"))
wall_A = wall_H * wall_W # Calculate wall area
print("Wall area:", '{:.0f}'.format(wall_A), "square feet")
paintNeeded = wall_A / 350 # Calculate Paint needed for wall
pri... | true |
5226c99becd7721dcced90cd85b26526fa8880c8 | ashish-dalal-bitspilani/python_recipes | /python_cookbook/edition_one/Chapter_One/recipe_two.py | 597 | 4.625 | 5 | # Chapter 1
# Section 1.2
# Swapping values without using a temporary variable
# Python's automatic tuple packing (happens on the right side)
# and unpacking are used to achieve swap readily
a,b,c = 1,2,3
print("pre swap values")
print('a : {}, b : {}, c : {}'.format(a,b,c))
a,b,c = b,c,a
print("post swap values")
p... | true |
43ab394f43b06ace4fffb0b09c18d01c04c0b962 | CruzAmbrocio/python-factorial | /application.py | 1,161 | 4.28125 | 4 | """This program calculates a Fibonacci number"""
import os
def fib(number):
"""Generates a Fibonacci number."""
if number == 0:
return 0
if number == 1:
return 1
total = fib(number-1) + fib(number-2)
return total
def typenum():
"""Function that allows the user to enter a numbe... | true |
29322f2c5a750b532c5faccb5549d29841bd5b14 | miku/khwarizmi | /sorting/median.py | 645 | 4.21875 | 4 | #!/usr/bin/env python
# coding: utf-8
"""
Swap the median element with the middle element. Create two smaller
problems, solve these.
Subproblems: Find the median of an unsorted list efficiently.
"""
def sort(A):
medianSort(A, 0, len(A))
def medianSort(A, left, right):
if left > right:
# find median ... | true |
1771618b573a48c8f0c19fbce9d50bf705fd481e | joedo29/Self-Taught-Python | /NestedStatementsAndScope.py | 1,367 | 4.46875 | 4 | # Author Joe Do
# Nested Statement and Scope in Python
'''
It is important to understand how Python deals with the variable names you assign.
When you create a variable name in Python the name is stored in a *name-space*.
Variable names also have a *scope*, the scope determines the visibility of that variable name to ... | true |
072ad3929e779ef840bc40875ff1eccaf7e55c1a | joedo29/Self-Taught-Python | /Files.py | 1,452 | 4.65625 | 5 | # Joe Do
# Python uses file objects to interact with external files on your computer.
# These file objects can be any sort of file you have on your computer,
# whether it be an audio file, a text file, emails, Excel documents, etc.
# Note: You will probably need to install certain libraries or modules to interact with ... | true |
0230151c53ea3f13baa6b353e2c9108452b1edff | shilpa5g/Python-Program- | /python_coding_practice/sum_of_series.py | 276 | 4.25 | 4 | # program to find Sum of natural numbers up to given range
terms = int(input("Enter the last term of the series: "))
if terms < 0:
print("please enter a positive number.")
else:
sum = 0
for i in range(1, terms+1):
sum +=i
print('sum of series = ',sum) | true |
55084a7529445303cf7dc531022ee39ab52613d2 | shilpa5g/Python-Program- | /python_coding_practice/palindrome.py | 246 | 4.5625 | 5 | # Program to check if a string is palindrome or not
string = str(input("enter a string: "))
rev_str = reversed(string)
if list(string) == list(rev_str):
print("The string is a palindrome.")
else:
print("The string is not a palindrome.") | true |
7d7ac0d51758458af03015b2b016c7608d266232 | fminor5/TonyGaddisCh13 | /p13-7button_demo.py | 849 | 4.28125 | 4 | import tkinter
import tkinter.messagebox
class MyGUI:
def __init__(self):
self.main_window = tkinter.Tk()
# Create a Button widget. The text 'Click Me!' should appear on the
# face of the Button. The do_something method should be executed when
# the user clicks the Button.
... | true |
7cdf5ba9b7c9cf90abcc0f0592cff859ecde851a | thangln1003/python-practice | /python/trie/208-implementTrie_I.py | 2,294 | 4.125 | 4 | """ 208. Implement Trie (Prefix Tree) (Medium)
https://leetcode.com/problems/implement-trie-prefix-tree/
Implement a trie with insert, search, and startsWith methods.
Example:
Trie trie = new Trie();
trie.insert("apple");
trie.search("apple"); // returns true
trie.search("app"); // returns false
trie.startsWi... | true |
a670acd7b46c33e6c19dbd4130be7b20860bc89e | thangln1003/python-practice | /python/1-string/438-findAllAnagrams.py | 2,175 | 4.125 | 4 | """ 438. Find All Anagrams in a String (Medium)
https://leetcode.com/problems/find-all-anagrams-in-a-string/
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,1... | true |
3c5bc82862d3f05da5ce7d0807de1e5d0e735e7d | rasmiranjanrath/PythonBasics | /Set.py | 521 | 4.25 | 4 | #A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets.
set_of_link={'google.com','facebook.com','yahoo.com','jio.com'}
#loop through set
def loop_through_set():
for links in set_of_link:
print(links)
loop_through_set()
#check if item exists or not
if 'google.com' ... | true |
5b7543e3b0fc8cf24b22afb680da2e4f28a1b9ac | LeenaKH123/python3 | /02_classes-objects-methods/02_04_classy_shapes.py | 1,078 | 4.4375 | 4 | # Create two classes that model a rectangle and a circle.
# The rectangle class should be constructed by length and width
# while the circle class should be constructed by radius.
#
# Write methods in the appropriate class so that you can calculate
# the area of both the rectangle and the circle, the perimeter
# of the... | true |
f7fe24777d99688ce0f67c7f16ee4788d4c694d4 | LeenaKH123/python3 | /02_classes-objects-methods/02_06_freeform.py | 695 | 4.125 | 4 | # Write a script with three classes that model everyday objects.
# - Each class should have an `__init__()` method that sets at least 3 attributes
# - Include a `__str__()` method in each class that prints out the attributes
# in a nicely formatted string.
# - Overload the `__add__()` method in one of the classes s... | true |
d9dcd1205b58e9f5502d6b2fb183b95ff6e24deb | arkoghoshdastidar/python-3.10 | /14_for_loop.py | 524 | 4.5 | 4 | # for loop can be used to traverse through indexed as well as un-indexed collections.
fruits = ["apple", "mango", "banana", "cherry"]
for x in fruits:
if x == "cherry":
continue
print(x)
else:
print("fruits list completely traverse!!")
# range function range(starting_index, last_index, step)
for... | true |
4ded74124b0a8a72d4f3ef553470bc01609be6b9 | shireeny1/Python | /python_basics_104_lists.py | 2,208 | 4.4375 | 4 | # Lists in Python
# Lists are ordered by index
## AKA --> Arrays or (confusingly) as objects in JavaScript
# Syntax
# Declare lists using []
# Separate objects using ,
# var_list_name = [0 , 1, 2, 3,..] --> index numbers
crazy_x_landlords = ['Sr. Julio', 'Jane', 'Alfred', 'Marksons']
print(crazy_x_landlords)
prin... | true |
5e7dbf191a2b1396cb23f1bdc870d8b1dbcbff7e | nirzaf/python_excersize_files | /section9/lecture_043.py | 289 | 4.125 | 4 |
### Tony Staunton
### Working with empty lists
# Empty shopping cart
shopping_cart = ['pens']
if shopping_cart:
for item in shopping_cart:
print("Adding " + item + " to your cart.")
print("Your order is complete.")
else:
print("You must select an item before proceeding.")
| true |
edb115e5a043e70668684de5ac215346c59df01b | nirzaf/python_excersize_files | /section9/9. Branching and Conditions/8.1 lecture_040.py.py | 324 | 4.21875 | 4 | ### 28 / 10 / 2016
### Tony Staunton
### Checking if a value is not in a list
# Admin users
admin_users = ['tony', 'frank']
# Ask for username
username = input("Please enter your username?")
# Check if user is an admin user
if username not in admin_users:
print("You do not have access.")
else:
print("Access ... | true |
d4d7ddf9bac3658959f888dda9c75d49491fdfad | AnetaEva/NetPay | /NetPay.py | 837 | 4.25 | 4 | employee_name = input('Name of employee: ')
weekly_work_hours = float(input('How many hours did you work this week?: '))
pay_rate = float(input('What is your hourly rate?: $'))
#Net Pay without seeing the breakdown from gross pay and tax using the pay rate * work hours * (1 - 0.05)
net_pay = pay_rate * weekly_work_h... | true |
43b8107a49178ce617fa90e55b0b3d612be117bb | cornielleandres/Intro-Python | /src/day-1-toy/fileio.py | 403 | 4.1875 | 4 | # Use open to open file "foo.txt" for reading
foo = open('foo.txt')
# Print all the lines in the file
for line in foo:
print(line)
# Close the file
foo.close()
# Use open to open file "bar.txt" for writing
bar = open('bar.txt', 'w')
# Use the write() method to write three lines to the file
lines = ['first line\n', ... | true |
08138bc7d63a9cc15ec13c8cf33e60cce825d6da | VinidiktovEvgenijj/PY111-april | /Tasks/a0_my_stack.py | 980 | 4.3125 | 4 | """
My little Stack
"""
my_stack = []
def push(elem) -> None:
"""
Operation that add element to stack
:param elem: element to be pushed
:return: Nothing
"""
global my_stack
my_stack.append(elem)
return None
def pop():
"""
Pop element from the top of the s... | true |
40b0eab57ae17cdb77045d0156e53e0ba073abd2 | Viiic98/holbertonschool-higher_level_programming | /0x0A-python-inheritance/4-inherits_from.py | 352 | 4.15625 | 4 | #!/usr/bin/python3
def inherits_from(obj, a_class):
""" inherits_from
Check if obj is a sub class of a_class
Return:
True if it is a subclass
False if it is not a subclass
"""
if type(obj) is not a_class and issubclass(type(obj), a_class):
return True... | true |
d15a5aa268e7d312cef56fdd19be4efe2a0b9fdc | dscottboggs/practice | /HackerRank/diagonalDifference/difference.py | 1,391 | 4.5 | 4 | from typing import List
"""The absolute value of the difference between the diagonals of a 2D array.
input should be:
Width/Height of the array on the first input line
any subsequent line should contain the space-separated values.
"""
def right_diagonal_sum(arrays: List[List[int]]) -> int:
"""Sum the right diago... | true |
b4729ac8cb9c4d7ba23b8fb98149a734ef517a93 | yawitzd/dsp | /python/q8_parsing.py | 1,343 | 4.375 | 4 | #The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program to... | true |
b12125bfd87a14b9fba134333f933e0adf308bb6 | talhahome/codewars | /Oldi2/Write_Number_in_Expanded_Form.py | 612 | 4.3125 | 4 | # You will be given a number and you will need to return it as a string in Expanded Form. For example:
#
# expanded_form(12) # Should return '10 + 2'
# expanded_form(42) # Should return '40 + 2'
# expanded_form(70304) # Should return '70000 + 300 + 4'
# NOTE: All numbers will be whole numbers greater than 0.
def expan... | true |
ea28dc883c613ace6f42e05c4bcd733df3482635 | talhahome/codewars | /Number of trailing zeros of N!.py | 580 | 4.3125 | 4 | # Write a program that will calculate the number of trailing zeros in a factorial of a given number.
# N! = 1 * 2 * 3 * ... * N
#
# Examples
# zeros(6) = 1
# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero
#
# zeros(12) = 2
# # 12! = 479001600 --> 2 trailing zeros
# Hint: You're not meant to calculate the factoria... | true |
3e27494fa5776ac2a3f8190bd688e6aacb5539c3 | imayush15/python-practice-projects | /Learn/ListEnd.py | 260 | 4.15625 | 4 | print("Program to Print First and last Element of a list in a Seperate List :=\n")
list1=['i',]
x = int(input("Enter the Range of list : "))
for i in range(x):
y = int(input("Enter the Value : "))
list1.append(y)
print(list1[1], list1[-1])
| true |
78d0f11ae198c5115cee65f7646a1cc00472b497 | piotrbelda/PythonAlgorithms | /SpiralTraverse.py | 1,280 | 4.1875 | 4 | # Write a function that takes in an n x m two-dimensional array
# (that can be square-shaped when n==m) and returns a one-dimensional array of all the array's
# elements in spiral order; Spiral order starts at the top left corner of the two-dimensional array, goes
# to the right, and proceeds in a spiral pattern all th... | true |
209019237804db02fcb51e4001df53aaff1e45b0 | kleutzinger/dotfiles | /scripts/magic.py | 2,524 | 4.25 | 4 | #!/usr/bin/env python3
"""invoke magic spells from magic words inside a file
magic words are defined thusly: (must be all caps)
#__MAGICWORD__# echo 'followed by a shell command'
put something of that format inside a file to set up running that command
additionally, #__file__# will be substituted with the path of t... | true |
6369192c8d069bc4fd9f3b49e1e0cc94b1cc124a | nihaal-gill/Example-Coding-Projects | /Egyption Fractions/EgyptianFractions.py | 1,000 | 4.28125 | 4 | #Language: Python
#Description: This program is a function that uses the greedy strategy to determine a set of distinct (i.e. all different) Egyptian
#fractions that sum to numerator/denominator. The assumptions in this program are that the numerator and denominator are positive integers
#as well as the numerator is... | true |
57060973638e77b4247be650fc3f065b3a06070c | BloodyInspirations/VSA2018 | /proj01.py | 2,321 | 4.375 | 4 | # Name:
# Date:
# proj01: A Simple Program
# Part I:
# This program asks the user for his/her name and grade.
#Then, it prints out a sentence that says the number of years until they graduate.
# Part II:
# This program asks the user for his/her name and birth month.
# Then, it prints a sentence that says the number ... | true |
65fb4afd1c43749106c02ed065d530e8bf3782b3 | KeerthanaPravallika/DSA | /Patterns/Xpattern.py | 558 | 4.28125 | 4 | '''
Write a program to take String if the length of String is odd print X pattern otherwise print INVALID.
Input Format:
Take a String as input from stdin.
Output Format:
print the desired Pattern or INVALID.
Example Input:
edyst
Output:
e t
d s
y
d s
e t
'''
word = input()
if len(word) % 2 == 0:
... | true |
488adf142b4eea5c71f5f3381b80935a33e47ebb | kayodeomotoye/Code_Snippets | /import csv.py | 848 | 4.1875 | 4 | import csv
from io import StringIO
def split_words_and_quoted_text(text):
"""Split string text by space unless it is
wrapped inside double quotes, returning a list
of the elements.
For example
if text =
'Should give "3 elements only"'
the resulting list would be:
... | true |
a29a74255df46a2d0944a8389558cc294ed2eacb | kayodeomotoye/Code_Snippets | /running_mean.py | 1,227 | 4.3125 | 4 | from itertools import islice
import statistics
def running_mean(sequence):
"""Calculate the running mean of the sequence passed in,
returns a sequence of same length with the averages.
You can assume all items in sequence are numeric."""
avg_list=[]
new_list = []
for num in sequence:
... | true |
e12ec0d529f890f1f46ead8feb24ce5ba1bef83a | rinoSantoso/Python-thingy | /Sorting.py | 1,256 | 4.21875 | 4 | def sort(unsorted):
sorted = []
sorted.append(unsorted[0])
i = 1
while i < len(unsorted):
for j in range(len(sorted)):
if unsorted[i] < sorted[j]:
sorted.insert(j, unsorted[i])
break
elif j == len(sorted) - 1:
sort... | true |
c0842c0917df268ba89c1d1fac5c46154ce24960 | twhorley/twho | /matplotlib_tests.py | 1,540 | 4.34375 | 4 | """
Script to play around with how to make a variety of plots using matplotlib and
numpy. I'll be using object-oriented interface instead of the pyplot interface to
make plots because these are far more customizable.
"""
import matplotlib.pyplot as plt
import numpy as np
# Create a figure with 2 axes, both same scal... | true |
a98813061b478d0d7be602d6ba503f33ed228863 | LaKeshiaJohnson/python-fizz-buzz | /challenge.py | 664 | 4.3125 | 4 | number = int(raw_input("Please enter a number: "))
# values should be stored in booleans
# If the number is divisible by 3, print "is a Fizz number"
# If the number is divisible by 5, print "is a Buzz number"
# If the number is divisible by both 3 and 5, print is a FizzBuzz number"
# Otherwise, print "is neither a fiz... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.