blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4485a43120b9ad713f361135d19c5b2b61634a63 | tup916/Summer2016_ComputerScience-Research-AudioProcessing | /semantic_metrics_IBM.py | 1,408 | 3.828125 | 4 |
#Author: Tushita Patel
#June, 2016
#Human Computer Interaction Lab
#Department of Computer Science
#University of Saskatchewan
#Semantic Metrics
#imports
import speech_recognition as sr
#input .wav file to be transcribed from the user
#the file should be located at the same folder as this code
fileNam... |
ae711ea94ac8f301b9baecb44d7e0c81356d6236 | MattySly/python-training-code | /scratches/functions.py | 259 | 3.515625 | 4 |
def function3(x, y):
return x + y
e = function3(1, 2)
print(e)
def function4(x):
print(x)
print("still in function")
return 3*x
f = function4(4)
print(f)
def function5(some_argument):
print(some_argument)
print("weee")
function5(4)
|
1cc5122e5c66d396e0dc0b524d9525bc39c29fb8 | miikanissi/python_course_summer_2020 | /week6_nissi_miika/week6_ass10_nissi_miika.py | 219 | 3.78125 | 4 | def search(array, n):
for i in array:
if i == n:
return True
return False
arr = [23,4,89,19,0,700,30]
print("Number 19 found: ", search(arr, 19))
print("Number 20 found: ", search(arr, 20))
|
81a862b2546e197be70de7e1c0e7d85dc190a9b2 | dandurden/dandurden | /lab4/lab_4v1.py | 3,347 | 3.875 | 4 | import pygame
from pygame.draw import *
from random import randint
pygame.init()
FPS = 30
screen = pygame.display.set_mode((1200, 900))
RED = (255, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
GREEN = (0, 255, 0)
MAGENTA = (255, 0, 255)
CYAN = (0, 255, 255)
BLACK = (0, 0, 0)
COLORS = [RED, BLUE, YELLOW, GREEN, MA... |
c47c529812d8f82caa24a8bb52470955e6358317 | anondev123/F20-1015 | /Lectures/18/op1.py | 104 | 3.6875 | 4 |
a = 2
b = 3
c = 4
x = a + b * c
# Will Print 14 becasue 3 * 4 = 12, then add + 2
print ( f"x={x}" )
|
4c08b92478d1a151d0076137ffd8752861562ef0 | stayfu0705/python1 | /homework/hw1.py | 1,809 | 3.71875 | 4 | '''
num=eval(input('input ur month:'))
if num in (12,1,2):
print("冬天!")
elif num in (3,4,5):
print("春天!")
elif num in (6,7,8):
print("夏天!")
elif num in (9,10,11):
print("秋天!")
else:
print("輸入錯誤")
'''
'''a=eval(input('輸入你的工時:'))
if a<60:
print(a*120,'元')
elif a>=61 and a<=80:
print(60*120... |
28ed8aaaf62478641dad42413a557615adba29cf | mitchell-johnstone/PythonWork | /PE/P051.py | 3,030 | 4.15625 | 4 | # By replacing the 1st digit of the 2-digit number *3,
# it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.
#
# By replacing the 3rd and 4th digits of 56**3 with the same digit,
# this 5-digit number is the first example having seven primes
# among the ten generated numbers, y... |
44ee0b3b2c3fdc991e13a586f68ead4ef485f040 | anuragchhipa123/ASD1998 | /Day 3/intersection.py | 206 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 9 12:35:09 2019
@author: DELL
"""
list1=set(input("Enter the set 1 : "))
list2=set(input("Enter the set 2 : "))
list3=list1.intersection(list2)
print(list3) |
313719a07a183df0ac5dd8f35adc3fbbda5b0129 | refanr/2020 | /sequence_analysis.py | 2,731 | 3.71875 | 4 | # Take in file names
# For each file, open it and read it
# Check if each number is actually a number and then put it in a sequence
# Make a sorted sequence and an ordered sequence
# Take the ordered sequence and find the median value
# Finally print the results
def process_all_files(filename_list):
for file in fi... |
84b41e6e8f04660a9328d3757e6900ba52311a5b | jacealan/eulernet | /level2/43-Sub-string divisibility.py | 2,047 | 3.96875 | 4 | #!/usr/local/bin/python3
'''
Problem 43 : Sub-string divisibility
The number, 1406357289, is a 0 to 9 pandigital number
because it is made up of each of the digits 0 to 9 in some order,
but it also has a rather interesting sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on.
In thi... |
bac4fec5d177b34c71b35dc5d55f0fc46d0a3c69 | oshtyrov/Python-basics | /Shtyrov_Aleksandr_dz4/Shtyrov_Aleksandr_dz4/task_06.py | 1,793 | 3.625 | 4 | # 6. Реализовать два небольших скрипта:
# а) итератор, генерирующий целые числа, начиная с указанного,
# б) итератор, повторяющий элементы некоторого списка, определенного заранее.
# Подсказка: использовать функцию count() и cycle() модуля itertools.
# Обратите внимание, что создаваемый цикл не должен быть бесконеч... |
ee856624e0eee7fd7015064e72d544478b8caa73 | yanivn2000/Python | /Syntax/Module6/05_exc_solution.py | 491 | 3.640625 | 4 | import re
def find_match(pattern, string, index):
x = re.search(pattern, string)
if x:
print(f"{index} - Match")
else:
print(f"{index} - No Match")
find_match('^[0-9][0-9][^-].', 'a1a3', 1) # Y
find_match('^[a-z][0-9][^-].', 'a1a3w', 1) # Y
find_match('^[a-z][0-9][^-].', 'a1a', 1) # N (mi... |
d698cf66a28a7564b335a532b2bc57f7fd8510fc | bimri/learning-python | /chapter_20/combining_items_in_iterables_reduce.py | 1,273 | 4.09375 | 4 | "Reduce function lives in functools module"
# Accepts aan iterable to process, but it's bot an iterable itself
# - it returns a single result.
from functools import reduce # Import in 3.X
# reduce passes the current sum or product. respectively
print(
reduce((lambda x, y: x + y), [1, 2,... |
c812247a6f71e564c190b45916e4b969c6ce8ccc | jsgf/EyeFiServer | /Server/EyeFiCrypto.py | 2,715 | 3.5 | 4 | import binascii
import struct
import array
import hashlib
class EyeFiCrypto():
# The TCP checksum requires an even number of bytes. If an even
# number of bytes is not passed in then nul pad the input and then
# compute the checksum
def calculateTCPChecksum(self, bytes):
# If the number of bytes I wa... |
6c7ed0e8148d7f93313f5cffecb58c3f71010dd0 | wzoreck/Curso_Python_Django | /Associacao_entre_classes/classes.py | 1,019 | 3.796875 | 4 | class Aluno:
def __init__(self, nome, sexo):
self.__nome = nome
self.__sexo = sexo
@property
def nome(self):
return self.__nome
@nome.setter
def nome(self, nome):
self.__nome = nome
@ property
def sexo(self):
return self.__sexo
... |
e1cf5c479c79e70f69b26a6f99ff480001384393 | takaping/Hangman | /Hangman/task/hangman/hangman.py | 1,161 | 3.8125 | 4 | # Write your code here
import random
word_list = ['python', 'java', 'kotlin', 'javascript']
print('H A N G M A N')
while input('Type "play" to play the game, "exit" to quit: ') == 'play':
correct_word = random.choice(word_list)
input_letters = set()
mistakes = 0
while mistakes < 8:
answer_wo... |
465ef6df4694640dd49574c6d8e994e1ffd6eaff | AMEERAZAM08/Codeinplace-Stringoperation | /main.py | 1,758 | 4.34375 | 4 |
#Strings are bits of text. They can be defined as anythi
astring = "Hello world!"
astring2 = 'Hello world!'
astring = "Hello world!"
print("single quotes are ' '")
print(len(astring))#12
#count char in given string
astring = "Hello world!"
print(astring.count("l"))#3
#indexing in srting but can't cha... |
ca2347e83c3e4315ae82462813910b4f6d26eabb | lumy/moulinette_simplon | /tests/rendu/lumy/part2/valid_password.py | 529 | 3.609375 | 4 | def has_alpha(string):
for i in string:
if 'a' <= i <= 'z' or 'A' <= i <= 'Z':
return True
return False
def has_digit(string):
for i in string:
if '0' <= i <= '9':
return True
return False
def has_special(string):
for i in string:
if not '0' <= i <= '9' and not 'a' <= i <= 'z' or 'A'... |
783c62937be52c125bc796749230c95e1da423a1 | Skared15/Homework | /homework_1.py | 1,266 | 3.953125 | 4 | # Task=1
print("----------Que.-1--------")
x,y,z=10,20.20,'Hello'
print(x)
print(y)
print(z)
print("--------Que.-2----------")
a=2+4j
b=2
a,b=b,a
print("a=",a,"and","b=",b)
print("---------Que.-3----------")
a=1
b=2
q=a
a=b
b=q
print("a=",a,"and","b=",b)
a,b=b,a
print("a=",a,"and","b=",b)
print("----------Que... |
81d96fdb11384cac3875c564e3110148ca479d31 | jiangyihong/PythonTutorials | /chapter9/my_die.py | 253 | 3.578125 | 4 | from chapter9.die import Die
six_die = Die()
for i in range(0, 10):
six_die.roll_die()
print("\n")
ten_die = Die(10)
for j in range(0, 10):
ten_die.roll_die()
print("\n")
twenty_die = Die(20)
for k in range(0, 10):
twenty_die.roll_die()
|
53a43f3febef8c5fb2351ea735d2644a4fa189c8 | sylverpyro/python-the-hard-way | /ex5.py | 685 | 4 | 4 | name = 'Zed A. Shaw'
age = 35 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
print ( "Let's talk about %s." % name )
print ( "He's %r inches tall." % height )
print ( " Which is %f cm." % ( height * 30.48 ) )
print ( "He's %r pounds heavy." % weight )
print ( " Which... |
3450e4977d454ca636eb5d02e711c89047b8c7c3 | VerdantFox/flask_course | /02-Flask-Basics/05-Routing_Exercise.py | 834 | 3.5 | 4 | # Set up your imports here!
from flask import Flask, request
app = Flask(__name__)
@app.route("/") # Fill this in!
def index():
# Welcome Page
# Create a generic welcome page.
page = "<h1>Welcome! Go to /puppy_latin/name to see your name in puppy latin</h1>"
return page
@app.route("/puppy_latin/<n... |
6b3e4b5a126c41224f67b823597dd6c22e3f8a73 | hnm6500/csci141---python | /findWord (1).py | 1,166 | 4.34375 | 4 | #Hrishikesh N Moholkar
import turtle
def Count_Words(textFileName):
"""
this function counts the no.of spaces between the words and adds one
which equals to number of words.
:param:textFileName
:return:
"""
count=0
"""count variable is assigned to count... |
2a9eed6bfbee5b1c83bcadb3f4096eaa336c7c0b | hellyhe/python-django-sample | /alg/sort.py | 774 | 4.125 | 4 | # -*- coding: utf-8 -*-
import random
def sort_print(func, items=None):
""" Create random data and sort """
if items is None:
items = [random.randint(-50, 100) for c in range(32)]
print 'before sort use <%s>: %s' % (func.func_name, items)
sorted_items = func(items)
print 'before sort use <... |
0e3359fd8cf67053951719097aa567a20bd4f3e2 | Adam1997/extended_euclidean_solver | /matrix.py | 1,121 | 3.53125 | 4 | class Matrix:
#functional
def __init__(self, r, c):
self.nrow = r
self.ncol = c
self.data = [[0]*r,[0]*c]
#other parameterised constructors needed
def getCol(self):
return self.ncol
def getRow(self):
return self.nrow
#setters
def setData(self, list):
... |
5272bf8112c361cf7e64a978a875f73e8d593783 | share020/dl | /assignments/mp2/src/utils.py | 4,084 | 3.953125 | 4 | """
HW2: Implement and train a convolution neural network from scratch in Python for the MNIST dataset (no PyTorch).
The convolution network should have a single hidden layer with multiple channels.
Due September 14 at 5:00 PM.
@author: Zhenye Na
@date: Sep 9
"""
import h5py
import numpy as np
def mnist_loader(pa... |
9bd1fc3c3e376535f512e379ff7fbea0f77f8aff | PeterHinge/CodingBat-Python-exercises | /String-2.py | 2,223 | 4.0625 | 4 | # String-2
"""Given a string, return a string where for every char in the original, there are two chars."""
def double_char(str):
double_str = ""
for i in str:
double_str += i * 2
return double_str
"""Return the number of times that the string "hi" appears anywhere in the given string."""
def co... |
318cb258d178464455cce312121f50125fec5a4f | hassan652/MRSP | /Useful Functions/auto_corr_Axx.py | 473 | 4.09375 | 4 | '''
Imagine we have a matrix X = np.matrix([[2.1,6.6],[4.6,5.3]])
Calculate autocorrelation function Axx. In the answer field provide Axx(1,1) using Matlab notation.
'''
import numpy as np
X = np.matrix([[2.1,6.6],[4.6,5.3]])
print('original matrix\n',X)
Xtrans = X.T
print('Transpose matrix\n',Xtrans)
Auto_correlatio... |
59e8f7e90985c0462693ad418a2c109a1b229133 | tomervain/vocaptcha | /lib/tts_module.py | 2,334 | 3.734375 | 4 | from google.cloud import texttospeech as tts
from playsound import playsound as ps
import os
def text_to_speech(input_text):
# Instantiates a client
client = tts.TextToSpeechClient()
# Set the text input to be synthesized
synthesis_input = tts.SynthesisInput(text=input_text)
# Build the voice re... |
b212d0fc905e347b54cd948f08ac848293c71c60 | hhhhhhhhhh16564/pythonLearn | /11/01.多进程.py | 6,753 | 4.03125 | 4 | # Unix/Linux操作系统提供了一个fork()系统调用,它非常特殊。普通的函数调用,
# 调用一次,返回一次,但是fork()调用一次,返回两次,因为操作系统自动把当前进程(称为父进程)复制了一份(称为子进程),
# 然后,分别在父进程和子进程内返回。
# 子进程永远返回0,而父进程返回子进程的ID。这样做的理由是,一个父进程可以fork出很多子进程,
# 所以,父进程要记下每个子进程的ID,而子进程只需要调用getppid()就可以拿到父进程的ID。
#
# Python的os模块封装了常见的系统调用,其中就包括fork,可以在Python程序中轻松创建子进程:
import os
#拿到本进程的ID os.getpid(... |
11a6a3e6103a49eb24c254ceef533d8f9b515dac | thisLexic/csci-51.01-proj | /proj.py | 17,009 | 3.5 | 4 | def get_details(process_list):
process_list.sort()
process_count = len(process_list)
total_waiting_time = 0
total_turnaround_time = 0
total_response_time = 0
print("Waiting times: ")
for p in process_list:
print(" Process ", p[0], ": ", p[4], "ns", sep="")
total_waiting_tim... |
ecc0fd5e604b877595013cacf25667129d7b0c01 | nirajgolhar/python-basics-programs | /Python Basics/age.py | 160 | 3.90625 | 4 | a=int(input('Enter a age'))
if(a>=18):
print(a,'you are Eligible')
else:
print(a,'you are not Eligible')
print("wait for",18-a,"Years")
|
38be9854a7c30f8c7974c4647028e65fb55eda09 | Elmorew3721/CTI110 | /P1Lab3_Interleved_ElmoreWalker.py | 71 | 3.8125 | 4 | print('Enter x: ')
x = int(5)
print(x)
print('x doubled is:', (2 * x)) |
29cd5f99db6ba2b33f5dab647417c50f96c740a8 | jackson-leite/Atividade-PBD-Semana03 | /ex04.py | 2,142 | 3.890625 | 4 | """2 Uma pista de Kart permite 10 voltas para cada um de 6 corredores. Escreva um
programa que leia todos os tempos em segundos e os guarde em um dicionário, em que
a chave é o nome do corredor. Ao final diga de quem foi a melhor volta da prova e em
que volta; e ainda a classificação final em ordem (1o
o campeão). O ... |
0d9a064535819a28860bfdd63aaba84760b407f9 | Daksh-CodingCamp/Python-Tutorial- | /List in Python Part1.py | 180 | 3.796875 | 4 | list1 = ['pencil', 'pen', 'eraser', 'sharpner']
print(type(list1))
list2 = [45, 44, 85, 99, 100]
list2.append("hi")
print(list2[2:5:2])
xyz = list2[2:5:2]
xyz.reverse()
print(xyz)
|
954197923782f9e7ef53983149b2172bba88e0d8 | XxdpavelxX/Python-Algorithms-and-Problems | /Interview Questions Practice/absolute_min.py | 619 | 3.671875 | 4 | #Given three arrays A,B,C containing unsorted numbers. Find three numbers a, b, c from each of array A, B, C such that |a-b|,
#|b-c| and |c-a| are minimum Please provide as efficient code as you can. Can you better than this ???
list1 = [1,3,5,4,9]
list2 = [0,8,7,6,2]
list3= [12,3,9,6,15]
def finder(listy1,listy2,list... |
b48509aa24efaf8763f44cf7b467797b53bbd570 | Nurtal/NETABIO | /netabio/na_manager.py | 10,932 | 3.5625 | 4 | """
=> Deal with NA in data files
"""
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
import operator
def check_NA_proportion_in_file(data_file_name):
"""
-> data_file_name is a csv file, generate via the
reformat_luminex_raw_data() function
-> Evaluate the proportion of NA valu... |
10e828b76fd1dc2ddd2f737a937702e4c2170e24 | amanansari10106/onlinec-linux | /temp/python practical/one.py | 1,923 | 3.828125 | 4 | def fib(n):
if n==1:
return 1
return n*fib(n-1)
global b
def numpalindrome(n):
b=0
z=n
while(True):
if n<10:
b = (b*10)+n
break
a = n%10
n = int(n/10)
b = (b*10)+a
if z==n:
print("number is palindrome")
e... |
afd5ff953e1fb850eea7dbd8b3366f14da736a97 | aaychen/Headstart | /hangman.py | 2,246 | 4.09375 | 4 | import random
def getWord(fileName):
with open(fileName, 'r') as file:
word_list = file.read().split('\n') # assuming each word is on a separate line
random.seed(3)
i = random.randint(0, len(word_list)-1) # random index for word_list
return word_list[i] # return a random word
def askAttempts()... |
04c3dea40e51d1e61db8ad6c3cadf9af8e8b0cec | RancyChepchirchir/AI-1 | /Module-2/AAI_Assignment_1_AI_Graphs_Uninformed_Search (1).py | 48,166 | 4.125 | 4 |
# coding: utf-8
# # Introduction to Artificial Intelligence
#
# ------------
#
# _Authors: Jacob Koehler, Dhavide Aruliah_
#
#
# ## Representing and Visualizing Graphs with Python
#
# This assignment prefaces later work with graph traversal problems. As preparation, you will cover ways to represent basic graph... |
e8e7f1cdcf7128a85bc329cccd097c9131a4e55f | RuchiBor/machine_learning_problems | /tensorflow_1_x/7_kaggle/learntools/sql/ex1.py | 2,307 | 3.625 | 4 | from learntools.core import *
class CountTables(EqualityCheckProblem):
_var = 'num_tables'
_expected = 1
_hint = \
"""Run `chicago_crime.list_tables()` in the top cell. Interpret the output to fill in `num_tables`"""
_solution = CS(
"""
chicago_crime.list_tables()
num_tables = 1 # also could have d... |
e6b5b10fc8ada75fdeff86c469719b85efba4837 | noamm19-meet/meet2017y1final-proj | /eman.py | 1,624 | 3.734375 | 4 | ###########the food and the score#############
import turtle
import random
square_size=20
score=0
pos_list=[]
stamp_list=[]
food_pos=[]
food_stamps=[]
turtle.register_shape('car.gif')
car = turtle.clone()
car.shape("car.gif")
turtle.hideturtle()
turtle.penup()
number_of_burgers=random.randint(1,5)
turtle.register_shap... |
e2460d910deda577b21586db4f4724b66f42e9c3 | juliancamilocamachotorres/learn-python | /example-2.py | 113 | 3.5 | 4 | Lado=int(input("ingrese el lado del cuadrado: "))
Perimetro=Lado*4
print("el perimetro es: ")
print(Perimetro) |
64eebb8ed6b01f3858629684704cba4f5bcf03c4 | Amruta329/123pythonnew- | /list.py | 319 | 4.0625 | 4 |
thislist = ["apple", "banana", "cherry"] #used to extend the elemts or it will add the second list into first list
tropical = ["mango", "pineapple", "papaya"]
thislist.extend(tropical)
print(thislist)
thislist.insert(2, "watermelon") #used to insert the elements aat index
print(this... |
2f9ac2f3935ed75b444df0d0defb19a2df863b60 | demar01/python | /Chapter_PyBites/107_Filter_numbers_with_a_list_comprehension/list_comprehensions.py | 580 | 4.09375 | 4 | from collections import namedtuple
numbers= [1,2,3,4]
#easier to create two functions first and then use them in the list comprehension
def is_even(num):
return num % 2 == 0
def is_positive(num):
return num > 0
BeltStats = namedtuple('BeltStats', 'score ninjas')
ninja_belts = {'yellow': BeltStats(50, 11),... |
36011880ba535c33782d318ce77dee5a44c4b5f7 | AlexJamesWright/Blackjack | /src/Table.py | 5,781 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 19 18:42:56 2019
@author: ajw1e16
Table class
"""
from DeckAndShoe import Shoe
from HandSeatAndDealer import Seat, Dealer
import utilityFunctions as ut
class Table(object):
"""
Physical table. Has seats, a dealer, and a shoe.
Paramet... |
24dccf28929b3bf5770f2646ff0f6fa0441f0247 | midhorse/hft-verilog-generator | /src/generator/gen_testbench.py | 3,995 | 3.671875 | 4 | '''
This file takes a csv formatted input data file and an algorithm name and generates two files:
a raw data file and a test bench in verilog used to run the the specified algorithm on the raw data file.
'''
import sys, csv, struct
def get_bin_from_int(num):
return bin(struct.unpack('!i',struct.pack('!f',float(n... |
922a23937c3a89c62c7cd8909852add27f2dd14b | meetofleaf/password-transformer | /firepass.py | 2,043 | 3.90625 | 4 | import random as r
print("\nFire Password")
print("_____________\n")
user_pass = input("Password: ")
def passgen(upass):
chars = list(upass)
for i in range(len(chars)):
if chars[i] == 'a':
chars[i] = '@'
elif chars[i] == 'A':
chars[i] = '4'
elif chars[i] == 'E'... |
7ab593a2c86294ad12248e47f7dce12560349759 | prashant97sikarwar/leetcode | /Tree/Validate_Binary_Search_Tree_naive.py | 711 | 4.0625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
## function to check whether the Tree is binary search tree or not.
def isValidBST(self, root):
ans = []
self.inorder(root... |
0c0e3c9c7951469857b332abf43a5099eb8d1a16 | jongpal/AlgorithmPrac | /karp-rabin.py | 1,099 | 3.5 | 4 | #karp rabin
#make time complexity of string search to O(n), linear time
s = 'jong'
t = 'songhyunham is very nice jong'
s_list = []
temp=[]
def init_calc (str_list, base = 10):
sum = 0
for i in range(len(str_list)):
sum += str_list[i]*(base**((len(str_list)-1)-i))
return sum
def hash(num, m):
return nu... |
1a57be66e483479f2ef7d3aab11f7ef292ffe9e8 | frankShih/LeetCodePractice | /75-sortColor/solution.py | 1,466 | 3.546875 | 4 | class Solution:
def sortColors(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
'''
# 80% two-run, naive solution
counter = [0]*3
for n in nums:
counter[n]+=1
... |
99e99cc2191e4cdf0bec54227943e2813f3a3c09 | AnnKuz1993/Python | /lesson_04/example_01.py | 734 | 3.859375 | 4 | """
Реализовать скрипт, в котором должна быть предусмотрена функция расчета заработной платы сотрудника.
В расчете необходимо использовать формулу: (выработка в часах*ставка в час) + премия.
Для выполнения расчета для конкретных значений необходимо запускать скрипт с параметрами.
"""
import sys
from lesson_04 import te... |
5d5486fcebf8ee5d8968fc877c01065279dad1aa | biosvos/algorithm | /프로그래머스/모의고사/main.py | 730 | 3.53125 | 4 | import itertools
def solution(answers):
patterns = [
[1, 2, 3, 4, 5],
[2, 1, 2, 3, 2, 4, 2, 5],
[3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
]
scores = []
for pattern in patterns:
scores.append(len([1 for a, b in zip(answers, itertools.cycle(pattern)) if a == b]))
answer = []
... |
3a42780034aab34280a2d9c6090bc39db94456bc | DomantasJonasSakalys/arnoldclark | /rock_paper_scissors.py | 1,133 | 4.03125 | 4 | import random
#The following describe the basic rules and selections. Key beats Values.
rules = {
'Rock' : ['Lizard', 'Scissors'],
'Paper' : [ 'Rock', 'Spock'],
'Scissors' : [ 'Paper', 'Lizard' ],
'Lizard' : ['Spock', 'Paper'],
'Spock' : ['Scissors', 'Rock']
}
#Making selections from the keys
selections = ', '.join... |
2f388e1a73bb97d833155706185c919f3825176a | Omri627/geo_war | /backend/facts/religion.py | 8,975 | 3.8125 | 4 | from db.business_logic.countries import CountriesData
from db.business_logic.religions import ReligionsData
from random import randint
# more_common_religion
# the method receives name of a country, and boolean variable indicate whether to build a true fact or a fake one
# and construct a fact claiming certain random... |
93d5790bad4024588d166b66f58746b2a817d340 | daniel26082/Practice | /main.py | 398 | 3.609375 | 4 | import turtle as trtl
# draw left curve 90 degrees
trtl.pendown()
for i in range(6):
trtl.forward(10)
trtl.left(15)
trtl.penup()
def draw_y_axis():
trtl.goto(0,0)
trtl.pendown()
trtl.forward(100)
trtl.backward(200)
trtl.penup()
def draw_x_axis():
trtl.goto(0,0)
trtl.left(90)
trtl.pendown()
trtl... |
46e8a5b2300112ccec6940fe52f38f678a7caa10 | RocketDonkey/project_euler | /python/problems/euler_002.py | 942 | 3.703125 | 4 | """Project Euler - Problem 2
Each new term in the Fibonacci sequence is generated by adding the previous two
terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum o... |
ecfe7e4abc05b198df98311fa433a296a80c22bc | AbrahamCain/Chemistry | /molesFromAtoms.py | 86 | 3.734375 | 4 | a = float(input("Atoms: "))
moles = a/(6.022*(10**23))
print("Moles = " + str(moles))
|
624f4f48e466cd470885dbdca5ac79db422af69b | anarchy-muffin/web-spider | /spider.py | 2,979 | 3.609375 | 4 | import HTMLParser
import urllib2
import parser
#make class LinkParser that inherits methods from
#HTMLParser which is why its passed to LinkParser definition.
#This is a function that HTMLParser normally has
#but we add functionality to it.
def handle_starttag(self, tag, attrs):
#looking for the beginning of ... |
56307a7262a79bb325f815f29401a59bf0cbf12a | wuping5719/PythonTest | /src/test/test24.py | 352 | 3.875 | 4 | # -*- coding: utf-8 -*-
'''
Created on 2017 年 9 月 14 日
@author: Nick
'''
'''
题目:一个5位数,判断它是不是回文数。
即12321是回文数,个位与万位相同,十位与千位相同。
'''
a = input("输入一串数字: ")
b = a[::-1]
if a == b:
print("%s 是回文数."% a)
else:
print("%s 不是回文数."% a)
|
8354909c36c866a82a0d3a237fdfaf331dae4b24 | szewczykmira/adventofcode | /2022/day3/solution.py | 1,014 | 3.625 | 4 | from typing import Set
from functools import reduce
from math import floor
from string import ascii_letters
INPUT_FILE = "input.txt"
def items_in_the_rucksack(line: str) -> Set[str]:
length = len(line)
half = floor(length / 2)
first = set(line[:half])
second = set(line[half:])
return first.inters... |
cc0dcdf0f55cbe6a8cf595a55c244339dc063eb6 | ilya0296/Artezio-Academy | /Lesson 1/ex8.py | 224 | 3.84375 | 4 | def hvalues(d):
a = list(d.values())
a.sort(reverse=True)
b = []
for x in range(3):
b.append(a[x])
return b
dt = {'a': 400, 'b': 500, 'c': 100, 'd': 800, 'e': 200}
print(hvalues(dt))
|
d2dd776609a7efe0d141343df4062e74d8f8407c | Yinghuochongxiaoq/Python_Succinctly | /functionDefault.py | 795 | 4.09375 | 4 | def say_hello():
print('Hello every one.')
say_hello()
def say_hello(name='FreshMan'):
print('Hello {}!'.format(name))
say_hello('FreshMan')
say_hello()
say_hello(name='FreshMan and JunJun')
def say_hello(first,last='FreshMan'):
'''Say hello'''
print('Hello {} {}!'.format(first,last))
say_hello('JunJun... |
409f67723d5479566826bcd909eac84cea0d99b0 | Natsu1270/Codes | /Hackerrank/LinkedList/DeleteNode.py | 505 | 3.796875 | 4 | from LinkedList import *
def deleteNode(head,pos):
if pos == 0:
return head.next
temp = head
prev = None
while pos > 0:
prev = temp
temp = temp.next
pos -= 1
prev.next = temp.next
del temp
return head
def deleteNodeRec(head,pos):
if pos == 0:
... |
d0bdc0a5818ad52fbbe564366b151d3c1e1f515d | LudicrousWhale/CSES-Problem-Set | /Permutations.py | 207 | 3.796875 | 4 | n = int(input())
if n == 1:
print (n)
elif n < 4:
print("NO SOLUTION")
else:
for i in range(2, n + 1, 2):
print(i, end = " ")
for i in range(1, n + 1, 2):
print(i, end = " ") |
23b4da3cd321145b89afaef4488510b11e11850a | sathishmepco/Python-Basics | /basic-concepts/data_structures/queue_demo.py | 843 | 4.34375 | 4 | from collections import deque
queue = deque(["Eric", "John", "Michael"])
print('The items in the queue are :',queue)
queue.append("Terry")
print('After appending Terry :',queue)
queue.append("Graham")
print('After appending Graham :',queue)
print('Pop the item from the queue :',queue.popleft())
print('After P... |
daaff54dd2784623d979924a82d891d8eec74c3f | sivajipr/python-course | /days/4/classes/exercises/counter/counter.py | 485 | 3.609375 | 4 | class Counter:
def __init__(self,count):
self.i=0
self.count=count
def __str__(self):
return "counter:%d" %(self.i)
def show(self):
print self.count
def increment(self):
self.i += 1
def decrement(self):
self.i -= 1
#c = Counter()
#c.show() # prints 0.
#c.increment()
#c.show() # prints 1
#c.decre... |
3226a1cd3c39aa7705968b94a10da6a5e0960430 | eelanpy/edabit | /76_disarium_num.py | 441 | 3.765625 | 4 |
def is_disarium(n):
num_disarium = 0
for i,j in enumerate(str(n)):
num_disarium += int(j) ** int(i+1)
print(num_disarium == n)
arg_is_disar = [1, 518, 6, 135, 75, 876, 175, 466, 372, 598, 696, 89]
correct_value = [True, False, True, False, False, True, True, False, False, True, True, True]
dict_arg_true_fa... |
a90ff3c43438300e686ac9bab589e0c124de9b0a | runnz121/Python_boot | /2weeks/2.py | 612 | 3.921875 | 4 | def grader(name,score):
grade = ''
if(100 >= score >= 95):
grade = 'A+'
elif(94 >= score > 90):
grade = 'A'
elif(89 >= score > 85):
grade = 'B+'
elif(84 >= score > 80):
grade = 'B'
elif(79 >= score > 75):
grade = 'C+'
elif (74 >= score > 70):
g... |
5e43682ca4a3d63f0ff22d91aaaf608e7092d9c7 | bijiawei0818/Learning-Python | /阶乘.py | 210 | 3.796875 | 4 | def recuration(n):
result=1
for i in range(1,n+1):
result*=i
return result
num=int(input("请输入一个整数:"))
result=recuration(num)
print("%d的阶乘是%d"%(num,result))
|
41048f520507adfddf2bc1ec2f5b1a2a6cf1a1f0 | yash1-2000/AxenousTest | /Q2_YashwantGaikwad.py | 550 | 4 | 4 | string = "EduCatiON"
lower = 0
upper = 0
for i in range(0, len(string)):
# for j in range(i+1, len(string)):
# if(string[i] == string[j] and string[i] != ' '):
# count = count + 1;
if(string[i].islower()):
string= string[0:i] + string[i].upper() + string[i+1: ]
l... |
6446f61ee7eb29db193dbd84a53effdf9e8e9608 | testcg/python | /code_all/day17/exercise04.py | 967 | 4.40625 | 4 | """
练习:使用学生列表封装以下三个列表中数据
list_student_name = ["悟空", "八戒", "白骨精"]
list_student_age = [28, 25, 36]
list_student_sex = ["男", "男", "女"]
"""
class Student:
def __init__(self, name="", age=0, sex=""):
self.name = name
self.age = age
self.sex = sex
# list_student_name = ["悟空", "... |
bfbfc45e55c0112d2f690cd77279d2977adae490 | dennisnderitu254/Andela-Exercises | /multiplicationtable.py | 463 | 4.4375 | 4 | # Nested for loop Example
# Print a multiplication table to 10 * 10
# Print column heading
print(" 1 2 3 4 5 6 7 8 9 10")
print(" +---------------------------------------------")
for row in range(1, 11):
if row < 10:
print(" ", end=" ")
print(row, "| ", end=" ")
for column in rang... |
4cf6c7d37888acbb8755d5a949acbf1b0721475d | sachio222/socketchat_v3 | /chatutils/db.py | 2,703 | 3.5 | 4 | import sqlite3
from sqlite3.dbapi2 import Cursor
def table_exists(cursor: sqlite3.Cursor, table_name: str) -> bool:
cursor.execute(
"SELECT count(name) FROM sqlite_master WHERE TYPE = 'table' AND name = '{}'"
.format(table_name))
if cursor.fetchone()[0] == 1:
return True
else:
... |
8211695ff52afae09515900b6d27fb1290501399 | rituc/Programming | /geesks4geeks/array/pair_sum.py | 726 | 3.828125 | 4 | # http://www.geeksforgeeks.org/write-a-c-program-that-given-a-set-a-of-n-numbers-and-another-number-x-determines-whether-or-not-there
# -exist-two-elements-in-s-whose-sum-is-exactly-x/
def main():
print "Enter number of test cases:"
T = int(input())
print "Enter array size and sum: "
for t in range(T):
N = int(in... |
9cb014ec7b545c617daa0ae014b3f0954d6737d5 | tjmode/placement | /13_hunter.py | 68 | 3.578125 | 4 | a=input()
s=a[::-1]
if a==s:
print("YES")
else:
print("NO")
|
4fce18838ef35d85f42fcc4070cc3de52cdbd3b0 | ivnxyz/evaluador-expresiones-algebraicas | /operators.py | 978 | 4.53125 | 5 | # Operadores permitidos
OPERATORS = [
'^',
'*',
'/',
'+',
'-'
]
# Regresa la posición en la jerarquía de algún operador
def get_operator_weight(operator):
if operator == '^': return 3
elif operator == '*' or operator == '/': return 2
elif operator == '+' or operator == '-': return 1
else: return 0
#... |
b4f5f77c333e1082204c86c9ba88b6a6024aea67 | roxyHan/Calculator- | /calculator.py | 422 | 3.703125 | 4 | # Design of the program
# Calculator program
def main():
# Get user input for the expression to calculate
# Evaluate the expression as a string
# Use infix concept for correct outputs
# Can use helper functions to recude code redundancy
# Ideas of helper functions would be: is_parity_of_parenthes... |
669eebede787b6672e6ad5ca9229ce69070dc5f4 | kulala2014/LeetCode_python | /get_vowel_num.py | 241 | 3.734375 | 4 | def getCount(input_str):
num_vowels = 0
vowel_str = ['a', 'e', 'i', 'o', 'u']
num_vowels = len([id for i in input_str if i in vowel_str])
return num_vowels
input_str = 'abracadabra'
result = getCount(input_str)
print(result) |
b5f505b7b0ff634019252f6ccfa806ca3874a635 | Gabriel300p/Computal_Thinking_Using_Python_Exercicios | /Exercicios Extras/exercicio04.py | 172 | 3.765625 | 4 | senha = int(input("Digite a senha: "))
senha_correta = 1234
if senha == senha_correta:
print("Acesso permitido")
else:
print("Você não tem acesso ao sistema")
|
5f3d600ccd9efad8a8391256a50722c1afdeed0e | Syliel/Python-learning | /jennyfun.py | 208 | 3.6875 | 4 | #!/usr/bin/env python3
def changeme( mylist):
mylist = [1,2,3,4];
print "Values inside the function: ", mylist
return
mylist = [10,20,30]
changeme( mylist);
print "Values outside the function: ", mylist
|
b16ccc7ca22d7836d601bf5fdfbb199e078a0d6b | ubnt-intrepid/project-euler | /002/002_gen.py | 216 | 3.515625 | 4 | #!/usr/bin/env python
def fibonatti(n_max=4000000):
f1, f2 = 1, 1
while f2 <= n_max:
yield f2
f2 += f1
f1 = f2 - f1
answer = sum(f for f in fibonatti() if f % 2 == 0)
print(answer)
|
fff01b304fdfc8de3c8fa9e3a5ec691ec6e9eaa1 | Simeon117/GUI- | /main.py | 11,597 | 3.859375 | 4 | from tkinter import *
import random
names = []
asked = []
score = 0
def randomiser():
global qnum
qnum = random.randint(1,10)
if qnum not in asked:
asked.append(qnum)
elif qnum in asked:
randomiser()
class QuizStarter:
def __init__(self, parent):#constructor, The __init__() function is called... |
4fc61690089b102743299a81de498d36adbc39a3 | damian1421/python | /CommonWords.py | 722 | 4.25 | 4 | #sololearn exercise: sets
"""Given two sentences, you need to find and output the number of the common words (words that are present in both sentences).
Sample Input:
this is some text
I would like this tea and some cookies
Sample Output:
2
The words 'some' and 'this' appear in both sentences.
You can use the split... |
b0fafb80e4c88b256ce68bfe44ba3233892925f6 | Her204/data_analysis_repo | /PRACTICE/mandelbrot.py | 684 | 3.5625 | 4 | from PIL import Image, ImageDraw
MAX_ITER = 80
WIDTH = 600
HEIGHT = 400
RE_START = -2
RE_END = 1
IM_START = -1
IM_END = 1
palette = []
im = Image.new("RGB",(WIDTH,HEIGHT),(0,0,0))
draw = ImageDraw.Draw(im)
def mandelbrot(c):
z=0
n=0
while abs(z) <=2 and n <MAX_ITER:
z = z*z +c
n+=1
re... |
fac7579d30780613a216c608db36f46bb9d87484 | avkramarov/gb_python | /lesson 6/Задание 2.py | 1,317 | 3.84375 | 4 | # Реализовать класс Road (дорога), в котором определить атрибуты: length (длина), width (ширина).
# Значения данных атрибутов должны передаваться при создании экземпляра класса.
# Атрибуты сделать защищенными. Определить метод расчета массы асфальта,
# необходимого для покрытия всего дорожного полотна.
# Использова... |
ae99cc8bc2cde2b0cdf7d52a1d2e2d1ec84e369a | tanjo3/HackerRank | /Python/Errors and Exceptions/Incorrect Regex.py | 207 | 3.609375 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import re
t = int(input())
for _ in range(t):
try:
re.compile(input())
print(True)
except:
print(False)
|
657effdfc9e292888d41d212c491411c618c99a2 | sjgridley/5023-OOP-scenarios | /turtle_drawing/drawing.py | 931 | 4.1875 | 4 | class Shape:
def __init__(self, colour: str, points, my_turtle):
self.colour = colour
self.points = points
self.my_turtle = my_turtle
def draw(self):
points = self.points
# Put the pen up, so the turtle isn't drawing on the canvas and move to first point
self.my_turt... |
6d39b4791935c78bf8f97a4a41423e87234bca7c | ruijuelu/Techdegree-Project-1 | /guessing_game.py | 4,306 | 4.1875 | 4 | import random
import time
def start_game(best_score = 6):
print("""
////////////////////////////////////////////
/////// WELCOME TO THE GUESSING GAME ///////
////////////////////////////////////////////
/////////////// INSTRUCTIONS: //////////////
// Guess a random number between 1 to 99 ///
... |
e9358873f6a3708bae3826f2e6db54341055d286 | Shivanibhadange/PythonTraining | /Python/dictionary.py | 1,017 | 3.703125 | 4 | empdata={'empno':101,
'name':'Ravi',
'salary':50000}
print(empdata)
print(empdata['name']) #Ravi
empdata['salary']=130000
print(empdata)
del empdata['name']
print(empdata)
empdata={'empno':101,
'name':'Ravi',
'salary':50000,
'name':'Anuj'}
print(empdata)#if th... |
c756757c4f1b5503ecdaed2b736ddf33d5f2a42b | ChuixinZeng/PythonStudyCode | /PythonCode-OldBoy/Day4/随堂练习/16_pickle序列化2.py | 313 | 3.671875 | 4 | # -*- coding:utf-8 -*-
# Author:Chuixin Zeng
import pickle
def sayhi(name):
print("hello,",name)
info = {
'name':'alex',
'age':'22',
'func': sayhi
}
f = open('text.text','wb')
# 下面的是另外一种用法,跟f.write(pickle.dumps(info))的意思是完全一样的
pickle.dump(info,f)
f.close() |
cceb7de39b69d5b0f76d3fefad2070588f6dad9e | utepe/CAA-Library | /TkDriver.py | 1,360 | 3.5 | 4 | import tkinter as tk
from tkinter import ttk
from FunctionAnalysis import polyAnalysis
from linearRegression import linearRegress
from linearAlgAnalysis import linAlgAnalysis
def getChoice():
print("\nCAA Library Main Menu")
print("------------------------")
print("[0] Terminate Program")
pri... |
54ff7c83ba31f081cfd08e74cc80edec2cc1b912 | priyanshusonii/college-assignment | /2..#Write a Python program to remove duplicates from a list of lists.py | 391 | 3.890625 | 4 | import itertools
number = [[110, 120], [240], [330, 456, 425], [310, 220], [133], [240]]
print("Original List", number)
number.sort()
new_number = list(number for number,_ in itertools.groupby(number))
print("New List", new_number)
#output:
#
#Original List [[110, 120], [240], [330, 456, 425], [310, 220], [133], [240... |
9d594fe7c50d0a5b834e9b0267d4327d6eeccac5 | wl-cp/example | /py实验1/exmple_3.py | 150 | 3.71875 | 4 | import math
a = int(input("请输入直角边a:"))
b = int(input("请输入直角边b:"))
c = math.sqrt((a**2) + (b**2))
print("斜边c:",c)
|
904f679ed565e8589612418dc944b5f417fdf3fb | jingzhij/Leetcode | /406 根据身高重建队列.py | 453 | 3.71875 | 4 | ### 解题思路
对身高逆序,对键值正序,先排序,
然后插入
为什么这么做?因为比它大的数字只存在与前面,按照键值进行插入一定没错
### 代码
```python3
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
people.sort(key = lambda x:(-x[0],x[1]))
output=[]
for a in people:
output.insert(a[1],a)
return o... |
ee93479353b275cb572faadb35dd70818b212ad3 | rameshmuruga/guvi_codekata | /ram.py | 107 | 3.890625 | 4 | x=raw_input("")
if('a'<x):
print("alphabet")
elif('A'<x):
print("alphabet")
else:
print("not alphabet")
|
152ae2bea576ce4e1c00ea3ee2490a7a4c4ac43e | ricklen/PythonTest | /12 Object Oriented Python/demo.py | 410 | 3.671875 | 4 | a_string = "this is \na string split \t\tand tabbed"
print(a_string)
raw_string = r"this is \na string split \t\tand tabbed"
print(raw_string)
b_string = "this is" + chr(10) + "a string split" + chr(9) + chr(9) + "and tabbed"
print(b_string)
backslash_string = "this is a backslash \\followed by some text"
... |
e69f48626283e08fd44d4af0071c244a6458f7f6 | Kings-Ggs-Arthers/CP3-Gun-siri | /assignments/Lecture50_Gun_S.py | 252 | 3.90625 | 4 | def addNum(x,y):
print(x + y)
def subNum(x,y):
print(x - y)
def multiNum (x,y):
print(x * y)
def divideNum (x,y):
print(x / y)
x = int(input("x :"))
y = int(input("y :"))
addNum(x,y)
subNum(x,y)
multiNum(x,y)
divideNum(x,y) |
a0a527c9713c8772020b322fa4cd4fcca5b0619d | omgitsomg/PythonPractice | /Day21Practice.py | 1,473 | 4.125 | 4 | # Today is day 21 of Python Practice.
# Today, I will focus on learning about exception handling
# in Python.
# This will be part 1.
# Python doesn't have a try catch like Java does, but it does have something
# similar called try except.
import sys
def divideBy0(num):
return (num / 0)
try:
divideBy0(10)
ex... |
dfacc93b7c8a7a4338d07b956c6cdc5c80a5595c | Navan05/Designing-a-user-specified-electrical-circuit-using-python | /PSP.py | 2,497 | 3.6875 | 4 | nr=int(input('Enter number of resistors in the first loop'))
nr1=int(input('Enter number of resistors in the second loop'))
l=180
import turtle
t=turtle
t.color('red')
for i in range(0,nr):
t.forward(100)
t.left(45)
t.forward(10)
t.right(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(9... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.