blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c22167ee72352ce55dfb2b3db6108857776f6c7c | lyannjn/codeInPlaceStanford | /Assignment2/hailstones.py | 829 | 4.5 | 4 | """
File: hailstones.py
-------------------
This is a file for the optional Hailstones problem, if
you'd like to try solving it.
"""
def main():
while True:
hailstones()
def hailstones():
num = int(input("Enter a number: "))
steps = 0
while num != 1:
first_num = num
# Even nu... | true |
83e0cd383f22f7f9483622e7df9acf195e790103 | NithinRe/slipting_current_bill | /Power_Bill.py | 1,043 | 4.15625 | 4 | print("----------------Electricity Bill---------------------")
x = int(input("what is cost of current : "))
y = int(input("Enter Number of units used : "))
z = x/y
print("Each unit is charged as : ",z)
print("-----------------------------------------------------")
meter1 = int(input("First floor number of units u... | true |
880b3b158b1f8e2b56d01ac8e6042cbd2d4b484a | Garrison-Shoemake/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 589 | 4.40625 | 4 | #!/usr/bin/python3
""" This function will print a square equal to the size given """
def print_square(size):
""" This function will raise errors if an integer is not given
as well as if the value is equal or less than zero. """
if not isinstance(size, int):
raise TypeError("size must be an intege... | true |
ab396ea8fa83578e55ee4e24db98b4830749cc27 | Garrison-Shoemake/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/tests/test_models/test_square.py | 1,879 | 4.21875 | 4 | #!/usr/bin/python3
""" this is the unittest file for the Base class """
import unittest
from models.square import Square
class SqrTest(unittest.TestCase):
""" These are the unit tests for the base class """
def test_basics2(self):
s = Square(1)
self.assertEqual(s.width, 1)
s = Squar... | true |
4d3a8bef55942c0f3c4142e807f539ac5cfcda46 | Garrison-Shoemake/holbertonschool-higher_level_programming | /0x0B-python-input_output/2-append_write.py | 247 | 4.28125 | 4 | #!/usr/bin/python3
""" This function appends a string to a file! """
def append_write(filename="", text=""):
""" apppends to the end of a file then returns character count """
with open(filename, 'a') as f:
return f.write(text)
| true |
978bad038ca358c0515806600ccd6bc92e53dfad | makpe80/Boot-camp | /7 lesson. Модуль 4. Модули и пакеты/code_examples/sphinx/ex_1.py | 291 | 4.125 | 4 | def say(sound:str="My")->None:
"""Prints what the animal's sound it.
If the argument `sound` isn't passed in, the default Animal
sound is used.
Parameters
----------
sound : str, optional
The sound the animal makes (default is My)
"""
print(sound)
| true |
0ab0a052a247fbcc29ad44ca7b05740eb65cd1f8 | Taranoberoi/Practise | /List Less Than Ten.py | 357 | 4.28125 | 4 | # Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# write a program that prints out all the elements of the list that are less than 10.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# b = []
# for i in a:
# print("Value is ",i)
# if i <= 10:
# b.append(i)
# els... | true |
463f9708d9e3cec7047f3541bc8f0b570b5b44dc | Taranoberoi/Practise | /10_LIST OVERLAP COMPREHESIONS.py | 690 | 4.25 | 4 | # This week’s exercise is going to be revisiting an old exercise (see Exercise 5), except require the solution in a different way.
# Take two lists, say for example these two:and write a program that returns a list that contains only the elements that are
# common between the lists (without duplicates). Make sure y... | true |
92a0429afb21d39eb64817d068b73f229a608c09 | Othielgh/Cisco-python-course | /5.1.11.7 - Palindromes.py | 905 | 4.25 | 4 | # Your task is to write a program which:
# asks the user for some text;
# checks whether the entered text is a palindrome, and prints result.
# Note:
# assume that an empty string isn't a palindrome;
# treat upper- and lower-case letters as equal;
# spaces are not taken into account during the ch... | true |
a0a00cec203bbaaeee83a82db647317f2db296b3 | Othielgh/Cisco-python-course | /5.1.11.11 - Sudoku.py | 1,186 | 4.3125 | 4 | # Scenario
# As you probably know, Sudoku is a number-placing puzzle played on a 9x9 board. The player has to fill the board in a very specific way:
# each row of the board must contain all digits from 0 to 9 (the order doesn't matter)
# each column of the board must contain all digits from 0 to 9 (again, the... | true |
fff52176408ddc67628b6c3707bc204363824ab8 | greenfox-velox/oregzoltan | /week-04/day-3/09.py | 476 | 4.125 | 4 | # create a 300x300 canvas.
# create a square drawing function that takes 1 parameter:
# the square size
# and draws a square of that size to the center of the canvas.
# draw 3 squares with that function.
from tkinter import *
root = Tk()
canvas = Canvas(root, width='300', height='300')
canvas.pack()
def draw_square... | true |
38bf2fa152fbe028217728b502544ce1f5732432 | greenfox-velox/oregzoltan | /week-04/day-3/11.py | 751 | 4.125 | 4 | # create a 300x300 canvas.
# create a square drawing function that takes 2 parameters:
# the square size, and the fill color,
# and draws a square of that size and color to the center of the canvas.
# create a loop that fills the canvas with rainbow colored squares.
from tkinter import *
import random
root = Tk()
ca... | true |
7a9084979864dc2e1bc3a23b964d8d9790370ee5 | haveano/codeacademy-python_v1 | /05_Lists and Dictionaries/02_A Day at the Supermarket/13_Lets Check Out.py | 1,142 | 4.3125 | 4 | """
Let's Check Out!
Perfect! You've done a great job with lists and dictionaries in this project. You've practiced:
Using for loops with lists and dictionaries
Writing functions with loops, lists, and dictionaries
Updating data in response to changes in the environment (for instance, decreasing the number of bananas ... | true |
97ce0591bd0ed48a9918db96043117d016f3cc06 | haveano/codeacademy-python_v1 | /11_Introduction to Classes/02_Classes/08_Modifying member variables.py | 1,115 | 4.375 | 4 | """
Modifying member variables
We can modify variables that belong to a class the same way that we initialize those member variables. This can be useful when we want to change the value a variable takes on based on something that happens inside of a class method.
Instructions
Inside the Car class, add a method drive_c... | true |
d2b8e32208cd60547fb0ce5e786064a1d4a17906 | haveano/codeacademy-python_v1 | /12_File Input and Output/01_File Input and Output/05_Reading Between the Lines.py | 847 | 4.4375 | 4 | """
Reading Between the Lines
What if we want to read from a file line by line, rather than pulling the entire file in at once. Thankfully, Python includes a readline() function that does exactly that.
If you open a file and call .readline() on the file object, you'll get the first line of the file; subsequent calls t... | true |
e988e9f53a578404a3c6c4b81174c704f395f19c | haveano/codeacademy-python_v1 | /10_Advanced Topics in Python/02_Introduction to Bitwise Operators/04_The bin() Function.py | 1,150 | 4.65625 | 5 | """
The bin() Function
Excellent! The biggest hurdle you have to jump over in order to understand bitwise operators is learning how to count in base 2. Hopefully the lesson should be easier for you from here on out.
There are Python functions that can aid you with bitwise operations. In order to print a number in its ... | true |
572f9b19515b5f46c03ddafedb0f93b37b13a49e | haveano/codeacademy-python_v1 | /08_Loops/02_Practice Makes Perfect/03_is_int.py | 1,183 | 4.21875 | 4 | """
is_int
An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not).
For the purpose of this lesson, we'll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0.
This means that, for this lesson, you can't just test the inp... | true |
6876089ff1413f4e3bc30adecefa91b75a59e006 | haveano/codeacademy-python_v1 | /07_Lists and Functions/01_Lists and Functions/11_List manipulation in functions.py | 594 | 4.34375 | 4 | """
List manipulation in functions
You can also append or delete items of a list inside a function just as if you were manipulating the list outside a function.
my_list = [1, 2, 3]
my_list.append(4)
print my_list
# prints [1, 2, 3, 4]
The example above is just a reminder of how to append items to a list.
Instructions... | true |
15f47141d90b1e773ff194272ae57c357f3572b4 | haveano/codeacademy-python_v1 | /10_Advanced Topics in Python/02_Introduction to Bitwise Operators/09_This XOR That.py | 1,487 | 4.15625 | 4 | """
This XOR That?
The XOR (^) or exclusive or operator compares two numbers on a bit level and returns a number where the bits of that number are turned on if either of the corresponding bits of the two numbers are 1, but not both.
a: 00101010 42
b: 00001111 15
================
a ^ b: 00100101 ... | true |
4b1a907a1f05d61a2904551c34cfc20e1a733840 | haveano/codeacademy-python_v1 | /08_Loops/01_Loops/13_For your lists.py | 625 | 4.78125 | 5 | """
For your lists
Perhaps the most useful (and most common) use of for loops is to go through a list.
On each iteration, the variable num will be the next value in the list. So, the first time through, it will be 7, the second time it will be 9, then 12, 54, 99, and then the loop will exit when there are no more valu... | true |
758a91bf1eefd576051c24401423f4c6578180fa | haveano/codeacademy-python_v1 | /03_Conditionals and Control Flow/02_PygLatin/06_Pop Quiz.py | 603 | 4.21875 | 4 | """
Pop Quiz!
When you finish one part of your program, it's important to test it multiple times, using a variety of inputs.
Instructions
Take some time to test your current code. Try some inputs that should pass and some that should fail. Enter some strings that contain non-alphabetical characters and an empty string... | true |
6efae81bdbee61a5e960c0bce1039a31a48c3bb2 | haveano/codeacademy-python_v1 | /11_Introduction to Classes/01_Introduction to Classes/03_Classier Classes.py | 967 | 4.46875 | 4 | """
Classier Classes
We'd like our classes to do more than... well, nothing, so we'll have to replace our pass with something else.
You may have noticed in our example back in the first exercise that we started our class definition off with an odd-looking function: __init__(). This function is required for classes, an... | true |
3c6f0c6039e2a9d52e415b7b235adda8f27bb3e6 | haveano/codeacademy-python_v1 | /03_Conditionals and Control Flow/02_PygLatin/01_Break It Down.py | 677 | 4.25 | 4 | """
Break It Down
Now let's take what we've learned so far and write a Pig Latin translator.
Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take:
Ask the user... | true |
26c8ad332a82464bb4e423fc0f801e8f709297f0 | haveano/codeacademy-python_v1 | /03_Conditionals and Control Flow/02_PygLatin/09_Move it on Back.py | 672 | 4.21875 | 4 | """
Move it on Back
Now that we have the first letter stored, we need to add both the letter and the string stored in pyg to the end of the original string.
Remember how to concatenate (i.e. add) strings together?
greeting = "Hello "
name = "D. Y."
welcome = greeting + name
Instructions
On a new line after where you ... | true |
ed920d881c1a5fa00c6137a741e648894730e987 | haveano/codeacademy-python_v1 | /10_Advanced Topics in Python/01_Advanced Topics in Python/04_Building Lists.py | 672 | 4.625 | 5 | """
Building Lists
Let's say you wanted to build a list of the numbers from 0 to 50 (inclusive). We could do this pretty easily:
my_list = range(51)
But what if we wanted to generate a list according to some logic—for example, a list of all the even numbers from 0 to 50?
Python's answer to this is the list comprehens... | true |
2b229803bcb9a175dac4b1b85e2b712c77adba7c | ankitandel/function.py | /4h.py | 311 | 4.1875 | 4 | # write a python program to print the even numbers from a given list.[1,2,3,4,5,6,7,8,9]
def is_even_num(b):
i=0
while i<=len(b):
if i%2==0:
print("even number",i,end="")
else:
print("odd number",i)
i=i+1
b=[1,2,3,4,5,6,7,8,9]
is_even_num(b)
| true |
21cced07ce4cf5abbcf22728b0a885585101320c | kavisha-nethmini/Hacktoberfest2020 | /python codes/DoubleBasePalindrome.py | 733 | 4.15625 | 4 | #Problem statement: The decimal number, 585 is equal to 1001001001 in binary.
#And both are palindromes. Such a number is called a double-base palindrome.
#Write a function that takes a decimal number n and checks if it's binary equivalent and itself are palindromes.
#The function should return True if n is a double-ba... | true |
5e94315bfe25f3afe469c6baacb18f0d123decde | piupom/Python | /tuplePersonsEsim.py | 2,212 | 4.71875 | 5 | # It is often convenient to bundle several pieces of data together. E.g. if the code processes information about people, then each person's information (name, age, etc.) could be bundled. This can be done in a naive manner with e.g. a tuple (also shown below), but classes provide a more convenient way. A class definiti... | true |
e8b3807b0f9d38fe7b554e73c91797fd8e13b062 | piupom/Python | /classFunctionsPersonsEsim.py | 1,538 | 4.40625 | 4 | # Classes have also other "special" functions. One common is __str__, which defines how to represent the object in string format (e.g. what is printed out if the object is passed to the print-function). Here we transform the printPersonObject-function from above into a __str__-member function. Now Person-objects can be... | true |
923a822bb263814d9af788e325e228cfba233894 | roblivesinottawa/intermediate_100_days | /day_twentythree/turtle_crossing/carmanager.py | 1,631 | 4.21875 | 4 | from turtle import Turtle
import random
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
STARTING_MOVE_DISTANCE = 5
MOVE_INCREMENT = 10
# create a class and methods to manage the movement of the cars
class CarManager:
def __init__(self):
# create a variable to store all cars and set it to an empty... | true |
690574f888f0c7a65aef7402f12c56e5a928e7dd | twopiharris/230-Examples | /python/basic3/nameGame.py | 533 | 4.25 | 4 | """ nameGame.py
illustrate basic string functions
Andy Harris """
userName = input("Please tell me your name: ")
print ("I will shout your name: ", userName.upper())
print ("Now all in lowercase: ", userName.lower())
print ("How about inverting the case? ", userName.swapcase())
numChars = len(userName)
print ... | true |
7d88f2a2dff5286c80d7fcf9a03fd70b9162f42f | twopiharris/230-Examples | /python/basic3/intDiv.py | 443 | 4.53125 | 5 | """ integer division
explains integer division in Python 3
"""
#by default, dividing integers produces a floating value
print("{} / {} = {}".format(10, 3, 10 / 3))
#but sometimes you really want an integer result...
#use the // to force integer division:
print("{} // {} = {}".format(10, 3, 10 // 3))
#integer d... | true |
92fc4e3107ecedca5a04673bd9b62e2c03a336e7 | davidtscott/CMEECoursework | /Week2/Code/tuple.py | 1,329 | 4.53125 | 5 | #!/usr/bin/env python3
# Date: October 2018
"""
Extracts tuples from within a tuple and outputs as seperate lines
"""
__appname__ = '[tuple.py]'
__author__ = 'David Scott (david.scott18@imperial.ac.uk)'
__version__ = '0.0.1'
__license__ = "License for this code/program"
birds = ( ('Passerculus sandwichensis','Sav... | true |
873879f49529cc6abfb81cb3258aa8fb431b1ca5 | Sahana-Chandrashekar/infytq | /prg23.py | 493 | 4.25 | 4 | '''
Write a python function to find out whether a number is divisible by the sum of its digits. If so return True,else return False.
Sample Input Expected Output
42 True
66 False
'''
#PF-Prac-23
def divisible_by_sum(number):
temp = number
s = 0
while number != 0:
re... | true |
88ab6d0234b210119fda15fe508a7fc65d0b94ab | Brijesh739837/Mtechmmm | /arrayinput.py | 242 | 4.125 | 4 | from array import *
arr=array('i',[]) # creates an empty array
length = int(input("enter the no of students"))
for i in range(length):
n = int(input("enter the marks of students"))
arr.append(n)
for maria in arr:
print(maria) | true |
56dfa6e4d1b0ef316cac9de3ad21287f69d0e854 | omostic21/personal-dev-repo | /guesser_game.py | 1,433 | 4.1875 | 4 | #I wrote this code just to play around and test my skils
#Author: Omolola O. Okesanjo
#Creation date: December 10, 2019
print("Welcome to the Number Guessing game!!")
x = input('Press 1 to play, press 2 for instructions, press 3 to exit')
x = int(x)
if x == 2:
print("The computer will pick a number within the... | true |
24a0066c1f6d87c37cf15b81eb59f28c199997f8 | cgarey2014/school_python_projects | /garey3/program3_3.py | 1,175 | 4.21875 | 4 | # Chris Garey #2417512
# This is original work by me, there are no other collaborators.
# Begin Prog
# Set the initial answer counter to zero
# Ask the first question, count one point if correct and no points if wrong.
# Ask the second question, count one point if correct and no points if wrong.
# Ask the third questio... | true |
44a981d0bb30cc57c6fd15ed98e02993129563cd | sprksh/quest | /recursion/backtracking/backtracking.py | 1,657 | 4.34375 | 4 | """
Backtracking is when you backtrack after recursion
Examples in n_queens in the bottom section
"""
class newNode:
# Construct to create a new node
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __repr__(self):
... | true |
6a55c9c131b08c9afd042592d7b3b5db8cec153e | insomnia-soft/projecteuler.net | /004/004.py | 831 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
def palindrome(n):
m = n
p = 0
while m > 0:
mod = m % 10
m /= 10
p = p * 10 + mod
if p == n:
return True
return False
def main():
"""
Largest palindrome product
Probl... | true |
19f2142d863f2105fd453b35dd9832bff8ffb9e5 | subash319/PythonDepth | /Practice16_Functions/Prac_16_10_count_even_odd.py | 374 | 4.28125 | 4 | # 10. Write a function that takes in a list of integers and returns the number of even and odd numbers from that list.
def count_even_odd(list_count):
even_count,odd_count = 0,0
for num in list_count:
if num%2 == 0:
even_count += 1
else:
odd_count += 1
return even_co... | true |
4410eadec793e5cfb189305a350f91052cc822e6 | subash319/PythonDepth | /Practice14_List_Comprhensions/Prac_14_6_cubes_all_odd.py | 292 | 4.53125 | 5 | # 6. This list comprehension creates a list of cubes of all odd numbers.
#
# cubes = [ n**3 for n in range(5,21) if n%2!=0]
# Can you write it without the if clause.
cubes = [n**3 for n in range(5, 21, 2)]
cubes_2 = [ n**3 for n in range(5,21) if n%2!=0]
print(cubes)
print(cubes_2) | true |
3687ac68a5e5a98d1972ae671b90d598f2055e84 | subash319/PythonDepth | /Practice17_Functions_2/Prac_17_6_kwargs.py | 493 | 4.125 | 4 | # def display(L, start='', end=''):
# for i in L:
# if i.startswith(start) and i.endswith(end):
# print(i, end=' ')
#
# display(dir(str), 'is', 'r')
# In the function definition of the function display(),
# make changes such that the user is forced to send keyword arguments for the last two parameters.... | true |
2b44c016feeed5be184877be0e84ba5ff8e7f38c | VishalSinghRana/Basics_Program_Python | /Squareroot_of_Number.py | 284 | 4.34375 | 4 |
y="Y"
while(y=="y" or y=="Y"):
number = int(input("Enter the number"))
if number < 0:
print("Please Enter a postive number")
else:
sqrt= number**(1/2)
print("The squareroot of the numebr is ",sqrt)
y=input("Do you want to continue Y/N?")
| true |
b81bf5104838515302768a79df37c945fa7a4f5a | kcwebers/Python_Fundametnals | /fundamentals/insertion.py | 2,060 | 4.3125 | 4 | # Build an algorithm for insertion sort. Please watch the video here to understand how insertion sort works and implement the code.
# Basically, this sort works by starting at index 1, shifting that value to the left until it is sorted relative to all values to the
# left, and then moving on to the next index positio... | true |
07a2b70ca25f20852834cf6b5451951ad90e4a33 | psyde26/Homework1 | /assignment2.py | 501 | 4.125 | 4 | first_line = input('Введите первую строку: ')
second_line = input('Введите вторую строку: ')
def length_of_lines(line1, line2):
if type(line1) is not str or type(line2) is not str:
return('0')
elif len(line1) == len(line2):
return('1')
elif len(line1) > len(line2):
return('2')
... | true |
45b08672f5802bd07e54d45df20b24c1538a2673 | jxthng/cpy5python | /Practical 03/q7_display_matrix.py | 383 | 4.4375 | 4 | # Filename: q7_display_matrix.py
# Author: Thng Jing Xiong
# Created: 20130221
# Description: Program to display a 'n' by 'n' matrix
# main
# import random
import random
# define matrix
def print_matrix(n):
for i in range(0, n):
for x in range (0, n):
print(random.randint(0,1), end=" ")
... | true |
02f76ae07d4bb429bf6a8319cce2aba0cb80ef58 | jxthng/cpy5python | /compute_bmi.py | 634 | 4.59375 | 5 | # Filename: compute_bmi.py
# Author: Thng Jing Xiong
# Created: 20130121
# Modified: 20130121
# Description: Program to get user weight and height and
# calculate body mass index (BMI)
# main
# prompt and get weight
weight = int(input("Enter weight in kg:"))
# prompt and get height
height = float(input("Enter heigh... | true |
3c144e821443e44da6317169ecdc9992134a34fc | DevJ5/Automate_The_Boring_Stuff | /Dictionary.py | 1,184 | 4.28125 | 4 | import pprint
pizzas = {
"cheese": 9,
"pepperoni": 10,
"vegetable": 11,
"buffalo chicken": 12
}
for topping, price in pizzas.items():
print(f"Pizza with {topping}, costs {price}.")
print("Pizza with {0}, costs {1}.".format(topping, price))
# There is no order in dictionaries.
print('che... | true |
0bb5501ebf856a20a70f2ec604495f21e10a4b0c | MachFour/info1110-2019 | /week3/W13B/integer_test.py | 399 | 4.25 | 4 | number = int(input("Integer: "))
is_even = number%2 == 0
is_odd = not is_even
is_within_range = 20 <= number <= 200
is_negative = number < 0
if is_even and is_within_range:
print("{} passes the test.".format(number))
# Else if number is odd and negative
elif is_odd and is_negative:
print("{} passes the test.... | true |
bf86e2e9ac26825248273684b72b95427cc26328 | MachFour/info1110-2019 | /week6/W13B/exceptions.py | 778 | 4.25 | 4 | def divide(a, b):
if not a.isdigit() or not b.isdigit():
raise ValueError("a or b are not numbers.")
if float(b) == 0:
# IF my b is equal to 0
# Raise a more meaningful exception
raise ZeroDivisionError("Zero Division Error: Value of a was {} and value of b was {}".format(a,b))
... | true |
da7b7caea279a8444cd63c43cabe65240ca21b57 | Jyun-Neng/LeetCode_Python | /104-maximum-depth-of-binary-tree.py | 1,301 | 4.21875 | 4 | """
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Note: A leaf is a node with no children.
Example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its depth = 3.... | true |
6e784b269099a926400bc136e6810610a96a88ed | Jyun-Neng/LeetCode_Python | /729-my-calendar-I.py | 2,328 | 4.125 | 4 | """
Implement a MyCalendar class to store your events.
A new event can be added if adding the event will not cause a double booking.
Your class will have the method, book(int start, int end).
Formally, this represents a booking on the half open interval [start, end),
the range of real numbers x such that start <= x ... | true |
4038b6ca7e62b6bd3b5ba7ef3cf01de2d3e8ee84 | rishabh2811/Must-Know-Programming-Codes | /Series/Geometric.py | 751 | 4.3125 | 4 | # Geometric.py
""" Geometric takes the first number firstElem, the ratio and the number of elements Num, and returns a list containing "Num" numbers in the Geometric series.
Pre-Conditions - firstElem should be an Number.
- ratio should be an Number.
- Num should be an integer >=1.
Geometric(firstElem=... | true |
24eb50260ff182ad58f58665b2bbbe609a713f6b | manansharma18/BigJ | /listAddDelete.py | 1,280 | 4.34375 | 4 | def main():
menuDictionary = {'breakfast':[],'lunch':[], 'dinner':[]}
print(menuDictionary)
choiceOfMenu = ''
while choiceOfMenu != 'q':
choiceOfMenu = input('Enter the category (enter q to exit) ')
if choiceOfMenu in menuDictionary:
addOrDelete= input('Do you want to list, a... | true |
0ab1712df48bd99d3e5c744138caaea015ca12e1 | Rupam-Shil/30_days_of_competative_python | /Day29.py | 496 | 4.1875 | 4 | '''write a python program to takes the user
for a distance(in meters) and the time was
taken(as three numbers: hours, minutes and seconds)
and display the speed in miles per hour.'''
distance = float(input("Please inter the distance in meter:"))
hour, min, sec = [int(i) for i in input("Please enter the time taken... | true |
48ded77911e4f9e63e254d4cc5265e02f8f593e1 | BrimCap/BoredomBot | /day.py | 1,010 | 4.3125 | 4 | import datetime
import calendar
def calc_day(day : str, next = False):
"""
Returns a datetime for the next or coming day that is coming.
Params:
day : str
The day you want to search for. Must be in
[
"monday"
"tuesday"
"wedn... | true |
ad1ae0039c48c95c13268cfd96241e93a858d57b | papri-entropy/pyplus | /class7/exercise4c.py | 710 | 4.15625 | 4 | #!/usr/bin/env python
"""
4c. Use the findall() method to find all occurrences of "zones-security".
For each of these security zones, print out the security zone name
("zones-security-zonename", the text of that element).
"""
from pprint import pprint
from lxml import etree
with open("show_security_zones.xml") as ... | true |
e0e0d097adba29f9673331887f6527caa5b3d2ad | fr3d3rico/python-machine-learning-course | /study/linear-regression/test4.py | 2,734 | 4.53125 | 5 | # https://www.w3schools.com/python/python_ml_polynomial_regression.asp
# polynomial regression
import matplotlib.pyplot as plt
x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
plt.scatter(x, y)
plt.show()
import numpy as np
import matplotlib.pyplot... | true |
02e08da64766c262406de320027d2d53b5e3dfa2 | Fanniek/intro_DI_github | /lambda.py | 1,305 | 4.53125 | 5 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 19:20:40 2019
@author: fannieklein
"""
#Exercise 1:
mylist =[" hello"," itsme ","heyy "," i love python "]
mylist = list(map(lambda s: s.strip(), mylist))
#print(mylist)
#Explanattion of Exercise 1:
#This function should use map function --> ma... | true |
8ad71cb6e4e52fc454528ad87e4ecf657a6e406f | userddssilva/ESTCMP064-oficina-de-desenvolvimento-de-software-1 | /distances/minkowski.py | 513 | 4.125 | 4 | def minkowski(ratings_1, ratings_2, r):
"""Computes the Minkowski distance.
Both ratings_1 and rating_2 are dictionaries of the form
{'The Strokes: 3.0, 'Slightlyt Stoopid: 2.5}
"""
distance = 0
commonRatings = False
for key in ratings_1:
if key in ratings_2:
distance += ... | true |
9ad2e6f1e44f976b5a34b08705420da4ee5598b5 | nihal-wadhwa/Computer-Science-1 | /Labs/Lab07/top_10_years.py | 2,524 | 4.21875 | 4 | """
CSCI-141 Week 9: Dictionaries & Dataclasses
Lab: 07-BabyNames
Author: RIT CS
This is the third program that computes the top 10 female and top 10 male
baby names over a range of years.
The program requires two command line arguments, the start year, followed by
the end year.
Assuming the working directory is set... | true |
6f2539ffb11dc17d1f277f6cbe7e7ed2b10377a1 | loyti/GitHubRepoAssingment | /Python/pythonPlay/bikePlay.py | 1,065 | 4.15625 | 4 | class Bike(object):
def __init__ (price,maxSpeed,miles):
self.price = "$Really$ Expen$ive"
self.maxSpeed = maxSpeed
self.miles = 0
def displayInfo(self):
print "A little about your Bike: $Price: {}, {} max kph & {} miles traveled".format(str(self.price), int(self.maxSpeed), str(s... | true |
9bcc9a4088f6081d67388d517bc7d0ef80154e3e | securepadawan/Coding-Projects | /Converstation with a Computer/first_program_week2.py | 2,283 | 4.125 | 4 | print('Halt!! I am the Knight of First Python Program!. He or she who would open my program must answer these questions!')
Ready = input('Are you ready?').lower()
if Ready.startswith('y'):
print('Great, what is your name?') # ask for their name
else:
print('Run me again when you are ready!')
exit()
m... | true |
f4f8dfb4f59a722fd628f0634654aca2ba592a5e | NguyenLeVo/cs50 | /Python/House_Roster/2020-04-27 import.py | 1,569 | 4.1875 | 4 | # Program to import data from a CSV spreadsheet
from cs50 import SQL
from csv import reader, DictReader
from sys import argv
# Create database
open(f"students.db", "w").close()
db = SQL("sqlite:///students.db")
# Create tables
db.execute("CREATE TABLE Students (first TEXT, middle TEXT, last TEXT, house TEXT, birth NU... | true |
7bab4b14a82a9e79dd6dd2ebc52f6a1c315d9176 | JASTYN/30dayspyquiz | /exam/spaces.py | 253 | 4.1875 | 4 | """
Write a loop that counts the number of words in a string
"""
space = ' '
count = 0
sentence = input("Enter a sentence: ")
for letter in sentence:
if letter == space:
count = count + 1
print(f'Your sentence has {count + 1} words')
| true |
d29b0a47e7fe7df6a7906e8c96e7e43492c8ccd9 | JASTYN/30dayspyquiz | /exam/hey/finalav.py | 980 | 4.1875 | 4 | def getNumberList(filename):
f = open(filename,'r')
#opening the file
line = f.readline()
#reading the file line by line
numbers = line.split(',')
#The split() method splits a string into a list.
numberList = []
#An array to store the list
for i in numbers:
numberL... | true |
2e4e0012235649961b56e64101e1b417ef98738e | hemanthkumar25/MyProjects | /Python/InsertionSort.py | 409 | 4.21875 | 4 | def insertionSort(list):
for index in range(1,len(list)):
currentvalue = list[index]
position = index
while position > 0 and list[position-1]>currentvalue:
list[position] = list[position -1]
position = position -1
list[position] = currentv... | true |
a72bec9020e351bc3ef6e30d72aa3202021f2eab | severinkrystyan/CIS2348-Fall-2020 | /Homework 4/14.11 zylab_Krystyan Severin_CIS2348.py | 790 | 4.125 | 4 | """Name: Krystyan Severin
PSID: 1916594"""
def selection_sort_descend_trace(integers):
for number in range(len(integers)):
# Sets first number of iteration as largest number
largest = number
for i in range(number+1, len(integers)):
# Checks for number in list that is larger ... | true |
fbeaf00fea7890184e40e34f3e403b2121f6b289 | BriannaRice/Final_Project | /Final_Project.py | 1,201 | 4.125 | 4 | '''
I already started before I knew that they all had to go together
so some of it makes sense the rest doesn't
'''
# 3/11/19 Final Project
# Brianna Rice
print('Pick a number between 1 and 30', "\n")
magic_number = 3
guess = int(input('Enter a number:', ))
while guess != magic_number:
print('Guess again', "\n")
... | true |
858fd9f1634b03d69550a3202c2f12a7295d568b | hutbe/python_space | /8-Decorators/decorators.py | 1,017 | 4.34375 | 4 | # Decorator
# Using a wrap function to add extra functions to a function
def my_decorator(fun):
def wrap_fun():
print(f"==== Function: {fun.__name__}")
fun()
return wrap_fun
@my_decorator
def say_hi():
print(f"Hello everyone, nice to be here!")
say_hi()
@my_decorator
def generator_even_odd():
result_list = [... | true |
9a6cd4518c1bb000496a8aef48336b7b5179f809 | hutbe/python_space | /13-FileIO/read_file.py | 1,054 | 4.34375 | 4 |
test_file = open('Test.txt')
print("File read object:")
print(test_file)
print("Read file first time")
print(test_file.read()) # The point will move to the end of file
print("Read file second time")
test_file.seek(0) # move the point back to the head of file
print(test_file.read())
print("Read file third time")
p... | true |
ed8e8f7646b93809bf53f84dc4654ecc61ffbac7 | Omkar2702/python_project | /Guess_the_number.py | 887 | 4.21875 | 4 | Hidden_number = 24
print("Welcome to the Guess The Number Game!!")
for i in range(1, 6):
print("Enter Guess", int(i), ": ")
userInput = int(input())
if userInput == Hidden_number:
print("Voila! you've guessed it right,", userInput, "is the hidden number!")
print("Congratulations!!!!! You too... | true |
7fbdcfad250a949cb0575167c87d212f376e4d98 | vaish28/Python-Programming | /JOC-Python/NLP_Stylometry/punct_tokenizer.py | 405 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Punctuation tokenizer
"""
#Tokenizes a text into a sequence of alphabetic and non-alphabetic characters.
#splits all punctuations into separate tokens
from nltk.tokenize import WordPunctTokenizer
text="Hey @airvistara , not #flyinghigher these days we heard? #StayingParkedStayingSa... | true |
0290746b9b476109ea203930c5ccaaf2ec98bf31 | qwatro1111/common | /tests/tests.py | 1,917 | 4.125 | 4 | import unittest
from math import sqrt
from homework import Rectangle
class Test(unittest.TestCase):
def setUp(self):
self.width, self.height = 4, 6
self.rectangle = Rectangle(self.width, self.height)
def test_1_rectangle_perimeter(self):
cheack = (self.width+self.height)*2
res... | true |
8c44895f64d1161588c25e339ff6b23c82d8290e | KhaledAchech/Problem_Solving | /CodeForces/Easy/File Name.py | 2,425 | 4.375 | 4 | """
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the s... | true |
33290292667e0df5ef32c562b2320933446a118e | KhaledAchech/Problem_Solving | /CodeForces/Easy/Helpful Maths.py | 1,112 | 4.21875 | 4 | """
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough fo... | true |
afebc658717b8f3badb5ee990c9d9e48ef32bc0e | makyca/Hacker-Rank | /Power-Mod_Power.py | 286 | 4.25 | 4 | #Task
#You are given three integers: a, b, and m, respectively. Print two lines.
#The first line should print the result of pow(a,b). The second line should print the result of pow(a,b,m).
a = int(raw_input())
b = int(raw_input())
m = int(raw_input())
print pow(a,b)
print pow(a,b,m)
| true |
e0f20d297d8816da124a9f4e8a41a23e680e95b7 | makyca/Hacker-Rank | /Sets-Symmetric_Difference.py | 719 | 4.28125 | 4 | #Task
#Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates
#those values that exist in either M or N but do not exist in both.
#Input Format
#The first line of input contains an integer, M.
#The second line contains M space-separated integers... | true |
8f6a0b68353c38fad53150c779444b96abc1b8e5 | levi-terry/CSCI136 | /hw_28JAN/bool_exercise.py | 1,284 | 4.15625 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: bool_exercise.py
# Purpose: This program is comprised of several functions.
# The any() function evaluates an array of booleans and
# returns True if any boolean is True. The all() function
# evaluates an array of booleans and returns True if all
# are True.
# Function to eval... | true |
1c73961f953b4686742f415bc9aaf2fe389f8d14 | levi-terry/CSCI136 | /hw_30JAN/recursion_begin.py | 1,860 | 4.15625 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: recursion_begin.py
# Purpose: This program implements two functions.
# The first function accepts an int array as a parameter
# and returns the sum of the array using recursion. The
# second function validates nested parentheses oriented
# correctly, such as (), (()()), and so o... | true |
7868d39dfc5a0e63481d605c23d303303c851bb9 | levi-terry/CSCI136 | /hw_28JAN/three_true.py | 912 | 4.34375 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: three_true.py
# Purpose: This program implements a function which returns
# True if 1 or 3 of the 3 boolean arguments are True.
# Function to perform the checking of 3 booleans
def three_true(a, b, c):
if a:
if b:
if c:
return True
... | true |
66afd8353ae48aa03ac42674765b59b18884d19a | wjwainwright/ASTP720 | /HW1/rootFind.py | 2,848 | 4.28125 | 4 | # -*- coding: utf-8 -*-
def bisect(func,a,b,threshold=0.0001):
"""
Bisect root finding method
Args:
func: Input function that takes a single variable i.e. f(x) whose root you want to find
a: lower bound of the range of your initial guess where the root is an element of [a,b]
b... | true |
fe0e8af3b6d088f25a8726e32abe1ab08c03b8c3 | vickyjeptoo/DataScience | /VickyPython/lesson3a.py | 381 | 4.1875 | 4 | #looping - repeat a task n-times
# 2 types :for,while,
#modcom.co.ke/datascience
counter = 1
while counter<=3:
print('Do Something',counter)
age=int(input('Your age?'))
counter=counter+1 #update counter
# using while loop print from 10 to 1
number=11
while number>1:
number=number-1
print(number... | true |
e9a0af2257266fa452fddf4b79e1939784bca493 | vickyjeptoo/DataScience | /VickyPython/multiplication table.py | 204 | 4.21875 | 4 |
number = int(input("Enter a number to generate multiplication table: "))
# use for loop to iterate 10 times
for i in range(1, 13):
print(number, 'x', i, '=', number * i)
#print a triangle of stars | true |
32bdec09e8dc8ef94efd14ff0ab50b7585fdda7d | vickyjeptoo/DataScience | /VickyPython/lesson5.py | 1,511 | 4.25 | 4 | #functions
#BMI
def body_mass_index():
weight=float(input('Enter your weight:'))
height=float(input('Enter your height:'))
answer=weight/height**2
print("Your BMI is:",answer)
#body_mass_index()
#functions with parameters
#base&height are called parameters
#these parameters are unknown,we provide them... | true |
a4322a82e093af0b6a1a4acdfcbb5540b7084db5 | PragmaticMates/python-pragmatic | /python_pragmatic/classes.py | 675 | 4.25 | 4 | def get_subclasses(classes, level=0):
"""
Return the list of all subclasses given class (or list of classes) has.
Inspired by this question:
http://stackoverflow.com/questions/3862310/how-can-i-find-all-subclasses-of-a-given-class-in-python
Thanks to: http://codeblogging.net/blogs/1/... | true |
b09b2657f56cb03fae84b598ce256753b6eb4571 | prashant523580/python-tutorials | /conditions/neg_pos.py | 336 | 4.4375 | 4 | #user input a number
ui = input("enter a number: ")
ui = float(ui) #converting it to a floating point number
#if the number is greater then zero
# output positive
if ui > 0:
print("positive number")
#if the number is less then zero
#output negative
elif ui < 0:
print("negative number")
#in all other case
else:
... | true |
6d8d75053d9d281db48f32327598b55e1010ee78 | deepak1214/CompetitiveCode | /InterviewBit_problems/Sorting/Hotel Booking/solution.py | 1,298 | 4.34375 | 4 | '''
- A hotel manager has to process N advance bookings of rooms for the next season.
His hotel has C rooms. Bookings contain a list A of arrival date and a list B of departure date.
He wants to find out whether there are enough rooms in the hotel to satisfy the demand.
- Creating a function hotel which will take 3 ... | true |
4eb966b642158fd2266ae747d4cd6fcf694acfe2 | deepak1214/CompetitiveCode | /LeetCode_problems/Invert Binary Tree/invert_binary_Tree.py | 1,436 | 4.125 | 4 | from collections import deque
class TreeNode:
def __init__(self,val):
self.val = val
self.left = None
self.right = None
def insert(root,node):
if root is None:
root = node
else:
if root.val < node.val:
if root.right is None:
... | true |
d4cc2c4c13be0e76bb0b78f50f32dacef61b63ee | deepak1214/CompetitiveCode | /Hackerrank_problems/counting_valleys/solution.py | 1,605 | 4.125 | 4 |
# Importing the required Libraries
import math
import os
import random
import re
import sys
# Fuction For Counting the Valleys Traversed. Takes the number of steps(n) and The path(s[D/U]). Returns the Number.
def countingValleys(n, s):
count = 0
number_of_valleys = 0 # Initialized Variables... | true |
26614f5cbe266818c5f34b536b9f921c922a18d2 | WSMathias/crypto-cli-trader | /innum.py | 2,012 | 4.5625 | 5 | """
This file contains functions to process user input.
"""
# return integer user input
class Input:
"""
This class provides methods to process user input
"""
def get_int(self, message='Enter your number: ', default=0, warning=''):
"""
Accepts only integers
"""
hasInputN... | true |
20191d04dad06de1f7b191ed7538828580eac557 | jeremycross/Python-Notes | /Learning_Python_JoeMarini/Ch2/variables_start.py | 609 | 4.46875 | 4 | #
# Example file for variables
#
# Declare a variable and initialize it
f=0
# print(f)
# # # re-declaring the variable works
# f="abc"
# print(f)
# # # ERROR: variables of different types cannot be combined
# print("this is a string" + str(123))
# Global vs. local variables in functions
def someFunction():
glo... | true |
6ec438602e86c1eeebbab11746d4445b84e0187a | jeremycross/Python-Notes | /Essential_Training_BillWeinman/Chap02/hello.py | 365 | 4.34375 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
x = 42
print('Hello, World. %d' % x) #you can use ''' for strings for '"' for strings, either works
# above line is legacy from python 2 and is deprecated
print('Hello, world. {}'.format(x))
# format is a function of the string object
print(f'Hello, world... | true |
9fbd24524c7fbeec9a79c7f6a2ecdc1d6992ab08 | Crewcop/pcc-exercises | /chapter_three_final.py | 822 | 4.21875 | 4 | # 3-8
# list of locations
destinations = ['london', 'madrid', 'brisbane', 'sydney', 'melbourne']
print(destinations)
# print the list alphabetically without modifying it
print('\nHere is the sorted list : ')
print(sorted(destinations))
# print the original order
print('\nHere is the original list still :')
print(dest... | true |
8b93a72a07be2865330628e84d8255718bf838d0 | aakash19222/Pis1 | /p.py | 351 | 4.1875 | 4 | def rotate(s, direction, k):
"""
This function takes a string, rotation direction and count
as parameters and returns a string rotated in the defined
direction count times.
"""
k = k%len(s)
if direction == 'right':
r = s[-k:] + s[:len(s)-k]
elif direction == 'left':
r = s[k:] + s[:k]
else:
r = ""
print... | true |
c8c3de51f3c5828ac8ce280924f83c7d8474b3c0 | PrinceCuet77/Python | /Extra topic/lambda_expression.py | 824 | 4.3125 | 4 | # Example : 01
def add(a, b) :
return a + b
add2 = lambda a, b : a + b # 'function_name' = lambda 'parameters' : 'return_type'
print(add(4, 5))
print(add2(4, 5))
# Example : 02
def multiply(a, b) :
return a * b
multiply2 = lambda a, b : a * b
print(multiply(4, 5))
print(multiply2(4,... | true |
bd802c4bae44b75a820c70349a5eab4221bac821 | PrinceCuet77/Python | /Tuple/tuple.py | 1,323 | 4.3125 | 4 | example = ('one', 'two', 'three', 'one')
# Support below functions
print(example.count('one'))
print(example.index('one'))
print(len(example))
print(example[:2])
# Function returning tuple
def func(int1, int2) :
add = int1 + int2
mul = int1 * int2
return add, mul
print(func(2, 3)) ... | true |
553c0af65afd7d80a9ebfca8a1bc80f1ab660726 | PrinceCuet77/Python | /List/list_comprehension.py | 1,520 | 4.28125 | 4 | # List comprehension
# With the help of list comprehension, we can create a list in one line
# Make a list of square from 1 to 10
sq = [i**2 for i in range(1, 11)]
print(sq)
# Create a list of negative number from 1 to 10
neg = [-i for i in range(1, 11)]
print(neg)
# Make a list where store the first character fro... | true |
712f46fc65f3c6d3c8ca8154748f9a942c6781f2 | cnaseeb/Pythonify | /queue.py | 815 | 4.125 | 4 | #!/usr/bin/python
class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items ==[] #further conditions implementation needed
def enqueue(self, item):
return self.items.insert(0, item) #further checks needed if queue already contains i... | true |
2d7308d13f713b7c98492c3a8aa0a95a2aad0903 | charliepoker/pythonJourney | /simple_calculator.py | 876 | 4.25 | 4 |
def add(x,y):
return x + y
def Subraction(x,y):
return x - y
def Multiplication(x,y):
return x * y
def Division(x,y):
return x / y
operation = input('''
Please type in the math operation you would like to complete:
+ for addition
- for subtraction
* for multiplication
/ for division
''')
num_1 = ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.