blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
efb458c413e6b350a28aad5f9d2448d12e0e8f93 | huotong1212/mylearnpy | /code/day05/描述符/describle1.py | 547 | 3.59375 | 4 | class Foo:
def __get__(self, instance, owner):
print('触发get')
def __set__(self, instance, value):
print('触发set')
def __delete__(self, instance):
print('触发delete')
#包含这三个方法的新式类称为描述符,由这个类产生的实例进行属性的调用/赋值/删除,并不会触发这三个方法
f1=Foo()
f1.name='egon'
f1.name
del f1.name
#疑问:何时,何地,会触发这三个方法的执行
#... |
d571718a1908f78e3d34d419dd4d9cae1987995e | shivam221098/news-api | /bookmark_db.py | 8,154 | 3.671875 | 4 | import sqlite3
from datetime import datetime
import get_news
DATABASE_FILENAME = "bookmark.db"
def database_setup():
connection = sqlite3.connect(DATABASE_FILENAME)
cursor = connection.cursor()
cursor.execute("DROP TABLE IF EXISTS bookmarks")
cursor.execute("DROP TABLE IF EXISTS bookmark_detail")
... |
bc33b7cef64aef10d849982037305625381974ea | acjensen/project-euler | /0010_SummationOfPrimes.py | 1,119 | 4.09375 | 4 | '''
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
'''
# implement seive of Eratosthenes
prime_limit = 2000000 # highest prime number to sum
total = 2
integers = [True]*prime_limit # true is prime number
def markPrimes(prime):
# 3. enumerate the multples... |
b822136ea88a4cd0999af75a88863513947e675e | scoutthedog/EasyFit | /reformat.py | 6,323 | 3.546875 | 4 | """
The reformat functions are used to reformat old data that preexisted the database
Do not use or worry about using this ever, hopefully most if not all old data should have been
convered if you are reading this. However if you are looking to understand this then see the documentation for the
excelcoordinates class ... |
e32f1ec894a07e5e485a04173ca0fcbdf816a928 | saurabh11baghel/dsalgo | /04quicksort/iisort.py | 1,209 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 11 17:18:01 2017
@author: abgoswam
"""
def iisort(a):
for i in range(1, len(a)):
for j in range(i, 0, -1):
if a[j] < a [j-1]:
# swap a[j] and a[j-1]
temp = a[j]
a[j] = a[j-1]
a[j-1] = ... |
6a8c779f8cfc8ac5a2da4b7dd604805d9947ca6d | AlexYuAn23/ml-garbage-classifier | /src/core.py | 5,306 | 3.625 | 4 | from math import e
import numpy
from numpy import log as log
def sigmoid(z):
"""
Runs a hypothesis through the sigmoid function.
:param z: A scalar or matrix hypothesis
:return: the hypothesis run through the sigmoid function
"""
return 1.0 / (1.0 + (e ** -z))
def sigmoid_derivative(sigmoid_o... |
ca161bf8c5f5d0c17fe7a2f6e21f480e67138902 | alan20062006/Wearable-Device-Data-Analysis | /TimeClass.py | 1,056 | 3.625 | 4 | class TimeClass(object):
def __init__(self,timestr):
self.hour = int(timestr[0])*10+int(timestr[1])
self.min = int(timestr[3])*10+int(timestr[4])
self.sec = int(timestr[-2])*10+int(timestr[-1])
def gethour(self):
return self.hour
def getmin(self):
return self.min
... |
6b70824b7dc1928cc9fb84fa22f01e718c06474a | 14Si28/python | /quadratic equation.py | 484 | 4.15625 | 4 | print("Program to calculate the values of the quadratic equation ax^2+bx+c=0")
a = input("Enter the value of a: ")
a = int(a)
b = input("Enter the value of b: ")
b = int(b)
c = input("Enter the value of c: ")
c = int(c)
#calculating the discriminant first then the roots
d = b*b - 4*a*c
if (d > 0):
d = d**0.5
pr... |
8bc4c0953b9a34b094cf9d8169187eaaf066ff03 | grigorghazaryan/python-homeworks | /Homework Dict and Files/homework_10.py | 325 | 4.125 | 4 | # 10. Write a program that takes a list of ten prices and ten products,
# applies an 11% discount to each of the prices displays the output like below.
fruits = [ "Apple 🍏", "Orange 🍊", "Pear 🍐" ]
prices = [ 3, 4, 5 ]
for fruit, price in zip(fruits, prices):
print(f"{fruit} $ {price - (price * 11 / 100)}") |
559024c215ca4bbf7a71b91239ae6e0b1645836c | hopensic/LearnPython | /src/leecode/1038.py | 1,185 | 3.5 | 4 | # Definition for a binary tree node.
from leecode.common.commons import TreeNode, buildTree
d = {}
class Solution:
def get_sumof_right(self, node):
if (node):
d[node.val] = node.val + self.get_sumof_right(node.right)
return d[node.val] + self.get_sumof_left(node.left, d[node.val]... |
a3db3d48d95b82527ae7c59d447f14add3287bb2 | SnehankaDhamale/Python-Assg-WFH- | /Assignment5/ex2.py | 269 | 4.1875 | 4 | #Wap to convert the content of files in reverse order.
fname=input("Enter the filename:") # reverse file linewise
for line in reversed(list(open(fname))): #inbuild reversed function
print(line.rstrip()) #rstrip remove trailing character and return copy of string
|
70f7bf726942e279a8589516c2a96bb3e81924e5 | patadadeburro/leetcode | /05/p05_brute_force.py | 2,119 | 4.03125 | 4 | '''
-------------------------------------------------------------------------------
problem: 5. Longest Palindromic Substring
Description:
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab... |
c1a07e7a0800b6995a8b6020ae98f7ab5b0ab765 | CS196Illinois/git-hw-fa2020-softwareJengineer | /WeekTwo/Addition.py | 150 | 3.6875 | 4 | # addition documentation
# parameters:
# x: Integer to add
# y: Integer to add
# returns: the sum of x and y
def addition(x, y):
return x * y
|
c38a0e1e58ca72e0058a743607ba2398d8e154a4 | quynhanhvl/logicalOperators | /practiceLogicalOperators.py | 216 | 3.5625 | 4 | '''
Created on Oct 5, 2019
@author: ITAUser
'''
from builtins import True
a = False
b = 20>9
c = 1==1
d=True
e=True
print(a and (b and c) or (d and e))
print ( a and b and c)
print(4==4 and (6==6 or 2<5) and 25<9)
|
733bd384e42430618eb2c8c7c42c0cc48a5b195f | pra733k/py_prac_prog | /op.py | 2,086 | 4.65625 | 5 | # --------- PYTHON OOPS ---------
# A practice code
class Car(): #parent class
# Constructors are used to initialize the object. Like methods, a constructor also contains
# a collection of statements(i.e. instructions) that are executed at the time of Object creation.
car_type = 'Sedan' #c... |
4739aa3f396a04484644312d0fa90457e57b7564 | its-Kumar/Python.py | /3_Strings/count.py | 277 | 3.984375 | 4 | s = input("Enter any string : ")
len_ = len(s)
char = 0
word = 0
for i in range(len_):
char += 1
if s[i] == " ":
word += 1
char -= 1
if i != 0:
word += 1
print("No of characters are : {0} , No of words are : {1}".format(char, word))
|
75bd7930fee530e81b11e1a60d884a00457a1101 | JaspreetSAujla/Escape_The_House | /Python/EscapeHouseGame.py | 1,902 | 4.21875 | 4 | from HouseClass import House
import time
class EscapeHouseGame:
"""
Class which initialises and runs the escaoe from the house game.
Methods:
__init__ = Initialises the variables.
run_game = Runs the game.
"""
def __init__(self):
"""
Defines the init... |
3f90a1136abea745a157a7ee42ce3b7e21f011d8 | Sheko1/SoftUni | /Python-Advanced/Multidimensional-Lists/Exercise/09_radioactive_mutant_vampire_bunnies.py | 1,962 | 3.5625 | 4 | from copy import deepcopy
def player_start(matrix_1):
player_position = None
for r in range(len(matrix_1)):
for c in range(len(matrix_1[r])):
if matrix_1[r][c] == "P":
player_position = (r, c)
break
return player_position
def multiply_bunnies(matrix_... |
d3ecbbceab8f4dad6ec1718d36f61fdd73004fed | yument7/PyLearn | /PyaBaseGrammer/ListTest.py | 969 | 4.34375 | 4 | #!/usr/bin/python3
# --coding=UTF-8--
def listTest():
list1 = [1,2,3,4,5]
list2 = list('abcd')
list3 = list(('pear','peach','orange','apple'))
list2[2] = "e" #修改元素值
del list2[3] # 删除元素
print("list1=",list1,",list2[2]=",list2[2],",list3[1:3]=",list3[1:3])
# append() 方法
list3.appen... |
1cf4bb75e5ee8d4f366ef50bd39d6a4a211e456d | salilkanitkar/lpthw_exercises | /e21.py | 1,007 | 4.34375 | 4 | #!/usr/bin/python
""" Exercise 21 """
def add(a, b):
print "Adding %d and %d:" % (a, b)
return a + b
def subtract(a, b):
print "Subtracting %d and %d:" % (a, b)
return a - b
def multiply(a, b):
print "Multiplying %d and %d:" % (a, b)
return a * b
def divide(a, b):
print "Dividing %d and %d:" % (a, b)
retur... |
ef6ae24606648e37bc3d5163d3e979a9a70ccf5f | trademark152/Data_Mining_USC | /hw1/minh_tran_hw1/minh_tran_task3.py | 3,528 | 3.78125 | 4 | """
Task 3: Exploration on Multiple Datasets (2 points)
In task3, you are asked to explore two datasets together containing review information (review.json) and business information (business.json) and write a program to answer the following questions:
"""
from pyspark.context import SparkContext
import time
import js... |
de5d41a5347531d3860868dc02355258d4853064 | IvayloSavov/Advanced | /exams/C# Advanced Exam - 24 Feb 2019/tron_racers.py | 3,101 | 3.59375 | 4 | def find_players(matrix):
first_player = ()
second_player = ()
for i in range(len(matrix)):
for j in range(len(matrix)):
if matrix[i][j] == "f":
first_player = i, j
elif matrix[i][j] == "s":
second_player = i, j
return first_player, second_... |
b4d2ac957acdbf7d37eea8d2cb3e2cd83d92e163 | poojamalviya/ds-algo | /heap.py | 2,023 | 3.90625 | 4 | class Heap(): #minheap
def __init__(self):
self.arr = []
self.size= 0
def insert(self, ele):
print self.size
if self.size == 0:
self.arr.append(ele)
self.size = self.size+1
else:
self.arr.append(ele)
self.size = self.size+... |
a0342d14d48ca9d31d292c4dea33ad7c5d8cfd1e | haowei-zhang/lintcode | /423_valid_parentheses.py | 603 | 3.921875 | 4 | class Solution:
"""
@param: s: A string
@return: whether the string is a valid parentheses
"""
def isValidParentheses(self, s):
# write your code here
stack = []
parentheses = {
'(': ')',
'[': ']',
'{': '}'
}
for c in s:
... |
0a0ebbe51b588fbb0ee98349c6ff39c67f901af8 | osandrolucas/Python_CeV | /Desafios/Desafio024.py | 512 | 4 | 4 | print("""Exercício Python 024: Crie um programa que leia o nome de uma cidade diga se ela
começa ou não com o nome "SANTO".""")
print('Meu jeito de fazer antes de ver a resposta....')
n_cidade = input('Escreva o nome de uma cidade: ')
d = n_cidade.split()
if d[0].upper() == 'SANTO':
print('Começa com Santo')
else:... |
c2d0f61bde4fabf2e53e240dd38f1ab42a4894ce | kapil87/Object-Oriented-Python-Code | /Chapter_4/MonsterExample.py | 1,125 | 3.953125 | 4 | # Main program for creating monsters
import random
class Monster():
def __init__(self, nRows, nCols, maxSpeed):
self.nRows = nRows # save away
self.nCols = nCols # save away
self.myRow = random.randrange(self.nRows) #chooses a random row
self.myCol = random.randrange(self.nCols)... |
56605c7fb699fea286a3bbcc8d41b9af13775297 | cpm205/Machine-Learning | /Datacamp/Python for ML/Functions.py | 1,137 | 4.0625 | 4 | # Create variables var1 and var2
var1 = [1, 2, 3, 4]
var2 = True
# Print out type of var1
print(type(var1))
# Print out length of var1
print(len(var1))
# Convert var2 to an integer: out2
out2 = int(var2)
# Create lists first and second
first = [11.25, 18.0, 20.0]
second = [10.75, 9.50]
# Paste together first and ... |
101f7183a4abafda0217e2719df22751ebd03469 | nasiana/python-explanations | /ex_1.py | 1,466 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 13 00:15:30 2021
@author: owned
"""
x = 5
print(id(x))
for i in range(x):
x = 2
print(id(x))
print(i)
"""
# Results from this code being executed
140733102072336
140733102072240
0
140733102072240
1
140733102072240
2
1407... |
f8e95cbdbfcf66de9dfa81a1b9621dc5092911dd | sny-tanaka/practicePython | /Practice/ProjectEuler/Problem7.py | 717 | 3.78125 | 4 | '''
素数を小さい方から6つ並べると 2, 3, 5, 7, 11, 13 であり, 6番目の素数は 13 である.
10001 番目の素数を求めよ.
'''
#素数判定関数
def prime_numbers(n):
flg = 1
m = n
while flg ==1:
i = 2
while True:
if n % i == 0:
if n == i:
flg = 0
break
else:
... |
070afb0913d7e7e1fe2e017f0edd9960d2ad126a | venkateshwaracholan/Thinkpython | /mini project 1/csv_dictreader.py | 491 | 3.71875 | 4 | import csv
with open('names.csv', 'w') as csvfile:
fieldnames = ['x', 'last_name']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
writer.writerow({'x': 'Baked', 'last_name': 'Beans'})
writer.writerow({'x': 'Lovely', 'last_name': 'Spam'})
writer.writerow({'xy': 'Wo... |
8ee753c1d44c724bd142453fa66b0deb59df82e7 | andrewwong97/facebook-pic-overlay | /filters.py | 1,921 | 3.625 | 4 | #!/usr/bin/env python
from PIL import Image
import os, sys
SIZE = 500
def resize_square(im):
# if square, make 500x500
width, height = im.size
if width > height:
height = int((SIZE*1.0/width) * height)
width = SIZE
else:
width = int((SIZE*1.0/height) * width)
height = SIZE
im = im.resize((width, heig... |
320c5067f7607baedb6009db27bca5f99e60b74e | muralimandula/cspp1-assignments | /m7/p3/Functions - Assignment-3/assignment3.py | 1,521 | 4.125 | 4 | """
A program that calculates the minimum fixed monthly payment needed
in order pay off a credit card balance within 12 months
using bi-section method
"""
def payingdebt_offinayear(balance, annual_interestrate):
""" A function to calculate the lowest payment"""
def bal_d(balance, pay, annual_interestrate):
... |
c16c30220473806b693942ca679b0928da083e83 | arunpandey77/real-python-test | /01_sql.py | 206 | 3.53125 | 4 | # create a sqlite3 database and table
import sqlite3 as sq
conn = sq.connect("new.db")
cursor = conn.cursor()
cursor.execute("""CREATE TABLE population (city TEXT,state TEXT, population INT)""")
conn.close
|
236012b21454dc33ed9965408ecdcfe6ae89ba0a | dodoingdy/leetcode | /word-search.py | 995 | 3.515625 | 4 | class Solution(object):
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
if not word or not board:
return False
for i,m in enumerate(board):
for j,n in enumerate(m):
if n ==... |
672477eaaca93ef64d1ea553f4376ebd78205d50 | JasonAntonino/qa-python-assessment-1a | /programs/questions.py | 12,132 | 4.4375 | 4 | # INSTRUCTIONS
# In case it is not clear, the Question appears first, then examples, then any hints and finally the function that you need to complete appears underneath:
# <QUESTION>
# <EXAMPLES>
# <HINT>
# You are allowed access to the internet for this assessment, or you could use the DOCUMENTATION that comes b... |
4cb4f65d8afe0828a022e84bfce82f80dff7ad3e | LukeHealy/AMI-Assignment | /src/sma/smanode.py | 1,885 | 3.6875 | 4 | ###
# A node in a graph.
#
import copy
import sys
class s_node:
def __init__(self, name_):
self.name = name_
self.children = []
self.edges = []
self.successors = []
self.parent = None
self.depth = 0
self.h = None
self.f = None
self.is_src = F... |
15469e6bbaf84d48115dd086a86d66c83cc3b86b | anujatayal/Leetcode | /MaximumSubarray.py | 1,124 | 3.921875 | 4 | # Given an integer array nums, find the contiguous subarray (containing at least one number) which has
# the largest sum and return its sum.
# # A subarray is a contiguous part of an array.
# Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
# Output: 6
# Explanation: [4,-1,2,1] has the largest sum = 6.
class Solution:
def m... |
f944d2224c2f143479880fca3edadd3333860b63 | dani-fn/Projetinhos_Python | /aulas/Aula#18a.py | 354 | 3.65625 | 4 | galera = list()
dado = []
for c in range(0, 3):
dado.append(str(input('Nome: ')))
dado.append(int(input('Idade: ')))
galera.append(dado[:])
dado.clear()
print(galera)
totmai = 0
for p in galera:
if p[1] >= 21:
print(f'{p[0]} é maior de idade.')
totmai += 1
print(f'Temo... |
76def4f2f4f58003e5ce6798ad05ea6646267593 | 1264799190/1803 | /4.2/7.题.py | 222 | 3.890625 | 4 | acc = "123456"
pwd = "abc"
if input('acc == acc and pwd == pwd') :
print('登陆成功')
elif input('acc == pwd and pwd == pwd'):
print('账号错误')
elif input('acc == acc and pwd == acc'):
print('密码错误')
|
8bd0102c7963fef97eb3485e551eb3c1bc8e9fce | miggoo/Week-11-HW | /wk11hwflaskapp1.py | 1,657 | 3.703125 | 4 | ### Routes
* `/api/v1.0/precipitation`
* Query for the dates and temperature observations from the last year.
* Convert the query results to a Dictionary using `date` as the key and `tobs` as the value.
* Return the JSON representation of your dictionary.
* `/api/v1.0/stations`
* Return a JSON list of sta... |
c5cde7df50968f2c9e2e13f0da5a02ff681747bd | balajiyuvan/PYTHON_programming | /code_katta/positive.py | 106 | 3.71875 | 4 | a=eval(input())
if (a>1):
print("postive")
elif (a==0):
print("zero")
else:
print("negative")
|
28291faf91297e53fd21b8b4e946ab97b5c2a41a | gauriindalkar/for-loop | /userinput se sum.py | 154 | 3.765625 | 4 | ######barbar number se userinput lekar sum print karo
# sum=0
# for i in range(1,11):
# a=int(input("enter number"))
# sum=sum+a
# print(sum)
|
bf884ad36b56bc8458a19570075a43d61ae42801 | su2me2rain/lethuylinh-fundamental-c4e16 | /Session 2/drawcode.py | 1,982 | 3.96875 | 4 | side = 2*int(input('Input the size: '))+1
# print CODE
for i in range(side):
if i==0 or i==side-1:
for j in range(side):
print("* ", end=(''))
print(' ',end=(''))
for j in range(side):
print("* ", end=(''))
print(' ',end=(''))
for j in range(int(side/2... |
8421aa97aeb0519b0c5b66ee1fdfcc6497af9dab | IMDCGP105-1819/portfolio-RJRichmond | /ex2.py | 923 | 4.46875 | 4 | print ("These are how many animals I have:")
# The "+", "-", "*", "/" are the basic opperators for addition, subtraction, multiplication and division.
print ("Cows", 15 + 30 / 6 )
print ("Sheep", 100 - 30 * 3 % 4)
# The "%" symbol is used to give a percentage of a number.
print ("Now I will count my plants:")
print ( ... |
fd5cfcb90e0fc28b55db1a1b4fb2a7c909ca15ed | udaysinghkushwah/Python_Examples | /class/Student.py | 372 | 3.546875 | 4 | class Student:
#This Program developed by UDAY
def __init__(self,rollno,name):
self.rollno=rollno
self.name=name
def talk(self):
print("Hello My name is:",self.name)
print("My Rollno is:",self.rollno)
s=Student(100,'UDAY')
print(s.name)
print(s.rollno)
s.talk()
s1=Student(1... |
246046b2834fa035e5612c40e6507cbe0210d723 | sendemina/lab-07-conditionals | /oddcalc.py | 433 | 3.953125 | 4 | firstnumber = input("Give me a number, any number... ")
secondnumber = input("Cool, now another number... ")
operation = input("Now choose an operation (mul, div, or mod) ")
if operation == "mul":
print(float(firstnumber) * float(secondnumber))
elif operation == "div":
print(float(firstnumber) / float(secondnumber)... |
142317d098f4ca9b7b1697887ba3253f54cecd61 | Shreeti-Masrani/Hashing | /hash1.py | 363 | 3.875 | 4 | import hashlib
str = input('Enter the string:: ')
print(str)
#using hash 3 diff hash algoriths
h1 = hashlib.sha256(str.encode())
h2 = hashlib.blake2b(str.encode())
h3 = hashlib.sha1(str.encode())
print("sh254 Algorithm :: ",h1.hexdigest())
print("blake2b Algorithm :: ",h2.hexdigest())
print("sha1 Algor... |
5bd6df96d146f9eeccddae975b86132d99f6ba84 | jacob3015/Baekjoon | /B_2743_MeasureWordLength.py | 616 | 3.859375 | 4 | """B 2743 단어 길이 재기(Measure Word Length)
Problem:
알파벳으로만 이루어진 단어를 입력받아, 그 길이를 출력하는 프로그램을 작성하시오.
Input:
첫째 줄에 영어 소문자와 대문자로만 이루어진 단어가 주어진다.
단어의 길이는 최대 100이다.
Output:
첫째 줄에 입력으로 주어진 단어의 길이를 출력한다.
"""
def solution():
"""주어진 단어의 길이를 출력한다.
Example:
>>> baekjoon : input word
>>> 8 ... |
ce0b9c46464266b2e08e72eeb413acb6350868fc | TarunDabhi27/LearningPython | /05-modules/module04-class-and-objects/StaticMethods_Example01.py | 376 | 3.640625 | 4 | class Calculator:
def fn(self,param1):
print(param1)
def add(numer_one,number_two):
return numer_one+number_two
@staticmethod
def multiply(number_one,number_two):
return number_one* number_two
if __name__ == '__main__':
obj = Calculator()
obj.fn("df")
print(Calcu... |
87526f01b881d5be224ece3e6ad06857f1c13c40 | Craig-Sperlazza/pandas | /1_analysis.py | 1,792 | 3.703125 | 4 | import pandas as pd
#load csv in as a data frame###############################################################################
df = pd.read_csv('pokemon_data.csv')
print(df.head(3))
print(df.tail(5))
# #load excel in as a data frame
# df_xlsx = pd.read_excel('pokemon_data.xlsx')
# print("EXCEL______________________... |
4c49234132e8422d59cc1d0a2a472c9896883994 | cesarcoboscv/prof-python | /sets.py | 425 | 3.765625 | 4 | def run():
my_set1 = {"pera","manzana", "uva", "fresa", "melon","guayaba"}
my_set2 = {"sandia","mango","manzana","platano","uva","frambuesa"}
union = my_set1 | my_set2
intersection = my_set1 & my_set2
diference = my_set2 - my_set1
simetric_diference = my_set1 ^ my_set2
print(union)
pri... |
2e01ef18cee8182cc1c598b948f3f2f2fa7c9602 | ranog/python_work | /capitulo_03-Introducao_as_listas/sua_propria_lista.py | 435 | 4.125 | 4 | # 3.3 - Sua própria lista:
# Pense em seu meio de transporte preferido, como motocicleta ou carro,
# e crie uma lista que armazene vários exemplos. Utilize sua lista para
# exibir uma série de frases sobre esses itens, como "Gostaria de ter
# uma moto Honda."
bens = ["Honda", "BMW", "Caloi"]
print("Gostaria de ter u... |
3f2ff8e92df63a535c76a4fc4f4f1fb972c32bae | hu22333/git | /python learn/应用基础/Python入门/week_L2/ex1.py | 399 | 3.578125 | 4 | #数值计算小练习
a = 0xa+0b1010+12.34
b = int(11.99)
print(a,b)
a,b = b,a
print(a,b)
a = -a
b = complex(b)
print(a,b)
print(a+b)
print(a+b==21.34+0j)
print(a+b==21.340000000000003)
print(round((a+b).real,2)==21.34)#四舍五入,实部,保留后两位
print(hex(425))#整数变十六进制
print(max(0x1a9,425,400))
print(425/125)
#
a = 123.456
b = 456.789
print(r... |
ee58f1971da0a88caa51c0a052468913f685c32a | maniraja1/Python | /proj1/Python-Test1/CodingInterview/String/phonenumber_mnemonic.py | 1,675 | 3.875 | 4 | '''
This is a backtracking algorithm. Start with an empty string get the first digit and the first character
associated with that digit. Then Get the next digit and the first character associated with that digit.
Add all the way upto the last digit once you reach till the end this is your first string you can append to... |
79bd10033826dbbd2e9bf0f7e8aaf8c5708b20af | lee2014/interview_code | /leetcode/289_game_of_life.py | 3,416 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
According to the Wikipedia's article:
"The Game of Life, also known simply as Life,
is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
Given a board with m by n cells, each cell has an initial state live (1) or dead (0).
Each ... |
29220d41069e0b19c20f49ce958480f0b29a03a3 | nadhiyap/begin | /chr.py | 44 | 3.53125 | 4 | n=int(input("enter the num"))
print(chr(n))
|
91f38daf0ee05e2956d5904f722abbcbefb139d0 | Nandhinichandran/pytho | /set13.py | 159 | 4.3125 | 4 | num=int(input("Enter the number to be reversed:"))
r=0
while(num>0):
digit=num%10
r=r*10+digit
num=num//10
print("Reverse of the given number:",r)
|
121bfdae79c590b8f8dd106bb67238edda4b0db2 | SABRIOUS/Python_Specialization | /Sentiment_Classifier.py | 4,297 | 4.15625 | 4 | # We have provided some synthetic (fake, semi-randomly generated) twitter data in a csv file
# named project_twitter_data.csv which has the text of a tweet, the number
# of retweets of that tweet, and the number of replies to that tweet.
# We have also provided lists of words that are considered positive (positive_word... |
dcc0b698752b919af405840f98e09ae7c2ae9a42 | zihuaweng/leetcode-solutions | /leetcode_python/160.Intersection_of_Two_Linked_Lists.py | 2,097 | 4.03125 | 4 | # https://leetcode.com/problems/intersection-of-two-linked-lists/
# method 1
# 两个链表如果有交叉的话,后面重合的部分是一样长度的。
# 所以首先遍历到两个链表一样长度的地方,然后两个链表同时前向遍历
# 判断是否有一样,一样就停止返回
# method 2
# https://leetcode.com/problems/intersection-of-two-linked-lists/discuss/49798/Concise-python-code-with-comments
# 两个指针拼接,如果有一样的话会访问到同一个节点,同时消除链表长度不同的... |
47814abea1749be652e6ae97f948dc00efbc248d | museHD/NCSS-Adv-2020 | /IMEI Validator/imei_validator.py | 634 | 3.984375 | 4 | number = input("Enter number: ")
def check_IMEI(n):
numList = []
str_num = str(n)
# Creating new list to store number
for num in str_num:
numList.append(int(num))
# Doubling every two numbers
doubled = numList
for eachnum in range((len(numList)-2),0,-2):
doubled[eachnum] = (numList[eachnum]*2)
# Add ea... |
a9f96d8c330d2bcbbe306a0b8e280b06fa7419e4 | BuiltinCoders/PythonTutorial | /comments, escape sequences & print statement.py | 554 | 3.796875 | 4 | # # 1. comments are in the programe but they not executable
# This is practice from student ... (This is single line comment)
# To use multiple line comments we use 'doc strings' we use triple quotes like ' """ '
# # 2. To edit end of line
# print('Hello World',end=' ')
# print('be confident')
# # 3. To print t... |
320060d2d32562d969cffd9745caae926be7eef8 | nisepulvedaa/curso-python | /07-ejercicios/ejercicio6.py | 319 | 4.125 | 4 | """
Ejercicio 6.mostrar todas las tablas de multiplicar del 1 al 10
mostratando le titulo de la tabla y luego las multiplicaciones del 1 al 10
"""
for indice in range(1,11):
print("Tabla del {}".format(indice))
for indice2 in range(1,11):
print("{} x {} = {}".format(indice, indice2, (indice*indice2)))
|
f87bf4138cfe9bd9c783e1174060e5e731fb13a6 | CiyoMa/leetcode | /reverseNodesInKGroup.py | 2,233 | 3.9375 | 4 | """
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only nodes itself may be changed.
Only constant memory is allowed.
For... |
f28f612142d8dd55e233aeeb850a4c2f32643d64 | Ajay0511/Roller-Coaster-Data-Visualization-Project- | /script.py | 4,921 | 3.796875 | 4 | import codecademylib3_seaborn
import pandas as pd
import matplotlib.pyplot as plt
# load rankings data here:
wood_rankings = pd.read_csv('Golden_Ticket_Award_Winners_Wood.csv')
steel_rankings = pd.read_csv('Golden_Ticket_Award_Winners_Steel.csv')
print(wood_rankings.head())
print(steel_rankings.head())
# write fun... |
357d2156944c5dd49201fb44e930de19f5b9ee00 | andrewparrish/mchackssmsrestaurants | /main/place.py | 510 | 3.515625 | 4 | class Place(object):
rating = 0.0
name = ''
price_level = 0
longitude = 0.0
latitude = 0.0
vicinity = ''
def __init__(self, rating, name, price_level, latitude, longitude, vicinity):
self.rating = rating
self.name = name
self.price_level = price_level
self.latitude = latitude
self.longitude = longitud... |
3009e76527826d287eeb4faa9243740af3a561ac | Gary-Makeschool-Projects/cs13 | /Code/bases.py | 4,373 | 4.1875 | 4 | #!python
import string
# Hint: Use these string constants to encode/decode hexadecimal digits and more
# string.digits is '0123456789'
# string.hexdigits is '0123456789abcdefABCDEF'
# string.ascii_lowercase is 'abcdefghijklmnopqrstuvwxyz'
# string.ascii_uppercase is 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# string.ascii_letters ... |
8fb78080cefaae61f06a9ea42e82b44a2c5170ee | jtambe/Python | /IfTripletExists.py | 900 | 3.75 | 4 |
#given an array check if there is a pythagorean triplet in it
#works in O(n^2)
def IfTripletExists(arr):
SquaredArr = []
for i in arr:
SquaredArr.append(i**2)
SortedSquaredArr = sorted(SquaredArr)
for i in reversed(range(len(SortedSquaredArr))):
l = 0
r = i-1
while(l... |
536b4d6ab12aa641257c11106aa6f643898b56ab | EY-cmyk/hw_lection3 | /hw_lection3_exercise3.py | 133 | 4.0625 | 4 | name = "Dima"
name2 = str(input("Input your name: "))
if name2 == name:
print("True")
elif name2 != name:
print("False") |
41a61a8ec350469cb08187ffebf396a4e6a8593c | sahil-athia/python-data-types | /numbers.py | 318 | 3.828125 | 4 | print(2 + 1, 3 - 4, 7 * 9, 9 / 3, 7 % 4, 2 ** 3)
# % sign is the mod operator, diplays remainder
# ** is to the power
print(2 + 10 * 10 + 3)
print((2 + 10) * (10 + 3))
# print 1 will use basic order of operations (* --> +)
print(0.2 + 0.1 - 0.3)
# this will not result in 0 since we are using folating point numbers |
22cc241d9611f7786681711a9bc58a4e77404281 | maxyshaa/cow_intership | /training/optimizers.py | 963 | 4 | 4 | import numpy as np
from training import compute_cost
from training import data_loader
def gradient_descent(x, y, params: np.ndarray, learning_rate: float, n_iter: Int) -> np.ndarray:
"""Apply a gradient descent as a optimization part.
Args:
x: Represents the feature samples.
y: Represents the... |
5c882b3cec5e3e76af5d5db4214c79ea20cb5a7c | IronE-G-G/algorithm | /Sort/radixSort.py | 452 | 3.609375 | 4 | def radicSort(nums):
if len(nums) <= 1:
return 0
max_value = max(nums)
base = 1
while max_value // base > 0:
sort_arr = [[] for _ in range(10)]
# 按基数分桶
for i in range(len(nums)):
to_i_arr = nums[i] // base % 10
sort_arr[to_i_arr].append(nums[i])
... |
380c04ccdb3a9f1aa6e79871255ca38696f295b5 | Milan9870/5WWIPython | /07a-Forlus/Processie van Echternach.py | 311 | 3.671875 | 4 | tijdstip = int(input('geef een tijdstip: '))
stappen = 0
gezette_stappen = 0
for i in range(1, tijdstip + 1):
if i % 2 != 0:
gezette_stappen = gezette_stappen * 2 + 2
stappen += gezette_stappen
else:
gezette_stappen /= 2
stappen -= gezette_stappen
print(int(stappen))
|
0efcad35b08b4362847edd6fafadefb71d6e4dce | jmocay/solving_problems | /string_reverse_words.py | 1,826 | 4.25 | 4 | """
Given a string of words delimited by spaces, reverse the words in string.
For example, given "hello world here", return "here world hello"
Follow-up: given a mutable string representation,
can you perform this operation in-place?
"""
def reverse_words(arr):
reverse(arr, 0, len(arr) - 1)... |
e2ef98e134306071620a021f7ab71e5e72f7269c | Kawser-nerd/CLCDSA | /Source Codes/AtCoder/abc111/B/4915673.py | 293 | 3.578125 | 4 | n = int(input())
if n <= 111:
print(111)
elif n <= 222:
print(222)
elif n <= 333:
print(333)
elif n <= 444:
print(444)
elif n <= 555:
print(555)
elif n <= 666:
print(666)
elif n <= 777:
print(777)
elif n <= 888:
print(888)
else:
print(999) |
0d6688665e84d2edd00d195c5b1b9783d06ec015 | TronVerma/Python-SIG-2015 | /class4/class4soln3.py | 895 | 3.75 | 4 | # Python SIG 2015, BMSCE, Bangalore
# Python SIG in-class assignment - Class 4 - PYA - 17-10-15
# Question and Solution by Pranav S Bijapur
# Question statement:
# Write a program to display the number of times a particular alphabet appears in a string.
# For example 'aabbBc' should return
# a was present 2 times... |
ad47f6f143fbb7d1cc89a8cfc81a2c2f03df8be0 | isidoraorellana/IntensivoNivelacion | /19082019/001740.py | 395 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
"""
#defino variables
g = 7
h = 8
if g < 8:
print 'g es menor a 8' #se muestra siempre que g sea menor a 8
else: #en caso de que g no sea menor a 8 se mostrara una de las siguientes opciones
if g == h:
print 'g es igual a h ' #se muestra cuando g es igual a h
... |
6910d7c0d3359ec4a2864d147128717ac0b640ba | OlehKSS/misa-project | /src/em.py | 2,200 | 3.5625 | 4 | """Helper functions for the EM algorithm."""
from math import sqrt, pi
import numpy as np
def gaussian_mixture(features, mean, cov):
"""
Return Gaussian mixture function for a class.
Inputs:
features (numpy.ndarray): n by d dimentional array of features of points from feature space, where d i... |
656cca5a59df642bdab0bbc43e3c128573aef02f | Filipe-Amorim1/Scripts-Python | /Aula14/Desafio61_Aula14.py | 951 | 3.921875 | 4 | # Refaça o DESAFIO 51, lendo o primeiro termo e a razão de uma PA
# mostrando os 10 primeiros termos da progressão usando a estrutura while.
primeiro = int(input('Digite o número inicial: ')) # digitou o número para começar a contagem
razão = int(input('Digite a razão da progressão: ')) # n que sera o tamanho da prog... |
f321a7bf08eae5f1f2183a2bed1f4a2be9e6c3d0 | emgoinv/math-programs | /PascalsTriangle.py | 627 | 3.921875 | 4 | import math
#prints n rows of Pascal's Triangle
def pascals_triangle(rows):
length = len(str(n_choose_k(rows, rows/2)))+2
print_row = ''
for n in range(0, rows+1):
for k in range(0, n+1):
print_row += pascal_format(length, n_choose_k(n, k))
print print_row
prin... |
1c01a16b078995d887cddb7aa90f5b64a0d8986b | mateuscardosodeveloper/GamesWithPython | /JogoDaAdivinhação/adivinhacao.py | 1,727 | 3.953125 | 4 | import random
def jogar():
print("---------------------------------")
print("Bem vindo ao jogo da Adivinhação.")
print("---------------------------------")
vida = 0
numero_secreto = random.randrange(1, 100)
pontos = 1000
print("Escolha um nível: (1) Fácil, (2) Normal, (3) Difícil.")
... |
bbb38c7792d4f55b42317751508636fcf4e706b2 | aash-gates/IBM_Digital_nation-Blocky | /blocky colors.py | 430 | 3.640625 | 4 | colors = None
def lists_sort(my_list, type, reverse):
def try_float(s):
try:
return float(s)
except:
return 0
key_funcs = {
"NUMERIC": try_float,
"TEXT": str,
"IGNORE_CASE": lambda s: str(s).lower()
}
key_func = key_funcs[type]
list_cpy = list(my_list)
return sorted(list_cpy... |
08f31f395e18690a6b4b2f4d1919ce57b320eed1 | eugengh/listaantrenament | /liste.py | 309 | 3.75 | 4 | lista1 = [1,4,7,23,50,-100,-2,0,-30]
print(lista1)
lista2 = sorted(lista1)
print(lista2)
lista3=lista1
lista3.sort(reverse=True)
lista1 = [1,4,7,23,50,-100,-2,0,-30]
print(lista3)
print(len(lista1))
print(max(lista1))
print(min(lista1))
print(lista1 + [-111])
lista1.insert(2, -222)
print(lista1) |
bd11b5a8b336c4c2409efdba8bca99db121214b7 | Kohdz/Algorithms | /LeetCode/easy/41_factorialTrailingZero.py | 600 | 4.15625 | 4 | # # https://leetcode.com/problems/factorial-trailing-zeroes/
# Given an integer n, return the number of trailing zeroes in n!.
# Example 1:
# Input: 3
# Output: 0
# Explanation: 3! = 6, no trailing zero.
# Example 2:
# Input: 5
# Output: 1
# Explanation: 5! = 120, one trailing zero.
def trailingZeroes(n):
# ... |
d0e38acdbf5f2919144c632e272f46b7656e1860 | Nipun2016/Core-Python-Training | /Exercises/Deepak/Flow and Control/p5.py | 258 | 3.6875 | 4 | def fun(list1,list2):
for i in list1:
if i in list2:
return True
else:
return False
if __name__ == "__main__":
list1 = [1,2,3,4]
list2 = [1,22,33,44]
print(list1)
print(list2)
print (fun(list1,list2))
|
40087eda1399955f00502ef670cbbfbbc2436d4f | mihirverma7781/Python-Scripts | /chap2/sformatting.py | 253 | 4.28125 | 4 | name = 'Mihir'
age = 19
print('hello = '+ name + ' your age ='+ str(age) )
# this is ugly syntax so we use String formatting
# python 3
print("your name = {} your age = {}" .format(name,age))
# python 3.6
print(f"your name = {name} your age = {age+5}")
|
7b83aea149fabf45d81df7c12f16fb94031b4786 | jamesmedlin/4x4-tic-tac-toe | /main.py | 7,790 | 3.921875 | 4 | import time
class Board:
def __init__(self):
self.reset_game()
def reset_game(self):
# The tic-tac-toe board will be represented as a 2d array. Blanks will be represented as .'s for
# graphical display and False = X's and True = O's for the moves.
self.board = [['.', '.', '.', '.'],... |
a25f2f357055cf03c4813ca0b6d937c99f4cf2fd | EliGorniak/python-gustavo-guanabara-course | /PythonAulas/aula006b.py | 480 | 4.15625 | 4 | # operadores aritméticos e tipos:
# crie um programa que leia dois numeros e mostre a soma entre eles
n1 = int((input('Digite um valor: ')))
n2 = int((input('Digite outro valor: ')))
soma = n1 + n2
print('A soma entre {} e {} é: {}!'.format(n1, n2, soma))
# crie um programa que leia algo pelo teclado e mostre na tel... |
34de604adfa9de004b6a9fd2928d878a084d021c | zhou-1/COVISS-Lab-Research | /OpenCV/Python/Gui Features/MouseAsAPaint-Brush/Third.py | 1,853 | 3.578125 | 4 | import numpy as np
import cv2 as cv
# free hand drawing
"""
# First we create a mouse callback function which is executed when a mouse event take place.
# List all available events available,
events = [i for i in dir(cv) if 'EVENT' in i]
print(events)
"""
"""
# Below, mouse callback function does one thing, it draws... |
f0ccf4084ecc3fe1a24f0b63a3c1734264f277b3 | zirui/challenges | /spoj/4.py | 973 | 3.53125 | 4 | import sys
#import psyco
#psyco.full()
op = ['+','-','*','/']
precedence = {k:v for k,v in zip(op,range(len(op)))}
#print precedence
def is_operator(ch):
return ch in ('+','-','*','/','^')
def is_operand(ch):
return 'a' <= ch <= 'z'
def rpn(infix_notion):
rst = ''
op_stk = []
for ch in infix_not... |
58591a440b210e43dbf21a65f08becb027fce7f4 | StarshineXIII/Portfolio | /PythonFundementals/pythonFundementals/compare.py | 458 | 4 | 4 | list_one = [1,2,5,6,2]
list_two = [1,2,5,6,2]
list_one = [1,2,5,6,5]
# list_two = [1,2,5,6,5,3]
# list_one = [1,2,5,6,5,16]
# list_two = [1,2,5,6,5]
# list_one = ['celery','carrots','bread','milk']
# list_two = ['celery','carrots','bread','cream']
def compare(partOne, partTwo):
if list_one == list_two:
... |
69b86011a2c13451eff05f2b932bf9b35d1c7e72 | saakethtypes/Compi | /insertion_sort.py | 266 | 4 | 4 | def insertion_sort(arr):
for i in range(len(arr)-1):
j = i + 1
while j > 0:
if arr[j-1]>arr[j]:
arr[j-1],arr[j] = arr[j] , arr[j-1]
j -= 1
return arr
arrr = [8,5,2,9,5,6,3]
print(insertion_sort(arrr)) |
8f4b2335bb78e265faf0eba76651ff1c345846ee | kchiu90/irqbalancing | /irq_balance.py | 2,519 | 3.609375 | 4 | #!/usr/bin/env python
"""
Task: IRQ Balancing Algorithm
Write a short python script to do an approximation of the best way to evenly balance these IRQs between two CPUs.
Your script should output:
- A list of IRQs to have their affinity set to CPU0 or CPU1.
- A metric showing how closely balanced the IRQs are.
Author... |
bbdf9f8d4415e731d8e4636064c8fe0ed57a7ada | Yatheen07/mnist-classification-feedForward-keras | /mnistClassification.py | 6,513 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 12 14:23:07 2018
@author: kmy07
"""
"""Step 1 : Import keras and mins dataset"""
from keras.datasets import mnist
import numpy as np
import matplotlib.pyplot as plt
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
"""Step 2: Understand the d... |
7e9f1322a30ce526565972e7d94ccb8acb4a51c8 | abhinai96/Python_Practise_Programs | /34 day 10 dict sqaure of key and only print keys.py | 292 | 4.03125 | 4 | #Define a function which can generate a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys. The function should just print the keys only.
d={}
for i in range(1,21):
d[i]=i*i
print(d)
for i in d.values():
print(i)
|
3bcdad04fcd617eb7f0d8fb14923780bf470dd66 | dpollak44/class | /python/37/app.py | 1,489 | 3.96875 | 4 | print("Hello World")
x: int = 5 # type annotation, help reader
print(x, type(x))
# - mypy linter will complain switching types (even without type annotation)
x = 'Hello'
print(x, type(x))
y = 1.5
print(y, type(y))
z = True
print(z, type(z))
my_long_variable_name = 5
very_big_int = 43785435684754785467549676749867546... |
617b4b8f58657602cec25d55d92626c255224ea0 | henriquecl/Aprendendo_Python | /Exercícios/Lista 4.1 - Seção 7 - Matrizes/Questão 5 - Encontrar valor na matrix.py | 795 | 3.984375 | 4 | """
Questão 5 - Leia uma matrix 5x5. Leia também o valorr X. O programa deverá fazer uma bsuca desse valor na matriz, e ao
final escrever a localização ou uma mensagem de não encontrado
"""
matrix = [[1, 2, 3, 4, 5], [789, 19, 19, 19, 19], [1891, 1, 1, 1, 1], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
linha = 0
coluna = 0
x = ... |
942246317ba1f8873c63e6c68bf66c1eedeeb601 | Saptarshi123/works | /Student.py | 554 | 3.625 | 4 | from course import Course
class Student:
courseNames=[]
def getRollNumber(self):
return self.rollNumber;
def setRollNumber(self,rollNumber):
self.rollNumber=rollNumber;
def getName(self):
return self.name;
def setName(self,name):
self.name=name;
def getCourseNames(self,course):
re... |
60c9b0aed7358051c53d36c9db3cd569a182f420 | sztxr/JetBrains_Projects | /Tic-Tac-Toe/Problems/Conditions & nested lists/task.py | 149 | 3.84375 | 4 | # the list "students" is already defined
print([s[0] for s in students if s[1] == 'A'])
# print([name for name, grade in students if grade == 'A'])
|
5030394bef5d28089cdf5e814382180bf42cf224 | LABETE/Python1_Homework | /final2.py | 10,569 | 3.953125 | 4 | #!/usr/local/bin/python3
""" Program for extract information of a document txt"""
import sys
exit_options_lst = ["Yes","No"]
menu_lst = ["Size of the word and number of words(1: 20)","Word and number of times that it is displayed(and: 15)","Words that are from the same size(3: and, the)","Exit from menu selection"]
t... |
dfb52879a8703f4e7673c6d9e340856e74c0a5e1 | alexandervpetrov/rosalind | /algo/19-INV/INV.py | 929 | 3.59375 | 4 | #!/usr/bin/env python
import sys
ifs = sys.stdin
ofs = sys.stdout
def numbers_from_line(d=' '):
return [int(s) for s in ifs.readline().strip().split(d)
if len(s.strip()) > 0]
def count_inv_and_merge_sorted(A, B):
n = len(A)
m = len(B)
C = []
i = 0
j = 0
inversions = 0
w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.