blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
092b2594f9159f72119349177487a3c0ffe8ebde | kronecker08/Data-Structures-and-Algorithm----Udacity | /submit/Task4.py | 1,306 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
call_outgoing = []
call_incoming = []
fo... | true |
d3760baba77aa112d2860cbeed1ef56f378347be | iamrobinhood12345/economic-models | /base-model.py | 2,642 | 4.21875 | 4 | # Basic Flow of Money Model
import sys
MODEL_NUMBER = 1
INPUT_STRING = """
MAIN MENU:
Input amount to loan (integer).
Input 'q' to quit program.
"""
EXIT_STRING = """
Thank you, goodbye!
By Ben Shields <https://github.com/iamrobinhood12345>... | true |
a868af86d0102fe2aafd0b10782840ecad86768e | KC1988Learning/TkinterLearning | /tutorial/grid.py | 2,025 | 4.15625 | 4 | import tkinter as tk
from tkinter import ttk
from window import set_dpi_awareness
def greet():
# add strip() to remove whitespace in string
print(f"Hello {user_name.get().strip() or 'World'}! How are you?")
set_dpi_awareness()
root = tk.Tk()
root.title("Greeting App")
# configure row and column property of ... | true |
24e335ecf0a79e60026e0a3f41f5277b7ab839ef | tikitae92/Python-IS340 | /Ch4/whileCheckout2.py | 1,011 | 4.15625 | 4 | #example of sale transaction in a store
#cashier doesnt know the # of items in a cart
#input price
#add to total and display in the while loop
#starts sale transaction and ends it when no items are left
#keep track of # of items in customer shopping cart
#print total # of items
#stop when user enter -1
#if nega... | true |
fbf74dfb475b7f1d3ee5e7a247c6c40b3a615d0e | camarena2/camarena2.github.io | /secretworld.py | 800 | 4.25 | 4 |
print(" Welcome to the Secret Word Game. Guess a letter in the word, then press enter:")
from random import choice
word = choice(["table", "chair", "bottle", "plate", "parade", "coding", "teacher", "markers", "phone", "grill", "friends", "fourth", "party"])
guessed = []
while True:
out = ""
for letter in... | true |
041dbf38767b723327ebf197bba3cf02bbf10a5b | raymccarthy/codedojo | /adam/firstWork/adam.py | 461 | 4.21875 | 4 | calculator = "Calculator:"
print(calculator)
one = input("Enter a number: ")
two = input("Enter another number: ")
three = input("Would you like to add another number?: ")
if three == "yes" or three == "Yes":
thre = input("What would you like that number to be: ")
answer = float(one) + float(two) + float(thre)... | true |
a7ea7d24373085e6822da0ff924304b434ed8d52 | pasanchamikara/ec-pythontraining-s02 | /data_structures/tuples_training.py | 507 | 4.46875 | 4 | # Tuples are unchangeable once created, ordered and duplicates are allowed.
vegetable_tuple = ("cucumber", "pumkin", "tomato")
# convert his to a set and assign to vegetable_set
# get the lenght of the tuple vegetable_tuple
fruit_tuple = ("annas", )
# get the result of print(type(fruit_tuple)) with and without com... | true |
6d2b06ebe279933bfaec64883289b897948d81ee | haider10shah/python-tricks | /functions.py | 1,905 | 4.3125 | 4 | def yell(text):
return text.upper() + '!'
def greet(func):
greeting = func('How are you')
return greeting
def whisper(text):
return text.lower() + '...'
def speak(text):
def whisper(t):
return t.lower() + '...'
return whisper(text)
def get_speak_func(text, volume):
def whispe... | false |
32d6e902356eeec9d4cfcab5bd4f1c8d4398dea3 | JoshuaR830/HAI | /Lab 1/Excercise 4/ex9.py | 272 | 4.28125 | 4 | words = ["This", "is", "a", "word", "list"]
print("Sorted: " + sorted(words))
print("Original: " + words)
words.sort()
print("Original: " + words)
# sorted(words) prints does not change the order of the original list
# words.sort() changes the original order of the list | true |
0fdac6ba0c12be57e9d07c067ce5be5042971876 | BurlaSaiTeja/Python-Codes | /Lists/Lists05.py | 342 | 4.21875 | 4 | """
Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers between 1 and 30 (both included).
"""
def sqval():
l=list()
for i in range(1,31):
l.append(i**2)
print(l[:5])
print(l[-5:])
sqval()
"""
Output:
[1, 4, 9, 16, 25]
[676, 72... | true |
e9ffcaced1121fa20de7c5f4df840bc8821a3c58 | anc1revv/coding_practice | /leetcode/easy/letter_capitalize.py | 490 | 4.375 | 4 | '''
Using the Python language, have the function LetterCapitalize(str) take the str
parameter being passed and capitalize the first letter of each word.
Words will be separated by only one space.
'''
def letter_capitalize(input_str):
list_words = input_str.split(" ")
for word in list_words:
for i in range(le... | true |
2b3c1bc9399793ce14fd920e8dfda39062655465 | Swastik-Saha/Python-Programs | /Recognize&Return_Repeated_Numbers_In_An_Array.py | 472 | 4.1875 | 4 | def repeated():
arr = []
length = int(raw_input("Enter the length of the array: "))
for i in range(0,length):
arr.append(int(raw_input("Enter the elements of an array: ")))
arr.sort()
count = 0
for i in range(0,length):
print "The number t... | true |
971881bad3c2980c5c2875ff07d1ac50d2a45299 | wojtekminda/Python3_Trainings | /SMG_homework/10_2_Asking_for_an_integer_number.py | 2,299 | 4.53125 | 5 | '''
Write input_int() function which asks the user to provide an integer number
and returns it (as a number, not as a string). It accepts up to 3 arguments:
1. An optional prompt (like input() built-in function).
2. An optional minimum acceptable number (there is no minimum by default).
3. An optional maximum acceptabl... | true |
09c024e3dfde0a07e652fd8bfb02357b736bc1ac | wojtekminda/Python3_Trainings | /SMG_homework/01_3_Should_I_go_out.py | 1,319 | 4.15625 | 4 | '''
A user is trying to decide whether to go out tonight.
Write a script which asks her a few yes-no questions and decides for her according to the following scheme:
[NO SCHEME]
'''
raining = input("Is it raining? ")
if raining == "yes":
netflix = input("Is the new episode on Netflix out already? ")
if netflix... | true |
2b11221a58ddff3101a95aa892b0ed5ab4997f80 | 5h3rr1ll/LearnPythonTheHardWay | /ex15.py | 1,076 | 4.375 | 4 | #importing the method argv (argument variable) from the library sys into my code
from sys import argv
"""now I defining which two arguments I want to have set while typing the
filename. So you are forced to type: python ex15.py ArgumentVariable1
ArgumentVariable2"""
script, filename = argv
#since the filename is give... | true |
a4877ed3f2bb5586e5143b85119eeb1f75efeb6c | kmjawadurrahman/python-interactive-mini-games | /guess_the_game.py | 2,176 | 4.40625 | 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
which_range = ""
# helper function to start and restart the game
def new_game():
# initialize global variables used in your code... | true |
336752945fd20ad86c8fef8d7fe7c319675385bd | prakrutivaghasiya/Python-programs | /Fibo.py | 266 | 4.125 | 4 | def Fibonacci(n) :
if n<0 :
print('Incorrect Input')
elif n == 1 :
return 0
elif n==2 :
return 1
else :
return Fibonacci(n-1) + Fibonacci(n-2)
print('Enter number : ')
number = int(input())
print (Fibonacci(number)) | false |
7c0d5b6e2a34573515eeefa8451ec93e94aecded | RaviKiranDev/Python-Exercises | /LogicAndLoopsExercise/LogicAndLoopsExercise/ifelse2.py | 233 | 4.4375 | 4 | x=int(input("Enter a number"))
if x%2==0:
if x%3==0:
print("even and divisible by 3")
else:
print("even")
else:
if x%3==0:
print("odd and divisible by 3")
else:
print("odd")
| false |
f95c90cefc62f8a1531c8a0d32ddc4e91a3dbc86 | Otumian-empire/python-oop-blaikie | /05. Advanced Features/0505.py | 604 | 4.15625 | 4 | # With context
# open file and close it
fp = open('Hello.txt', '+a')
print('I am a new text file', file=fp)
fp.close()
# We don't have to close it
with open('Hello.txt', '+a') as op:
print('I am a new line in the Hello.txt file', file=op)
# seems like not a valid python3 code
# class MyWithClass:
# def __e... | true |
566946645bd44e94bafe916c9e2f0aeadd4b1cb5 | mjayfinley/Conditions_and_Functions | /EvenOdd/EvenOdd.py | 220 | 4.3125 | 4 | numberInput = int(input("Please enter a number: "))
if numberInput == 0:
print("This number is neither odd or even.")
elif numberInput %2 == 0:
print("This number is even")
else:
print("This number is odd")
| true |
a73f1008e48dfa6d13e7481ebb4f795e272fa773 | artliou/ucb | /cs61a/lab/lab01/lab01_extra.py | 738 | 4.21875 | 4 | """Coding practice for Lab 1."""
# While Loops
def factors(n):
"""Prints out all of the numbers that divide `n` evenly.
>>> factors(20)
20
10
5
4
2
1
"""
"*** YOUR CODE HERE ***"
a = n
while a > 0:
if n % a == 0:
print(a)
a = a - 1
def fal... | false |
4bf95784f9344a328e8032c2a9339693cb4c6ee6 | Coliverfelt/Aulas_Python | /Aula007.py | 810 | 4.15625 | 4 | n1 = int(input('Digite um valor: '))
n2 = int(input('Digite outro: '))
soma = n1 + n2
subtracao = n1 - n2
multiplicacao = n1 * n2
divisao = n1 / n2
divisaointeira = n1//n2
exponenciacao = n1**n2
resto = n1 % n2
print('A soma entre os valores {} e {} vale {}'.format(n1, n2, soma), end='. ')
print('A subtração entre os... | false |
ee6e08c183fe4ee4624cc5e68044b9b19f506c07 | ShanYouGuan/python | /others/Test_Class.py | 1,003 | 4.21875 | 4 | class people:
name = ""
age = 0
__weigt = 0
def __init__(self,a, n, w):
self.name = n
self.age = a
self.__weight = w
def speak1(self):
print("{}说:我今年{}岁,我{}斤".format(self.name, self.age,self.__weight))
class student(people):
grade = ''
def __init__(self,n, a, ... | false |
695355269bae1334c7370ee5b99c7d67aa1fc42b | ShanYouGuan/python | /Algorithm/bubble_sort.py | 286 | 4.125 | 4 | def bubble_sort(list):
for i in range(0, len(list)):
for j in range(len(list)-i-1):
if list[j] > list[j+1]:
list[j], list[j+1] = list[j+1], list[j]
lista = [1, 3, 6, 5, 4, 2]
bubble_sort(lista)
for i in range(0, len(lista)):
print(lista[i]) | false |
08a27190e2210d7bedda769c93c6a9d710cb474e | BarDalal/Matrices--addition-and-multiplication | /AddMinPart.py | 1,148 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Name: Bar Dalal
Class: Ya4
The program adds the common parts of two matrices.
The sum's size is as the common part's size.
"""
import numpy as np
def MinAddition(a, b):
"""
The function gets two matrices.
The function returns the sum of the common parts of the m... | true |
afa5e2e385ff2086f25c471ac148c7032980d250 | nighatm/W19A | /app.py | 1,004 | 4.1875 | 4 | import addition
import subtraction
import multiplication
import divide
print("Please choose an operation")
print("1: Addition")
print("2: Subtraction")
print("3: Multiplication")
print("4: Division")
try:
userChoice = int(input ("Enter Choice 1 or 2 or 3 or 4 : "))
except:
print ('You have ent... | true |
51cc0c2b610846a0f4fcc8b0e4e2eb57d15d683a | DikranHachikyan/python-20201012 | /ex58.py | 1,068 | 4.25 | 4 |
# клас
class Point():
#Променлива на класа (статична променлива)
label = 'A'
# Конструктор на класа - инициализация на данните на класа
def __init__(self, x = 0, y = 0, *args, **kwargs):
print('object constructor')
# данни на класа
self._x = x
self._y = y
# Метод на... | false |
cfd8276cedbf35d4542948135e6c68c986d00c89 | Coadiey/Python-Projects | /Python programs/PA7.py | 2,214 | 4.15625 | 4 | # Author: Coadiey Bryan
# CLID: C00039405
# Course/Section: CMPS 150 – Section 003
# Assignment: PA7
# Date Assigned: Friday, November 17, 2017
# Date/Time Due: Wednesday, November 22, 2017 –- 11:55 pm
#Description: This program is just a simple class setup that changes the output into a string based on the input... | true |
7713164280f6733d072ad02e09bc19aa450e361c | SP18-Introduction-Computer-Science/map-and-lists-biren3008 | /Assignment2.py | 546 | 4.375 | 4 | # List and Map Biren 3008
# Create a List
number = []
number.append([1,2,3,'List','Map'])
n = number[0]
print("List : ")
print(n)
print("List Elements are")
for listElem in n :
print(listElem)
# Create a Map
myMap = {0 : "List", 1 : "Map", 2 : "Biren_3008"}
print("Map Dictionary with Value :... | false |
96672006f4ee0b8ce9cb023f0f14c9a5eb385b71 | EmreTekinalp/PythonLibrary | /src/design_pattern/factory_pattern.py | 1,791 | 4.1875 | 4 | """
@author: Emre Tekinalp
@contact: e.tekinalp@icloud.com
@since: May 28th 2016
@brief: Example of the factory pattern.
Unit tests to be found under:
test/unit/test_factory_pattern.py
"""
from abc import abstractmethod
class Connection(object):
"""Connection class."""
@abstractmethod
... | true |
368b33debeaf5fbfec24a6504b4eba9531403030 | Bongio03/TPSIT | /Code/Code1.py | 1,184 | 4.3125 | 4 | '''
Implementare i metodi enqueue() e dequeue() e creare un programma che permetta
all’utente di riempire una coda di numeri interi di lunghezza arbitraria. Successivamente
testare la funzione dequeue per svuotare la coda.
'''
def dequeue(queue): #Funzione per svuotare la coda
return queu... | false |
f9ff6527ee3c680cefc70bb37a49ba2465005b51 | kirushpeter/flask-udemy-tut | /python-level1/pypy.py | 2,426 | 4.25 | 4 | """
#numbers
print("hello world")
print(1/2)
print(2**7)
my_dogs = 2
a = 10
print(a)
a = a + a
print(a)
puppies = 6
weight = 2
total = puppies * weight
print(total)
#strings
print(len("hello"))
#indexing
mystring = "abcdefghij"
print(mystring[-1])
print(mystring[0:7:2])#start is included start stop and ... | true |
45510428c4984ac3ff42c204393bce6e7372ea90 | farahnazihah/DDP1-2019 | /Lab1/challenge1.py | 800 | 4.15625 | 4 | import turtle
turtle.speed(20)
#drawing a circle
turtle.color('yellow')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
turtle.penup()
turtle.forward(40)
turtle.left(90)
turtle.forward(120)
turtle.right(90)
#drawing two eyes
turtle.color('black')
turtle.begin_fill()
turtle.circle(10)
tu... | false |
eeb0f0366684a36245718065c8858f43f70736f7 | danielstaal/project | /code/chips_exe.py | 2,117 | 4.15625 | 4 | '''
Executable file Chips & Circuits
Date: 26/05/2016
Daniel Staal
This program allows the user to choose a print, netlist, search methods and
a filename to output the result
To execute this program: python chips_exe.py
'''
import astar3D
import netlists
import time
import sys
if __name__ == "__main__":
... | true |
1f32a7062a40bc6e14c6c0f7ba17d065746feb7c | josh-perry/ProjectEuler | /problem 1.py | 439 | 4.21875 | 4 | # Problem 1: Multiples of 3 and 5
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def euler_1():
total = 0
for i in range(1, 1000):
if i % 3 == 0 or i % 5 == ... | true |
5f046618b7c307efab1b8c6ccbafe06a4afc4e93 | khoipn1504/Practices | /Data Structures/Sorting and Selection/MergeSort.py | 678 | 4.125 | 4 | def merge(S1, S2, S):
# merge 2 sorted lists S1 and S2 into properly list S
i = j = 0
while i+j < len(S):
if j == len(S2) or (i < len(S1) and S1[i] < S2[j]):
S[i+j] = S1[i] # copy ith element of S1 as next item of S
i += 1
else:
S[i+j] = S2[j] ... | false |
a185c1f5b1101ae320e5781d1a73548e270a6f57 | Zahidsqldba07/code-signal-solutions-GCA | /GCA/2mostFrequentDigits.py | 1,053 | 4.125 | 4 | def mostFrequentDigits(a):
#Tests
# a: [25, 2, 3, 57, 38, 41] ==> [2, 3, 5]
# a: [90, 81, 22, 36, 41, 57, 58, 97, 40, 36] ==> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# a: [28, 12, 48, 23, 76, 64, 65, 50, 54, 98] ==> [2, 4, 5, 6, 8]
"""
Given an array of integers a, your task is to calculate the digits that occur the mos... | true |
da574aa59126be1b3964190559c478a296f5b4a9 | Zahidsqldba07/code-signal-solutions-GCA | /arcade/intro/026-evenDigitsOnly.py | 515 | 4.1875 | 4 | def evenDigitsOnly(n):
n = [int(i) for i in str(n)]
for d in n:
if d%2 != 0:
return False
return True
"""
Check if all digits of the given integer are even.
Example
For n = 248622, the output should be
evenDigitsOnly(n) = true;
For n = 642386, the output should be
evenDigitsOnly(n) =... | true |
8d9c2d0492cfb620649087e4e007031357eee827 | Zahidsqldba07/code-signal-solutions-GCA | /GCA/2countWaysToSplit.py | 1,719 | 4.1875 | 4 | def countWaysToSplit(s):
listS= list(s)
# print (listS)
lenS = len(listS)
count = 0
for i in range(1,lenS):
for j in range(i+1, lenS):
ab = s[0:j]
bc = s[i:lenS]
ca = s[j:lenS] + s[0:i]
# print("AB is :",ab,"BC is:",bc,"CA is:",ca)
... | true |
b5224f264e6e51d57eacf32a54564688eed5c143 | Zahidsqldba07/code-signal-solutions-GCA | /arcade/intro/09-allLongestStrings.py | 1,206 | 4.125 | 4 | """
Given an array of strings, return another array containing all of its longest strings.
Example
For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the output should be
allLongestStrings(inputArray) = ["aba", "vcd", "aba"].
Input/Output
[execution time limit] 4 seconds (py3)
[input] array.string inputArray
A n... | true |
ac6519b87bdd7461be54798c7a74088110759986 | kampetyson/python-for-everybody | /8-Chapter/Exercise6.py | 829 | 4.3125 | 4 | '''
Rewrite the program that prompts the user for a list of
numbers and prints out the maximum and minimum of the numbers at
the end when the user enters “done”. Write the program to store the
numbers the user enters in a list and use the max() and min() functions to
compute the maximum and minimum numbers after t... | true |
b3bc71dff70c5bf4e21e0bc4e2af3f826c41406d | kampetyson/python-for-everybody | /2-Chapter/Exercise3.py | 212 | 4.15625 | 4 | # Write a program to prompt the user for hours and rate perhour to compute gross pay.
hours = int(input('Enter Hours: '))
rate = float(input('Enter Rate: '))
gross_pay = hours * rate
print('Pay:',gross_pay) | true |
789ffe90d787d656159bbefc7dfeafb7bd02a287 | kampetyson/python-for-everybody | /7-Chapter/Exercise2.py | 1,108 | 4.15625 | 4 | # Write a program to prompt for a file name, and then read
# through the file and look for lines of the form: X-DSPAM-Confidence: 0.8475
# When you encounter a line that starts with “X-DSPAM-Confidence:”
# pull apart the line to extract the floating-point number on the line.
# Count these lines and then compute the... | true |
9b3edb65b838b153430aa177b1609260908e98b4 | kampetyson/python-for-everybody | /7-Chapter/Exercise1.py | 614 | 4.40625 | 4 | # Write a program to read through a file and print the contents
# of the file (line by line) all in upper case. Executing the program will
# look as follows:
# python shout.py
# Enter a file name: mbox-short.txt
# FROM STEPHEN.MARQUARD@UCT.AC.ZA SAT JAN 5 09:14:16 2008
# RETURN-PATH: <POSTMASTER@COLLAB.SAKAIPRO... | true |
21045c28a2f3a5e004a2b42b3d6f7d04aa122e8a | usmansabir98/AI-Semester-101 | /PCC Chapter 5/5-5.py | 779 | 4.125 | 4 | # 5-5. Alien Colors #3: Turn your if-else chain from Exercise 5-4 into an if-elifelse
# chain.
# • If the alien is green, print a message that the player earned 5 points.
# • If the alien is yellow, print a message that the player earned 10 points.
# • If the alien is red, print a message that the player earned 15 poin... | true |
8f6f7f0c6308b83fa51fbdf2f2e00717f736b63e | CISVVC/test-ZackaryBair | /dice_roll/main.py | 2,080 | 4.28125 | 4 | """
Assignment: Challenge Problem 5.13
File: main.py
Purpose: Rolls dice x amount of times, and prints out a histogram for the number of times that each number was landed on
Instructions:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An... | true |
bb3e967a7776b571cca10fdb988cb09b8980cf63 | gptix/cs-module-project-algorithms2 | /moving_zeroes/moving_zeroes.py | 458 | 4.28125 | 4 | '''
Input: a List of integers
Returns: a List of integers
'''
def moving_zeroes(arr):
# Your code here
original_length = len(arr)
out = [element for element in arr if element is not 0]
out = out + [0]*original_length
return out[:original_length]
if __name__ == '__main__':
# Use the main funct... | true |
db13074a2c8dca8e5d1708a80760d6626f3b0b9b | AdyGCode/Python-Basics-2021S1 | /Week-7-1/functions-4.py | 1,251 | 4.34375 | 4 | """
File: Week-7-1/functions-4.py
Author: Adrian Gould
Purpose: Demonstrate taking code and making it a function
Move the get integer code to a function (see functions-3
for the previous code)
Design:
Define get_integer function
Define number to be None
While nu... | true |
425571e8bb0512c2a92f9068883189291acb771b | AdyGCode/Python-Basics-2021S1 | /Week-13-1/gui-7-exercise.py | 1,242 | 4.1875 | 4 | # --------------------------------------------------------------
# File: Week-13-1/gui-7-exercise.py
# Project: Python-Class-Demos
# Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au>
# Created: 11/05/2021
# Purpose: Practice using GUI
#
# Problem: Create a GUI that asks a user for their name and
# ... | true |
b306448e151d13b2caeb8cfced3a9650affc29ba | jfbeyond/Coding-Practice-Python | /101_symmetric_tree.py | 1,026 | 4.15625 | 4 |
# 101 Symmetric Tree
# Recursively
def isSymmetric(root):
# current node left child is equal to current node right child
if not root: return False
return checkSymmetry(root, root):
def checkSymmetry(node1, node2):
if not node1 and not node2: return True
if node1 and node2 and node1... | true |
1cca5cc40e84e7e4b314ded2f82786d5e845b0f2 | rocooper7/5.Webscraping | /3.Curso_Scrapy/1.Gen_Iter/15.iteradores.py | 284 | 4.3125 | 4 | my_list = [1, 2, 3, 4, 5] #Iterable, como funciona for
my_iter = iter(my_list) #Se convierte en iterador
print(type(my_iter))
# Extraer los elementos
print(next(my_iter))
print(next(my_iter))
print(next(my_iter))
print(next(my_iter))
print(next(my_iter))
print(next(my_iter)) | false |
1353ee42c247cd5d9a30cb3bd9fc5f33639d181a | F4Francisco/Algorithms_Notes_For_PRofessionals | /Section1.2_FizzBuzzV2.py | 777 | 4.125 | 4 | ''' Optimizing the orginal FizzBuzz:
if divisable by 3 sub with Fizz
if divisable by 5 sub with Buzz
if divisable by 15 sub with FizzBuzz
'''
# Create an array with numbers 1-5
number = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
#iterate through the array and check which numbers are fizz and which are Buzz
for num ... | true |
e5e7ef14baa4d4b7b3596bb4adf7cadaddea2e07 | SimaFish/python_practice | /class_practice/auto.py | 2,571 | 4.40625 | 4 | # Zen of Python
import this
# The definition of a class happens with the `class` statement.
# Defining the class `Auto`.
# class Auto(object): is also an allowable definition
class Auto():
# ToDo class attributes vs. instance attributes
# https://www.toptal.com/python/python-class-attributes-an-overly-thorough... | true |
43594d3f6b04fcee5ff2285226da49fd96471d89 | SimaFish/python_practice | /modules/mod_string.py | 1,027 | 4.25 | 4 | import string
# String constants (output type: str).
# The lowercase letters 'abcdefghijklmnopqrstuvwxyz'.
print('1: ' + string.ascii_lowercase)
# The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
print('2: ' + string.ascii_uppercase)
# The concatenation of the ascii_lowercase and ascii_uppercase constants descri... | true |
6896682b041713dff84ab145274b7858f3f3c7bc | seo0/MLstudy | /adsa_2016/module13_graphs01/part02_basics02/graphs_etc.py | 1,760 | 4.3125 | 4 |
import networkx as nx
import matplotlib.pyplot as plt
from module13_graphs01.part01_basics.graphs_basics import print_graph, display_and_save
def modulo_digraph(N,M):
"""
This function returns a directed graph DiGraph) with the following properties (see also cheatsheet at: http://screencast... | true |
1895a345a9021d25dcdc91982ff00b6f3090474a | luckydimdim/grokking | /tree_breadth_first_search/minimum_depth_of_a_binary_tree/main.py | 1,086 | 4.1875 | 4 | from collections import deque
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
def find_minimum_depth(root):
'''
Find the minimum depth of a binary tree.
The minimum depth is the number of nodes along the shortest path
from the root node to the nearest leaf... | true |
48f1fa5d3668a54ec73e49e377c610b3bfdba024 | luckydimdim/grokking | /modified_binary_search/search_bitonic_array/main.py | 1,139 | 4.15625 | 4 | def search_bitonic_array(arr, key):
'''
Given a Bitonic array, find if a given ‘key’ is present in it.
An array is considered bitonic if it is monotonically increasing and then monotonically decreasing.
Monotonically increasing or decreasing means that for any index i in the array arr[i] != arr[i+1].
... | true |
9e429a3d67b58bd3e34e0868fa203e80c8215925 | luckydimdim/grokking | /modified_binary_search/next_letter/main.py | 1,092 | 4.125 | 4 | import string
def search_next_letter(letters, key):
'''
Given an array of lowercase letters sorted in ascending order,
find the smallest letter in the given array greater than a given ‘key’.
Assume the given array is a circular list,
which means that the last letter is assumed to be connected with ... | true |
5921d9a5ee2ca9e587ea6d8a54cdaf6126ffd510 | luckydimdim/grokking | /subsets/permutations_recursive/main.py | 535 | 4.1875 | 4 | from collections import deque
def find_permutations(nums):
'''
Given a set of distinct numbers, find all of its permutations.
'''
result = []
permutate(nums, 0, [], result)
return result
def permutate(nums, i, current, result):
if i == len(nums):
result.append(current)
return
for l in range(... | true |
57bf01794444f9e3fc31973d50f33a3cdbd9639b | luckydimdim/grokking | /tree_breadth_first_search/zigzag_traversal/main.py | 1,289 | 4.15625 | 4 | from collections import deque
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
def traverse(root):
'''
Given a binary tree, populate an array to represent its zigzag level order traversal.
You should populate the values of all nodes of the first level from lef... | true |
667a2a4a9b01eb0f6705f6846263c634ee9405f2 | luckydimdim/grokking | /two_heaps/find_the_median_of_a_number_stream/main.py | 1,373 | 4.25 | 4 | from heapq import *
class MedianOfAStream:
'''
Design a class to calculate the median of a number stream. The class should have the following two methods:
insertNum(int num): stores the number in the class
findMedian(): returns the median of all numbers inserted in the class
If the count of numbers inser... | false |
0c0d6e43383e97d87fdc6afb562af33a00152f8c | MariaGabrielaReis/Python-for-Zombies | /List-02/L2-ex005.py | 576 | 4.125 | 4 | #Exercise 05 - List 02
#Faça um Programa que leia três números e mostre o maior e o menor deles.
print('O maior e o menor nº dentre 3')
#entrada de dados
a = int(input("a:"))
b = int(input("b:"))
c = int(input("c:"))
# JEITO DO PROFESSOR
# se o a for o maior
if a>=b and a>=c: print('Maior: ', a)
# se o b for o maior
e... | false |
03e7a2218937f12112e322ac88ce065cceb7b23f | darshanchandran/PythonProject | /PythonProject/Classes and Modules/Classes/Compositions.py | 336 | 4.28125 | 4 | #This program shows how compositions work with out inheriting the parent class
class Parent(object):
def boss(self):
print("I'm the boss")
class Child(object):
def __init__(self):
self.child = Parent()
def boss(self):
print("Child is the boss")
self.child.boss()
son = Chi... | true |
49fe5540582f959dbff34fa2a46ff80abdeac2ac | Diatemba99/Notebook | /list.py | 650 | 4.125 | 4 | week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saterday", "Sunday"]
print(week[3])
week[1]="Lundi"
print(len(week))
print((week))
print("----------------------------------")
mylist=[1, 56, "hello", [7, 20], True]
print(len(mylist[3]))
mylist.append("Toyota")
print(mylist)
mylist.insert(2, "Z... | false |
c0c7027ee70e6be6a0f9b067fc0f1df9b6276bc0 | EmissaryEntertainment/3D-Scripting | /Week_2/McSpadden_Exercise_2.3.py | 699 | 4.21875 | 4 | #Use each form of calculation besides modulus
print("2 + 5 = " + str(2+5))
print("2 - 5 = " + str(2-5))
print("2 * 5 = " + str(2*5))
print("2 / 5 = " + str(2/5))
print("2 ** 5 = " + str(2**5))
#Calculation whos resluts depend on order of operations
print("160 + 5 * 7 = " + str(160 + 5 * 7))
#Force change order of oper... | true |
ac951d9f278b6ec976a41e167ba50b6388432c96 | EmissaryEntertainment/3D-Scripting | /Week_3/McSpadden_Exercise_3.5_PEP8.py | 522 | 4.15625 | 4 | # ALPHABET SLICE
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
slice = alphabet[0:3]
for letter in slice:
print("First slice: " + letter)
slice = alphabet[4:8]
for letter in slice:
print("Second slice: " + letter)
slice = alphabet[2:]
for letter in slice:
print("Third slice: " + letter)
# PROTECTED L... | false |
2c709c8d07c8a738177250eb5b4d029c3945dd7b | EmissaryEntertainment/3D-Scripting | /Week_4/McSpadden_Exercise_4.3.py | 897 | 4.25 | 4 | #THREE IS A CROWD
print("-------THREE IS A CROWD-------")
names = ["Jose", "Jim","Larry","Bran"]
def check_list(list):
if len(list) > 3:
print("This list is to crowded.")
check_list(names)
del names[0]
check_list(names)
#THREE IS A CROWD - PART 2
print("-------THREE IS A CROWD - PART 2-------")
def check_l... | true |
567addd4e775a0a80665b75a1666cbf1fdda28e9 | KumarjitDas/Algorithms | /Algorithms/Recursion/Python/countdown.py | 911 | 4.5 | 4 | def countdown(value: int):
""" Print the countdown values.
countdown
=========
The `countdown` function takes an integer value and decreases it. It prints
the value each time it. It uses 'recursion' to do this.
Parameters
----------
value: int
an integer value
Returns
-------
... | true |
110c972931fe16b1d605396a7d2813388ebf3282 | HossamSalaheldeen/Python_lab1 | /prob3.py | 915 | 4.1875 | 4 | # Problem 3
#-------------
# Consider dividing a string into two halves.
# Case 1:
# The length is even, the front and back halves are the same length.
# Case 2:
# The length is odd, we'll say that the extra char goes in the front half.
# e.g. 'abcde', the front half is 'abc', the back half 'de'.
# Given 2 strings, a a... | true |
2a7963e01f163f9b2c85e8d64de66630914f7328 | JemrickD-01/Python-Activity | /WhichWord.py | 617 | 4.21875 | 4 | def stringLength(fname,lname):
if len(fname)>len(lname):
print(fname,"is longer than",lname)
elif len(fname)<len(lname):
print(lname,"is longer than",fname)
else:
print(fname,"and",lname,"have the same size")
choices = ["y","n"]
ans="y"
while ans=="y":
x=input... | true |
af1ecc1dfb000a8dd0aab062123a29c489a7f426 | Raj-kar/PyRaj-codes | /password.py | 1,300 | 4.28125 | 4 | ''' Homework 1 -
WAP to genarate a secure password.
- 1. password must contains minimim 8 char.
- 2. both upper and lower case.
- 3. must contains two number and one special char.
bonus - shuffle the password, for better security.
Homework 2 -
Optimize the below Code.
'''
# Wap to check a password is secure o... | true |
82fc2124669344ca0291a5d9bef9d8f70b01e7b9 | avantikabagri/lecture8 | /3/gradepredict_stubs.py | 2,028 | 4.21875 | 4 |
# reads a CSV from a file, and creates a dictionary of this form:
# grade_dict['homeworks'] = [20, 20, 20, ...]
# grade_dict['lectures'] = [5, 5, 5, ...]
# ...
# params: none
# returns: a dictionary as specified above
def get_data():
return {}
# param: list of lecture excercise scores
# return: total scores for lec... | true |
42ea0a6fe036ea1fbb3059a715461680a0e13146 | saubhik/catalog | /src/catalog/tries/add-and-search-word-data-structure-design.py | 2,412 | 4.3125 | 4 | # Add and Search Word - Data structure design
#
# https://leetcode.com/problems/add-and-search-word-data-structure-design/
#
import unittest
from typing import Dict
class TrieNode:
def __init__(self):
self.children: Dict[str, TrieNode] = dict()
self.end: bool = False
class WordDictionary:
d... | true |
58d34d94f58f56f4c1e8dbf9d3b8a97d23ed8e0e | Ry09/Python-projects | /Random Stuff/collatz.py | 1,142 | 4.65625 | 5 | # This is a program to run the Collatz Sequence. It will
# take a number from the user and then divide it by 2 if
# it is even, or multiply by 3 and add 1 if it is odd. It
# will loop through this until it reaches the value of 1.
def collatz(num):
try:
num = int(num)
print(num)
if num == 1:... | true |
c5184214e0daa2623467ba19929296893138d682 | denis-meshcheryakov/Learn_python_lesson_1 | /dicts.py | 308 | 4.1875 | 4 | dict1 = {"city": "Москва", "temperature": "20"}
print(dict1['city'])
dict1['temperature'] = int(dict1['temperature']) - 5
print(dict1)
if 'country' not in dict1:
print('country is not in keys')
print(dict1.get('country', 'Россия'))
dict1['date'] = '27.05.2019'
print(len(dict1))
print(dict1)
| false |
7c369fcf4710b134b7437724685698895b2f50aa | ProgFuncionalReactivaoct19-feb20/clase03-Jdesparza | /Ejercicio3.py | 624 | 4.125 | 4 | """
Ejemplo 7
Jdesparza
Funcional - Aplicando función filter
Dadas las siguiente ciudades, filtrar aquellas que tienen un número par como longitud en sus caracteres.
Loja, Pichincha, Guayaquil, Zamora, Ibarra, Manabi, Machala, Portoviejo, Macas
"""
# se crea una lista con las ciudades
ciudades = ["Loja", "Pich... | false |
927170aae55b2529e503f3e1836cd0ac6d18516b | rayadamas/pythonmasterclassSequence | /coding exercise 14.py | 662 | 4.21875 | 4 | # Write a program which prompts the user to enter three integers separated by ","
# user input is: a, b, c; where those are numbers
# The following calculation should be displayed: a + b - c
# 10, 11, 10 = 11
# 7, 5, -1 = 13
# Take input from the user
user_input = input("Please enter three numbers: ")
# Sp... | true |
a6c5cc0f90f540202efa1c8f6b1098d99c3c4397 | surprise777/StrategyGame2017 | /Game/current_state.py | 1,959 | 4.3125 | 4 | """module: current_state (SuperClass)
"""
from typing import Any
class State:
"""a class represent the state of class.
current_player - the player name who is permitted to play this turn.
current_condition - the current condition of the state of the game
"""
current_player: str
current_condit... | true |
a23930569e83eb420cc1f2290f35bb43853be0c2 | caboosecodes/Python_Projects | /python_If.py | 297 | 4.25 | 4 |
height = 200
if height > 150:
if height > 195:
print('you are too tall ride the roller coaster')
else:
print('you can ride the roller coaster')
elif height >= 125:
print('you need a booster seat to ride the roller coaster')
else:
print('where are your parents?')
| true |
2590e80758fe499b1d133a86ac83a60b5185c350 | matbc92/learning-python | /Data Structures/ds_seq.py | 1,372 | 4.5 | 4 | # listas strings e tuples, são sequencias, uma vez que sequencias sao conjuntos ordenados
# uma vez que eles sao ordenados pode se utilizar uma operação chamada slicing,
# ou seja selecionar apenas alguns itens desta sequencia, para tanto é necessario dizer
# a posição do primeiro e do ultimo item que se quer slecionar... | false |
8305a8bfae9ee64d3f446e485c8c602e50e6abb5 | matbc92/learning-python | /flow control/if_e_while.py | 1,619 | 4.25 | 4 | #if condiciona o programa a executar um bloco de instruções se certas condições forem atendidas
# e outro(s) se condições diferentes ocorrerem, as condições diferentes podem ser especificadas
# por meio do comando elif, que efetivamente cria um outro nó de if, ou simplesmente permanecerem
# como qualquer coisa diferen... | false |
4ef85b3373806e1e5b05cbfd22e85abff40b12fe | matbc92/learning-python | /input_output/io_input.py | 686 | 4.4375 | 4 | # programa simples com duas funções definidas,
# uma que inverte uma string de texto, usando um operador sobre sequencias
# que inverte a ordem, e uma função que utiliza esta função de
# reversão para testar se a string é palindromica ao comparar
# com o resultado da função que inverte o texto
def reverse(text):
r... | false |
c901a714e56f22c3f31fef767205df16ab561035 | ScottSko/Python---Pearson---Third-Edition---Chapter-5 | /Chapter 5 - Maximum of Two Values.py | 379 | 4.21875 | 4 | def main():
num1 = int(input("Please enter a value: "))
num2 = int(input("Please enter another value: "))
greater_value = maximum(num1, num2)
print("The greater value is", greater_value)
def maximum(num1,num2):
if num1 > num2:
return num1
elif num1 == num2:
print("The ... | true |
a8a822c69bad9199cdbc345d6fc0ed7ed905162a | srikanthanagaraja/Python_Examples | /Scripts/List/List.py | 647 | 4.15625 | 4 | my_list = ['p','r','o','b','e']
# Output: p
print(my_list[0])
# Output: o
print(my_list[2])
# Output: e
print(my_list[4])
# Error! Only integer can be used for indexing
# my_list[4.0]
# Nested List
n_list = ["Happy", [2,0,1,5]]
# Nested indexing
# Output: a
print(n_list[0][1])
print("The index of Happy is ",n_li... | false |
3ce6d57c9a06622e7cae3f1bc2fa2baa1946be36 | Nikhil-Xavier-DS/Sort-Search-Algorithms | /bubble_sort.py | 467 | 4.28125 | 4 | """
Implementation of Bubble Sort.
"""
# Author: Nikhil Xavier <nikhilxavier@yahoo.com>
# License: BSD 3 clause
def Bubble_sort(arr):
"""Function to perform Bubble sort in ascending order.
TIME COMPLEXITY: Best:O(n), Average:O(n^2), Worst:O(n^2)
SPACE COMPLEXITY: Worst: O(1)
"""
for outer in ra... | true |
b8d279107217bfbf7174bb4dd054b254a5e90a7c | SreeramSP/Python-Programs-S1 | /factorial.py | 235 | 4.1875 | 4 | n=int(input("Enter the number="))
factorial=1
if n<0:
print("No negative Numbers")
elif n==0:
print("The factorial of 0 is 1")
else:
for i in range(1,n+1):
factorial=factorial*i
print("Factorial=",factorial)
| true |
19d17745e0d2aee9ab3b65763076772ba449c6f9 | richartzCoffee/aulasUdemy | /templates2/sorted.py | 359 | 4.125 | 4 | """
sorted com qualquer interavel
"""
numero = [1,2,3,56,41,5]
print(numero)
print(tuple(sorted(numero)))
print(sorted(numero,reverse=True))
usuarios =[
{"usarname":"daniel","tw":["oi"]},
{"usarname": "daaniaaaaaaael", "tw": [],"cor":"amarelo"},
{"usarname":"daniaael","tw":["oi"]}
]
print(sorted(usuarios,ke... | false |
283112adcd03688236d72a9748711469976a4976 | standrewscollege2018/2021-year-11-classwork-SamEdwards2006 | /Paracetamol.py | 662 | 4.125 | 4 | #sets the constants
AGE_LIMIT = 12
WEIGHT_LIMIT = 0
on = 1
#finds the users age
while(on > 0):
age = int(input("How old are you: "))
#tests if the age is more than 12,
#if not, it will go to the else.
if age >= AGE_LIMIT:
print("Recommend two 500 mg paracetamol tablets")
elif age >= 0:
... | true |
78a556658eea5d03ebbdd76ecf3e7d2888f3860c | rafa761/leetcode-coding-challenges | /2020 - august/008 - non-overlapping intervals.py | 1,500 | 4.40625 | 4 | """
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Example 1:
Input: [[1,2],[2,3],[3,4],[1,3]]
Output: 1
Explanation: [1,3] can be removed and the rest of intervals are non-overlapping.
Example 2:
Input: [[1,2],[1,2],[1,2]]
... | true |
d434bdf3a1a81c9a1742259d0c683d373bdba1a4 | Shinji94/python_programming_coursework | /slides/Week 7/Point.py | 545 | 4.28125 | 4 | class Point:
""" Point class represents and manipulates x,y coords. """
def __init__(self, x=0, y=0):
""" Create a new point at x, y """
self.x = x
self.y = y
def distance_from_origin(self):
""" Compute my distance from the origin """
return ((self.x ** 2) + (self.y... | false |
0c4e754032669f8fc75184a5cdfe9ae0e23bf904 | vismayatk002/PythonAssignment | /Algorithm Programs/BubbleSort.py | 592 | 4.3125 | 4 | """
@Author : Vismaya
@Date : 2021-10-20 07:36
@Last Modified by : Vismaya
@Last Modified time : 2021-10-20 07:47
@Title : Bubble Sort
"""
arr = []
def bubble_sort():
n = len(arr)
for i in range(n - 1):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
... | false |
2442c3261cc4d4280d0a46878a3e10d250298b4a | vismayatk002/PythonAssignment | /BasicCorePrograms/PrimeFactors.py | 542 | 4.3125 | 4 | """
@Author : Vismaya
@Date : 2021-10-18 11:39
@Last Modified by : Vismaya
@Last Modified time : 2021-10-18 12:52
@Title : Prime factors of a number
"""
def is_prime(num):
flag = 0
for j in range(2, num):
if num % j == 0:
flag = 1
break
j += 1
... | true |
d2e113be4619cdd2b389dd8066e067c2ee1f1440 | gsmcclellan/sorting_algorithms | /merge.py | 749 | 4.34375 | 4 | """
A merge sort recursively splits a list into smaller lists until they
have a len of one or zero, then combine each list into a single
sorted list
"""
def merge_sort(nums):
if len(nums) > 1:
first_half = nums[:len(nums)//2]
second_half = nums[len(nums)//2:]
first_half = merge_sort(first_half)
second_h... | false |
33579d9a2d351a6a33f82b708c68be6233c45afb | DrSneus/cse-20289-sp21-examples | /lecture09/is_anagram.py | 2,111 | 4.1875 | 4 | #!/usr/bin/env python3
import os
import sys
# Functions
def usage(status=0):
print(f'''Usage: {os.path.basename(sys.argv[0])} [flags]
-i Ignore case distinctions
This program reads in two words per line and determines if they are anagrams.
''')
sys.exit(status)
def count_letters(string):
''' Retur... | true |
0b777077897ac2ae8fc9bea47dae6853cafd31fd | jemarsha/leetcode_shenanigans | /Random_problems/Merged_k_linked_lists.py | 1,138 | 4.375 | 4 | #from typing import List
class Node:
def __init__(self,value):
self.value = value
self.next = None
def merge_lists(lists):
"""
This function merges sorted linked lists- Reads the values in one at a time into a list O(kn). Then
sorts them O(nlogn). Then puts them into a linked list (... | true |
81ade07d0881570c4d1ddc424c107c9e2e51dfef | nicecoolwinter/note | /python/data/python_book_slides/code_5/Person_2.py | 756 | 4.1875 | 4 |
class Person():
HI_STR = 'Hi, I am '
def __init__(self, name, age):
self.name = name
self.age = age
def say_hello(self):
print('Hello, I am ' + self.name)
def say_hi(self):
print(Person.HI_STR + self.name)
def __str__(self):
... | false |
70826eefc7345f3d96c93173f0b17a4b5c1123e5 | Sumanpal3108/21-days-of-programming-Solutions | /Day14.py | 371 | 4.625 | 5 | str1 = input("Enter any String: ")
str2 = input("Enter the substring you want to replace: ")
str3 = input("Enter the string you want to replace it with: ")
s = str1.replace(str2,str3)
print("The original string is: ",str1)
print("The substring you want to replace: ",str2)
print("The string you want to use instead... | true |
35d63b5e2f65b675c138fcc477b9a4d0185f33c7 | Sumanpal3108/21-days-of-programming-Solutions | /21daysprogrammingDay1.py | 683 | 4.15625 | 4 | import math
a = float(input("Enter the coefficient a: "))
b = float(input("Enter the coefficient b: "))
c = float(input("Enter the coefficient c: "))
print("The quadratic equation is: {}X2 + {}X + {} = 0".format(a,b,c))
d = b**2 - 4*a*c
print('The value of d is: ',d)
if d>0:
r1 = (-b + math.sqrt(d))/(... | false |
fe511ba08d1ba756f4a7b7122ccee3b331bdf1a3 | Yasir77788/Shopping-Cart | /shoppingCart.py | 1,959 | 4.21875 | 4 | # shopping cart to perform adding, removing,
# clearing, and showing the items within the cart
# import functions
from IPython.display import clear_output
# global list variable
cart = []
# create function to add items to cart
def addItem(item):
clear_output()
cart.append(item)
print("{} ha... | true |
6f4cfa2188d0845d9ad888f1540edd6f74c83b87 | Kevinloritsch/Buffet-Dr.-Neato | /Python Warmup/Warmup #3 - #2 was Disneyland/run3.py | 766 | 4.125 | 4 | import math
shape = input("What shape do you want the area of? Choose a rectangle, triangle, or circle ;) ")
if shape=='rectangle':
rone = input("What is the length of the first side? ")
rtwo = input("What is the length of the second side? ")
answer = int(rone)*int(rtwo)
print(answer)
elif shape=='t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.