blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
06cee3b6c3d1dc86c477216ae1ac9369b75dbdf0 | chasegarsee/Algorithms | /recipe_batches/recipe_batches.py | 1,679 | 4.1875 | 4 | #!/usr/bin/python
import math
def recipe_batches(recipe, ingredients):
# getting the Keys from the KEY::VALUE pairs
current_recipe = set(recipe.keys())
print(current_recipe) # printing the keys
if current_recipe.intersection(ingredients.keys()) != current_recipe:
# if they keys in current ... | true |
b5dcd8002e7ffa859e27cd377b9a3b3c57502e9a | jollypanther/pylearn | /computation/prime.py | 1,413 | 4.1875 | 4 | import itertools
from math import sqrt
# Straight Forward
def is_prime1(n):
if n < 2: # to skip 0,1
return False
for i in range(2, n):
if not n % i:
return False
return True
# Optimization
def is_prime(n):
if n < 2:
return False
elif n <= 3: # 2 or 3, to sa... | false |
23f2a8f4b69924299a87f3821777b1ba6ddcf691 | dev-bloke/examples | /python/simple/collections.py | 1,829 | 4.3125 | 4 | # Simple list and indexing
first_list = [1, 2, 3]
print(first_list[0])
# Working from the end of the list and appending.
second_list = [1, "b", 3, "Hello"]
print(second_list[3])
print(second_list[-2])
second_list[1] = "B"
second_list.append("world")
second_list.append(first_list)
print(second_list)
# Extending, ins... | true |
06dbec69c44712a70985ed9ce526d2c86082c871 | lovababu/python_basics | /datastructures/dictionary.py | 1,105 | 4.5 | 4 | about = {"Name": "Avol", "Age": 32, "Address": "Bangalore"} # called dictionary key value pairs.
print(type(about))
# access keys.
# returns all keys as dict_keys (Note: dict_keys is not a list, index access may result type error).
keys = about.keys()
print(type(keys))
print(keys) # keys[0] result type error dict_... | true |
f98695e91393a328c2a34d197d07c10828069598 | zefe/python | /src/palindromo.py | 318 | 4.125 | 4 |
def palindromo(word):
reversed_word = word[::-1]
if reversed_word == word:
print('Si es un palindromo')
print(reversed_word)
else:
print('No es un palindromo')
def run():
word = str(input('Ingreasa una palabra: '))
palindromo(word)
if __name__ == '__main__':
run() | false |
13f8de43d416d3fce542c6e7db56b88d5af8efe0 | samirad123/lablec1 | /q18.py | 331 | 4.28125 | 4 | print("1.If you pick an apple a banana.\n""2.If you pick oranges you an pick grapes.\n""3.If you pick grapes you can pick bananas.")
choice = print(input("\nEnter the fruit you want and you will get another fruit: "))
if choice == 'apple':
print("Banana")
elif choice == 'oranges':
print("grapes")
else:
prin... | false |
ff2ba366ce3df5ad0049f46db9e44a5e50942675 | ratanvishal/hello-python | /main12.py | 384 | 4.1875 | 4 | #a=8
#b=5
#c=sum((a,b))
#print(c)
#def function(a,b):
#print("hello function r u there",a+b)
def function(a,b):
"""This is the function which calculates the average of two numbers. and this function does't work for three numbers"""
average= (a+b)/2
# print(average)
return (average)
#v=funct... | true |
4a1ca395e27d9d76e2aac32577598275fa340796 | jennyChing/mit-handout_practice | /sUsingQ_1.py | 1,176 | 4.25 | 4 | class Stack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.q1 = []
def push(self, x):
"""
:type x: int
:rtype: nothing
"""
self.q1.append(x)
print("push",self.q1)
def pop(self):
"""
... | false |
73a6a5a6f21b8e7f0a8a234836b9864c021c12b6 | green-fox-academy/Unicorn-raya | /week-01/day-2/count_from_to.py | 586 | 4.375 | 4 | # Create a program that asks for two numbers
# If the second number is not bigger than the first one it should print:
# "The second number should be bigger"
#
# If it is bigger it should count from the first number to the second by one
#
# example:
#
# first number: 3, second number: 6, should print:
#
# 3
# 4
# 5
fi... | true |
1b0fcc447b81b5ee00c14a93b8d87802997c3593 | green-fox-academy/Unicorn-raya | /week-01/day-3/Functions/Sort_that_list.py | 992 | 4.21875 | 4 | # Create a function that takes a list of numbers as parameter
# Returns a list where the elements are sorted in ascending numerical order
# Make a second boolean parameter, if it's `True` sort that list descending
def bubble(arr):
arr_length = len(arr)
if arr_length == 0:
return -1
for i in rang... | true |
aeeb60f44fafdf45d1c48180c6f1957adb84f2c8 | green-fox-academy/Unicorn-raya | /week-01/day-2/draw_pyramid.py | 460 | 4.25 | 4 | # Write a program that reads a number from the standard input, then draws a
# pyramid like this:
#
#
# *
# ***
# *****
# *******
#
# The pyramid should have as many lines as the number was
length = int(input())
level = 0
tmp = ""
while level < length + 1:
for i in range(length-level):
tmp += " "
... | true |
9e464ff53c74b314555a19755b90c971a2d4efbf | green-fox-academy/Unicorn-raya | /week-01/day-3/Functions/Factorial.py | 224 | 4.34375 | 4 | # - Create a function called `factorio`
# that returns it's input's factorial
def factorio( number ):
if number == 1:
return number
else:
return number * factorio (number - 1)
print(factorio(5))
| true |
df537e9f10b48efe9aaf4c43adb75cc2d1a16984 | aleluc91/numerical-analysis | /src/MCD.py | 453 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 18:47:07 2018
@author: aleluc
"""
def MCD_recursive(m, n):
if m > n:
return MCD_recursive(m-n , n)
elif n > m:
return MCD_recursive(m, n-m)
else:
return m
def MCD(m, n):
while m != n:
if m > n... | false |
9d9afc31d603928f64561a29faafe584b8296be4 | aduxhi/learnpython | /mid_test/lac_string_2.py | 863 | 4.21875 | 4 | #!/usr/bin/python
'''
Write a recursive procedure, called laceStringsRecur(s1, s2), which also laces together two strings. Your procedure should not use any explicit loop mechanism, such as a for or while loop. We have provided a template of the code; your job is to insert a single line of code in each of the indicated... | true |
ef6c2b63ae1b3ef0175632bf06fc8123eed45d37 | aduxhi/learnpython | /return_print.py | 715 | 4.15625 | 4 | # -*- coding: UTF-8 -*-
'''
the print() function writes, i.e., "prints",a string in the console. The return statement causes your function to exit and hand back a value to its caller.(使函数终止并且返回一个值给它的调用者) The point of functions in general is to take in inputs and return something. The return statement is used when a fun... | true |
492afa72418991d88094b69f59f6f548abf5fe0a | aduxhi/learnpython | /ProblemSet3/getGuessedWord.py | 656 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
# 返回已经猜到的单词
def getGuessedWord(secretWord, lettersGuessed):
'''
secretWord: string, the word the user is guessing
lettersGuessed: list, what letters have been guessed so far
returns: string, comprised of letters and underscores that represents
what letters in secretWor... | true |
d591b7440e04f08c2c65f2aa93e386db4ef5595b | danieltran-97/Python-practice | /polygon.py | 655 | 4.21875 | 4 | import turtle
class Polygon:
def __init__(self, sides,name, size=100):
self.sides = sides
self.name = name
self.size = size
self.interior_angles = (self.sides -2) * 180
self.angle = self.interior_angles/self.sides
def draw(self):
for i in range(self.sides):
... | true |
7b6866d61792eb6c0fd76f25fc0ea2a113816620 | albertopuentes/python-exercises | /warmup.py | 721 | 4.125 | 4 | # 1
input_truck = "toyota tacoma"
input_truck.split()
make = input_truck.split()[0]
model = input_truck.split()[-1]
truck = dict(make = make, model = model)
print(truck)
# 2
input_truck = "toyota tacoma"
input_truck.split()
make = input_truck.split()[0]
model = input_truck.split()[-1]
truck = dict(make = make, m... | false |
3b6dbcc99b5fddb652c3bf6fc0ff43c3162879b2 | Karanvir93875/PythonStuff | /RealTimeClock.py | 907 | 4.15625 | 4 | #This is a program which provides a close to accurate representation of real time
import os #clear screen functioning
import time
#variables display time length
seconds = float(0) #want to display decimals of each second
minutes = int(0) #want min to be dislayed as whole numbers
hours = int(0) #want hours ... | true |
bac9df13893156f4d650b4446423ea862246a45a | ferryleaf/GitPythonPrgms | /numbers/find_armstrong_number.py | 604 | 4.3125 | 4 | '''
Find all Armstrong numbers between two integers.
Example:
num=153
len(num)=3
1^3+5^3+3^3=153
Yes Armstrong number.
'''
def find_armstrong_number(lower,upper):
for i in range(lower,upper+1):
order=len(str(i))
temp=i
sum=0
while(temp!=0):
digit=temp%10
s... | false |
2dfe462d34c82b016bb249e719f86b1ca81d9603 | ferryleaf/GitPythonPrgms | /numbers/plus_minus.py | 2,118 | 4.15625 | 4 | #!/bin/python3
'''
Given an array of integers,
calculate the fractions of its elements that are positive, negative, and are zeros.
Print the decimal value of each fraction on a new line.
Note: This challenge introduces precision problems.
The test cases are scaled to six decimal places,
though answers with absolute er... | true |
11cc4e82a74f71bf0c395392b69bb827e5719544 | ferryleaf/GitPythonPrgms | /arrays/rotate_array.py | 1,792 | 4.15625 | 4 | '''
Given an unsorted array arr[] of size N, rotate it by D elements
in the COUNTER CLOCKWISE DIRECTION.
Example 1:
Input:
N = 5, D = 2
arr[] = {1,2,3,4,5}
Output: 3 4 5 1 2
Explanation: 1 2 3 4 5 when rotated
by 2 elements, it becomes 3 4 5 1 2.
Example 2:
Input:
N = 10, D = 3
arr[] = {2,4,6,8,10,12,14,16,18,20}
... | true |
d9b2b796b2d33143feb70e02676cc6b701d36c54 | ferryleaf/GitPythonPrgms | /trees/binary_search/level_order_traversal.py | 2,050 | 4.34375 | 4 | # Convert Tree into List/Queue
class Node:
def __init__(self, ele):
self.ele = ele
self.left = None
self.right = None
# Inserting an Element into Tree in Binary Search Tree Style
def insert(self, ele):
if self.ele is None:
self.ele = Node(ele)
else:
... | false |
fd461e5e74a42b5e42b6d28e7d656811263f8c69 | ferryleaf/GitPythonPrgms | /numbers/factor_of_numbers.py | 450 | 4.125 | 4 | '''
Find the Factors of a Number:
Example:
The factors of 320 are:
1
2
4
5
8
10
16
20
32
40
64
80
160
320
'''
import math
class Solution:
def find_factors(self,num:int) -> None:
factors=list()
for i in range(1,int(math.sqrt(num))+1):
if(num%i==0):
factors.append(i)
... | true |
de46cea01e81b8c4fe93c82a4e692ae76fc5a493 | ferryleaf/GitPythonPrgms | /strings/strstr.py | 1,504 | 4.125 | 4 | '''
Your task is to implement the function strstr. The function takes two strings
as arguments (s,x) and locates the occurrence of the string x in the string s.
The function returns and integer denoting the first occurrence of the string x
in s (0 based indexing).
Example 1:
Input:
s = GeeksForGeeks, x = Fr
Output:... | true |
e2c29fc113ab6d9f05e9d32e34127571032502f5 | ferryleaf/GitPythonPrgms | /searching_sorting/binary_search.py | 1,390 | 4.125 | 4 | '''
Given a sorted array arr[] of N elements, write a function to search a
given element X in arr[] using Binary Search Algorithm.
'''
def binary_search_iterative(arr, X):
left = 0
right = len(arr) - 1
while(left <= right):
mid = left + ((right - left) // 2)
if arr[mid] == X:
r... | false |
2279685ca3bb5e6292f371a5b51f798a48d638a7 | iicoom/Note | /Interview/Algorithm-DS/Sort/1.冒泡/BubbleSort.py | 287 | 4.21875 | 4 | rawArr = [1, 3, 5, 10, 9, 8]
print rawArr
for i in range(0, len(rawArr))
print rawArr[i]
def bubbleSort(arr):
for i in range(1, len(arr)):
for j in range(0, len(arr)-i):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr | false |
5d4a34e282b9f7a119110f197a9d5af1c791adc6 | Gaurav-Dutta/python_learning | /Basics/Functions/function1.py | 921 | 4.21875 | 4 | #a function is defined by using the ketyword "def". The block of code following the funciton definition is called function block
#function may or may not return a value if the function returns a value it uses the return keyword to return a value
#the first functionn below does not return any value, the second function ... | true |
56a689b12738635f8e5afbefe694677f81e2e51b | Gaurav-Dutta/python_learning | /Basics/datatypes/list3.py | 544 | 4.65625 | 5 | #many times we have to access each item in a list and do something with it, a process called list iteration
#the simplest way of doing list iteration is using for each method on the list
myList = ["dog", "cat", "penguin", "giraffe"]
for animal in myList:
print(animal.capitalize())
print("hello")
#adding othe... | true |
84c3d33f89d054cda35e0533dbd82ad4ad30bbb5 | shaikhjawad94/MITx-6.00.1x | /PS2/P3.py | 1,124 | 4.125 | 4 | low = balance / 12
high = (balance * (1 + (annualInterestRate/12.0))**12.0) / 12.0
minPay = (low + high) / 2
rerun = True
#low is the lowest minimum possible payment, i.e., when interest is 0%
#high is highets possible payment, i.e., when one payment made at the end of the year
def FixedPayBis(balance, annualIntere... | true |
91a74cdc29907b5227b6fd6f0163f50aa85c2eac | rohw/InClassGit | /divisor.py | 227 | 4.1875 | 4 | def divisor(x):
print("The divisors are:", end=" ")
i = 1
while i <= x:
if (x % i == 0):
print(i, end=" ")
i += 1
x = int(input("Please enter a number for its divisors: "))
divisor(x)
| false |
23efc9bf59c75c93eb3dc71c5c170943b5b24df2 | tarunsingh8090/twowaits_python_programs | /Day 3/Problem 5.py | 503 | 4.15625 | 4 | size1 =int(input("Enter the no. of elements that you want to enter in List1:"))
List1=[]
print("Enter elements in List1 one by one:")
for i in range(size1):
List1.append(input())
size2= int(input("Enter the no. of elements that you want to enter in List2:"))
List2=[]
print("enter elements in List2 one by one... | true |
b197373baee082d3870197644e098d5ccdc4c9a6 | evamaina/Basics | /sort.py | 317 | 4.25 | 4 | start_list = [5, 3, 1, 2, 4]
square_list = []
# Your code here!
for number in start_list:
number = number**2
square_list.append(number)
square_list.sort()
print square_list
"""Write a for-loop that iterates over start_list and .append()s each number squared (x ** 2) to square_list.
Then sort square_list!""" | true |
68834fc74c7c5b40e0d42b732cac0612cb2a8992 | evamaina/Basics | /my_dict2.py | 386 | 4.46875 | 4 | my_dict = {
'name': 'Nick',
'age': 31,
'occupation': 'Dentist',
}
print my_dict.items()
print my_dict.keys()
print my_dict.values()
"""While .items() returns an array of tuples with each tuple consisting of a key/value pair from the dictionary:
The .keys() method returns a list of the dictionary's keys, and
... | true |
faf3315834df46189041f21df16000fe277bb240 | Pytho-pixel/Calculator-Python- | /main.py | 364 | 4.3125 | 4 | num_1 = int(input('Enter Number 1 - '))
operator = input('Enter operator - ')
num_2 = int(input('Enter Number 2 Here - '))
if operator == '+':
print(num_1 + num_2)
elif operator == '-':
print(num_1 - num_2)
elif operator == '*':
print(num_1 * num_2)
elif operator == '/':
print(num_1 / num_2)
... | false |
33246c7deb869e8eb6f06f45aa2ca9137d29b68b | gtmkr1234/learn-python39 | /learn-python39/looping/else_with_loop.py | 716 | 4.125 | 4 | # else part with for loop
# optional section
n = int(input('enter the last range '))
for k in range(1, n+1):
if k > 5:
break
print(k, end=' ')
print('next>', end='')
else:
print('else part of for loop')
print('\nafter loop')
# prime no. without using third variable
k = int(input('Enter the numb... | false |
bce4ab96307b6335aacbdf6efcbaf38f92387e83 | JPoser/python-the-hardway | /Exercise 33/ex33st5.py | 389 | 4.1875 | 4 | # Learn Python The Hard Way - Exercise 33 study drill 5
# Copied by Joe Poser
i = 2
max = 10
numbers = []
increase = 2
def count(i):
for i in range(i, max):
print "At the top i is %d" % i
numbers.append(i)
i = i + increase
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
... | true |
6e517cac536fb7bc827979ee81e448c89ca6cf9e | JPoser/python-the-hardway | /Exercise 30/ex30st4.py | 1,224 | 4.34375 | 4 | # Learn Python The Hard Way - Exercise 30
# Copied by JPoser
# Sets the value of people to 30
people = 30
# Sets the value of cars to 40
cars = 40
# Sets the value of buses to 15
buses = 15
# Checks if cars are greater than people
if cars > people:
# If cars are greater than people prints this string
pr... | true |
cff2259fbf8e9b71c9cf246627600695c1baed45 | JPoser/python-the-hardway | /Exercise 7/ex7st1.py | 1,043 | 4.15625 | 4 | # Learn Python The Hard Way. Exercise 7 Study Drill 1.
# Copied by JPoser
# prints string
print "Mary had a little lamb."
# prints string with string nested inside
print "It's fleece was white as %s." % 'snow'
# prints string
print "And everywhere that mary went."
# prints string 10 times
print "." * 10 # wh... | true |
f4db9cf283618b2912702f42d61dca43e86f0504 | JPoser/python-the-hardway | /Exercise 4/ex4st3.py | 1,276 | 4.34375 | 4 | # Learn Python The Hard Way, Exercise 4 Study Drill 3.
# Copied by JPoser.
# Assigns variable "cars" to the integer (in future written as int) 100
cars = 100
# Assigns variable "space_in_a_car" to the floating number 4.0
space_in_a_car = 4.0
# Assigns the variable "drivers" to int 30
drivers = 30
# Assigns t... | true |
e821fa06ec048569e90cde1194aeb4faf15d10b4 | RidaATariq/ITMD_413 | /Assignment-4/HW_4/program-2/main.py | 1,482 | 4.25 | 4 | """
This program asks the user to enter two 3x3 matrices to be multiplied
and then it gets the result.
Name: Cristian Pintor
"""
matrixA = []
matrixB = []
print('Enter a 3x3 matrix for matrix A: ')
for i in range(9):
matrixA.append(eval(input()))
print('Enter a 3x3 matrix for matrix B')
for i in range(9):
m... | true |
6f557ae80a05f830d801d159aa2e54c612e58ae3 | RidaATariq/ITMD_413 | /Assignment_15/cpintor_HW_15/question_17.1/main.py | 2,109 | 4.375 | 4 | import sqlite3
connection = sqlite3.connect('books.db')
import pandas as pd
# 1. Select all authors' last names from the authors
# table in descending order
output_1 = pd.read_sql("""SELECT last
FROM authors
ORDER BY last DESC""",
connection)
print(... | true |
61269f6c768d5965e50de89834b6d89fad9c88b1 | RidaATariq/ITMD_413 | /Assignment-2/Module-3_Lopping/while-loop-2.py | 462 | 4.1875 | 4 | '''
This program demonstrates the concept of while loop.
'''
import random
# Generate a random number to be guessed
number = random.randint(0, 100)
print("Guess a magic number between 0 and 100")
guess = -1
while guess != number:
guess = eval(input("Enter your guess: "))
if guess == number:
print("... | true |
3812633581de8a898f8d978cf0c7e589323d4b30 | RobRoger97/test_tomorrowdevs | /cap3/63_Average.py | 363 | 4.21875 | 4 | #Read a value from user
num = int(input("Enter a number: "))
sm=0.00
count=0
#Loop
if num==0:
print("Error message: the first number can't be 0")
else:
while num!=0:
count=count+1
sm = sm+num
num = int(input("Enter a number: "))
#Compute the average
average=sm/count
#Display ... | true |
8d68b11c78a261b452176bcf9dc7abd61732c276 | RobRoger97/test_tomorrowdevs | /cap2/58_Is_It_a_Leap_Year.py | 622 | 4.375 | 4 | # Read the year from the user
year = int(input("Enter a year: "))
# Determine if it is a leap year
#Any year that is divisible by 400 is a leap year.
if year % 400 == 0:
isLeapYear = True
#Of the remaining years, any year that is divisible by 100 is not a leap year.
elif year % 100 == 0:
isLeapYear = False... | true |
31dca49e06b0a06e436dd8abed18510140e6ec16 | RobRoger97/test_tomorrowdevs | /cap2/62_Roulette_Payouts.py | 1,319 | 4.125 | 4 | ##
# Display the bets that pay out in a roulette simulation.
#
from random import randrange
# Simulate spinning the wheel, using 37 to represent 00
value = randrange(0, 38)
if value == 37:
print("The spin resulted in 00...")
else:
print("The spin resulted in %d..." % value)
# Display the payout for a single n... | true |
e8f9c0ab9af876319bcec91df8d79769920effc0 | RobRoger97/test_tomorrowdevs | /cap5/ex110_Sorted_Order.py | 382 | 4.375 | 4 |
#Read a integer from the user
integ = int(input("Enter a integer: "))
# Start with an empty list
lis=[]
#While loop
while integ!=0:
lis+=[integ]
print(lis)
integ = int(input("Enter a integer: "))
#Sort the value of the list
lis.sort()
#Display the values in ascending order
print("The values, sorted i... | true |
bbc19ce55b709f62bc8e97b08ea104851ba49728 | RobRoger97/test_tomorrowdevs | /cap2/55_Wavelengths_of_Visible_Light.py | 625 | 4.25 | 4 | #Read the wavelenght from the user
w_lenght = int(input("Enter a wavelenght: "))
#Report its color
if w_lenght>= 380 and w_lenght<450:
color = "Violet"
elif w_lenght>=450 and w_lenght<495:
color = "Blue"
elif w_lenght>=495 and w_lenght<570:
color = "Green"
elif w_lenght>=570 and w_lenght<590:
color = "... | false |
fad3b778a58587f27e8a349ab5195914ba9f25d1 | RobRoger97/test_tomorrowdevs | /cap2/42_Note_to_Frequency.py | 725 | 4.1875 | 4 | #Note's frequency
C4_f = 261.63
D4_f = 293.66
E4_f = 329.63
F4_f = 349.23
G4_f = 392.00
A4_f = 440.00
B4_f = 493.88
#Read the note name from user
name = input ("Enter the two character note name, such as C4: ")
#Store the note and its octave in separate variables
note = name[0]
octave = int(name[1])
#Get the frequen... | true |
93d7bdb71b4db9b716b7b5aa22ab1e821e1cb6e3 | RobRoger97/test_tomorrowdevs | /cap3/75_Is_a_String_a_Palindrome.py | 513 | 4.40625 | 4 | # Read the string from the user
line = input("Enter a string: ")
is_palindrome = True
i = 0
#While loop to scroll through the string
while i < len(line) / 2 and is_palindrome:
# If the characters do not match then mark that the string is not a palindrome
if line[i] != line[len(line) - i - 1]:
is_palindrom... | true |
3d01523003458f3d773435d65c4cee5905eb55dd | RobRoger97/test_tomorrowdevs | /cap6/ex140_postal_codes.py | 1,043 | 4.125 | 4 | code = input("Enter a postal code: ").upper()
lis = list(code)
dic = {'Newfoundland':'A','Nova Scotia':'B','Prince Edward Island':'C','New Brunswick':'E',\
'Quebec':['G','H','J'],'Ontario':['K','L','M','N','P'],'Manitoba':'R','Saskatchewan':'S',\
'Alberta':'T','British Columbia':'V','Nunavut':'X','Northwest T... | false |
4567fafd5bce319bb17e7b1b90c455e6cda5a3f5 | RobRoger97/test_tomorrowdevs | /cap2/44_Faces_on_Money.py | 677 | 4.21875 | 4 | #Name and value
G_Wash = "George Washington"
T_Jeff = "Thomas Jefferson"
A_Lin = "Abraham Lincoln"
A_Ham = "Alexander Hamilton"
A_Jack = "Andrew Jackson"
U_Sg = "Ulysses S. Grant"
B_Fran = "Benjamin Franklin"
#Read the denomination from user
d = int(input("Enter the denomination of a banknote: "))
#Check of name ... | false |
677e1fa22ecacc625f85aef5b2d586b202e0b9fe | muondu/datatypes | /megaprojects/strings/st4.py | 429 | 4.125 | 4 | print("Enter your name in small letters")
a = input("Enter your first word of your name: ")
print(a.upper())
b = input("Enter your second word of your name: ")
print(b)
c = input("Enter your third word of your name: ")
print(c.upper())
d = input("Enter your fourth word of your name: ")
print(d)
e = input("Enter you... | true |
5766ba5c7fd8c06a386984124c24074d19f06764 | sacheenanand/pythonbasics | /quick_sort.py | 1,231 | 4.3125 | 4 | #Quick sort is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays.
#A large array is partitioned into two arrays one of which holds values smaller than the specified value, say pivot, based on which the partition is made and
#another array holds values greater than ... | true |
58fbd02b4bd79c57b9ec7d5a52016ca6689bab8c | Judy-special/Python | /02-basic-201807/is_Palindrome.py | 576 | 4.15625 | 4 | # coding = utf8
def is_Palindrome(the_str):
"""
本函数用来判别是否为回文字符串
"""
l = len(the_str) - 1
n = int(l/2)
if len(the_str) == 0:
print("The String is Null")
elif len(the_str) > 0:
temp = []
for i in range(n):
if the_str[i]==the_str[l-i]:
temp.ap... | true |
e343c335766ff26481a4daf445d7bf5615de2486 | Pajace/coursera_python_miniproject | /miniproject2.py | 2,442 | 4.125 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import random
# 1. initialize global variable
num_range = 100
remaining_guesses = 7
user_guesses = 0
secret_number = random.randrange(0, num_range)... | true |
d4be5236a64fdc4114e017a4b5e65da20a4b6f18 | aronaks/algorithms | /algorithms/gfg_arrays2.py | 543 | 4.34375 | 4 | def find_leaders(keys):
"""
Write a function that prints all the LEADERS in the array. An element is leader
if it is greater than all the elements to its right side. And the rightmost
element is always a leader. For example int the array {16, 17, 4, 3, 5, 2},
leaders are 17, 5 and 2.
"""
... | true |
e1dbe97738f28b03916540a49a6ebe0db0e25bbd | nicholas0417/python-tutorial | /data_types/product.py | 238 | 4.15625 | 4 | # Q1
num1 = int (input("please enter number1:"))
num2 = int (input("please enter number2:"))
product = num1 * num2
# If product is greater than 1000
if (product < 1000):
print("The product is : " product)
else:
print(num1 + num2)
| true |
91cc8136c752f5397b51511012fe2be70a3993fd | AaronAikman/MiscScripts | /Py/AlgorithmsEtc/BuildingHeight.py | 351 | 4.15625 | 4 | # CalculateBuildingHeight.py
# Aaron Aikman
# Calculate height of a building based upon the inputted number of floors
while True:
numFloors = input("Enter a number of floors (returns cm):")
if (numFloors == ""):
break
buildingHeight = ((3.1 * numFloors) + 7.75 + (1.55 * (numFloors / 30)))
print... | true |
2d635fb9dd499cd344039e1b980c938188e08b09 | Gaurav715/DDS1 | /main.py | 2,596 | 4.28125 | 4 | # Python program for implementation of BubbleSort
def bubbleSort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the eleme... | true |
5a801a5c74adfcf8384e518c6715671834d81cc8 | bogdan19adrian/b2b_festival | /common/common.py | 437 | 4.125 | 4 | import re
# Make a regular expression
# for validating an Email
regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
# Define a function for
# for validating an Email
def validate_email(email):
# pass the regualar expression
# and the string in search() method
if (re.search(regex, email)):
pri... | false |
de3fa85ee012acb070b0023e2be345d43f3aab43 | CaptainCrossbar/CodeWars | /(8) Is it a number?.py | 348 | 4.1875 | 4 | def isDigit(string):
#Check to see if string is an integer
try:
int(string)
return True
#String was no an integer
except:
#Check to see if string is a float
try:
float(string)
return True
#String is no a valid integer or float
excep... | true |
c1dbde41aa30ce350a1ef3266c92f8ec8cec96bd | melissav00/Python-Projects | /project_exercise2.py | 479 | 4.1875 | 4 | start = int(input("Pick a starting number for a list:"))
end = int(input("Pick a ending number for a list:"))
def generateNumbers(start,end):
num_list=[]
if start == end:
print("Both values are equal to each other. Please input opposite values.")
elif start > end:
print("Enter a start val... | true |
c26edaa2be2871462292fd22c1e45ef0fc24c386 | fp-computer-programming/cycle-3-labs-p22cgussen | /lab2-2.py | 260 | 4.21875 | 4 | # Author CCG 9/28/21
number = input("Type a number")
if int(number) % 2 == 0:
print("You have an even number!")
else:
print("You have an odd number!")
if int(number) >= 0:
print("x is a positive number")
else:
print("x is a negative number") | false |
71400360a39ed118953261791fbac2066c112d27 | Moiz-khan/Piaic_Assignment01 | /co-ordinate.py | 377 | 4.21875 | 4 | #program to measure distance
def distance(x1, y1, x2, y2):
return (x2 - x1)**2 + (y2 - y1)**2
x1 = int(input("Enter Co-ordinate of x1: "))
y1 = int(input("Enter Co-ordinate of y1: "))
x2 = int(input("Enter Co-ordinate of x2: "))
y2 = int(input("Enter Co-ordinate of y2: "))
print("Distance between points(",x1,","... | false |
bdd47bd94d25de8b95debacc99fbed3fc14f294a | Moiz-khan/Piaic_Assignment01 | /copiesof string.py | 208 | 4.21875 | 4 | #program to print copies of string
str = input("Enter String: ")
n = int(input("How many copies of String you need: "))
print(n, "copies of",str,"are ",end=" ")
for x in range(1,n+1):
print(str,end=" ")
| true |
9ce34e74be5fd35c0c2c2638b7dc7057b562a83d | Moiz-khan/Piaic_Assignment01 | /divisible.py | 318 | 4.21875 | 4 | #number is completely divisible by another number
num = int(input("Enter Numerator: "))
deno = int(input("Enter Denominator: "))
if( num%deno == 0):
{
print("Number", num , "is completely divisible by", deno)
}
else:
{
print("Number", num , "is not completely divisible by", deno)
}
| false |
5e48ffd4a519bf0a0a5e2f42f645f2ae37f9cb22 | heis-divine/PythonCalculator | /main.py | 1,309 | 4.28125 | 4 | # Calculator project
print("What Calculation would you like to perform?")
print("1)Addition\n2)Subtraction\n3)Multiplication\n4)Division")
choice = int(input("Enter preferred Option: "))
if choice == 1:
print("Addition")
num1 = int(input("Enter first number:"))
num2 = int(input("Enter second number:"... | true |
c994c56cf773a7c24b6aef21fe93e1dfbad83fc4 | SivaCn/Bigdata.model | /src/utils/chains.py | 2,000 | 4.25 | 4 | #! /usr/bin/python
"""Linked list Representation and implementation.
"""
# -*- coding: utf-8 -*-
## ------ Imports ------ ##
## ------ Imports ------ ##
__author__ = "Siva Cn (cnsiva.in@gmail.com)"
__website__ = "http://www.cnsiva.com"
class Node:
"""Referential Structure used to create new nodes"""
def ... | false |
75752fa8139a12de337fa40553785211469139d2 | Zahidsqldba07/PythonPrac | /Time & Calendar.py | 618 | 4.25 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import time
import datetime
import calendar
# In[2]:
### Get the current date and time
print(datetime.datetime.now())
# In[3]:
### Get just the current time
print(datetime.datetime.now().time())
# In[4]:
start = time.time()
print("hello")
end = time.time()
p... | true |
9eaa0b1c7da2c45fe62ee929143597f3beddeb9c | Zahidsqldba07/PythonPrac | /Python Tips.py | 1,336 | 4.21875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Swapping Values
# In[1]:
x,y = 10, 5
print(x,y)
# In[2]:
x,y =y,x
print(x,y)
# # Combining a list of strings into a single one
#
# In[3]:
sentence = ['Why','is','the','rum','gone','?']
concat_sen = "".join(sentence)
print(concat_sen)
# # Initiallizing a list
# ... | false |
5e4f7196eece576d7a5cc69017c35eeee6056d75 | Zahidsqldba07/PythonPrac | /Logic 1.py | 2,303 | 4.21875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # You and your date are trying to get a table at a restaurant. The parameter "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If ... | true |
38c45a4fbd57093e586ed9c1fe820b958a1d0343 | codevr7/samples | /one-bit_binary_adder.py | 275 | 4.15625 | 4 | #binary adder
choices = ['0','1']
problem = input("select 2 numbers between 0 and 1(0,1)")
if problem != '0' or problem != '1':
print("binary adder cannot process numbers other than 1 and 0")
if problem_1 != :
print("binary adder cannot process numbers more than 1")
| true |
1b36b1abc616005a72e5b7bd72dbf081152b62e1 | codevr7/samples | /odd_sort.py | 536 | 4.28125 | 4 | # A function for sorting only odd numbers from a list of mixed numbers
def odd_sort(n):
l = len(n)# The length of the input
for i in range(0, l):# A range for 0 to length of input
for j in range(i, l):# A second range for evaluating for each number
if n[i]%2 != 0:# Evaluating each number, wh... | true |
f06708b1981654e8736f6d959c675e9d7f50f683 | CyborgVillager/Learning_py_info | /py_4_evry_one/Dictionary/bk0/dic0.py | 1,853 | 4.21875 | 4 | # making a dictio maps englihs to spanish words
# importing from spanish_numb_info
# install PyDictionary
# exception error list: https://www.programiz.com/python-programming/exceptions
"""''''''
from PyDictionary import PyDictionary
english_to_spanish = PyDictionary()
print(english_to_spanish.translate("Range",'es'... | false |
3ece7ee246f9e1367949690c1c38ddabac94a198 | pragyatwinkle06/Python_patterns_and_codes | /ZIGZAG PATTERN CHALLENGE3.py | 1,149 | 4.40625 | 4 | # Python3 ZIGZAG PATTERN CHALLENGE3
# Function to print any string
# in zigzag fashion
def zigzag(s, rows):
# Store the gap between the major columns
interval = 2 * rows - 2
# Traverse through rows
for i in range(rows):
# Store the step value for each row
step = interval - 2 * i
# Itera... | true |
303052540a0f284b4c1b97143cb54b1cd7c05e52 | LauraValentinaHernandez/Taller-estructuras-de-control-selectivo | /Ejercicio14.py | 901 | 4.28125 | 4 | """
Desarrolle un programa en Python que calcule y muestre el monto que debe pagar ar suscriptor por concepto de consumo de luz eléctrica y servicio de aseo urbano. Dicho monto se calcula multiplicando la diferencia de la lectura anterior y la lectura actual por el costo de cada Kilovatio hora, según la siguiente escal... | false |
6dbaeac22713d2537bc8eae746781641e8b0a86a | NoahNacho/python-solving-problems-examples | /Chapter7/Exercise1.py | 308 | 4.28125 | 4 | # Write a function to count how many odd numbers are in a list.
# Base of function was taken from Chap6 Exercise14
def is_even(n):
num = 0
for odd in n:
if (odd % 2) == 0:
pass
else:
num += 1
return num
odd_list = [1, 2, 3, 4, 5]
print(is_even(odd_list)) | true |
8cb6d0552df6cbd44d7462aa9a0fdc5b91f90474 | denny61302/100_Days_of_Code | /Day19 Racing Game/main.py | 1,371 | 4.1875 | 4 | from turtle import Turtle, Screen
import random
colors = ["red", "yellow", "green", "blue", "black", "purple"]
turtles = []
for _ in range(6):
new_turtle = Turtle(shape="turtle")
turtles.append(new_turtle)
is_race_on = False
screen = Screen()
screen.setup(width=500, height=400)
user_bet = screen.textinput(ti... | true |
c0f64d4b90693d45bfe23da72c3cba4a2632bd61 | darrenredmond/programming-for-big-data_10354686 | /CA 1/TestCalculator.py | 2,884 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 16 19:08:49 2017
@author: 10354686
"""
# Import the Python unittest functions
import unittest
# Import the functions defined in the 'Calculator' file
from Calculator import *
# Create a class which extends unittest.TestCase
class TestCalculator(unittest.TestCase):
... | true |
af68068c121d2eeebb9a1f1e1daaadb89af9b634 | abby-does-code/machine_learning | /quiz2.py | 2,781 | 4.5 | 4 | # Start#
"""You are to apply skills you have acquired in Machine Learning to correctly predict the classification of a group of animals. The data has been divided into 3 files.
Classes.csv is a file describing the class an animal belongs to as well as the name of the class. The class number and class type are the two... | true |
b883911a98cd09445da07329c1cdca5ebb24391e | joedo29/DataScience | /MatplotlibPractices.py | 733 | 4.25 | 4 | import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 100)
y = x*2
z = x**2
# Exercise 1: Create a single plot
fig1 = plt.figure()
ax1 = fig1.add_axes([0.1, 0.1, 0.8, 0.8])
ax1.set_xlabel('X')
ax1.set_ylabel('Y')
ax1.set_title('Outer Plot')
ax1.plot(x,y)
# Exercise 2: plot inside a plot
ax2 = fig1.add_... | true |
737baea08cfb3099f127d972318818e92f915437 | mattyice89/LearnPythonTheHardWay | /ex19.py | 1,243 | 4.15625 | 4 | # defining the argument Cheese and crackers and naming your variables
def cheese_and_crackers(cheese_count,boxes_of_crackers):
# printing out the first variable, named "cheese_count"
print(f"You have {cheese_count} cheeses!")
# printing out the second variable, named "boxes_of_crackers"
print(f"You have... | true |
96c2ccd7e834bb194bb50973e772580784ee9455 | trustme01/PythonCrashCourse2 | /ch_3/cars.py | 753 | 4.59375 | 5 | # Sorting a list PERMANENTLY with the sort() method.
# Alphabetically:
cars = ['bmw', 'audi', 'toyota', 'subaru']
cars.sort()
print(cars)
# Reverse alphabetically:
cars.sort(reverse=True)
print(cars)
# Sorting a list TEMPORARILY with the sort() method.
cars2 = ['bmw', 'audi', 'toyota', 'subaru']
print('\nHere is th... | true |
9be69557321c8e1c498e26371acb00e06fc3bad5 | MDCGP105-1718/portfolio-S191617 | /ex8.py | 730 | 4.25 | 4 | portion_deposit = 0.20
current_savings = 0
r = 0.04
monthly_interest = current_savings*(r/12)
monthly_salary= annual_salary/12
total_cost = float(input("Total cost of the house"))
annual_salary= float(input("Enter the starting annual salary:"))
portion_saved= float(input("How much money do you want to save?"))
semi_an... | true |
2288678a651b13e959bcb43c28771c64a2ec3dd8 | amey-kudari/NN_nLines | /I_am_trask/basic-python-network/2-layer-simple.py | 2,282 | 4.15625 | 4 | """
code taken from "https://iamtrask.github.io/2015/07/12/basic-python-network/"
I learnt about neural networks from here, but I feel this is a little complicated
as it needs you to actually compute the matricies on paper to see what is happening.
I made a simpler model that isnt full batch training, and in my opini... | true |
eb48a58c8578f145a0b9a892c5b4efb100314fdd | Ridwanullahi-code/basic-python | /exercise1.py | 313 | 4.4375 | 4 | # write a python program which accepts the users's first and last name
# and print them in reverse order with space between them
# assign first name value
first_name = 'Ridwanullahi'
last_name = 'Olalekan'
# To display the input values
print(f'{last_name} {first_name}')
print(name)
print("school")
| true |
b686a22202aa61eb9a909d195d83fc6197595a51 | mccarvik/cookbook_python | /1_data_structs_algos/1_17_extract_subet_dict.py | 636 | 4.125 | 4 |
prices = {
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}
# Make a dict of all prices over 200
p1 = {key:value for key,value in prices.items() if value > 200}
print(p1)
# Make a dict of all tech names
tech_names = ['AAPL','IBM','HPQ','MSFT']
p2 = {key:value for key,value in prices.it... | false |
181165441ccf08e506b38f64ad9b5dea8de93f33 | jesusdmartinez/python-labs | /14_list_comprehensions/14_04_fish.py | 277 | 4.15625 | 4 | '''
Using a listcomp, create a list from the following tuple that includes
only words ending with *fish.
Tip: Use an if statement in the listcomp
'''
fish_tuple = ('blowfish', 'clownfish', 'catfish', 'octopus')
list = [w for w in fish_tuple if w[-4:] == 'fish']
print(list) | true |
fef717e2f35131316bf6f6d9bfd2b4f69df91e53 | jesusdmartinez/python-labs | /03_more_datatypes/1_strings/03_04_most_characters.py | 445 | 4.40625 | 4 | '''
Write a script that takes three strings from the user and prints the one with the most characters.
'''
string1 = str(input("please input a string1"))
string2 = str(input("please input a string2"))
string3 = str(input("please input a string3"))
len1 = len(string1)
len2 = len(string2)
len3 = len(string3)
big = max... | true |
1c6d7f8e10eee6f71804df3c4847cacb24e60966 | jesusdmartinez/python-labs | /13_aggregate_functions/13_03_my_enumerate.py | 333 | 4.25 | 4 | '''
Reproduce the functionality of python's .enumerate()
Define a function my_enumerate() that takes an iterable as input
and yields the element and its index
'''
def my_enumerate():
my_num = input("create a list of anything so I can enumerate")
new_num = my_num.split()
print(list(enumerate(new_num)))
m... | true |
7a4c9ddf6fe4e1f00bdc287e1efbcf11c50127fd | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Task 2/3.py | 635 | 4.15625 | 4 | #TASK TWO
#OPERATORS AND DECISION MAKING STATEMENT
#3. Write a program in Python to implement the given flowchart:
a, b, c = 10, 20, 30
avg = (a + b + c) / 3
print("Avg = ", avg)
if avg > a and avg > b and avg > c:
print("Avg higher than a, b, c")
elif avg > a and avg > b:
print("Avg higher th... | false |
347b7a7baabf1a8713e4a30df0bbc95ed1c179b0 | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Task 4/11.py | 592 | 4.125 | 4 | # TASK FOUR
# TRADITIONAL FUNCTIONS,ANONYMOUS FUNCTIONS &
# HIGHER ORDER FUNCTIONS
# 11. Write a program which uses map() and filter() to make a list whose elements are squares of even
# numbers in [1,2,3,4,5,6,7,8,9,10].
# Hints: Use filter() to filter even elements of the given listUse map() to generate a list o... | true |
b8d6cefaa900afdff0cb72b063f2b8d3f2e55f38 | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Task 2/4.py | 499 | 4.15625 | 4 | #TASK TWO
#OPERATORS AND DECISION MAKING STATEMENT
#4. Write a program in Python to break and continue if the following cases occurs:
#If user enters a negative number just break the loop and print “It’s Over”
#If user enters a positive number just continue in the loop and print “Good Going”
x = int(input("Enter... | true |
a30e6a2547e8a4e3227359660e1be7b4c7a55aeb | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Additional Task/5.py | 388 | 4.15625 | 4 | # EXTRA TASK
# DATA STRUCTURES
# 5. Write a program in Python to reverse a string and
# print only the vowel alphabet if it exists in the
# string with their index.
x = input("Enter the String: ")
y = x[::-1]
print("Reversed String: ", y)
vow = ['a','e','i','o','u','A','E','I','O','U']
print("Only Vowel... | false |
7e0b5ce3a86eae805fad3f1de40b0340c8978032 | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Task 1/4.py | 263 | 4.34375 | 4 | #TASK ONE NUMBERS AND VARIABLES
#4. Write a program that takes input from the user and prints it using both Python 2.x and Python 3.x Version.
color = raw_input("Enter the color name: ")
#print(color)
color = input("Enter the colour name: ")
print(color)
| true |
5154b91ee876350111fd6f0a8c35d268798ee742 | ankitpatil30/Ankit_Python_Projects | /Python_Assignments/Task 4/9.py | 624 | 4.34375 | 4 | # TASK FOUR
# TRADITIONAL FUNCTIONS,ANONYMOUS FUNCTIONS &
# HIGHER ORDER FUNCTIONS
# 9. Write a function called showNumbers that takes a parameter called limit. It should print all the
# numbers between 0 and limit with a label to identify the even and odd numbers.
# Sample input: show Numbers(3) (where limit=3)
... | true |
adaf84e3ecda29d8d4748db2590325e3e5a0baff | nandoangelo/nandoangelo-python-cursoemvideo | /mundo-1/desafio000.py | 490 | 4.25 | 4 | # DESAFIO 000
# Aqui eu resolvi experimentar o uso das variáveis em Python
#
# -------------------------------------- Mundo I / Aula 04 ----
# Entradas
nome = input ('Qual o seu nome?\n')
idade = input ('Quantos anos você tem?\n')
# Saida
print('Olá,', nome,'. Com ', idade, 'anos eu também já programava.')
'''
Usa... | false |
a712f5b8ba3aaf1e1a8c219e54b4c07b7b1d50e4 | himsila/CP3-Sila-Sobaeam | /Lecture50_Sila_S.py | 430 | 4.1875 | 4 | def Plus(x, y):
print(f"{x} + {y} = {x + y}")
def Minus(x, y):
print(f"{x} - {y} = {x - y}")
def Multiplying(x, y):
print(f"{x} * {y} = {x * y}")
def Division(x, y):
print(f"{x} / {y} = {int(x / y)}")
print("-------- Let's Cal! --------")
x = int(input("First number : "))
y = int(input("Second number :... | false |
4fcadc2b4105a17dc95f54cca290644e3436b75a | ujwalnitha/stg-challenges | /learning/basics12_number_converter_class.py | 1,108 | 4.15625 | 4 | ''''
This file is to wrap number to words code in a class
Reference: https://www.w3schools.com/python/python_classes.asp
If we have to use a method from Class, outside calling file
-we have to import the class in calling file
-create an object and call function
-if it is a static function, call ClassName.function_na... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.