blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3f9247d1c7d9538a20aa26e1dae4736284fc6b4c | mgoldstein32/python-the-hard-way-jupyer-notebooks | /ex15.py | 483 | 4.375 | 4 | #importing arguments
#assigning variables to said arguments
print "Type the filename:"
#assigning a variable called "txt" as the file being opened
txt = raw_input("> ")
#printing out the file
print "Here's your file %r" %txt
filename = open(txt)
print filename.read()
#doing it again with a different variable... | true |
9407a8304b4a4236ddc45934aea4b91bbe7da0d4 | cloudmesh-community/sp19-222-89 | /project-code/scripts/read_data.py | 1,003 | 4.21875 | 4 | #this function is meant to read in the data from the .csv file and return
#a list containing all the data. It also filters out any rows in the
#data which include NaN as either a feature or a label
"""Important note: when the data is read using the csv.DictReader,
the order of the features is changed from the original... | true |
78ee951a2cd1745691f28bc36e674c358792a8b2 | jurentie/python_crash_course | /chapter_3/3.8_seeing_the_world.py | 420 | 4.40625 | 4 | places_to_visit = ["Seattle", "Paris", "Africa", "San Francisco", "Peru"]
print(places_to_visit)
# Print in alphabetical order
print(sorted(places_to_visit))
# Show that list hasn't actually been modified
print(places_to_visit)
# Print list in reverse actually changing the list
places_to_visit.reverse()
print(place... | true |
3a69957eac67a12c16cf6e5bb2c28eb7dc87a950 | HaoMood/algorithm-data-structures | /algds/ds/deque.py | 1,541 | 4.28125 | 4 | """Implementation of a deque.
Queue is an ordered collection of items. It has two ends, a front and a rear.
New items can be added at either the front or the rear. Likewise, existing items
can be removed from either end. It provides all the capabilities of stacks and
queues in a single data structure.
"""
from __futu... | true |
bca0941d748df7a79930774c1e57287ddbfdc8e9 | sylwiam/ctci-python | /Chapter_4_Trees_Graphs/4.2-Minimal-Tree.py | 883 | 4.125 | 4 | """
Given a sorted (increasing order) array with unique integer elements, write
an algorithm to create a binary search tree with minimal height.
"""
from binary_tree import BinaryTree
# @param li a list of sorted integers in ascending order
# @param start starting index of list
# @param end ending index of list
def c... | true |
6767de31ed8eea4e1c0489ed5a1a7ad3b0f9bca7 | sylwiam/ctci-python | /Chapter_2_Linked_Lists/2.7_Intersection.py | 2,760 | 4.15625 | 4 | """
2.7 Intersection: Given two (singly) linked lists, determine if the two lists intersect. Return the inresecting node.
Note that the intersection is defined based on reference, not value.
That is, if the kth node of the first linked list is the exact same node (by reference) as the jth node of the
second list, the... | true |
76375c4530dc177c5587eeace5e53a23df692f1e | ghj3/lpie | /untitled14.py | 691 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 17 22:13:36 2018
@author: k3sekido
"""
def isWordGuessed(secretWord, lettersGuessed):
'''
secretWord: string, the word the user is guessing
lettersGuessed: list, what letters have been guessed so far
returns: boolean, True if all th... | true |
dbf9328fd348044e9dda97a75e7a0ca4312ef1e4 | augustoscher/python-excercises | /hacking/picking-numbers.py | 619 | 4.25 | 4 | #
# Given an array of integers, find and print the maximum number of integers you can select
# from the array such that the absolute difference between any two of the chosen integers is less than or equal to 1
#
# Ex:
# a = [1,1,2,2,4,4,5,5,5] -> r1 = [1,1,2,2] and r2 = [4, 4, 5, 5, 5]
# result would be 5 (length of s... | true |
b79bcd4bc7ae9fc8fc1c6d38e0ddc20a55e33ff6 | piwan/PyTemperature | /temperature.py | 2,082 | 4.1875 | 4 | class Temperature:
"""Temperature conversion and presentation class"""
def __init__(self, celsius=0):
"""
Construct new Temperature
:param celsius: temperature value in Celsius
"""
self.celsius = celsius
@property
def celsius(self):
"""Temperature value ... | false |
ac73357099eec0d42992610677661f1ee21cea38 | pokemonball34/PyGame | /quiz.py | 1,378 | 4.59375 | 5 | # A Function that asks for the initial temperature type and converts it from Celsius to Fahrenheit or vice versa
def temperature_type_def(temperature_type):
# Conditional to check if user typed in C or c to convert from C -> F
if temperature_type == 'C' or temperature_type == 'c':
# Asks the user for t... | true |
9b5504ebd01228f23fbb55d87c0c29eb942ab25b | bwayvs/bwayvs.github.io | /Ch5_milestone.py | 2,589 | 4.15625 | 4 | print()
print("You wake up to find yourself trapped in a deep hole. How will you get out?")
print()
look = input("Type LOOK UP or LOOK DOWN for more details: ")
print()
if look.upper() == "LOOK UP":
print()
print("You see a pull string attached to the ceiling.")
pull_string = input("Maybe you shoul... | true |
3fa2cc87a45bc022d7f44fcf173dcc8b028d950e | FarnazO/Simplified-Black-Jack-Game | /python_code/main_package/chips.py | 900 | 4.1875 | 4 | '''
This module contains the Chips class
'''
class Chips():
'''
This class sets the chips with an initial chip of 100 for each chip object
It contains the following properties:
- "total" wich is the total number of chips, initially it is set to 100
It also contains the following methods:
... | true |
efd5e6e4fdaa571aea4b16c99e84e6fc3046a544 | N-SreeLatha/operations-on-matrices | /append.py | 371 | 4.375 | 4 | #appending elements into an array
import numpy as np
a=np.array(input("enter the elements for the first array:"))
b=np.array(input("enter the elements for the second array:"))
print("the first array is:",a)
print ("the second array is:",b)
l=len(b)
for i in range(0,l):
a=np.append(a,b[i])
print("the new array formed b... | true |
cc1ca54cd720e9403f2bdf20ccde569838a37ffb | siddharth952/DS-Algo-Prep | /Pep/LinkedList/basic.py | 856 | 4.34375 | 4 |
# single unit in a linked list
class Element(object):
def __init__(self,value):
self.value = value
self.next = None
class LinkedList(object):
def __init__(self, head=None):
# If we establish a new LinkedList without a head, it will default to None
self.head = head
def app... | true |
89a86ec738390178a218821719f3959213d0f1ad | R-Tomas-Gonzalez/python-basics | /list_intro_actions_methods.py | 2,863 | 4.53125 | 5 | #lists are pretty much arrays with some differences
#collections of items
#lists are Data Structures
li = [1,2,3,4,5]
li2 = ['a', 'b', 'c']
li3 = [1,2,'a',True]
# Data Structures - A way for us to organize info and data
#Shopping Cart Example
shopping_cart = [
'notebooks',
'sunglasses',
'toys',
'grapes'... | true |
3884eb54e7e03a3ef48250ac38e73501f51b3ad0 | bommankondapraveenkumar/PYWORK | /code47.py | 1,282 | 4.125 | 4 | def horoscope():
M=input("enter the month and date :\n")
S=M.split()
month=S[0]
day=int(S[1])
print("YOUR ZODIAC SIGN IS:")
if(month=="december"):
if(day>21):
print("Capricorn")
else:
print("sagittarius")
elif(month=="january"):
if(day>19):
print("aquarius")
else:
print("capric... | false |
a71b77d255c9db65dc6e6bd7dffb6683494eb31d | bommankondapraveenkumar/PYWORK | /code45.py | 510 | 4.21875 | 4 | def squarecolor():
letter=input("enter the letter")
number=int(input("enter the number"))
evencolum=['b','f','d','h']
oddcolum=['a','c','e','g']
evenrow=[2,4,6,8]
oddrow=[1,3,5,7]
if(letter in evencolum and number in evenrow or letter in oddcolum and number in oddrow):
print("square is black")
... | true |
b6be82f0a96114542689840b501cae39305b284f | bommankondapraveenkumar/PYWORK | /code38.py | 445 | 4.34375 | 4 | def monthname():
E=input("enter the month name:\n")
if(E=="january" or E=="march" or E=="may" or E=="july" or E=="august" or E=="october" or E=="December"):
print(f"31 days in {E} month")
elif(E=="february"):
print("if leap year 29 otherwise 28")
elif(E=="april" or E=="june" or E=="september" or E=="nove... | true |
bbe61dbdac5acdbd4baa422c303664481b308763 | mdeora/codeeval | /sum_of_digits.py | 422 | 4.15625 | 4 | """
Given a positive integer, find the sum of its constituent digits.
Input sample:
The first argument will be a text file containing positive integers, one per line. e.g.
23
496
Output sample:
Print to stdout, the sum of the numbers that make up the integer, one per line.
e.g.
5
19
"""
import sys
with open(sys... | true |
a7bcd098bef75d2226097d4d11f0a6ce957fd43c | sidduGIT/linked_list | /single_linked_list1.py | 734 | 4.1875 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def printlist(self):
temp=self.head
while(temp):
print(temp.data)
temp=temp.next
first=LinkedList()
first.head=... | true |
7f9c06979dd778bf0313bffacd4b954fe55498aa | sidduGIT/linked_list | /linked_list_all_operations.py | 1,336 | 4.125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def insert_at_end(self,data):
new_node=Node(data)
if self.head==None:
self.head=new_node
return
cur=self.hea... | true |
06966d4ff9727c6eb910497e92654ad6eec68810 | sidduGIT/linked_list | /doubly_linkedlist_delete_at_first.py | 1,619 | 4.25 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
self.prev=None
class Doubly_linkedlist:
def __init__(self):
self.head=None
def insert_at_end(self,data):
if self.head==None:
new_node=Node(data)
self.head=new_node
... | true |
1e1b603ef227a61948ea220bbb0bf261f73ad3b9 | DarkEyestheBaker/python | /ProgramFlow/guessinggame.py | 1,290 | 4.15625 | 4 | answer = 5
print("Please guess a number between 1 and 10: ")
guess = int(input())
if guess == answer:
print("You got it on the first try!")
else:
if guess < answer:
print("Please guess higher.")
else: # guess must be greater than answer
print("Please guess lower.")
guess = int(input(... | true |
d08f70e1711874ed57fbdc089835155e4d98bd57 | beechundmoan/python | /caesar_8.py | 1,359 | 4.3125 | 4 | """
All of our previous examples have a hard-coded offset -
which is fine, but not very flexible. What if we wanted to
be able to encode a bunch of different strings with different
offsets?
Functions have a great feature for exactly this purpose, called
"Arguments."
Arguments are specific parameters that w... | true |
fbcd09f15d85456e86ac136af36b7797f730ca94 | bhushankorpe/Fizz_Buzz_Fibonacci | /Fizz_Buzz_Fibonacci.py | 1,727 | 4.3125 | 4 | #In the programming language of your choice, write a program generating the first n Fibonacci numbers F(n), printing
#"Buzz" when F(n) is divisible by 3.
#"Fizz" when F(n) is divisible by 5.
#"FizzBuzz" when F(n) is divisible by 15.
#"BuzzFizz" when F(n) is prime.
#the value F(n) otherwise.
#We encourage you to... | true |
fd0c0d40b181c03d4a0e3d1adcbe37ee69e31bbf | Polinq/InfopulsePolina | /HW_3_Task_6.2.py | 382 | 4.3125 | 4 | def is_a_triangle(a, b, c):
''' Shows if the triangle exsists or not. If it exsisrs, it will show "yes" and if it does not exsit it will show "no". (num, num, num) -> yes or (num, num, num) -> no.'''
if (a + c < b or a + b < c or b + c < a):
print('NO')
else:
print('YES')
# пример использов... | true |
5a4f54078e1a341c9107f9efec5726b869a0fc27 | Polinq/InfopulsePolina | /HW_3_Task_6.1.py | 313 | 4.40625 | 4 | def is_year_leap(a):
'''The function works with one argument (num) and shows if the year is leap. If the year is leap it shows "True", if the year is not leap it shows "False"'''
if ((a % 4 == 0 and a % 100 != 0) or (a % 400 == 0)):
print('True')
else:
print('False')
is_year_leap(4)
| true |
df1af2c50ba4f110e76c4609518c6e9e166a1fe4 | kavyan92/code-challenges | /rev-string/revstring.py | 610 | 4.15625 | 4 | """Reverse a string.
For example::
>>> rev_string("")
''
>>> rev_string("a")
'a'
>>> rev_string("porcupine")
'enipucrop'
"""
def rev_string(astring):
"""Return reverse of string.
You may NOT use the reversed() function!
"""
# new_string = []
# for char in range((len(... | true |
c2b7982dc8b822a17f9d60634888c0b3ae151884 | alvas-education-foundation/spoorti_daroji | /coding_solutions/StringKeyRemove.py | 377 | 4.28125 | 4 | '''
Example
If the original string is "Welcome to AIET" and the user inputs string to remove "co" then the it should print "Welme to AIET" as output .
Input
First line read a string
Second line read key character to be removed.
Output
String which doesn't contain key character
'''
s = input('Enter The Main String: ')
... | true |
0607f73a1d10f718b4dea2d28c7a6a64b73233af | SpiffiKay/CS344-OS-py | /mypython.py | 1,078 | 4.15625 | 4 | ###########################################################################
#Title: Program Py
#Name: Tiffani Auer
#Due: Feb 28, 2019
#note: written to be run on Python3 :)
###########################################################################
import random
import string
#generate random string
#adapted from tuto... | true |
bb797f115f513f5210013037f1cda1a86aefe6df | Phazon85/codewars | /odd_sorting.py | 673 | 4.1875 | 4 | '''
codewars.com practice problem
You have an array of numbers.
Your task is to sort ascending odd numbers but even numbers must be on their places.
Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.
'''
def sort_array(source_array):
temp = sorted([i for i in... | true |
91092e769d5b1258414d8cac0b3009a9f59b4ef3 | jk555/Python | /if.py | 1,503 | 4.25 | 4 | number = 5
if number == 5:
print("Number is defined and truthy")
text = "Python"
if text:
print("text is defined and truthy")
#Boolean and None
#python_course = True
#if python_course:
# print("This will execute")
#aliens_found = None
#if aliens_found:
# print("This will not execute"... | true |
137af1c6366d00b78500c8b111ad5e6b3bc6121e | rameshroy83/Learning | /Lab014.py | 227 | 4.15625 | 4 | #!/usr/bin/python2
'''
In this code we will talk about escape sequecnce \n is for a new line, \t for a tab.
\'' to print quote \\ to print backslash.
'''
a = input("Enter the string")
print("You entered the string as \n",a)
| true |
bffbe1b30baf3a918462905e96e3a853b96388a6 | for-wd/django-action-framework | /corelib/tools/group_array.py | 449 | 4.21875 | 4 | def groupArray(array, num):
"""
To group an array by `num`.
:array An iterable object.
:num How many items a sub-group may contained.
Returns an generator to generate a list contains `num` of items for each iterable calls.
"""
tmp = []
count = 0
for i in array:
count +=... | true |
0927f0c0882096fec39a956385abe8509ccabb38 | nashj/Algorithms | /Sorting/mergesort.py | 1,197 | 4.25 | 4 | #!/usr/bin/env python
from sorting_tests import test
def merge(left_list, right_list):
# left_list and right_list must be sorted
sorted_list = []
while (len(left_list) > 0) or (len(right_list) > 0):
if (len(left_list) > 0) and (len(right_list) > 0):
if left_list[0] < right_list[0]:
... | true |
428ae6aee6bf3d0a604320a2cabe06cb0757bf42 | nashj/Algorithms | /Sorting/quicksort.py | 588 | 4.1875 | 4 | #!/usr/bin/env python
from sorting_tests import test
def quicksort(list):
# Lists of length 1 or 0 are trivially sorted
if len(list) <= 1:
return list
# Break the list into two smaller lists by comparing each value with the first element in the list, called the pivot.
pivot = list[0]
lte... | true |
0109651e4e3977981ff67b5d226589f2763225d6 | TimDN/education-python | /functions/function.py | 1,033 | 4.15625 | 4 | def say_hello(name):
print("Hello {}!".format(name))
def combine_name(fname, sname, mname = ""):
return "{} {} {}".format(fname, mname, sname)
def read_number():
number = input("Give number: ")
if is_special_operator(number):
handle_special_operator(number)
else:
return ... | false |
b04548acb91ff5e1a6d32b547ed68480db462f7c | TimDN/education-python | /class/basic.py | 491 | 4.34375 | 4 | class Person: # create a class with name person
first_name = "Foo" # class variable
foo = Person() # Create a Person object and assign it to the foo variable
bar = Person() # Create a Person object and assign it to the bar variable
print(foo.first_name) #prints Foo
print(bar.first_name) #prints Foo
bar.firs... | true |
7b824c269e031a2b621ee9c69f571970ccfc5ec9 | usmannA/practice-code | /Odd or Even.py | 508 | 4.3125 | 4 | '''Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2?
Extras:
If the number is a multiple of 4, print out a different message.'''
entered_number= int(input("Please enter any... | true |
5def7924086f2dcfd0121f7a6979fb5cbbf47e6d | standrewscollege2018/2021-year-11-classwork-padams73 | /zoo.py | 273 | 4.25 | 4 | # Zoo program
# Start by setting a constant
# This is the age limit for a child
CHILD_AGE = 13
# Get the age of the user
age = int(input("What is your age?"))
# Check if they are a child
if age < CHILD_AGE:
print("You pay the child price")
print("Welcome to the zoo") | true |
2681d86a929e491d1bc7774d9ce8f346ab5c8161 | standrewscollege2018/2021-year-11-classwork-padams73 | /madlib.py | 333 | 4.25 | 4 | # This program is a Madlib, getting the user to enter details
# then it prints out a story
print("Welcome to my Madlib program!")
# Get their details
body_part = input("Enter a body part:")
name = input("Enter a name:")
# Print the story
print("Hello {}, you have the strangest looking {} I have ever seen".format(name... | true |
aafa7894fa867811e663cf65282ece2445fe700e | standrewscollege2018/2021-year-11-classwork-padams73 | /for_user_input.py | 316 | 4.1875 | 4 | # In this program the user enters a starting
# value, stopping value, and step
# The program then counts up
# Get inputs from user
start_num = int(input("Start?"))
stop_num = int(input("Stop?"))
step = int(input("Change each time?"))
# Print the numbers
for num in range(start_num, stop_num+1, step):
print(num) | true |
5fd1994db19c724283342c9c6a08671949bdc0db | VictorB1996/GAD-Python | /GAD-05/oop.py | 2,542 | 4.40625 | 4 | from abc import abstractmethod
class Animal:
number_of_legs = 4
def __init__(self, name, breed=None):
self._name = name
self.breed = breed
# def set_name(self, name):
# self._name = name
#
# def get_name(self):
# return self._name
@property
def name(self)... | false |
c1c77ddd5cb6b430281603fcb29680c0181898be | VictorB1996/GAD-Python | /GAD-02/Homework.py | 432 | 4.28125 | 4 | initial_list = [7, 8, 9, 2, 3, 1, 4, 10, 5, 6]
ascending_list = sorted(initial_list)
print("Ascending order: ")
print(ascending_list)
descending_list = sorted(initial_list, reverse = True)
print("\nDescending order: ")
print(descending_list)
print("\nEven numbers using slice: ")
print(ascending_list[1::2])
print("\... | true |
f9411bce9690b08a947a99ef66cd0423949a7ec4 | lukew2251/Scripting | /Mod01Tutorial.py | 1,309 | 4.375 | 4 | 'Luke Willis'
'Tutorial #1'
print('Task 1')
print('Hello World')
input()
print('Task 2')
user_guess = input('Please enter an integer: ')
print (user_guess)
input()
print('Task 3')
user_guess = int(user_guess)
converted_user_guess = int(user_guess)
print(user_guess * 3)
print(converted_user_guess * 3)
... | false |
d8cf3b2cb04b117c5ed1478384723b1df83290e8 | Jangchezo/python-code-FREE-SIMPLE- | /readReverse.py | 736 | 4.125 | 4 | # readReverse.py
#test code
"""
reverseRead(file)
->print from the end of the file
"""
file = open('c:/Users/JHLee/Desktop/test.txt', 'r')
lines = file.readlines()
for i in range(0, len(lines)):
print(lines[len(lines)-i-1][0:-1])
# Real code 1
file = open('c:/Users/JHLee/Desktop/test.txt', ... | true |
3b00e1478f40be5570bea24005279ba4f673c38e | grohj17/comp110-21ss1-workspace | /exercises/ex02/vaccine_calc.py | 1,290 | 4.15625 | 4 | """A vaccination calculator."""
__author__ = "730201179"
from datetime import datetime, timedelta
population: str = input("How large is the population? ")
doses_given: str = input("How many doses of the vaccine have already been administered? ")
doses_per_day: str = input("How mainy doses are being given daily? ")
t... | false |
7f48cdb6cbd455fcf38fbb1a0c4f6819e3f6b8a0 | Elvolox/ExerciciosPythonCurso | /Desafio28.py | 361 | 4.125 | 4 | import random
numero = int(input('Digite um numero de 0 a 5: '))
numeroc = random.randint(0,5)
if numero == numeroc:
print('Voce acertou o número que a maquina pensou, sou número foi {} e o da maquina foi {}'.format(numero, numeroc))
else:
print('Que pena , você errou, seu número {} não é igual da m... | false |
4b4f24d14742b12f8c806f7c911976105bdd6d35 | lukeblanco/python_b | /luke/desafio1.py | 314 | 4.21875 | 4 | ##Diseñar un programa en el cual el usuario ingrese tres números, uno a la vez, y se muestre a la salida el promedio de los tres números.
num = int( input("Ingrese Primer Numero: ") )
num = num+int( input("Ingrese Segundo Numero: ") )
num = num+int( input("Ingrese Tercero Numero: ") )
num = num/3
print(num)
| false |
727a3fadc945279790ace65b0810de18791f0c2a | jeancarlov/python | /decisionB.py | 2,913 | 4.46875 | 4 | # ----- Design Tool - PseudoCode ---------
# Create main function and inside the main function enter the variables codes for input and output
# Display Menu options and request user to make a selection
# Enter variables with input request to the use
# print user input result
# Create if statements to check if variable ... | true |
cb56d6e59567c3713f2b9fff7efea89ed5d29c77 | atbohara/basic-ds-algo | /linkedlist/rearrange_pairs.py | 1,420 | 4.25 | 4 | """Rearrange node-pairs in a given linked list.
Demonstration of 'runner' technique.
"""
from linked_list import Node
from linked_list import LinkedList
def rearrange_pairs(orig_list):
"""Modifies the input list in-place.
O(N).
"""
slow_ptr = orig_list.head
fast_ptr = orig_list.head
while fas... | true |
b106c568098b8d4db825de07a3f6d869f4a0fc0e | abokumah/Lab_Python_02 | /solutions/extra_credit_solutions/Lab03_2.py | 828 | 4.71875 | 5 | """
Lab_Python_02
Extra Credit
Solutions for Extra Credit Question 1
"""
# getting input from the user
unencrypted = int(raw_input("Enter a number to encrypt: "))
encrypted = 0
encrypted_old = 0
while unencrypted > 0:
# multiplying both the encrypted numbers by 10
encrypted *= 10
encrypted_old *= 10
#gettin... | true |
1e3b15e3576fa57b0af51d37cf91cbf158d0a4a2 | cnluzon/advent2016 | /scripts/03_triangles.py | 2,969 | 4.15625 | 4 | import argparse
"""
--- Day 3: Squares With Three Sides ---
Now that you can think clearly, you move deeper into the labyrinth of hallways
and office furniture that makes up this part of Easter Bunny HQ. This must be a
graphic design department; the walls are covered in specifications for
triangles.
Or are they?
The... | true |
147db49069181bfd366e2975da98f704e3a7ca89 | Jetroid/l2c | /solutions/l2s_solution14.py | 674 | 4.4375 | 4 | #Write a program that will print out the contents of a multiplication table from 1x1 to 12x12.
# ie. The multiplication table from 1x1 to 3x3 is as follows:
# 1 2 3
# 2 4 6
# 3 6 9
#Hint: You'll probably want to use two for loops for each number.
#Reminder: To print something without putting a newline on the end, you... | true |
a2dcded762980962a583a58af292352dcb1185b9 | Jetroid/l2c | /solutions/l2c_solution11.py | 650 | 4.4375 | 4 | #Finish the if/elif/else statement below to evaluate if myInt is divisible by 4, else evaluate if it is divisible by 3.
#Try out myInt for several different values!
#Reminder: We can use the modulo operator to get the remainder. eg: 7 % 3 is equal to 1. (because 2*3 + 1 is equal to 7)
#Hint: If a modulo result i... | true |
77166e51f2facbc44dd6e1763ea5111f45276e69 | Vampirskiy/helloworld | /venv/Scripts/Урок1/if_simple.py | 310 | 4.125 | 4 | age=int(input('Введите свой возраст'))
#Если возраст меньше 18 лет
#Вывести на экран "Доступ запрещен"
if age<18:
print('Пошел на хуй!')
elif age==18:
print('Вам точно 18?')
else:
print('Доступ открыт') | false |
3383c4a85f5db4d89293ff8e43183a4e3832be83 | wa57/info108 | /Chapter8/Chapter8Ex1.py | 1,069 | 4.25 | 4 | """a) _____ Assume “choice” is a variable that references a string.
The following if statement determines whether choice is equal to ‘Y’ or ‘y’.:
if choice == ‘Y’ or choice == ‘y’:
Rewrite this statement so it only makes one comparison and does not use the or operator.
b) _____ Write a loop that counts the number of ... | true |
98bdd82a126a576d54c51b03d9201ee1ffa22b46 | wa57/info108 | /Chapter7/AshmanLab4Problem1.py | 2,300 | 4.15625 | 4 | #Project Name: Lab 4 Homework
#Date: 4/28/16
#Programmer Name: Will Ashman
#Project Description: Lab 4 Homework
#Resource used for table formatting: http://knowledgestockpile.blogspot.com/2011/01/string-formatting-in-python_09.html
#WA - Import the math module to perform calculations
import math
def main():
#WA -... | true |
cc2e5541bc5a57ca67de5109dae3f5cc976d560d | wa57/info108 | /Lab2/TestFunctions.py | 843 | 4.21875 | 4 | #WA - Gathers a positive, negative, and inclusive number between 48-122
#WA - As well as a string from the user
posInteger = float(input('Positive integer: '))
negInteger = float(input('Negative integer: '))
myChar = int(input('Integer between 48 and 122 inclusive: '))
myString = input('String: ')
#WA - outputs absolu... | true |
730667d8c9bfd1f0883a35d85468609387b33ca7 | chenhuang/leetcode | /maxSubArray.py | 1,575 | 4.1875 | 4 | #! /usr/bin/env python
'''
Maximum Subarray
Given an array of integers, find a contiguous subarray which has the largest sum.
Note
The subarray should contain at least one number
Example
For example, given the array [−2,2,−3,4,−1,2,1,−5,3], the contiguous subarray [4,−1,2,1] has the largest sum = 6.
Maximum Subarra... | true |
9ca5bf3b0e75a993f519289bbc5b50ca7e8f5b68 | chenhuang/leetcode | /insert.py | 2,143 | 4.15625 | 4 | #! /usr/bin/env python
'''
Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start times.
Example 1:
Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]... | true |
896c390f0835370f76156d3c3de4e2997a7d7522 | sauravrana1983/Python | /Challenge/Introductory/7_Print.py | 261 | 4.1875 | 4 | # Read an integer .
# Without using any string methods, try to print the following:
# Note that "" represents the values in between.
# Input Format
# The first line contains an integer .
def printAll(value):
print(*range(1,value + 1), sep='')
printAll(10) | true |
372d7c1cfb442b51ee13d70fe0a7f56bcde4184e | King-Of-Game/Python | /Example/list/翻转列表.py | 695 | 4.1875 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# __author__ : YiXuan
# __date__ : 12/31/2020 2:50 PM
# __software__ : PyCharm
'''
翻转列表
方法一:使用内置函数 reversed()
方法二:使用列表的内置方法 list.sort()
方法二:使用列表的第三个参数
'''
def reversed_list1():
list1 = [1,2,3]
new_list = [i for i in reversed(list1)]
print(new_list)
def... | false |
db0c042f6507dc4c8bacf40b15fdf12d0dfff57c | King-Of-Game/Python | /Algorithm/插入排序.py | 1,159 | 4.21875 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# __author__ : YiXuan
# __date__ : 1/23/2021 8:23 PM
# __software__ : PyCharm
'''
插入排序(英语:Insertion Sort)是一种简单直观的排序算法。
它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入。
'''
# 从小到大排列
def insertionSort(lst):
for i in range(1, len(lst)):
key = lst[i]
... | false |
a795f444b9265560800773b2cbd980ba6eb989e6 | Abinash-giri/mypractise | /AgeCalculator.py | 761 | 4.21875 | 4 | #Program to calculate age of a person
import datetime
def calculateAge(dob):
'''Calulate's a person age'''
today = datetime.date.today()
age = today.year - dob.year
return age
def checkDate(dob):
'''Checks if date is valid or not'''
day,month,year = dob.split('/')
isvaliddate = True
... | true |
f57eebb51e5cf1fa20b4b2fbdecf21ecc555e5dc | HoangQuy266/nguyenhoangquy-fundamental-c4t4 | /Session04/sheep.py | 580 | 4.21875 | 4 | print ("Hello, my name is Hiepand these are my sheep size: ")
sheep = [5, 7, 300, 90, 24, 50 ,75]
print (sheep)
for i in range (3):
print("MONTH", i+1)
print ("Now one month has passed and this is my flock: ")
new_sheep = [x+50 for x in sheep]
print (new_sheep)
max_sheep = max(new_sh... | true |
9839709ad5c1b281e13e9cd0cbe3e3eeb736513d | ashutoshkmrsingh/Library-Management-System-Console-based- | /faculty.py | 1,334 | 4.375 | 4 | """
faculty module contains FacultyClass and faculty_list data structure.
FacultyClass used to create faculty objects.
And, faculty_list is a list data structure which stores the faculty objects,
and used for modifying faculty data and storing it in a pickle file named as "faculty_data.pkl"
"""... | true |
c2af48a092afd6f5ea2e2080b38ebc4eb099045f | symonk/python-solid-data-structures-and-algorithms | /algorithms/searching/binary_search.py | 884 | 4.25 | 4 | import random
import typing
def binary_search(arr: typing.List[int], target: int) -> int:
"""
Performs a binary search through arr. Divide and conquer the list to achieve
o(log n) performance. Pre requisites are that `arr` must be already sorted.
:param arr: The (sorted) sequence of integers.
:p... | true |
a8ad59d9cdb2baf7d7b33188f42bdf3af7a7d0ed | GeorgeDiNicola/blackjack-game | /application/utils.py | 790 | 4.25 | 4 | from os import system, name
def get_valid_input(prompt, possible_input, error_message):
"""Retrieve valid input from the user. Repeat the prompt if the user gives invalid input.
Keyword Arguments:
prompt (string) -- the question/input prompt for the user.
possible_input (list) -- the allowable input for the pro... | true |
91f35e9fcb6f5aaaf03d1e34353a33c405c0e581 | skurtis/Python_Pandas | /Question3.py | 1,578 | 4.125 | 4 | #!/usr/bin/env python3
datafile = open("CO-OPS__8729108__wl.csv") # open the CSV file as the variable "datafile"
diffmax = 0 # starts the max difference between final and initial mean as 0
for i in datafile:
if i.startswith('Date'): # skips the first line (header) but makes sure the previous line is designated as "p... | true |
6f9357e25c29399021993de2c12c3edb1581c6da | Sablier/Sorts | /Structure/Dequeue.py | 924 | 4.1875 | 4 | class Dequeue(object):
"""构造一个双端队列"""
def __init__(self):
self.data = []
def add_front(self, content):
"""添加一个元素到头部"""
self.data.insert(0, content)
def add_rear(self, content):
"""添加一个元素到队尾"""
self.data.append(content)
def remove_front(self):
"""从队... | false |
1364cf38e545880dc0694b9400f227e9bef16438 | PIfagor/ApplicationProgramming-15 | /SecondLabor/Point.py | 1,376 | 4.21875 | 4 | __author__ = 'Wise'
from math import sqrt
class Point:
def __init__(self, x, y):
self._x = x
self._y = y
return
def equals(self, another_point):
return self._x == another_point._x and self._y == another_point._y
def distanse(self, another_point):
assert isinstance... | false |
e48c040f638eda0e83d01e812c34386af253b29b | cspyb/Graph-Algorithms | /BFS - Breadth First Search (Iterative).py | 897 | 4.21875 | 4 | """
BFS Algorithm - Iterative
"""
#graph to be explored, implemented using dictionary
g = {'A':['B','C','E'], 'B':['D','E'], 'E':['A','B','D'], 'D':['B','E'], 'C':['A','F','G'], 'F':['C'], 'G':['C']}
#function that visits all nodes of a graph using BFS (Iterative) approach
def BFS(graph,start):
queue =... | true |
eb415e333c7e0db6ef2e5542b7daaf6b07813c1c | ElliotFriend/bin | /fibonacci.py | 436 | 4.15625 | 4 | #!/usr/bin/env python3
import sys
# Start the sequence. It always starts with [0, 1]
f_seq = [ 0, 1 ]
# Until the length of our list reaches the limit that
# the user has specified, continue to add to the sequence
while len(f_seq) <= int(sys.argv[1]):
# Add the last two numbers in the list, and stick
# that ... | true |
040c39b646a03fb71fbae182b336d1367ffe8d8c | agermain/Leetcode | /solutions/1287-distance-between-bus-stops/distance-between-bus-stops.py | 1,298 | 4.125 | 4 | # A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n.
#
# The bus goes along both directions i.e. clockwise and counterclockwise.
#
# Return the shortest distance betwee... | true |
486023ab94e7e490a5ca39bfa2224c26c469f617 | beth2005-cmis/beth2005-cmis-cs2 | /cs2quiz3.py | 1,645 | 4.75 | 5 | # 1) What is a recursive function?
# A function calls itself, meaning it will repeat itself when a certain line or a code is called.
# 2) What happens if there is no base case defined in a recursive function?
#It will recurse infinitely and maybe you will get an error that says your maximum recursion is reached.
# 3)... | true |
31f900dde317cc4b7d78cbedca4c6beb09aa5229 | swheatley/LPTHW | /ex5.2.py | 763 | 4.34375 | 4 | print "LPTHW Lesson 5.2 \n \t Python format characters"
print '% :', "This character marks the start of the specifier"
print 'd :', "Integer/decimal"
print 'i :', "Integer/decimal"
print 'o :', "Octal value"
print 'u :', "Obsolete type- identical to 'd' "
print 'x :', "Hexadecimal(uppercase)"
print 'e :', "Floating ... | true |
c4259a587814ff544af950d1383199fc40daf12e | swheatley/LPTHW | /ex40.1.py | 888 | 4.15625 | 4 | # Exercise 40: Modules, Classes, and Objects
mystuff ={'apple', "I AM APPLES!"}
print mystuff['apple']
#this goes in mystuff.py
def apple():
print "I AM APPLES!"
import mystuff
mystuff.apple()
def apple():
print "I AM APPLES!"
# this is just a variable
tangerine = "Living reflection of a dream"
import mystuff
... | false |
5d93d04b10b4b45fa27233a37798dd6948feebd5 | chengbaobao630/practies | /07-19/Student.py | 706 | 4.125 | 4 | from datetime import datetime
class Person(object):
def __init__(self):
print("person init")
self.__birth = datetime.now()
def birth(self):
return self.__birth
class Man(object):
def __init__(self):
print(r"i'm a man")
class Student(Man, Person):
def __init__(se... | false |
2a0a967462c5958e31e20cbe1cfce34be2a05a93 | pjain4161/HW08 | /fun2.py | 1,139 | 4.25 | 4 | # Borrowed from https://realpython.com/learn/python-first-steps/
##############################################################################
#### Modify the variables so that all of the statements evaluate to True. ####
##############################################################################
var1 = -588
var2... | true |
546ee390dfe4711bab61a6648daae43389ec8b4d | irsol/hacker-rank-30-days-of-code | /Day 9: Recursion.py | 446 | 4.3125 | 4 | """
Task
Write a factorial function that takes a positive integer,N as a parameter and prints the result
of N!(N factorial).
Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial,
you will get a score of 0.
Input Format
A single integer,N (the argument to pass to factorial... | true |
e07b328b02a76c8cc243bcf7002b07cf96f8b8fc | infractus/my_code | /RPG Dice Roller/rpg_dice_roller.py | 2,336 | 4.4375 | 4 | #Dice roller
import random
roll = True #this allows to loop to play again
while roll:
def choose_sides(): #this allows player to choose which sided die to roll
print('Hello!')
while True:
sides=(input('How many sides are the dice you would you like to roll?' ))
if sides.isd... | true |
5bd8b16f9adeb479b29a0970406cf62d5e4a7477 | paigeweber13/exercism-progress | /python/clock/clock.py | 1,145 | 4.125 | 4 | """
contains only the clock object
"""
class Clock():
"""
represents a time without a date
"""
def __init__(self, hour, minute):
self.hour = hour
self.minute = minute
self.fix_time()
def __repr__(self):
# return str(self.hour) + ':' + "{:2d}".format(self.minute)
... | true |
1ac9e7c54261c2c15c3856ccba743791d2e3cd41 | amacharla/holbertonschool-higher_level_programming | /0x06-python-classes/6-square.py | 2,343 | 4.3125 | 4 | #!/usr/bin/python3
class Square:
def __init__(self, size=0, position=(0, 0)):
"""
Calls respective setter funciton
Args:
size: must be int and greater than 0
position: must be tuple and args of it must be int
"""
self.size = size
self.position ... | true |
217c17718277bd9eebc936314da74581bf1c5d07 | Kevin-Rush/CodingInterviewPrep | /Python/findMissingNumInSeries.py | 617 | 4.21875 | 4 | '''
1. Find the missing number in the array
You are given an array of positive numbers from 1 to n, such that all numbers from 1 to n are
present except one number x. You have to find x. The input array is not sorted. Look at the below array
and give it a try before checking the solution.
'''
def find_missing(input):... | true |
958e8293912a6df866ea3b8821948db8dc3540e4 | Kevin-Rush/CodingInterviewPrep | /Python/TreeORBST.py | 712 | 4.25 | 4 | '''
6. Determine if a binary tree is a binary search tree
Given a Binary Tree, figure out whether it’s a Binary Search Tree. In a binary search tree, each
node’s key value is smaller than the key value of all nodes in the right subtree, and is greater than
the key values of all nodes in the left subtree. Below is an ... | true |
e1fa4cc48342e31acfbfc03bb7dba9addb12711a | subashreeashok/python_solution | /python_set1/q1_1.py | 1,325 | 4.21875 | 4 | '''
Name : Subahree
Setno: 1
Question_no:1
Description:Finding the largest odd numbers
'''
x=raw_input("enter X: ")
y=raw_input("enter Y: ")
z=raw_input("enter Z: ")
a=int(x)
b=int(y)
c=int(z)
if(a%2!=0 and b%2!=0 and c%2!=0):#all are odd numbers
if(a>b and a>c):
print("a is large")
eli... | false |
5f815d28e7ed7d3a54819698c3446cdfc6b146c8 | subashreeashok/python_solution | /python_set1/q1_3.py | 486 | 4.15625 | 4 | '''
Name : Subahree
Setno: 1
Question_no:3
Description:get 10 numbers and find the largest odd number
'''
try:
print "enter the numbers: "
max=0
#getting 10 numbers
for i in range(0,10):
num=int(raw_input())
#print(num)
#checking odd or not
for j in range(0,10):
if(num%2!=0):... | true |
7042390201ce8b3fc1a3d34d8ef24599dc947445 | realrlgus/Python_Practice | /20200203/DataType/String.py | 2,309 | 4.25 | 4 | # 파이썬에서 문자열 만드는 방법
# 큰 따옴표
double_quotes = "Hello Python"
# 작은따옴표
single_qoutes = 'Hello Python'
# 삼중 큰 따옴표
triple_double_quotes = """Hello Python"""
# 삼중 작은따옴표
triple_single_quotes = '''Hello Python'''
# 삼중 큰, 작은 따옴표를 사용 시 다수의 라인이 포함된 문자열 작성 가능
# 문자열 연산 string = Python is fun!
head = "Python"
tail = " is fun!"
string... | false |
4cbba297236116927584453cab7e9d579b93f3a1 | DeltaEcho192/Python_test | /pos_neg_0_test.py | 267 | 4.1875 | 4 | test1=1;
while test1 != 0:
test1=int(input("Please enter a number or to terminate enter 0 "))
if test1 > 1:
print("This number is positve")
elif test1 < 0:
print("This number is negative")
else:
print("This number is zero")
| true |
59588a208d398b0c0f0621d99e188318d771646f | esther4599/Python01_Starting_Python | /15.클래스와객체지향프로그래밍/02.인스턴스이해.py | 766 | 4.125 | 4 | #클래스와 인스턴스?
print(type(5)) # <class 'int'>
print(isinstance(5, int))
num1 = []
print(type(num1))
num2 = list(range(10))
print(num2)
chr = list('Hello')
print(chr)
print(type(num1), type(num2), type(chr)) # 모두 <class 'list'>
print(isinstance(num1, list)) # True
print(num1 == list) # False
'''
위와 같은 결과? class = 분류... | false |
32d0350eead71df434bd5a6cf065c18d5007ff46 | Kify7/Python_string_data | /manipular_strings.py | 1,588 | 4.3125 | 4 | #CONCATENATIG STRINGS
a = "hello"
b = a + "There"
c = a + ' ' + 'There'
print(b)
print(c)
#USING IN AS A LOGICAL OPERATOR
fruit = 'banana'
print('n' in fruit)
print('t' in fruit)
if 'a' in fruit :
print('Found it!')
#STRING COMPARISON
word = input("enter word: ")
if word == 'banana' :
print('Al right, banan... | false |
9728556ef7629be2b859b6482bcb2ebe2fc690ae | ultra-programmer/Complete_Python3_Bootcamp_Final_Captsone_Projects | /text/pig_latin.py | 558 | 4.125 | 4 | """
Pig Latin!
"""
while True:
try:
STRING = input('Please enter the word to be translated into pig latin: ')
if len(STRING.split()) > 1:
raise RuntimeError
elif len(STRING.split()) < 1:
raise RuntimeError
except RuntimeError:
print('Please enter a word to... | false |
a956e9f48c66200f088ac091faac027169e43040 | Roy-Wells/Python-Code | /算法第四版(python)/第一章 基础/03Queue.py | 1,030 | 4.21875 | 4 | """
P78.队列
class Queue.Queue(maxsize=0)
FIFO即First in First Out,先进先出。Queue提供了一个基本的FIFO容器,使用方法很简单,maxsize是个整数,指明了队列中能存放的数据个数的上限。
一旦达到上限,插入会导致阻塞,直到队列中的数据被消费掉。如果maxsize小于或者等于0,队列大小没有限制。
常用基本方法:
Queue.qsize() 返回队列的大小
Queue.empty() 如果队列为空,返回True,反之False
Queue.full() 如果队... | false |
e744e1dc6f4ee7b3a9917cb05c9a9cfc82de8b09 | SushanthPS/Python | /0primeNumber.py | 287 | 4.15625 | 4 |
def isprime(n):
if n==1:
return False
elif n==2 or n==3:
return True
elif n%2==0:
return False
else:
for i in range(3,n//2,2):
if n%i==0:
return False
return True
print(isprime(13)) | false |
91cb2e4f2e111bee836829551d4da8b8d59366a1 | kinghaoYPGE/career | /python/20190117/Code/c2.py | 1,010 | 4.125 | 4 | """
python常用高阶函数
map, reduce, filter, sorted
"""
# map reduce 是一个算法模型--hadoop(map/reduce:映射,规约),并行计算
# map 映射
list_a = [1, 2, 3, 4, 5]
def my_square(x):
return x**2
r = map(my_square, list_a)
print(list(r))
# reduce
# reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
# 从序列头计算到尾
from functools import reduce
def minus(x, y)... | false |
acb25112304c3b8e372806b92a8294be764da0c8 | kinghaoYPGE/career | /python/20190124/Code/c2.py | 1,267 | 4.125 | 4 | """
collections模块:就是对'组'数据结构的补充
"""
# tuple->namedtuple(命名元组)
from collections import *
point = (1, 2) # 坐标点
Point = namedtuple('Point', ['x', 'y'])
p = Point(1, 2) # 结构化
print('x: %s, y: %s' % (p.x, p.y))
print(isinstance(p, Point))
print(isinstance(p, tuple))
# list(线性存储:查询元素快,插入删除效率低)->deque(双向列表如 队列、栈): 首尾插入删除效率... | false |
97f02f7148f3afc7bd4b190a20d0b87d30a210f2 | fmarculino/CursoEmVideo | /ExMundo2/Ex041.py | 812 | 4.15625 | 4 | """
A confederaçã nacional de natação precisa de um programa que
leia o ano de nascimento de um atleta e mostre sua categoria, de
acordo com a idade:
- Até 9 anos: MIRIM
- Até 14 anos: INVFANTIL
- Até 19 anos: JUNIOR
- Até 24 anos: SENIOR
- Acima: MASTER
"""
from datetime import date
dtnascimento = int(input('Digite o... | false |
37e26a32544446f0780d2a902598e23bf84f578d | fmarculino/CursoEmVideo | /ExMundo2/Ex059.py | 1,239 | 4.4375 | 4 | """
Crie um programa que leia dois valores e mostre um menu como o ao lado
da tele:
Seu programa deveŕa realizar a operação solicitada em cada casoself.
[1] Somar
[2] Multiplicar
[3] Maior
[4] Novos números
[5] Sair do programa
"""
valor1 = float(input('Digite o primeiro valor: '))
valor2 = float(input('Digite o segund... | false |
0c63157083ee466ff665870a7d70c3e0c09c62f6 | 15AshwiniI/PythonPractice | /Calculator.py | 570 | 4.1875 | 4 | #this is how you comment in python
print "Welcome to Calculator!"
print "Enter your first number"
a = input()
print "Enter your second number"
b = input()
print "What calculation whould you like to do?"
print "Addition, Subtraction, Multiplication, Division"
p = raw_input()
if p == "Addition":
print "Answer: "+... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.