blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
649a147ef905bd7d163a9c1c5d48b4d8666ec757 | 20yvette/CSC148 | /CSC148/Assignment/A1/student.py | 13,894 | 4.125 | 4 | # Assignment 1 - Managing Students!
#
# CSC148 Fall 2014, University of Toronto
# Instructor: David Liu
# ---------------------------------------------
# STUDENT INFORMATION
#
# List your group members below, one per line, in format
# <full name>, <utorid>
# <Yansen Yang>, <yangya26>
# <Yanyan Yvette>, <>
# ... |
1b495aa6ba8ba165614fdc4ca7a9250b2319c924 | 20yvette/CSC148 | /CSC148/Exercise/e9/heap_test.py | 862 | 3.5 | 4 | # Exercise 9 TESTS
#
# CSC148 Fall 2014, University of Toronto
# Instructor: David Liu
# ---------------------------------------------
"""Exercise 9 TESTS.
Note: all tests provided here. In future weeks,
only a subset of the tests will be provided,
and you'll be encouraged to write your own.
"""
import unit... |
fa08f8d4368b0b295056d3bcded3340fcfdc0dc6 | 20yvette/CSC148 | /CSC148/Exercise/e5/list_map_test.py | 761 | 3.65625 | 4 | # Exercise 5, Task 1 TESTS
#
# CSC148 Fall 2014, University of Toronto
# Instructor: David Liu
# ---------------------------------------------
"""Exercise 5, Task 1 TESTS.
Warning: This is an extremely incomplete set of tests!
Add your own to practice writing tests,
and to be confident your code is correct!
... |
c2f8cbc9f590f8bfdcc14b0475c8425692d4dd20 | jcpatrick/PythonBaseCode | /0-1基础部分/对象.py | 918 | 4.1875 | 4 | class Mouse:
'''声明一个类'''
#初始化对象,会被自动调用
def __init__(self,new_name,new_age):
print("init...")
self.name = new_name
self.age = new_age
#__str__()方法,用于获取对象信息,没有该方法的话print(对象)时返回的是内存地址
def __str__(self):
return "%s is %d years old!"%(self.name,self.age)
#方法
... |
a2495e501a0910d67eac9b665fdda32f0d03b757 | jcpatrick/PythonBaseCode | /0-1基础部分/单例模式.py | 507 | 3.515625 | 4 | class DanLi(object):
__instance = None
__init__flag = False #初始化标记
def __new__(cls, name):
if cls.__instance == None:
cls.__instance = object.__new__(cls)
print("111")
return cls.__instance
def __init__(self, name):
if DanLi.__init__flag == False:... |
994624dd856fa4659a63579d86990fac1dd5003d | jcpatrick/PythonBaseCode | /0-1基础部分/房子(面向对象).py | 1,042 | 3.640625 | 4 | class House:
def __init__(self, new_area, new_intro,new_addr):
self.area = new_area
self.intro = new_intro
self.addr = new_addr
self.left_area = new_area
self.contentItems = []
def __str__(self):
msg = "房子总面积为:%d,剩余空间:%d,户型:%s,位置:%s \n 房子中添加的内容%s"%(self.... |
5252092adeb8e0de2cf07010e5cdbbcf1abeebbe | boblutz13/CS50 | /pset7/houses/roster.py | 487 | 3.609375 | 4 | import cs50
import csv
from sys import argv, exit
if len(argv) != 2:
print("Usage: python roster.py house")
exit()
db = cs50.SQL("sqlite:///students.db")
house = db.execute("SELECT first, middle, last, birth FROM students WHERE HOUSE = ? ORDER BY last, first", argv[1])
for row in house:
if not row["midd... |
e85e4c41bfd708ef54b16ed056fe4f9ad1aca4ce | sisterme3/AI-Project | /Unused/buttons.py | 582 | 3.703125 | 4 | #this will be the buttons class where board would get inputs
# import Board
# from tkinter import *
# #buttons
# button1 = Button(Board.topFrame, text="Start", fg="red", command=Board.CreateBoard)
# button2 = Button(Board.topFrame, text="Stop", fg="green")
# button3 = Button(Board.topFrame, text="Solve", fg="blue")
#... |
b0e90cc8d98f3c305caed412035953fbed086500 | MohdMazher23/PythonAssingment | /Day6/FilePrintLineWord.py | 493 | 3.90625 | 4 |
word_count=0
line_count=0
char_count=0
with open("sample.txt",'r') as fp:
lines=fp.readlines()
for i in lines:
line_count+=1
words=i.split()
word_count+=len(words)
rem_line=i.strip('\n')
for j in rem_line:
char_count+=1
... |
600ec634a6b833822f00515dfd850841a1e9b2a0 | MohdMazher23/PythonAssingment | /Day5/MulTable.py | 250 | 3.875 | 4 | num=int(input("ENTER TABLE NO\n"))
for i in range(1,11):
print(num,"X",i," =",num*i)
#output
"""
ENTER TABLE NO
9
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
"""
|
e1989e1663d9c917963d85d0579819f10e97ca0a | MohdMazher23/PythonAssingment | /Day3/Vowles.py | 570 | 4.125 | 4 | word=input("ENTER ANY WORD OR SENTENCE :\n ")
l_word=list(word.lower())
vowel=['a','e','i','o','u']
print("VOWELS PRESENT IN A GIVEN WORD IS:")
count=0
for i in l_word:
for j in vowel:
if i==j:
print(i,end=" ")
count+=1
print("\nTHE TOTAL NO OF VOWELS PRESENT IN A GIVEN W... |
b57693a6e3d2e7659a9005e3b39e85eec81e546f | MohdMazher23/PythonAssingment | /Day5/MaxThree.py | 188 | 4 | 4 | def max_num(num1,num2,num3):
value=max(num1,num2,num3)
print("THE MAXIMUL VALUE AMOUNG THEM IS:",value)
max_num(55,78,32)
#OUTPUT
#THE MAXIMUL VALUE AMOUNG THEM IS: 78
|
4c31d5410e33f9630e85044043aaf4b7900f461c | patsand24/movie_trailer_site | /media.py | 763 | 3.53125 | 4 | import webbrowser
# Parent Class used in case future Child Class is added later
class Video():
def __init__(self, video_title, video_duration):
self.title = video_title
self.duration = video_duration
#Child of Video
class Movie(Video):
""" This class provides a way to store movie related infor... |
ae5f95e1b4a8f6de2294742a0cadff639d21d87e | LajosNeto/patterns-101 | /creational/abstract-factory/python/forges/zora_forge.py | 1,785 | 4.3125 | 4 | """
Abstract Factory design pattern implementation.
This example illustrates the usage of the abstract factory design pattern.
Implements the Zora Forge, a concrete implementation of a forge.
"""
# Author:
# Lajos Neto <lajosneto@gmail.com>
from __future__ import annotations
from abc import ABC, abstractmethod
fr... |
b5861355e697c7ac013083a077e1cbebef95f5c7 | hwijeen/NLP101 | /POS_tagger/wasted/wasted1.py | 2,806 | 3.65625 | 4 |
class Node():
def __init__(self, elem, morph=None):
self.elem = elem # 음소
self.morph = morph # 이 노드까지 포함해서 만든 형태소(가능할 경우)
self.children = {}
class Trie():
def __init__(self):
self.head = Node(None)
def add_node(self, morph):
curr_node = self... |
cccf586d3175b1513daaeef42bbf4216e3fb5dba | fevenMwoldu/passwordLocker | /locker_test.py | 5,718 | 3.6875 | 4 | import unittest # Importing the unittest module
from locker import User, Credential # Importing the user and credential classes
class TestUser(unittest.TestCase):
def setUp(self):
'''
Set up method to run before each test cases.
'''
self.new_user = User("feven", "abc123") # crea... |
9ff77c0a77849f0d5661ef544371c699671109ad | unhyperbolic/SnapRepr | /src/manifold/triangulation.py | 21,964 | 3.6875 | 4 | import copy
import operator
import globalsettings
def left_out_number(l):
"""
>>> left_out_number([0,1,3])
2
"""
i = 0
while i in l:
i = i + 1
return i
class edge(list):
def __init__(self,tetrahedron,vert_0,vert_1):
super(edge,self).__init__((tetrahedron,vert_0,ver... |
6789e96c127d6b784f907a51c0e096ef5fc11276 | unhyperbolic/SnapRepr | /src/algebra/matrix.py | 7,854 | 3.53125 | 4 | def identity_matrix(size,the_type):
return matrix([[the_type.one() if i==j else the_type.zero()
for j in range(size)]
for i in range(size)],the_type)
class matrix(object):
"""
Represents a matrix
>>> matrix([[1,2,3],[2,3,5]],int)
matrix([
[ 1,... |
3ddf0f5b6bb0a9a9e5b88264255026db4af00d34 | edponce/vetk | /quality/w2v_helper.py | 8,378 | 3.578125 | 4 | # This script contains a bunch of useful functions for a variety of tasks
# related to processing word vectors.
import numpy as np
# Read a word embedding or document embedding file and return a dictionary.
# Note that if you run this on a doc embedding, you'll get <ID> <vec> whereas
# on a word embedding file you... |
ab327a23331df8ccb3001b847b21dd298857b540 | Said-Akbar/exercises | /Python_by_Zelle/chapter_7/overtime.py | 1,015 | 4.0625 | 4 | # exercises from chapter 7. 12/28/2019 SaidakbarP
# ex1. overtime
def overtime():
h = int(input("Enter hours: "))
r = float(input("Enter rate: "))
w = 0
if h>40:
w = 40*r + h%40*1.5*r
else:
w = h*r
return w
# ex11. leap year
def leap_year(y):
if y%4 == 0 or y%400==0:
... |
51f840c59a18647179c10fb5ea260af9118ef68a | Said-Akbar/exercises | /integers.py | 1,270 | 4.03125 | 4 | # Integers: Recreation one, level 5kyu.
# link: https://www.codewars.com/kata/55aa075506463dac6600010d
'''
Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square!
Given two integers m, n (1 <= ... |
02be4079ebe2aed11bc8ccfdc81e906c4d779c7e | Said-Akbar/exercises | /Python_by_Zelle/chapter_6/exercise.py | 769 | 3.71875 | 4 | # ex14 chapter 6 12/28/2019 SaidakbarP
def squareEach(nums):
for i in range(len(nums)):
nums[i] *= nums[i]
def sumList(nums):
x = 0
for i in nums:
x = x + i
return x
def toNumbers(strList):
#print(strList)
for i in range(len(strList)):
strList[i] = int(strList[i])
def ma... |
5daf0b07f4e19f2ab73b4d08f1d858ab62941642 | Said-Akbar/exercises | /Python_by_Zelle/chapter_4_ex/ex7.py | 1,365 | 3.921875 | 4 | # ex 7 Circle Intersection. Created by SaidakbarP 12/24/2019
from graphics import *
def main():
#r = int(input("Enter Radius of the circle: "))
win = GraphWin("Circle Intersection", 640, 640)
win.setCoords(-10, -10, 10, 10)
# entry box for radius
radius_entry = Entry(Point(-3, 9), 10)
radius_en... |
16ce93dd97858ef96d9da8ea03cab730902e2b69 | Eddyszh/holbertonschool-higher_level_programming | /0x0A-python-inheritance/10-square.py | 407 | 3.546875 | 4 | #!/usr/bin/python3
"""Square Module
Contains a claas that creates a square
"""
Rectangle = __import__("9-rectangle").Rectangle
class Square(Rectangle):
"""
Creates a square object
"""
def __init__(self, size):
"""
Class constructor
"""
self.integer_validator("size... |
ce8797fea8e4f0dfc41ffabf665adc8eeac332c6 | Eddyszh/holbertonschool-higher_level_programming | /0x03-python-data_structures/9-max_integer.py | 200 | 3.640625 | 4 | #!/usr/bin/python3
def max_integer(my_list=[]):
if len(my_list) == 0:
return None
max_v = my_list[0]
for i in my_list:
if i > max_v:
max_v = i
return max_v
|
f4c1c3176981576cc6efe0e737016186eecd23b9 | jronquillog2/TAREA-ESTRUCTURA-DE-DATOS | /ejercicio3.py | 317 | 3.8125 | 4 | #3. Construir un algoritmo tal, que dado como dato la calificación de un alumno en un examen
import os
print("Consulta si aprobo o no ")
nota = float(input("ingrese la calificacion del examen:"))
if nota >= 7:
print ("Usted esta aprobado")
else:
print("proceso terminado")
os.system ('pause')
|
92a0f6bd4dbc80928eaeec0879019bd3f91ec6fe | jronquillog2/TAREA-ESTRUCTURA-DE-DATOS | /ejercicio7.py | 382 | 3.796875 | 4 | #Leer tres números enteros diferentes entre sí y determinar el número mayor de los tres.
import os
a = float (input ('Ingresa el valor de a: '))
b = float (input ('Ingresa el valor de b: '))
c = float (input ('Ingresa el valor de c: '))
mayor=a
if mayor<b:
mayor=b
if mayor<c:
mayor=c
print ('Valor... |
998473bfd25713fb7665150f9e018241bda8f466 | specialjin1/SICP | /SCIP_1.19.py | 549 | 3.75 | 4 | def fib(n):
def even(number):
return number%2==0
def square(number):
return number*number
def fib_iter(a, b, p, q, count):
if count==0:
return b
elif even(count)==0:
print(a, ' ', b, ' ', p*p+q*q, ' ', q*q+2*p*q, ' ', int(count/2))
return... |
1a75de6bad8ece89084f283a6d145bf9be52f751 | fengjisen/python | /20190107/index.py | 1,939 | 4.3125 | 4 | '''
比较运算符优先级高于逻辑运算符
and or not
优先级:() > not > and > or
or x or y 如果x为True则返回x,如果x为False返回y值。因为如果x为True那么or运算就不需要在运算了,因为一个为真则为真,所以返回x的值。
如果x的值为假,那么or运算的结果取决于y,所以返回y的值
and x and y 如果x为True则返回y值。如果x为False则返回x值。如果x的值为True,and的运算不会结束,会继续看y的值,所以此时真与假取决于y的值,所以x如果为真,则返回y的值。
如果x为假,那么and运算就会结束运算过程了,因为有一... |
bb0c5858ff55d79bb239f511993ffe0ad3fce664 | ellen0wangcx/FCND-Backyard-Flyer-Solution | /FCND-Backyard-Flyer/udacidrone/udacidrone/connection/connection.py | 7,131 | 3.640625 | 4 | """API definition for connections to a drone.
Defines a class to be subclassed by specific protocol implementations for
communication with a drone.
"""
import traceback
from abc import ABCMeta, abstractmethod
from udacidrone.messaging import MsgID
class Connection(object):
"""
Abstract class for a connecti... |
f889bdbc397e8aef049d31cb331af5a6710866c4 | indiamai/Numerical-Methods-in-Python | /graphs.py | 3,868 | 4.4375 | 4 | ##-----------GRAPHS-------------
import turtle
def plotgraph(valuestoplot,turtle1,number):#function to plot graph, with the values, turtle to plot it with and the number denoting the colour to use as parameters
colours=["black","red","blue"]#list of possible colours
turtle1.hideturtle()#do not animate dr... |
66f56d73703b0167fa761e3ca9c597f475601bc3 | sandinocoelho/Empire-of-Code | /Pangram.py | 588 | 3.890625 | 4 | def check_pangram(text):
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
text = text.upper()
for i in abc:
if i not in text:
return False
return True
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert check_pangram("The qu... |
23ff33755606bd69444f303efc45a2dca448cc25 | nursin/Python-Fundamentals | /Weeks1-2/cc_reverse.py | 82 | 4.03125 | 4 |
name = input("What is your name? ")
print("Your name reversed is:", name[::-1])
|
8871656f1bffa55192cfe0b8e571a7540693f4b2 | michael-mck-doyle/Python | /04_conditionals_loops/04_02_month.py | 919 | 4.46875 | 4 | '''
Take in a number from the user and print "January", "February", ...
"December", or "Other" if the number from the user is 1, 2,... 12,
or other respectively. Use a "nested-if" statement.
'''
month = input("Enter a number between 1 - 12, corresponding to a month: ")
x = int(month)
if x == 1:
print("The month i... |
04bb835a356415dcb1a33d3ae65ef53e56589797 | michael-mck-doyle/Python | /03_more_datatypes/3_tuples/03_12_list_to_tuple.py | 255 | 4.25 | 4 | '''
Write a script that takes a list and turns it into a tuple.
'''
txt = input("write a sentence containing repeating words: ")
b = txt.split(" ")
print("list: ", b)
print()
b = tuple(b)
print("tuple: ", b)
print()
b = list(b)
print("list: ", b)
|
0b61d89d95418b9336d976eed3b23d400b11c1fb | michael-mck-doyle/Python | /15_generators/15_02_divisible.py | 205 | 4.1875 | 4 | '''
Create a Generator that loops over the given list and prints out only
the items that are divisible by 1111.
'''
gen = (x for x in range(1, 101) if x % 3 == 0)
print(gen)
for g in gen:
print(g)
|
77eaa2aa7c78c109ab5e0375bd6872e69804787f | michael-mck-doyle/Python | /01_python_fundamentals/01_03_yeehaw.py | 258 | 3.875 | 4 | '''
Write the necessary code to display the follow message to the console
I'm a programmer now.
Yeehaw!
Coding here I come!
'''
print("I'm a programmer now.")
print("Yeehaw!")
print("Coding here I come!")
name = input("Enter a name: ")
print(name)
|
18f8d738d4906ccb4ffe9af0462f28a26d832fe4 | michael-mck-doyle/Python | /19_Practice_Folder/practice_files/19_17_requests_library.py | 1,721 | 3.59375 | 4 | '''
The requests library is the de facto standard for making HTTP requests in Python
Requests - Requests’ is a simple, easy-to-use HTTP library written in Python.
requests is different from urllib - what are the differences
References
Python requests - https://realpython.com/python-requests/
HTTP Request Methods ... |
49b3d698ec81081a9380e8ed3e8d4d52d20a9367 | michael-mck-doyle/Python | /05_string_formatting/05_01_fstring.py | 1,467 | 4.375 | 4 | '''
Using f-strings, print out the first name, last name, and quote of each person in the given dictionary,
formatted like so:
"The inspiring quote" - Lastname, Firstname
'''
famous_quotes = [
{"full_name": "Isaac Asimov", "quote": "I do not fear computers. I fear lack of them."},
{"full_name": "Emo Philips... |
d212cd97d108389482d4a69a363e13b2e73eff51 | michael-mck-doyle/Python | /14_list_comprehensions/14_05_shirt_shop.py | 949 | 4.5625 | 5 | '''
Using a list comprehension, create a *cartesian product* (google this!)
of the given lists.
Then open up your online shop ;)
See: itertools — Functions creating iterators for efficient looping
https://docs.python.org/3/library/itertools.html#itertools.product
itertools.product(*iterables, repeat=1)¶
Cartesian pr... |
61e0b992cb6238884eb7b3d8db192ea4ce05ab46 | michael-mck-doyle/Python | /06_functions/test_rock_paper_scissors.py | 552 | 3.671875 | 4 | import unittest
import rock_paper_scissors
class TestGame(unittest.TestCase):
""" tests to ensure the rock, paper, scissors game works as expected"""
def test_user_rps(self):
self.assertEqual(rock_paper_scissors.get_user_hand(1), "paper")
self.assertEqual(rock_paper_scissors.get_user_hand(2), ... |
379359a095bd8217b5252aa4cf9324db3c1719dd | michael-mck-doyle/Python | /03_more_datatypes/3_tuples/03_16_pairing_tuples.py | 949 | 4.34375 | 4 | '''
Write a script that takes in a list of numbers and:
- sorts the numbers
- stores the numbers in tuples of two in a list
- prints each tuple
If the user enters an odd numbered list, add the last item
to a tuple with the number 0.
Note: This lab might be challenging! Make sure to discuss it with your me... |
c8dfe4d9c948d954c924ed7f70f9c5b4abdf8ddd | michael-mck-doyle/Python | /07_classes_objects_methods/07_01_car.py | 833 | 4.5 | 4 | '''
Write a class to model a car. The class should:
1. Set the attributes model, year, and max_speed in the __init__() method.
2. Have a method that increases the max_speed of the car by 5 when called.
3. Have a method that prints the details of the car.
Create at least two different objects of this Car class and dem... |
2165ecd87d55dbc9b4640190fa1ad3519edbbc9e | michael-mck-doyle/Python | /19_Practice_Folder/practice_files/19_14_for.py | 3,301 | 4.84375 | 5 |
'''
__ For....in.. __ statement
example taken from book, "A Byte of Python", "Control Flow" section - https://python.swaroopch.com/control_flow.html
Traversal with a for loop - http://greenteapress.com/thinkpython2/html/thinkpython2009.html#sec94
The for..in statement is another looping statement which iterates... |
78590cf90948d6a583aed575218dbde2c90ac9c8 | michael-mck-doyle/Python | /19_Practice_Folder/api_practice/api_tutorial/YAML/yaml_2.py | 832 | 3.625 | 4 | import yaml
from yaml import load, dump
yaml.load(stream= , Loader=) # # what does stream and loader do/mean in yaml file?
print (yaml.load(stream=???, Loader=???"""
... name: Vorlin Laruknuzum
... sex: Male
... class: Priest
... title: Acolyte
... hp: [32, 71]
... sp: [1, 13]
... gold: 423
... inventory:
... - a Ho... |
c5f21e47a16ecb7dfa9408fa505047fd2aed0e45 | michael-mck-doyle/Python | /19_Practice_Folder/practice_files/19_09_sets.py | 1,212 | 4.25 | 4 |
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print(basket) # show that duplicates have been removed
print('orange' in basket) # fast membership testing
print('crabgrass' in basket)
# Demonstrate set operations on unique letters from two words
a = set('ab... |
e91f0093f992e6d28da903437af729d5cd9c63b6 | michael-mck-doyle/Python | /21_regex/regex_01.py | 1,168 | 4.03125 | 4 | '''
__References__
Regular Expressions: Regexes in Python, Part 1 - https://realpython.com/regex-python/
regex has many functions available in the module "re" which are accessible
by using "import re" or more specifically "from re import module_name"
example function:
re.search(<regex>, <string>)
check out https:/... |
ad44a9c15e20d7fd7989cabbd3b921bb187ffbc9 | asinck/tegilbor | /keybindings.py | 7,736 | 3.765625 | 4 | #this file has almost all of the key bindings for the main program.
#if I ever rebind the almost 200 combinations again, I am so writing a
#secondary program to format everything for me. Careful listing,
#grouping, and reassignment of all the keys took days; typing in the
#assignments and formatting everything took FO... |
665d0a917b71e890272b6c1a06046dfef74ede79 | ayolerin/Ayo_Heather_DSA_project | /Main_File_Clothes_Functions.py | 3,275 | 4.1875 | 4 | # Ayo-fisher Oluwapamilerin
# this is where we are importing
from Main_File_Customer_Class import *
from Main_File_Owner_Class import *
from Caps_Clothes_Class import *
from CropTop_Clothes_Class import *
from Hoody_Clothes_Class import *
first_name = input("What is your first name? e.g(Heather) ")
last_nam... |
8b1f53cbc54d7e7ff9ac38c05523a44f3feba3dc | Phantom-Thief/PROJET-BITCOIN | /FieldElement.py | 5,780 | 3.8125 | 4 | class FieldElement(object):
def __init__(self,num,prime):
if num >= prime or num < 0:
error = "L'attribut num = {} n'est pas dans le corps 0....{}".format(num,prime-1)
raise ValueError(error)
self.num = num
self.prime = prime
def __repr__(self):
return "{}... |
1eaf6dbb00e0b654a1c35c435bf0313c2de0ca5d | anil0775/Python | /sumOfNumbers.py | 159 | 4.15625 | 4 | """Program for calculating sum of two number"""
num1 = input("Enter the first number: ")
num2 = input("Enter the second number: ")
sum = num1 + num2
print(sum) |
85eebfc7205f997439d9bc55b9c9c0047a3e200f | JasonHarrer/PythonFun_OOP_Mathdojo | /mathdojo.py | 1,001 | 4.03125 | 4 | #!/usr/bin/env python
import unittest
class MathDojo:
def __init__(self):
self.result = 0
def add(self, num, *nums):
self.result += num
for n in nums:
self.result += n
return self
def subtract(self, num, *nums):
self.result -= num
for n in nums... |
eaa2e9ed083ae95dfc4acb886b16b010370b6b4c | enigdata/coding-drills | /String/palindrome_paris.py | 2,378 | 4 | 4 | '''
Given a list of unique words, find all pairs of** distinct** indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Example
Given words = ["bat", "tab", "cat"]
Return [[0, 1], [1, 0]]
The palindromes are ["battab", "tabbat"]
Given words = ["abcd", "... |
28bf98bd5f172332b7d5d45942d467f828c089a9 | rajesh0025/dsa_problem_solving | /array/RotateMatrix90.py | 718 | 4.15625 | 4 | """
Problem Statement:
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given i... |
c51fbebf4342d6bd54f5e45cd7731272663966c8 | rajesh0025/dsa_problem_solving | /array/FindOddFrequencyElement.py | 708 | 3.875 | 4 | """
Given a non-empty array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
Example 1:
Input: [2,2,1]
Output: 1
Example 2:
Input: [4,1,2,1,2]
Output: 4
"""
#Approch 1 ... |
4c1a808f04a4929d37b85bebbc5eb2d92c7e39c1 | diexiaoxi/- | /solve_equation.py | 1,651 | 3.8125 | 4 | """
解下列二元一次方程
2x-y=3
3x+y=7
"""
# 导入模块
from sympy import *
# 将变量符号化
x = Symbol('x')
y = Symbol('y')
z = Symbol('z')
# 解一元一次方程
expr1 = x*2-4
r1 = solve(expr1, x)
r1_eq = solve(Eq(x*2, 4), x)
print("r1:", r1)
print("r1_eq:", r1_eq)
# 解二元一次方程
expr2 = [2*x-y-3, 3*x+y-7]
r2 = solve(expr2, [x, y])
print("r1:", r2)
#... |
c5b763c802ae2cbfe9f8cab8c0dd8c316da8fe5c | cmhiscmh/COMP9517-Computer-vision-20T2 | /COMP9517_20T2_Lab4/Lab4_submit.py | 3,263 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:44:36 2020
@author: sanch
"""
import numpy as np
import matplotlib.pyplot as plt
from sklearn import metrics
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklear... |
6ff0ab29e1e33adf7c09b0769f8e266557f534bc | john-do3/HackerRankPythonPractice | /BasicDataTypes/find-second-maximum-number-in-a-list.py | 352 | 3.515625 | 4 | # https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
first = -101
second = first
for i in arr:
if first < i:
first = i
for i in arr:
if i != first:
if (second < i):
... |
343fff824dc1a11d78d9a072e59c004500260c29 | john-do3/HackerRankPythonPractice | /BasicDataTypes/py-the-captains-room.py | 327 | 3.609375 | 4 | # https://www.hackerrank.com/challenges/py-the-captains-room/problem
k, k_list = int(input()), list(map(int, input().split()))
room_hash = dict()
for item in k_list:
if item in room_hash:
room_hash[item] += 1
else:
room_hash[item] = 1
for key, v in room_hash.items():
if v < k:
pri... |
b00153a3d12b52d616d4e2de55a4cecc52d34db4 | aadityagupta0804/PythonPrograming | /dicegame.py | 2,584 | 3.59375 | 4 | #Python test login and register w classes (NEA)
import random
import time
import unittest
class USERS(unittest.TestCase):
def create(self):
username = input("Pls enter a usn: ")
password = input("Pls enter a pswd: ")
logform = "{u}:{p}".format(u = username, p = password)
with open... |
504b4139053335ef5d71c4a9a7fd452449265e66 | Angie-gh/unit1 | /week05_EncryptionProject_Angie_ExtraCredit_Part7_Part8_b.py | 7,320 | 4.46875 | 4 |
"""
Finally, only a few truly amazing people are going to remember a random ording of 26 letters. We would like to have a way to use a password of around 7 characters. How can we use a password to scramble our alphabet into some order? Its not as bad as you might think at first. Do the following:
Remove any dupli... |
3edb5ac8088032ff78cf0f3dde78339a9af992ad | worldyone/workspace | /AtCoder/abc101/b/main.py | 188 | 3.734375 | 4 | #!/usr/bin/env python3
def main():
strN = input()
N = int(strN)
S = sum([int(n) for n in strN])
if N % S == 0:
print("Yes")
else:
print("No")
main()
|
a1050bbefe68f762b3ff9c33e30729d6cdd3b97a | slcka/Assignment.01 | /dd.py | 2,176 | 3.53125 | 4 | from pyspark.sql import SparkSession
# Create a SparkSession
spark = (SparkSession
.builder
.appName("SparkSQLExampleApp")
.getOrCreate()
)
# Path to data set
csv_file = "C:\AJAN\ebook\Spark\spark-3.0.0-bin-hadoop2.7\data\departuredelays.csv"
# Read and create a tempor... |
4285eb31c84698e954b3d5c2efff20cefe56da85 | martin-costa/incremental-cycle-detection | /Python Graphs/BFG09.py | 3,101 | 3.640625 | 4 | from graphs import *
import math
# O(n^2 log n) algorithm from BFG 2009, almost optimal for dense graphs
class BFG09:
def __init__(self, n):
# the size of the graph
self.n = n
self.lg_n = math.ceil(math.log2(n))
# graph of added edges (initially n isolated nodes)
self.G =... |
071ccf3ae726e1f9facc39e25bf4e409d92e4f72 | SahilChoudhary22/SimpleAppsRepo | /DSA-Files/BFS.py | 1,803 | 4.4375 | 4 | # making the node class
class Node:
def __init__(self, name):
self.name = name
# list containing adjacent nodes
self.adjacencyList = []
# whether a node is visited or not
self.visited = False
# not useful in current case
self.predecessors = None
... |
c3742cdf2d9fb26c62d1cc81f0938a726b410385 | ed100miles/StructuresAndAlgorithms | /SearchTrees/bst_simple.py | 1,590 | 4.125 | 4 | class Node:
def __init__(self, data=None):
self.data = data
self.left = None
self.right = None
class BST:
"""Simple implementation of a binary search tree"""
def __init__(self):
self.root = None
def insert(self,data):
if self.root is None:
self.root ... |
f4dd5e54d8111fd68d692c7c5e188083bac57a35 | ed100miles/StructuresAndAlgorithms | /PQsAndHeaps/heap_PQ.py | 3,359 | 3.890625 | 4 | """
Implementation of heap min-oriented priority queue using array based binary tree.
See ~Trees/array_binary_tree.py for a reminder on level numbering:
- if position p is the root of tree T, then f(p) = 0
- if p is the left child of position q, then f(p) = 2f(q) + 1
- if p is the right child of position ... |
233c6f5e0cfe06074c459833ea6387b6b49f88a1 | XUTPbIU-6O6EP/HW1 | /task1.py | 291 | 3.8125 | 4 | print ('Введите min и max значение и я посчитаю для \nВас сумму цифр между ними включая min и max')
a=input()
b=input()
S=0
i=int(a)
while i<int(b):
i=i+1
S=S+i
S=S+int(a)
print ('Сумма чисел =', S)
|
e7fc60d55c8302fd1dda2bedc0cedec4624b02a7 | Ash-one/raspberrypiLED | /Animation/Dot/DotAnimation.py | 628 | 3.578125 | 4 | from Animation.AbstractAnimation import AbsractAnimation
import numpy as np
import random
class DotAnimation(AbsractAnimation):
def __init__(self,sustain=40,count=10,height=60,width=90):
super(DotAnimation,self).__init__(height,width,sustain)
self.count = int(count)
def createAnimation(self)... |
d77a731b4b04ce7fe23b455525dafd943b02960f | els-pnw/twitter-sentiment | /lib/helper_functions.py | 3,393 | 3.5 | 4 | import json
import numpy as np
def flatten_tweets(tweets_json):
""" Flattens out tweet dictionaries so relevant JSON
is in a top-level dictionary.
Borrowed from datacamp, with modification to support
tweepy.Cursor api.search
Parameters
----------
tw... |
89cbb4495056d14d9e6896069c3c869624e7af8c | zhugexiu/code-for-python-beginner | /IfElse.py | 819 | 4.125 | 4 | coordinates = (4, 5)
print(coordinates[1])
def say_hi():
print("Hello User")
say_hi()
def cube(num):
return num*num*num
result = cube(4)
print(cube(3))
print(result)
is_male = True
is_tall = True
if is_male:
print("You are a male")
else:
print("you are not a male")
def max_num(num1, num2, nu... |
f32b017cd3387585510fdbe192a2bd8b9c806ac6 | dawbit/-SEM3-JS | /python/82.py | 236 | 3.890625 | 4 | def get_int(msg):
This function get some number from user.
while True:
try:
n = int(input(msg))
return n
except ValueError:
print(This is not number. Try again)
x = get_int(Give number: )
print(Your number: , x) |
48a5e8e768315b7b966302ee7c5b852920fae5e1 | dawbit/-SEM3-JS | /python/78.py | 223 | 4.125 | 4 | vowel = [a,e, y, u, i, o]
newList = []
string = input(Type your string: )
for i in string:
if i in vowel:
if i in newList:
pass
else:
newList.append(i)
print(Vowel in this string: ,newList)
|
7fb3ab5db2f1721867f8d218676c1b394d691c3f | dawbit/-SEM3-JS | /python/114.py | 189 | 3.71875 | 4 | from math import tan
import math
def field():
length = int(input())
number = int(input())
area = (number * length ** 2) / (4 * tan(math.pi / number))
print(area)
field() |
708652410d4cad64dad70a7080f8f0397ba87190 | geoffreeve/Area-Perimeter-Calculator | /resub.py | 4,680 | 4.25 | 4 | from math import pi
# check function
def check(question, num, cont):
shape_list = ["circle", "square", "rectangle", "rhombus", "parallelogram"]
valid = False
while not valid:
try:
# If num == "yes" then program is looking for a number
if num == "yes":
... |
fffac3862d388738f742d48e218e3dfdb06de56f | nham/linux_setup | /pomo.py | 363 | 3.59375 | 4 | #!/bin/python
import time, sys, os
if len(sys.argv) == 1:
mins = 30
else:
mins = int(sys.argv[1])
print("counting down {} minutes".format(mins))
elapsed = 0
tick_len = 1 # in minutes
while elapsed < mins:
time.sleep(tick_len*60)
elapsed += tick_len
print("{} minutes left".format(mins - elapsed))... |
5c4f065d768f2aab2f950dea2dd6aae70d76d4d2 | joana04/Teoria-Computacional | /Entrega Final/palindromos/pal.py | 1,962 | 3.59375 | 4 | import random
def menu():
entra=1
fp=open("Palindromo.txt","w")
fp.close()
ubi=open ("Camino.txt","w")
ubi.close()
while entra==1:
ubi=open ("Camino.txt","a")
ubi.close()
fp=open ("Palindromo.txt","a")
fp.close()
print("\n\t\tSeleccione la opcion deseada\n 1.-Manual\n 2.-Automatico\n")
o... |
8cef53dca52e9a87e8c931a089b7410e53ac184b | fedecaccia/data_structures | /fixed_queue.py | 1,694 | 3.515625 | 4 | class FixedQueue(object):
def __init__(self, size):
self.size = size
self.used = 0
self.elems = [None]*size
def __len__(self):
return self.used
def getElems(self):
return self.elems
def enqueue(self, value):
if self.used >= self.size:
r... |
5ddf319bf8b6597282f48c730748a6fee735a021 | curioussmind/hardcore_py | /write_files/total.py | 911 | 3.90625 | 4 | from typing import TextIO
from io import StringIO
def sum_number_pairs(input_file: TextIO, output_file: TextIO) -> None:
"""Read the data from input_file, which contains
two floats per line separated by a space. output_file
for writing and, for each line in input_file,
write a line to output_file th... |
51cbf5f757ff960a2ea490bbdbbee740cf4c529e | curioussmind/hardcore_py | /function/designing_function.py | 793 | 4.59375 | 5 | # HOW TO DESIGN A BEAUTIFUL FUNCTION
"""
we can use the following questions before designing function
1. name of the function --> must reflect the function
2. the paramters and information they refer to
3. the calc we will do with that information
4. what info does the funtion return
5. does it work as we expect?
"""
... |
fcc987bf8a33411ff5a99eeca02211b237c1e506 | curioussmind/hardcore_py | /lists/list_comprehensions.py | 1,686 | 4.5625 | 5 | # list comprehensions are a way to build a new list by applying an expression
# to each item in a sequence and are close relatives to for loops
res = [c * 4 for c in 'SPAM'] #list comprehensions
print(res)
# list comprehensions above == for loop below
ok = []
for c in 'SPAM':
ok.append(c * 4)
print(ok)
# lists a... |
9d4df59aa09fd7839fee1d1ec5f5d47058b99e9f | coursekevin/avlpy | /avlpy/save_avl_file.py | 1,338 | 3.90625 | 4 | def save_avl_file(fname,surfaces):
""" This function saves a surface list to an avl file
---------------------------------------------------------------------------------
INPUTS
- fname: filename to be saved
- surfaces: surfaces list containing dictionaries of sections
"""
line_count = 0;
with open(f... |
6db455ee688caae1813819262211650b33faf2d8 | bellTurt1e/bellTurt1e.github.io | /yuh/4_Looped_gon.py | 361 | 3.71875 | 4 | """
Import your n_gon file using:
from n_gon import *
We are going to call the function inside a FOR loop using i as the number of sides (n)
*Don't forget to import turtle and create a Turtle() to be used in this
"""
from n_gon import
import turtle
sven = turtle.Turtle
def gref():
for i in range():... |
a0521df028cba8f04baaa68944dd00687a5b5e53 | YKPS-FooBar/Projects | /001 - Guess the Number/yoyo-lu.py | 481 | 4.21875 | 4 | print ('Welcome to the game of guessing numbers!')
number = 14
guess = int (input ('Please input a number between 1-100: '))
while guess != number:
if guess > number:
print ('My number is smaller.')
guess = int (input ('Please input a number between 1-100: '))
elif guess < number:... |
0c36dc1506fe60df2b9100509db18e19dcd3991a | YKPS-FooBar/Projects | /001 - Guess the Number/nicole-zhang.py | 286 | 4.125 | 4 | a = 3
guess = int(input("Please guess a number between 1 and 10:"))
if guess == a:
print("Correct")
while guess != a:
print("You are wrong")
guess = int(input("Please guess a number between 1 and 10:"))
if guess == a:
print("Correct")
break
|
9292b4481bd1b3a726c9635b83acd39c15866ada | cybertraining-dsc/sp20-516-252 | /test.py | 3,730 | 3.703125 | 4 | import random # random number generator
import sys # system module
import os
# # lambda
# # Syntax: lambda arguments: expression
#
# greeter = lambda x: print('Hello %s!' %x)
# print(greeter('Albert'))
#
# all_names = ['surname', 'rename', 'nickname', 'acclaims', 'defame']
# filtered_names = list(filter(lambda x: 'nam... |
1d928e23d3505bac12fcdfcc40f01ba814938ad1 | robyeva/Miscellaneous | /image_features_recognition.py | 1,372 | 3.703125 | 4 | __author__ = 'Roberta Evangelista'
__email__ = 'roberta.evangelista@posteo.de'
"""Modified from the LinkedIn Learning course:
Building Deep Learning Applications with Keras 2.0, by Adam Geitgey """
import numpy as np
from keras.preprocessing import image
from keras.applications import resnet50
# Load Keras' ResNet5... |
aed4af2c525b525b864ea99726292276812e7e7f | pol1969/sql | /sql_print_fetchall.py | 310 | 4.0625 | 4 | #создает SQLite базу и таблицы
import sqlite3
#create a new database if database doesn't already exist
with sqlite3.connect("new.db") as connection:
c = connection.cursor()
c.execute("SELECT firstname, lastname from employees")
rows = c.fetchall()
for r in rows:
print(r[0], r[1])
|
637e8b668c922d066bfde84d0592d48e3c5121ef | Johanstab/INF200-2019-Exercises | /src/johan_stabekk_ex/ex01/letter_counts.py | 873 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Solution to task C on exercise 01 in INF200
"""
def letter_freq(txt):
"""
This code counts the frequency of how many times a character is used.
:param txt: input for the user of the code.
:return: Returns a dictionary where the frequency of characters in txt is placed, wi... |
18b32072d7a1274fc5e9dec7b0f3b472f4db963b | Johanstab/INF200-2019-Exercises | /src/johan_stabekk_ex/ex02/message_entropy.py | 1,232 | 3.96875 | 4 | # -*- coding: utf-8 -*-
import numpy as np
__author__ = 'Johan Stabekk'
__email__ = 'johan.stabekk@nmbu.no'
def letter_freq(txt):
"""
This code counts the frequency of how many times a character is used.
:param txt: input for the user of the code.
:return: Returns a dictionary where the frequency of... |
a0690ab38ff550e8c49c2d2c16c189acc0650e72 | ptdk1020/PasswordStrength | /scripts/feature_maps.py | 3,103 | 3.765625 | 4 | """This file contains feature extracting and data enrichment functions"""
import string
from zxcvbn import zxcvbn
def length(password):
return len(password)
def num_lowercase(password):
"""Count the number of lower case letter"""
lower_alphabet = string.ascii_lowercase
count = 0
for letter in p... |
c00eea23349b0f3b473eeaea538df7ec38ce7756 | besirgurel/Python_Week_4 | /random password.py | 1,019 | 3.703125 | 4 | from tkinter import *
import random,string
def power():
lbl.config(text="Your password: {}".format(assign_password()))
def assign_password():
au2="".join(random.choice(string.ascii_uppercase) for x in range(2))
digits2="".join(random.choice(string.digits) for x in range(2))
punctuation2="... |
b6980c6cff34a736de1c6954f97fe074746e1d1f | Masstran/turtle_crossing | /car.py | 344 | 3.703125 | 4 | from turtle import Turtle
class Car(Turtle):
def __init__(self, color, position):
super().__init__()
self.color(color)
self.penup()
self.shape("square")
self.goto(position)
self.shapesize(stretch_len=2)
self.setheading(180)
def move(self, speed):
... |
7856cc37c4fb7c64009cff74f0f96d838d716fe2 | Oscar6/RPG | /rpg1.py | 1,892 | 4.1875 | 4 | #!/usr/bin/env python
# In this simple RPG game, the hero1 fights the goblin1. He has the options to:
# 1. fight goblin1
# 2. do nothing - in which case the goblin1 will attack him anyway
# 3. flee
def main():
health = 10
power = 5
health = 6
power = 2
hero1 = Hero()
goblin1 = Goblin()
class... |
1c441973d93bdb6e30a7e11ac2bf26779926f706 | itongit/PythonSelenium | /Game/level1.py | 769 | 3.84375 | 4 | from random import randint
class level1(object):
def __init__(self):
#receive the answer result,if result = 1 ,answer is right,else answer is wrong
self.level = 1
self.right_wrong = 1
def choose_problem(self):
print "First ,Welcom to the game!"
result = "problem"+str(randint(1,1))
self... |
9d2a0a41d64c955f0b4b4491ac4b4a0fc2dc8b52 | dayalnigam/-Python-Development-Intern | /q.5.py | 499 | 4.0625 | 4 | #q.5: Write a Python program that takes a text file as input and returns the number ofwords of a given text file.
count = 0;
class wordcount:
def __init__(self,f):
self.myfile=f
def wordfile(self):
count=0
for i in self.myfile:
w=i.split(" "+","+"")
... |
08b0d3ffdf57b70c6d76a3aa913a1d3189b70c11 | derxir/n2w_public | /main.py | 1,589 | 3.546875 | 4 | '''n2w: convert numbers in text into words.
Usage:
n2w [--text <text>] [--filepath <filename>]
Examples:
$ n2w -f 'test/test_input.txt'
eleven
twenty-one
$ n2w -t 'a 1 b 23'
one
twenty-three
'''
import argparse
import os
import sys
def main():
parser = argparse.ArgumentParser(descrip... |
10f318664ccc532cc2cacb76bde173ba557b4719 | surfish101/Painonhallinta | /kysymys.py | 1,571 | 3.515625 | 4 | # Rutiineja tietojen kysymiseen käyttäjältä
# Kirjastojen & moduulien lataukset
import sanity2
# Funktioiden määrittelyt
def kysy_liukuluku(kysymys, alaraja, ylaraja):
"""Kysyy käyttäjältä liukuluvun tai kokonaisluvun ja tarkistaa syötteen oikean tietotyypin ja suuruuden
Args:
kysymys (string): Käyt... |
ad3c854aeec0cb5c1e1391173b345cf823018e6c | markpeppers/python | /validateStackSequences.py | 629 | 3.609375 | 4 | from typing import List
class Solution:
def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
tstack = [] # test stack
while (len(pushed) > 0):
tstack.append(pushed[0])
pushed = pushed[1:]
while tstack and tstack[-1] == popped[0]:
... |
580da84cde637cccacde7671a66c2892d3c09f47 | mikealford/ktbyers_python | /week1/exe2.py | 542 | 3.515625 | 4 | user_input = input("Enter IP address: ")
octets = user_input.split('.')
print("\n")
print("{:^15}{:^15}{:^15}{:^15}".format('Octet1','Octet2','Octet3','Octet4'))
print('-' * 80)
print("{:^15}{:^15}{:^15}{:^15}".format(octets[0], octets[1], octets[2], octets[3]))
print("{:^15}{:^15}{:^15}{:^15}".format(bin(int(octets[0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.