blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
78a6692323c23224843718e96be5991a39cca86d | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/TinaB/lessonTwo_TB/FizzBuzz.py | 1,153 | 4.3125 | 4 | # Goal:
# Write a program that prints the numbers from 1 to 100 inclusive.
# But for multiples of three print “Fizz” instead of the number.
# For the multiples of five print “Buzz” instead of the number.
# For numbers which are multiples of both three and five print “FizzBuzz” instead.
# Fizzbuzz to 100
def fizzbuzz(... | true |
04c2d0a0d8be7b9ad2db4ae0ee4b001c1e6b5ecc | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Sean_Tasaki/Lesson3/strformat_lab.py | 1,638 | 4.5 | 4 | """
Sean Tasaki
5/10/2018
Lesson03.strformat_lab
"""
def task_one():
tuple1 = (2, 123.4567, 10000, 12345.67)
results = 'file_{:0>4d} : {:3.2f} , {:.2e} , {:03.2e}'.format(*tuple1)
print("Task One results:")
print(results)
def task_two():
results = ('file_0002', 123.46, 1.00e+04, 1.23... | false |
9aef7bd624c31ca29c7ea9ef05178381e9e8c0d6 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/ian_letourneau/Lesson03/slicing_lab.py | 1,825 | 4.40625 | 4 | #!/usr/bin/env python3
# Ian Letourneau
# 4/26/2018
# A script with various sequencing functions
def exchange_first_last(seq):
"""A function to exchange the first and last entries in a sequence"""
return seq[-1:] + seq[1:-1] + seq[:1]
def remove_every_other(seq):
"""A function to remove every other entr... | true |
6674a268183ec7ca465b28e57ba8b49e1ab8546c | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/AurelPerianu/Lesson4/trigrams.py | 2,662 | 4.5 | 4 | #!/usr/bin/env python3
# Lesson 4 - Trigrams
import random
import string
def main_fct():
#input_file = input("Please enter the name of a file (with extension):\n")
input_file='sherlock_small.txt'
with open(input_file, 'r') as f:
text = f.read()
#remove unprintable characters
filter(lambda x... | true |
da5e4f291652ac9ade4aa67d9932e20c79fc47e7 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Dennis_Coffey/lesson03/list_lab.py | 2,920 | 4.28125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 5 21:07:54 2018
@author: denni
"""
"""Lesson 3 - List Lab assignment - Series of 4 steps modifying a list of fruits"""
#Series 1:
#Create list of fruits
fruits = ['Apples','Pears','Oranges','Peaches']
print(fruits)
#Copy original fruits list for ... | true |
23ff6a6c03b18dacce7e2262092f331ed56f6f5b | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/carlos_novoa/lesson03/list_lab.py | 2,955 | 4.125 | 4 | #!/usr/bin/env python3
"""
Lesson3, List Lab Excercises
"""
def is_int(str):
"""Helper function to check that input can be cast into int"""
try:
int(str)
return True
except ValueError:
return False
def series1():
print("::: Series 1 :::::::")
# print intial list
fru... | true |
9454d2775fbfff92a7abd259490189e8280430e3 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/stefan_lund/Lesson_2/series.py | 1,585 | 4.3125 | 4 | # python3
# series.py
# functions to produce Fibonacci and Lucas number series
def fibonacci(n):
"""
recursively computes the n'th value in the Fibonacci serie:
0, 1, 1, 2, 3, 5, 8, 13, ...
"""
if n == 0 or n == 1:
return n
else:
return fibonacci(n - 1) + fibon... | false |
0e8b5ff1fc9c1bcb1d0bf2260afc794c997ef982 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/mark_luckeroth/lesson03/list_lab.py | 1,791 | 4.15625 | 4 | #!/usr/bin/env python3
#series 1
list1 = ['Apples','Pears','Oranges','Peaches']
print(list1)
add_fruit = input("Please input the name of a fruit to add to the list: ")
list1.append(str(add_fruit))
print(list1)
while True:
list_position = input("Enter a number between 1 and 5 to select a fruit from the list: ")
... | true |
53c6eb5356e7537754f45f0e4babf3457d0a8641 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Craig_Morton/lesson08/Circle.py | 2,109 | 4.1875 | 4 | # ------------------------------------------------- #
# Title: Lesson 8, pt 1/2 Circle
# Dev: Craig Morton
# Date: 9/23/2018
# Change Log: CraigM, 9/23/2018, pt 1/2 Circle
# ------------------------------------------------- #
from math import pi
from functools import total_ordering
import random
import time
@tota... | true |
5a7a6bf9fe258e1fdbf0009b0f08883ea90731ee | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/luyao_xu/lesson04/trigrams.py | 2,102 | 4.1875 | 4 | import random
def read_file(filename):
"""
Read file into a new list of words
:param f: filename
:returns: read file
"""
with open(filename, 'r') as f:
text = f.read()
return text
def trigram_dict(s):
"""
set up a trigram dictionary
:param s:the split word
:pa... | true |
818f6cb4660de46b9a0f1f282b08298a097ea508 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/smckellips/lesson08/circle.py | 1,843 | 4.125 | 4 | #!/usr/bin/env python
import math
class Circle(object):
def __init__(self, radius):
self._radius = float(radius)
def get_radius(self):
return self._radius
def get_diameter(self):
return self._radius * 2
def set_diameter(self,diameter):
self._radius = float(diameter /2)
... | false |
0d515d74112d4d194e16552c9b480226aaba161e | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Craig_Morton/lesson03/strformat_lab.py | 2,578 | 4.15625 | 4 | # ------------------------------------------------- #
# Title: Lesson 3, pt 3/4, String Formatting Exercise
# Dev: Craig Morton
# Date: 8/20/2018
# Change Log: CraigM, 8/20/2018, String Formatting Exercise
# ------------------------------------------------ #
# !/usr/bin/env python3
def first_task():
"""First... | false |
48e5ee6bcb8c0c9fb10f54fd96f4e96e9056a5f4 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/ChelseaSmith/Lesson2/series.py | 1,524 | 4.34375 | 4 | def fibonacci(n):
if n == 0: # initializes the series
return 0
elif n == 1:
return 1
else:
return fibonacci(n-2) + fibonacci(n-1) # function recursion to calculate values beyond the first two
def lucas(n):
if n == 0: # initializes the series
return 2
elif n == 1:... | true |
499e0dfc7e4970bea55e30cbd0c29c4036b9ecd1 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Wieslaw_Pucilowski/lesson03/list_lab.py | 1,960 | 4.21875 | 4 | #!/usr/bin/env python3
__author__ = "Wieslaw Pucilowski"
# Series 1
fruits=["Apples", "Pears", "Oranges", "Peaches", "Pineapples"]
list_fruits=fruits
print("List of fruits:")
print(list_fruits)
list_fruits.append(input("What fruit would you like to add to the list: "))
print("List of fruits:")
print(list_fruits)
p... | false |
dd7882ce1afedab638dc354fa42ffb62c3903f74 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/csdotson/lesson08/circle.py | 2,014 | 4.53125 | 5 | #!/usr/bin/env python3
import math
class Circle:
"""Create a Circle class representing a simple circle"""
def __init__(self, radius):
if radius < 0:
raise ValueError("radius can't be less than 0")
self._radius = radius
@property
def radius(self):
return self._radiu... | true |
093e571055ae258dd05a5c4aa608fd79683f1815 | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/rgpag/lesson04/trigrams.py | 1,570 | 4.1875 | 4 | #!/usr/bin/env python3
import random
# txt file to be used
text_in = 'sherlock_full.txt'
with open(text_in) as f:
msg = f.read()
# manipulate text file to be more trigram friendly
string = msg.lower()
string = string.replace("\n", " ")
string = string.replace("--", " ")
string = string.replace("-", " ")
spl_stri... | false |
7886724d68b0a852164116395ed4b8af843d916e | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/Sahlberg/Lesson8/Circle.py | 1,826 | 4.375 | 4 |
class Circle(object):
"""For manipulating circles"""
import math as m
def __init__(self, radius):
"""Initialize radius"""
self._radius = radius
@property
def radius(self):
"""radius property"""
return self._radius
@property
def diameter(self):
"... | false |
c90f77973cf02908e094e2609026fb9ec39eab1b | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/TressaHood/lesson04/dict_lab.py | 1,331 | 4.15625 | 4 | #!/usr/bin/env python3
# Activity 1 Dictionary and Set lab
def main():
# Dictionaries 1
# create a dictionary
d = {"name": "Chris", "city": "Seattle", "cake": "Chocolate"}
print(d)
# remove last item
d.pop("cake")
print(d)
# add new item
d["fruit"] = "Mango"
print(d)
#... | true |
192fabca7fb01a38c0bad5f30ed010c6330c0d6c | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/srepking/Lesson04/kata.py | 1,779 | 4.1875 | 4 | import random
trigram = {}
# Read in a file line by line and create a dictionary of trigrams.
string_words = ''
with open('sherlock.txt', 'r') as from_file:
for line in from_file:
word = ''
for char in line:
if char.isalpha():
word += char.lower()
else:
... | true |
a1d4b01c4e9369f66536905d2eaee6bba29bc6bf | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/AurelPerianu/Lesson3/string_lab.py | 1,433 | 4.34375 | 4 | #!/usr/bin/env python3
#string formatting
#task1
# Write a format string that will take the following four element tuple:
tuple1 = (2, 123.4567, 10000, 12345.67)
# and format it
formatted1= 'file_{0:03d}: {1:.2f}, {2:.2e}, {3:.2e}'.format(*tuple1)
# results: 'file_002 : 123.46, 1.00e+04, 1.23e+04'
print (formatted1... | false |
e2df6228ccc92fe905762ff250f2e235e6cde07f | Shubh250695/Python-modules | /M01.py | 1,197 | 4.34375 | 4 | # write a Python program to read data from a file which has text containing emails,
# write only the emails from the file into another file.
# You can use 're' module to extract emails from the text file.
import re
fileToRead = 'Sample01.txt'
fileToWrite = 'Output01.txt'
delimiterInFile = [',', ';']
def ... | true |
2646cdfc686be5545fa88d83ab336baa9f71a3e1 | L1ves/pythonNaPrimere | /empty_list.py | 1,534 | 4.25 | 4 | #empty_list.py
"""
Создайте пустой список с име-
нем nums. Предложите поль-
зователю последовательно
вводить числа. После ввода
каждого числа добавьте его
в конец списка nums и вы-
ведите список. После того как
пользователь введет три числа,
спросите, хочет ли он оставить
последнее введенное число
в списке. Если польз... | false |
356e403b4bff5a5e92fc596a80ce1e7f1a17d1b3 | xurror/365-days-of-code | /projects/Classic_Algorithms/closest_pair_problem.py | 1,030 | 4.15625 | 4 | from math import pow, sqrt
#calculate the distance between 2 points
def distance(tuple1, tuple2):
x1, y1 = tuple1[0], tuple1[1]
x2, y2 = tuple2[0], tuple2[1]
d = pow((x1 - x2), 2) + pow((y1 - y2), 2)
d = sqrt(d)
return d
def createPoint(x, y):
point = ()
"""point.append"""
def compareDist... | false |
9796ce2512388ee195f7283fa67b6c69f1363dc6 | ragulkesavan/python-75-hackathon | /RECURSION/recursion.py | 406 | 4.15625 | 4 | '''PROBLEM: Calculate the total number of possible squares in a chess board of n*n size (n is got from user)'''
def chess(n):
if n==1:
return 1
else :
return (n*n)+chess(n-1)
n=int(input("give the n-chess board size : "))
print("\nthe chess board has "+str(chess(n))+" possible squares")
'''
OUT... | true |
4f881d4928f10da1ead7e189b60e6b24fed50c4a | ragulkesavan/python-75-hackathon | /TUPLES/tuple.py | 1,513 | 4.5 | 4 | #tuples
'''TUPLES ARE UNCHANGABLE ORDERED COLLECTION OF DATA VALUES
ONCE TUPLES ARE CREATED NEW VALUES CANNOT BE ADDED,EXISTING VALUES CANNOT BE
DELETED OR RE-ORDERED OR CHANGED
TUPLES ARE REPRESENTED USING ROUND BRACES () INBETWEEN VALUES ARE SEPERATED BY COMMA
TUPLES ARE IMMUTABLE'''
#TUPLE CREATION... | true |
c63fffe0abbdf509e9cd70df059b1aee770ffed5 | ragulkesavan/python-75-hackathon | /INHERITANCE/hybrid_inheritance.py | 1,454 | 4.4375 | 4 | #MULTIPLE INHERITANCE
#When a child class inherits from multiple parent classes, it is called as multiple inheritance.
class orders:#DEFINITION PARENT CLASS
l=[]
def order(self):
product_name=input("enter the name of product : ")
quantity=int(input("enter the quantity of product : "))
a... | true |
cae545f616c84d80dfad4a056af570cee0f7e3fb | ericgtkb/design-patterns | /Python/TemplateMethod/HouseBuilder/house.py | 1,052 | 4.1875 | 4 | import abc
class House(abc.ABC):
def build_house(self):
# Can be set as final in python 3.8 using the final decorator
self.build_foundation()
self.build_pillars()
self.build_walls()
self.build_windows()
print('The house is built!')
def build_foundation(self):
... | true |
a0c07a217df2219053dd65579c8eaa88af670eae | carlson9/python-washu-2014 | /day1/class1.py | 373 | 4.15625 | 4 | def is_triangle(first, second, third):
lengths = sorted([first,second,third])
if lengths[2] <= lengths[0]+lengths[1]:
print "Yes"
else: print "No"
def prompt():
first = int(raw_input("Input first side: ",))
second = int(raw_input("Input second side: ",))
third = int(raw_input("Input thi... | true |
d3dde4521bea8c8385cc0dc12a8ad01351c199d6 | carlson9/python-washu-2014 | /assignment1/school.py | 1,534 | 4.3125 | 4 | class School():
def __init__(self, school_name): #initialize instance of class School with parameter name
self.school_name = school_name #user must put name, no default
self.db = {} #initialize empty dictionary to store kids and grades
def add(self, name, student_grade): #add a kid to a... | true |
f33052966054b29233e4301dac759c420d324953 | magnusjacobsen/algopy | /sorting/mergesort.py | 1,133 | 4.28125 | 4 | '''
Mergesort
- first the list is recursively divided down to pairs of 2
- then sorts those pairs, and then
- merges all the pairs until the entire list is mergesorted
'''
def sort(a, inplace=True):
if not inplace:
a = list(a)
n = len(a)
aux = [None] * n
rec_sort(a, aux, 0, n - ... | false |
42270d36edde93effd9f08251a53bef71acb341c | agodi/Algorithms | /Python/TreeCommonAncestor.py | 248 | 4.25 | 4 | def appendsums(lst):
"""
Repeatedly append the sum of the current last three elements of lst to lst.
"""
for i in range(25):
aux = lst[-1] + lst[-2] + lst[-3]
lst.append(aux)
print(lst[20])
appendsums([0, 1, 2]) | true |
13478c287305f67d016828532cc7f5d44fcdcbec | AJohnson24/CodingPractice | /DailyCodingProblem/10.py | 585 | 4.21875 | 4 | #!/usr/bin/env python3
# Good morning! Here's your coding interview problem for today.
# This problem was asked by Apple.
# Implement a job scheduler which takes in a function f and an
# integer n, and calls f after n milliseconds.
import time
import sys
def scheduler(f, n):
print(f"waiting {n} milliseconds")
time.... | true |
51f660859a5a037a94e9d2abe4c108adcfad35c1 | KojoBoat/Global-code | /while_loop.py | 853 | 4.25 | 4 | #while loops
#i=6
#while(i < 19):
## i += 1
# print (i)
# i = 13
# print ("Even numbers between 12 and 20 \n# i = 13
# print ("Even numbers between 12 and 20 \n")
# while (i < 20):
# if i % 2 == 0:
# print(i)
# i = i + 1")
# while (i < 20):
# if i % 2 == 0:# i = 13
# print ("Even numbers between 1... | false |
88df0b5d81710743a62ed140443aded52ae5ceda | enriqueboni80/puc-python-exercicio_01 | /exercicio1.py | 1,303 | 4.3125 | 4 | from collections import deque
print("")
print("-----------------")
print("")
print("Enrique Bonifacio")
print("")
print("Exemplo de Lista:")
thislist = {"apple", "banana", "cherry"}
print(thislist)
print("")
print("Exemplo de Tuplas:")
thistuple = ("apple", "banana", "cherry")
print(thistuple)
print("")
print("exemp... | false |
66ca1583771051ee8a700364e081cf06025c9670 | mejn0ur/novetres | /cosseno_angulo.py | 1,229 | 4.21875 | 4 | #Este programa calcula o cosseno de um angulo
#lido atraves do TGT - Teorema Geral da Trigonometria
#Antes de tudo, importamos a biblioteca math
import math
print 'Entre com o angulo cujo cosseno calcularemos:'
angulo = float(raw_input('> '))
print 'O resultado pode obtido de 3 maneiras:'
print ' '
print '1. Calcul... | false |
7626d15bb5d26ad5b39034b4e74f1eb0e7cfe865 | mejn0ur/novetres | /le_imprime_matriz.py | 610 | 4.1875 | 4 | #programa recebe numeros de uma matriz e retorna a matriz
print 'Este programa recebe uma matriz e imprime-a.'
print ''
matriz = []
linha = []
print 'Entre com a quantidade de linhas:'
lin = int(raw_input('-> '))
print 'Entre com a quantidade de colunas:'
col = int(raw_input('-> '))
print 'E agora a matriz.'
for ... | false |
558ffc3400d66cf7dca027ac72850387a047fe2e | lephdao/cracking-coding-interview | /Array and String/length_of_longest_substring.py | 980 | 4.1875 | 4 | '''
Given a string s, find the length of the longest substring without repeating characters.
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
'''
def lengthOfLongestSubstring(s):
if len(s) == 1:
return 1
if s == "" or s == " ":
retur... | true |
6a9b1dcf902cd8beac2fdb728539bd21ddba9bfc | mambalong/Algorithm_Practice | /SlidingWindow/0438_findAnagrams.py | 1,430 | 4.125 | 4 | '''
438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
Strings consists of lowercase English letters only and the length of both strings s and p will not
be larger than 20,100.
The order of output does not matter.
Example 1:
Input:
s: "cb... | true |
0c06db606ee0ab3899b3ccc506113b8b88dbc273 | xsong15/codingbat | /list-1/sum3.py | 223 | 4.15625 | 4 | def sum3(nums):
"""
Given an array of ints length 3, return the
sum of all the elements.
"""
return sum(nums)
print(sum3([1, 2, 3])) #→ 6
print(sum3([5, 11, 2])) #→ 18
print(sum3([7, 0, 0])) #→ 7 | true |
138e492317b185f0b17e6d04635ff21b27c20e11 | adamcfro/practice-python-solutions | /fibonacci.py | 335 | 4.21875 | 4 | def fib_nums():
new_nums = 'yes'
while new_nums == 'yes':
number = int(input("How many Fibonacci numbers would you like to generate?: "))
a = 0
b = 1
for num in range(1, number + 1):
print(a)
a, b = b, a + b
new_nums = input("More nums? (yes or no)... | true |
3fcd80f1586f84ecb5ec40bd82f323c87c8e61de | PedroRgz/Sesiones-Python | /generadores.py | 783 | 4.15625 | 4 | '''
Son estructuras que extraen valores de una función
Se almacenan de uno en uno
Cada vez que se genera, se mantiene en un estado pausado
hasta que se solicita el siguiente --> Susp de estado
sustituye el 'return' de una funcion por 'yield' que
construye un objeto iterador
def numspares():
.
.
.
yield... | false |
5a0e316aa72b56a5e6f503a8b152ddb689076640 | jviray/python-practice | /factorial.py | 311 | 4.125 | 4 | """
Write a function that takes an integer `n` as an input;
it should return n*(n-1)*(n-2)*...*2*1. Assume n >= 0.
As a special case, `factorial(0) == 1`.
Difficulty: easy.
"""
def factorial(n):
factorial = 1
if n >= 1:
for i in range(2, n + 1):
factorial *= i
return factorial
print(factorial(7)) | true |
14fd536ebf075902e093ce736c61be10642f506a | brinsga/python-bootcamp | /Day_1/HW01_ch05_ex03.py | 2,593 | 4.625 | 5 | #!/usr/bin/env python
# HW02_ch05_ex03
# If you are given three sticks, you may or may not be able to arrange them in
# a triangle. For example, if one of the sticks is 12 inches long and the other
# two are one inch long, it is clear that you will not be able to get the short
# sticks to meet in the middle. For any t... | true |
f7ef8a44f33ee7ebbd587d5e1f4db2b171df3ac5 | MahaLakshmi0411/Circle | /area.py | 316 | 4.15625 | 4 | pi=3.14
r=float(input("Enter the radius of a circle:"))
area=pi*r*r
print("The area of the circle is =%.2f"%area)
i = input("Input the Filename: ")
extns =i.split(".")
# repr() function is used to returns a printable representation of a object(optional)
print ("The extension of the file is : " + repr(extns[-1]))
| true |
2230a476c21238983cd77a4760c17a532ee8b1af | hifra01/is_fibonacci | /isFibonacci.py | 520 | 4.375 | 4 | isFibonacci = int(input("Input number = "))
fibNum = 1
container1 = 0
container2 = 0
while fibNum < isFibonacci:
container2 = container1
container1 = fibNum
fibNum = container1 + container2
if isFibonacci == fibNum:
print(isFibonacci,"is a fibonacci number")
print("Previous fibonacci number is", con... | false |
7dcf4aebff94e3c2ffce8b9ca6a3c9f5e3884cfa | loghmanb/daily-coding-problem | /facebook_ways_to_detect.py | 1,837 | 4.125 | 4 | '''
Ways to Decode
Asked in: Facebook, Amazon
https://www.interviewbit.com/problems/ways-to-decode/
A message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given an encoded message containing digits, determine the total number of ways to decode i... | true |
95378c4ed795ff4814cc9251f59ba6b32cdbdf25 | loghmanb/daily-coding-problem | /problem050_microsoft_eval_tree.py | 1,046 | 4.3125 | 4 | '''
This problem was asked by Microsoft.
Suppose an arithmetic expression is given as a binary tree. Each leaf is an integer and each internal node is one of '+', '−', '∗', or '/'.
Given the root to such a tree, write a function to evaluate it.
For example, given the following tree:
*
/ \
+ +
/ \ / \
... | true |
06f8fef593620ee02a121393ca57c85423822d93 | loghmanb/daily-coding-problem | /problem049_amazon_max_sum_contiguous_sub_arr.py | 963 | 4.21875 | 4 | '''
This problem was asked by Amazon.
Given an array of numbers, find the maximum sum of any contiguous subarray of the array.
For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since we would take elements 42, 14, -5, and 86.
Given the array [-5, -1, -8, -9], the maximum sum would... | true |
8657a264fe128c104278cae2f6270143b4e0a872 | loghmanb/daily-coding-problem | /facebook_max_sum_contiguous_subarray.py | 1,563 | 4.15625 | 4 | '''
Max Sum Contiguous Subarray
https://www.interviewbit.com/problems/max-sum-contiguous-subarray/
Asked in: Facebook, Paypal, Yahoo, Microsoft, LinkedIn, Amazon, Goldman Sachs
Find the contiguous subarray within an array, A of length N which has the largest sum.
Input Format:
The first and the only argument contai... | true |
2266a9a8f7f860f613deb4b683e36ad84082fdb0 | loghmanb/daily-coding-problem | /google_pascal_triangle.py | 1,127 | 4.25 | 4 | '''
https://www.interviewbit.com/problems/pascal-triangle/
Pascal Triangle
Asked in: Google, Amazon
Given numRows, generate the first numRows of Pascal’s triangle.
Pascal’s triangle : To generate A[C] in row R, sum up A’[C] and A’[C-1] from previous row R - 1.
Example:
Given numRows = 5,
Return
[
[1],
... | false |
f7bbb5526b0bd0c24148857ddb37b37078dd72f8 | loghmanb/daily-coding-problem | /problem065_amazon_print_clockwise.py | 1,822 | 4.3125 | 4 | '''
This problem was asked by Amazon.
Given a N by M matrix of numbers, print out the matrix in a clockwise spiral.
For example, given the following matrix:
[[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]]
You should print out the following:
1
2
3
4
5
10
15
20
19
18
17
16
1... | true |
85083b4f2cf7e2f2f6efb458d9e068962bf27824 | loghmanb/daily-coding-problem | /problem037_google_power_set.py | 763 | 4.59375 | 5 | '''
This problem was asked by Google.
The power set of a set is the set of all its subsets. Write a function that, given a set, generates its power set.
For example, given the set {1, 2, 3}, it should return {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}.
You may also use a list or array to represent a set.
... | true |
553ee8e48c3c2a5be6ed0bcdc5d8fd05c7a417be | 100121358/1CodesAndStuffs | /1CodesAndThings.py | 1,132 | 4.375 | 4 | # Strings
# data that falls within " " marks
# concatenation
# put 2 or more strings together
firstName = "Fred"
lastName = "Flintstone"
print(firstName + " " + lastName)
fullName = firstName + " " + lastName
print(fullName)
# repitition
# Repitition operator: *
print("Hip"*2 + "Hooray!")
def rowYourBoat():... | true |
59fef44ab945a24868c77d7f12e0f369b1372589 | ivoree/egg-order | /egg-order.py | 1,884 | 4.25 | 4 | #14/2/21
#Ivory Huang
#Egg order program
#V1a: create loop in get_orders function to get customers names and egg num
#functions
def get_orders(names, egg_order):
#Collects order information - name, number of eggs – in a loop. Store in 2 lists.
#Call read_int function to ensure you have a valid input
... | true |
f80812eb080aa10ee3a00ade642c68d46a0d4888 | mchen06/python_class_code | /python_projects/bubble_sort.py | 735 | 4.1875 | 4 | list = [3, 4, 1, 1, 8]
def bubble_sort(list):
# sorts in place
length_list = len(list) - 1
comparisons = 0
x = 0
has_swaped = True
while has_swaped != False:
has_swaped = False
y = 0
while y < length_list - x:
comparisons = comparisons + 1
if list... | true |
5a959eada00b487a4bc1d5037d1a2dbd90da3b43 | l200170083/prak_ASD_C | /Modul_8(2)_C/modul8(2).py | 1,874 | 4.15625 | 4 | print ("================NOMOR1=====================")
class Queue():
def __init__(self):
self.qlist = []
def is_empty(self):
return len(self) == 0
def __len__(self):
return len(self.qlist)
def enqueue(self, data):
self.qlist.append(data)
def dequeue(self):
... | false |
f258d3be7157102100bc3d285a9465c4814bb969 | erobic/neural_networks | /src/simple_network.py | 2,875 | 4.15625 | 4 | import numpy as np
'''
A simple neural network with single hidden layer
'''
# Even no. of 1s = 1
training_data = np.array([
[[0, 0, 1], 0],
[[0, 1, 1], 1],
[[1, 0, 1], 1],
[[1, 1, 1], 0]
])
def sigmoid(z):
return 1.0/(1.0+np.exp(-z))
def sigmoid_deriv(z):
return z*(1-z)
def feedforwa... | true |
2044dc4a1fd7d4d5481887b73813340e3913b1f8 | sabinbhattaraii/python_assignment_2 | /q12.py | 379 | 4.28125 | 4 | '''
Create a function, is_palindrome, to determine if a supplied word is
the same if the letters are reversed
'''
def is_palindrome(string):
string = string.lower()
if list(string) == list(reversed(string)):
return 'The word is palindrome'
else:
return 'The word is not palindrome'
string ... | true |
3131eb96e58ff19f85cdd910f3006dc398258192 | sabinbhattaraii/python_assignment_2 | /q15.py | 831 | 4.28125 | 4 | '''
Imagine you are designing a banking application. What would a
customer look like? What attributes would she have? What methods
would she have?
'''
class Bank():
def __init__(self):
self.amount = int(input('Enter the amount of money you have'))
def deposite_money(self,money):
self.amount = ... | true |
e70dad15bd76770a61a3fa89ee41deb499ce3ac9 | tejasgondaliya5/basic-paython | /basicpython/classandobject.py | 1,168 | 4.1875 | 4 | class Student: # Student is class but "S" is capital is good practice but not compulsory
pass
raj = Student() # harry and larry is object
ravi = Student()
raj.std = 12 # harry.std and harry.name is instance variable
raj.name = "raj"
ravi.std = 10
print(raj, ravi)
print(raj.name, ravi.std)
class Employe:... | false |
de09e332925a88e8a5cf342e5584d7470b91adee | guimevn/exerciciosPythonBrasil | /01_estruturaSequencial/ex017.py | 1,432 | 4.25 | 4 | import math
"""Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada
Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em latas de
18 litros, que custam R$ 80,00 ou em galões de 3,6 litros, que custam R$ ... | false |
063377c9c9f5351c6543df8c413b961462cb962d | pattypmx/def | /22.文件的相关操作.py | 730 | 4.1875 | 4 | # 有些时候,需要对文件进行重命名、删除等一些操作,python的os模块中都有这么功能
# 重命名
import os
# os.rename("wenzi1.txt", "wenzi11.txt")
# 创建文件
# p = open("haha.txt", "w")
# 删除文件
# os.remove("word3.txt")
# ----------------------------
#创建文件夹
# os.mkdir("helloword")
# os.mkdir("helloword.txt")
# 删除文件夹
# os.rmdir("helloword.txt")
# -----------------... | false |
9c2cda88ea275dc3a96287da6978c46346a8ec77 | IvanShamrikov/COURSES---INTRO-PYTHON | /Lesson1 - INTRO/Homework_Lesson1.py | 1,595 | 4.25 | 4 | #1. Дано два числа (a=10, b=30). Вывести на экран результат математического взаимодействия (+, -, *, / ) этих чисел.
print('Task 1')
print('----------------')
a = 10
b = 30
print("a + b =", a + b)
print("a - b =", a - b)
print("a * b =", a * b)
print("a / b =", a / b)
print("\n")
#2. Создать переменную и за... | false |
e4fded88028d58bc84e851f7f7beb73bf77a1c16 | George-Went/Gwent-Library-Python | /Basic_Programs/Lists.py | 360 | 4.40625 | 4 | myList = []
myList.append(1)
myList.append(2)
myList.append(3)
print(myList[0])
print(myList[1])
print(myList[2])
for x in myList:
print(x)
numbers = [1 ,2, 3]
strings = ["Hello", "World"]
names = ["John", "Eric", "Jessica"]
third_name = names[2]
print(numbers)
print(strings[0] + " " + strings[1])
print("the th... | true |
66722612187059f5314c74126251ed099d795a69 | vedantnanda/Python-and-ML | /18_5_18/LA12.py | 264 | 4.15625 | 4 | #LA12 Palindrome Check
#Accept a string and check if string is palindrome or not
s1 = str(input("Enter String: "))
if len(s1)==0:
print("Empty String")
else:
s2 = s1[::-1]
if s1==s2:
print("Palindrome")
else:
print("Not Palindrome") | false |
84a7cc036543f618ddead85d792824b5df491722 | vedantnanda/Python-and-ML | /17_5_18/HA11.py | 840 | 4.125 | 4 | #Calculator using function
#HA11
def addit(a,b):
return(a+b)
def subit(a,b):
return(a-b)
def mulit(a,b):
return(a*b)
def divit(a,b):
return(a/b)
print("Calculator using function")
n1 = float(input("Enter first number: "))
n2 = float(input("Enter second number: "))
ch = str(input("Enter choice(A:Addition,S:Substrac... | false |
29aa9354e288bc5a8fda963839123c01f0164083 | Ge0dude/AlgorithmsCoursera | /Course1/week5/coinChanging.py | 912 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 19 17:41:48 2017
@author: brendontucker
using this as an example to better understand dynamic programming
lets do some debugging with print statements
"""
coinValueList = [1, 5, 21, 25]
change = 63
minCoins = [0 for x in range(change + 1)]
for ce... | true |
4ad1559ebb5ec35f73ece414489f4154323cb2eb | LookerKy/Python-Advanced | /src/Section02-01.py | 2,454 | 4.21875 | 4 | # Section02-01
# Python Advanced
# 데이터 모델
# 참조 : https://docs.python.org/3/reference/datamodel.html
# Namedtuple 실습
# 파이썬의 중요한 핵심 프레임워크(data type) -> 시퀀스(Sequence) 반복(Iterator) 함수(Function) 클래스(Class)
# 객체 -> 파이썬의 데이터를 추상화
# 모든 객체 -> id 와 type 을 가지고있음
# 일급 객체
# 일반적인 튜플 사용
from math import sqrt
from collections import... | false |
13350ab70b8a45e5fb64723aff3020cbc612e476 | zzh730/LeetCode | /String/Multiply Strings.py | 673 | 4.1875 | 4 | __author__ = 'drzzh'
'''
python占便宜的一种方式
'''
class Solution:
# @param {string} num1
# @param {string} num2
# @return {string}
def multiply(self, num1, num2):
return str(int(num1) * int(num2))
'''
面试碰到应该用如下方法:小学乘法的实现
Three Functions:
1.multiplyChar(string, char, nu... | false |
5cea1c6236e8cb3e55abac4ad64c38e12a8ce066 | zzh730/LeetCode | /Tree/preorder.py | 1,358 | 4.125 | 4 | __author__ = 'drzzh'
"""
都是非递归写法:
1。backtracking 如果左节点存在,入栈,访问,不存在,出栈,访问右节点,注意终止条件,stack空了要停止循环
2. 根节点出栈,然后如果有右节点就入栈,如果有左节点就入栈
3. 一定注意在else后检查stack是否为空
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
tree = TreeNode(1)
tree.left = ... | false |
b9c5a6d08e004c566ca2e69051c4a9a8b39dd6df | fionacahill/greenpepper | /PBJ.py | 993 | 4.125 | 4 | bread = 7
jelly = 4
pb = 4
if bread>=2 and jelly>=1 and pb>=1:
print "You can have lunch today"
else:
print "No sandwich for you"
if bread>=2 and jelly>=1 and pb>=1:
sandwich=bread/2
if pb<sandwich:
sandwich = pb
if jelly<sandwich:
sandwich = jelly
print sandwich
print "I can make {0} sandwiches".for... | true |
f63945f0d5bd465b57d4c5c40329d43adcf558b5 | tacolim/Python_Algorithms | /palindrome.py | 1,547 | 4.28125 | 4 | """
Return true if the given string is a palindrome. Otherwise, return false.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everyth... | true |
5c2a152bbcd04b82732e987e1dd9a57ce1115283 | Dagmoores/PythonStudies | /Projeto_Integrador_Estudos/problema_pratico3-8.py | 342 | 4.125 | 4 | # Retirado do livro Introdução à Computação em Python - Um Foco no Desenolvimento de Aplicações - PERKOVIC, Ljubomir
# Defina, diretamente no shell interativo, a função média(), que aceita dois números como entrada e retorna a média dos números. Um exemplo de uso é: >>> average(2, 3.5) 2.75
def f(x, y):
return (x +... | false |
583b23baececfe4afddd9f1c1706e3580772a49b | Dagmoores/PythonStudies | /Projeto_Integrador_Estudos/problema_pratico3-2.py | 1,353 | 4.125 | 4 | #Retirado do livro Introdução à Computação em Python - Um Foco no Desenolvimento de Aplicações - PERKOVIC, Ljubomir
#Traduza estas instruções condicionais em instruções if do Python:
#(a)Se idade é maior que 62, exiba 'Você pode obter benefícios de pensão'.
#(b)Se o nome está na lista ['Musial', 'Aaraon', 'Williams'... | false |
c2a89bfcd011d2a3931e6d1522183f75ac191103 | angel-robinson/validadores-en-python | /#converssores_booleano.py | 864 | 4.125 | 4 | #conversores tipo booleano
#convertir la cadena "3" a booleano
x="3"
a=bool(x)
print(a,type(a))
#convertir la cadena "angel" a booleano
x="angel"
a=bool(x)
print(a,type(a))
#convertir la cadena "38" a booleano
x="38"
a=bool(x)
print(a,type(a))
#convertir el enetero 8 a booleano
x=8
a=bool(x)
print(a,typ... | false |
5c915b4c2b6055fcd9c1911611a4f57f9612bb40 | ramprasadgk/PhilosophyOfPython | /BubbleSort.py | 577 | 4.25 | 4 | print ('begin')
def bubblesort(U):
swapped = False
for i in range(len(U)):
swapped = False
for j in range(len(U)-1-i):
if(U[j] > U[j+1]):
U[j],U[j+1]= U[j+1],U[j]
print ("swapped ",U[j], 'and',U[j+1])
swapped = True
pri... | false |
3153f620619967c90783491238477c39e681af7b | TMFrancis/Lecture4 | /main.py | 427 | 4.15625 | 4 | # Lecture 4
# September 1, 2021
# Turtle library
import turtle
turtle.color("black", "red")
turtle.begin_fill() #start process
turtle.circle(75) #
turtle.end_fill()
def draw_square(t, sz):
for i in range(6):
t.forward(sz)
t.left(60)
wn = turtle.Screen()
wn.bgcolor("lig... | false |
adafb62d7438f44a424023a65aad35dba4462934 | KanchanRana/Information_Security | /IS_A_1_Additive_cipher.py | 2,452 | 4.625 | 5 | '''Ques 1. Write a program that can encrypt
and decrypt using the Additive Cipher.'''
#index of character is its value
alpha_list=['A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z']
''' encrypt_the_plain_text() is a fun... | true |
08d70a6c3d6f164d0302e90742b33317a69110cf | attapun-an/topscore-project | /simple.py | 1,026 | 4.40625 | 4 | """
OpenTopScore(fileName)
This function creates a new, empty, top score text file if it doesn't exist,
otherwise it opens the text file filename (string) and returns a list of the
contents
AddScore(name, score, filename)
This procedure takes 3 parameters, the name (string), score (integer) and
the top score filen... | true |
635809a3d18a8b4b7e3ac6fd46880b0a5a538a3a | karafede/pyhon_stuff | /app.py | 1,435 | 4.28125 | 4 |
print("Hello World")
print("/___|")
print(" /|")
print(" / |")
print(" / |")
# create variable
character_name = "George"
character_age = "50"
is_male = False
print("There was once a guy named " + character_name + ",")
print("he was" + character_age + " years old,")
character_name = "Tom"
print("he l... | false |
bb3fb7bf84f11dcb698b7928c1cc3536c65b879a | skyswordLi/Python-Core-Program | /Chapter2/sumAndAverage.py | 904 | 4.28125 | 4 | print "This script computes some values' summary and average."
print "------------------------------------------"
print "-------------Give your choice-------------"
print "---------1 means compute summary----------"
print "---------2 means compute average----------"
print "--------------X means quit---------------... | true |
95d854d4e9a5ef623d766e207875243b07bdaba3 | skyswordLi/Python-Core-Program | /Chapter6/change.py | 599 | 4.1875 | 4 | def upper_lower_change(my_str):
str_len = len(my_str)
output_str = ''
for i in range(str_len):
if my_str[i].isupper():
output_str += my_str[i].lower()
elif my_str[i].islower():
output_str += my_str[i].upper()
else:
output_str += my_str[i]
ret... | false |
1288376bdc72c3d0b1e8a8556f682b3a373cabbb | skyswordLi/Python-Core-Program | /Chapter2/sumOfArrayAndPuple.py | 896 | 4.125 | 4 | array = [1, 2, 3, 4, 5]
fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
print "-" * 40
print "Get summaries by calling sum function:"
print sum(array)
print sum(fibonacci)
print "-" * 40
arrayLen = len(array)
fibonacciLen = len(fibonacci)
print "-" * 40
print "Ger summaries by using while loop:"
sumArray = 0
sumFi... | false |
73499d8e0ded33f336ac4d610a15e367c08013ea | skyswordLi/Python-Core-Program | /Chapter5/score.py | 441 | 4.1875 | 4 | def grade(score):
assert 0 <= score <= 100, 'Wrong input score!'
if 90 <= score <= 100:
return 'A'
elif 80 <= score < 90:
return 'B'
elif 70 <= score < 80:
return 'C'
elif 60 <= score < 70:
return 'D'
elif 0 <= score < 60:
return 'F'
print "Please input y... | true |
d51a73e4e33d8fbd6e07e79fff740e03f26f2146 | Automedon/Codewars | /8-kyu/Return Two Highest Values in List.py | 621 | 4.34375 | 4 | """
Description:
In this kata, your job is to return the two highest values in a list, this doesn't include duplicates.
When given an empty list, you should also return an empty list, no strings will be passed into the list.
The return should also be ordered from highest to lowest.
If the argument passed isn't a lis... | true |
9faf9f52ef81370438c9192d23813b51c709659f | Tanja75/Python-tasks-solution | /String_reverse.py | 224 | 4.40625 | 4 | #Function that reverses the string:
def string_reverse(str1):
rstr1=""
index=len(str1)
while index>0:
rstr1 += str1[index -1]
index=index-1
return rstr1
print(string_reverse("python")) | true |
cd50c5bd3ec12122fceb23b80923b4c70e2ce725 | zangkhun/leepy | /search/LC22.py | 1,734 | 4.125 | 4 | """
22. 括号生成
给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。
例如,给出 n = 3,生成结果为:
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]
"""
# "括号约束"组合搜索模板
# 这里每个位置都有两种选择进行组合, 但同时又有全局约束.
# 注意与 lc784 的局部位置多可能性的"排列搜索"问题比较
# 剪枝条件的写法上, 第二种方法更为清晰
class Solution(object):
def generateParenthesis(self, n):
... | false |
d1b554548e9b76612436f55f7b86f41aa9af4f25 | dmlogv/hr-mgfn-automation | /gppl/py/e_sorter.py | 2,160 | 4.3125 | 4 | #!/usr/bin/env python
"""Сортировка людей"""
class Meat:
def __init__(self, name, age):
"""Данные людей
Args:
name (str): Имя
age (int): Возраст
"""
if not isinstance(name, str) or len == 0:
raise ValueError('name must be non-empty str')
... | false |
cbea9f3520e67d6b65d16f8b675f8e0268172b10 | legacy72/geek_brains_homeworks_examples_940 | /lesson_2/task_2.py | 662 | 4.1875 | 4 | """
Для списка реализовать обмен значений соседних элементов, т.е.
Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить
на своем месте. Для заполнения списка элементов необходимо использовать функцию input().
"""
l = input('Введите список значений через ... | false |
a9bf59670061c279655b0346b2cbfed251ec4934 | legacy72/geek_brains_homeworks_examples_940 | /lesson_3/task_3.py | 316 | 4.21875 | 4 | """
Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух
аргументов.
"""
def my_func(a, b, c):
return a + b + c - min([a, b, c])
print(my_func(1, 2, 3))
| false |
7bbae2705bd5b373eebfe106989fa73114d72580 | legacy72/geek_brains_homeworks_examples_940 | /lesson_2/task_4.py | 521 | 4.375 | 4 | """
Пользователь вводит строку из нескольких слов, разделённых пробелами. Вывести каждое слово с новой строки.
Строки необходимо пронумеровать. Если в слово длинное, выводить только первые 10 букв в слове.
"""
words = input('Введите слова через пробел: ').split()
for i, word in enumerate(words, 1):
print(f'{i}: {w... | false |
3f060b1e9dbb260ac6fa4b566d256110ad8cbf08 | legacy72/geek_brains_homeworks_examples_940 | /lesson_1/task_2.py | 503 | 4.4375 | 4 | """
Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс.
Используйте форматирование строк.
"""
time_in_seconds = int(input('Введите кол-во секунд: '))
minutes = time_in_seconds // 60
seconds = time_in_seconds % 60
hours = minutes // 60
minutes = minutes % 60
p... | false |
278d9eb16ebad5e515b87573022d396e05cce2f7 | taepd/study | /Machine Learning/수업 자료/1주차_파이썬 프로그래밍/제04일차/myArrSum.py | 344 | 4.15625 | 4 | # 리스트의 모든 요소들의 합을 구해주는 함수 arrsum
def arrsum(data):
total = 0
for item in data:
total += item
return total
mylist = [10, 20, 30]
result = arrsum(mylist)
print(result)
mydata = (1, 2, 3)
result = arrsum(mydata)
print(result)
myset = set((11, 22, 33))
result = arrsum(myset)
print(result) | false |
0519a64e3938b4f567b674acfc766372e0ef4e1f | Hank02/CodeEval | /easy/penultimate_word.py | 724 | 4.25 | 4 | # print next-to-last word of each input string
# each string has more than one word
import sys
# open file with comma-separated list of integers
def file_open():
# get inout file name as command line argument
in_file = sys.argv[1]
# open input file
test_cases = open(in_file, "r")
return test_cases... | true |
0bd64fedc0c0b0bf4e0e9f4c85ebb9f1539a1c4a | Hank02/CodeEval | /easy/longest_word.py | 698 | 4.375 | 4 | # print the longest word in a sentence
# if more than one, print the left-most one
import sys
def file_open():
# get inout file name as command line argument
in_file = sys.argv[1]
# open input file
test_cases = open(in_file, "r")
return test_cases
# funtion to print in title case
def longest_word... | true |
911c96d588df562ed190c1cf7b786441f5a78d62 | AnupreetMishra/creating-static-variable-oops- | /main.py | 675 | 4.21875 | 4 | class Student:
dept='BCA' #define class
def __init__(self,name,age):
self.name=name #instance variable
self.age=age #instance variable
#define the object of student class
stud1=Student('ANU', '22')
stud2=Student('ANKIT' , '19')
print(stud1.dept)
print(stud2.dept)
print(stud1.name)
pr... | true |
225e5540b6996e40ab5ee461b26aa46d7635975a | AreRex14/ppdtmr-python-training | /script-10.py | 1,927 | 4.125 | 4 | # Classes and Objects
# basic class
class ClassName(object):
"""docstring for ClassName"""
def __init__(self, arg):
super(ClassName, self).__init__()
self.arg = arg
class MyClass():
variable = "hello"
def function(self):
print("This is a message inside a class.")
myobjectx = MyClass() # ... | true |
1de9de90abb9edd40590ce6d6e3e32d98b5871bd | AlexMan2000/ICS | /Lectures/Lecture 6/quicksort_student.py | 750 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 6 20:05:43 2019
@author: xg7
"""
def quicksort(seq):
if len(seq) <= 1:
return seq
low, pivot, high = partition(seq)
return quicksort(low) + [pivot] + quicksort(high)
def partition(seq):
"""complete the function"""
pivo... | true |
ca9e6a0b79162a852a99c1b50db3e4586a1a35f1 | mohnoor94/CorePythonCourse | /28 - Lecture 19/module_01/math_helpers.py | 377 | 4.3125 | 4 | def multiply(num1, num2, *numbers):
"""
Multiply all values and return the result.
"""
result = num1 * num2
if len(numbers):
for num in numbers:
result *= num
return result
def avg(*numbers):
"""
Return the average of all numbers.
"""
... | true |
8975d1a0db28d952721747d232c7aa043106649e | orlewilson/lab-programacao-tin02s1 | /aulas/exemplo5.py | 1,518 | 4.25 | 4 | """
Disciplina: Laboratório de Programação
Professor: Orlewilson B. Maia
Autor: Orlewilson B. Maia
Data: 31/08/2016
Descrição: Exemplos com condições (if).
"""
"""
Sintaxe
if (condição):
bloco verdadeiro
else:
bloco falso
if (condição):
bloco verdadeiro
else:
if (condição):
bloco verdadeiro
if (condição):... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.