blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
a608ecf745ee5e7759b13d12e80d1b1d5be51221 | opatiny/mobile-robotics | /exercices/w1/LA/__tests__/squareErr.test.py | 243 | 3.59375 | 4 | from squareErr import squareErr
matrix = [[1, 2], [3, 4]]
print("matrix")
squareErr(matrix)
matrix1 = [[1, 2], [3, 4, 5]]
print("matrix1")
squareErr(matrix1)
matrix2 = [[1, 2, 5], [3, 4, 5], [4, 7, 9]]
print("matrix2")
squareErr(matrix2) |
6e501cf6917de0acfeffee29671e4e9a67b6ca99 | impacevanend/unalPython | /clase/while.py | 1,147 | 3.78125 | 4 | # *explicaciòn inicial
# i = 0
# while i <=6:
# print(i)
# i +=1
# * Comparación de varialbes hasta salir del ciclo
# i = 2
# j = 25
# while i < j:
# print(i,j, sep = ", ")
# i *= 2
# j += 10
# print("The end.")
# print(i,j, sep =", ")
#*Uso del break
# suma = 0
# while True:
# dato = i... |
fbb50eaf8ef8d106919d23f9c380ef6b9d241280 | tonmoy71/MITx-6.00x | /Excercise/Comparison.py | 169 | 4.28125 | 4 | # Comparison between three numbers
x = int(raw_input('x : '))
y = int(raw_input('y : '))
z = int(raw_input('z : '))
if x>y and x>z:
print(' x is largest')
|
813eecc574c7918642e706196a0efe193d912148 | extremums/the-simplest-programs | /Sodda dasturlar/Nechta parta kerakligini aniqlovchi dastur.py | 344 | 3.59375 | 4 | #Nechta parta kerakligini aniqlovchi dastur
a=int(input("Birintchi guruhdagi o'quvchilari sonini kiriting - "))
b=int(input("Ikkinchi guruhdagi o'quvchilar sonini kiriting - "))
c=int(input("Uchinchi guruhdagi o'quvchilar sonini kiriting - "))
d=a+b+c
a1=d//2
a2=d%2
if a2>0 :
a1=a1+1
else :
a1=a1
print(a1," ta ... |
0299f028d184c6a77d12f8b3a5f22a4f410c5917 | dylandelacruz/pig-latin | /pig_latin.py | 1,528 | 3.890625 | 4 | def logo():
print ("███████████████▀█████████████████████████████████")
print ("█▄─▄▄─█▄─▄█─▄▄▄▄███▄─▄████▀▄─██─▄─▄─█▄─▄█▄─▀█▄─▄█")
print ("██─▄▄▄██─██─██▄─████─██▀██─▀─████─████─███─█▄▀─██")
print ("▀▄▄▄▀▀▀▄▄▄▀▄▄▄▄▄▀▀▀▄▄▄▄▄▀▄▄▀▄▄▀▀▄▄▄▀▀▄▄▄▀▄▄▄▀▀▄▄▀")
print (" By. Dylan Dela Cruz.")
logo()... |
7190cfe8bc742a170deff7cdde7fcd80d33bf36e | SeNSE-lab/SeNSE-lab.github.io | /pubs/sortRefs.py | 1,672 | 3.921875 | 4 | #!/usr/bin/python
import sys
import re
if (len(sys.argv) != 2):
print 'You need to pass in the unsorted HTML file.'
sys.exit(1)
try:
htmlfile=open(sys.argv[1],'r')
except IOError:
print 'Invalid file. Does it exist?'
sys.exit(2)
allLines=htmlfile.readlines()
htmlfile.close()
tupleList=[]
for l... |
806f5826f9e0bdf970e06e8911fee374c498b168 | Abarbasam/Langtons-Ant-Terminal | /Langtons_Ant.py | 2,908 | 3.859375 | 4 | # Jan 27, 2017 - Sam Abarbanel
# This script models "Langtons Ant." Search it up for a better understanding
from time import sleep
# Setting up directions for the ant
UP = [-1, 0]
RIGHT = [0, 1]
DOWN = [1, 0]
LEFT = [0, -1]
directions = [UP, RIGHT, DOWN, LEFT] # This makes changing directions easier
direction_Pointe... |
a27dc183388f48c8f53e21df914dc48d969b6c92 | ChaitanyaPuritipati/CSPP1 | /CSPP1-Practice/cspp1-assignments/m7/Functions - Square Exercise 20186018/square.py | 512 | 4.0625 | 4 | '''
Author: Puritipati Chaitanya Prasad Reddy
Date: 6-8-2018
'''
# Exercise: square of a number
# This function takes in one number and returns one number.
def square(x_num):
'''
x: int or float.
'''
return x_num**2
def main():
'''
main function starts here
'''
input_num = input()
in... |
c841a23e4ce7eebee2e1edce47e9bfec3be92338 | trunghieu11/PythonAlgorithm | /Contest/HackerRank/Python/DataTypes/Lists.py | 500 | 3.703125 | 4 | __author__ = 'trunghieu11'
n = int(input())
list = []
for i in range(n):
line = input().split()
if line[0] == "insert":
list.insert(int(line[1]), int(line[2]))
elif line[0] == "print":
print(list)
elif line[0] == "remove":
list.remove(int(line[1]))
elif line[0] == "append":
... |
fa6b793eaaa31ff4853aa8a2327222e1aae42994 | jessehagberg/python-playground | /ex22.py | 2,070 | 4.03125 | 4 | #Exercise 22: What do you know so far?
print
-- String Delimiters, operators, conversion and formatting
""
''
"'"
'"'
\[char] escape sequences \n for newline \t for tab, etc...
-- String methods
[string].split
-- command line arguments
from sys import argv
argv
script, arg1 = argv
-- user ... |
05dfac5b442e518a2a177dfc39c8ea899f4fc6f8 | frankfka/LabelWise-Backend | /nutrition_parser/parser_functions.py | 3,636 | 3.546875 | 4 | import re
from typing import Optional
from nutrition_parser.util import get_float
def parse_calories(clean_text: str) -> Optional[float]:
"""
Returns calories parsed from the text
Regex:
- Look for "calorie"
- Match anything except for digits
- Match 1-3 digits (the capturing group)
- Ma... |
ce74beb2b5d043dcd2016b1a6d8d9d69c9e48a3d | maniCitizen/-100DaysofCode | /W3Schools Exercises/Strings/String from 1st and last chars.py | 260 | 3.671875 | 4 | def return_word(word):
if len(word) < 2:
return None
else:
position = len(word)-2
new_word = word[:2]+word[position:]
return new_word
print(return_word("w3resource"))
print(return_word("w3"))
print(return_word("w")) |
0e53b1768e71f20bbec0d618f7375fa3ab81633c | shiki7/leetcode | /0007: Reverse Integer/solution.py | 417 | 3.515625 | 4 | class Solution:
def reverse(self, x: int) -> int:
str_x = str(x)
if str_x[-1] == 0:
str_x = str_x[:-1]
if str_x[0] == "-":
temp = str_x[1:]
str_x = str_x[0] + temp[::-1]
else:
str_x = str_x[::-1]
int_x = int(str_x)
if in... |
543f2cd03bc71fda93cd78d7f2d06095961251ec | l3e0wu1f/python | /Final Project/ShoppingCart.py | 5,945 | 3.8125 | 4 | # INF322 Python
# Josh Lewis
# Final Project: Interactive Shopping Cart
# An application for users to shop at a farmer's market produce stand. It pulls the inventory from an external file, logs errors to an
# external log file if the inventory file is not found, and uses OOP to modify and display the contents of a ... |
f0c27551d40250870b62861bf5d30eaefc5adcc4 | tyellaineho/python-related-code | /Python-HackerRank/solutions.py | 523 | 3.59375 | 4 | # Solve Me First: https://www.hackerrank.com/challenges/solve-me-first/problem
def solveMeFirst(a,b):
# Hint: Type return a+b below
return a+b
num1 = input()
num2 = input()
res = solveMeFirst(num1,num2)
print res
# A Very Big Sum: https://www.hackerrank.com/challenges/a-very-big-sum
def aVeryBigSum(ar):
sum ... |
f6568553aaf759e0e0a72f15e2f50eddf0327b58 | godiatima/Python_app | /calc.py | 146 | 3.8125 | 4 | number_one = input()
number_two = input()
print('Calculating results...')
result = number_one * number_two
print('The result is: ' + str(result)) |
f5553c68550c4db682fe771bd0148265862d3cea | SuperMartinYang/learning_algorithm | /leetcode/python_learning/file_pattern.py | 764 | 3.90625 | 4 | import re
def build_matches_and_apply_function(pattern, search, replace):
def matches_rule(noun):
return re.search(pattern, noun)
def apply_rule(noun):
return re.sub(search, replace, noun)
rules = []
# with can define a file context, after this context, file will automaticaly closed
with open('p... |
648acb0ceedb04aed7fd7f062ec177a529f2bb5e | caodongxue/python_all-caodongxue | /day-11/airconditioner/demo4.py | 4,039 | 3.671875 | 4 |
class Student:
__num = None
__name = None
__age = None
__sex = None
__hight = None
__weight = None
__grade = None
__address = None
__phone_code = None
def __init__(self,num,name,age,sex,hight,weight,grade,address,phone_code):
self.__num = num
self.... |
9bb40839b999bd07713fffd803acd72c6035dec7 | GParolini/python_ab | /exceptionhandling/demo_withlog.py | 699 | 3.6875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 30 08:20:56 2019
@author: giudittaparolini
"""
import logging
logging.basicConfig(filename="mylogdemo.log", level=logging.DEBUG)
try:
f= open("myfile.txt", "w")
a, b = [int(x) for x in input("Enter two numbers: ").split()]
logging.inf... |
81c28e966fa2f07ffdfc1b7951815c5ac9602c1c | saenyakorn/2110101-COMP-PROG | /05/05_List_12.py | 388 | 3.703125 | 4 | name = ["Robert","William","James","John","Margaret","Edward","Sarah","Andrew","Anthony","Deborah"]
nick = ["Dick","Bill","Jim","Jack","Peggy","Ed","Sally","Andy","Tony","Debbie"]
t1 = {k:v for k,v in zip(name,nick)}
t2 = {k:v for k,v in zip(nick,name)}
n = int(input())
for i in range(n):
s = input()
print("{}... |
622b9a8709ff4997119601f51708bc2958fb1c34 | mexcaptain93/channelstat | /gui.py | 575 | 3.78125 | 4 | import tkinter as tk
import tkinter.ttk as ttk
class GUI():
"""Класс для графического интерфейса"""
def __init__(self, function):
window = tk.Tk()
window.title("Парсер событий")
heading = tk.Label(text="Парсер событий")
text_box = tk.Text(
width=160,
he... |
4e85db84d8e3dd606689e3af6ff7fe973ac9fb85 | jeckles/crypto | /numtheory.py | 977 | 3.546875 | 4 | from decimal import *
getcontext().prec = 50 # set our precision to be very high
# Euler's totient function
def phi(n):
result = n # initialze result as n
# consider all prime factors of n for every prime < square root of n
p = 2
while(p * p <= n): # for primes less than the square ro... |
618dff8a282152092def4435ebafbfd8f718a136 | shuyangw/cs585-final-project-submission | /src/runner.py | 14,150 | 3.765625 | 4 | from rnn import *
from preprocessor import Preprocessor
import tensorflow as tf
import numpy as np
import os
import sys
import time
class Runner(object):
"""
The Runner class is the main class that will perform the entirety of the
training and the predicting.
The constructor will take in all of the... |
334dfe01053f3590f454ad06ee7aa17b0120ebb1 | dineshpabbi10/DS-Itronix | /Day7/4.py | 643 | 4 | 4 | class Employee:
increment=1.5 #This is common for all the employee
def __init__(self,fname,lname,salary):
self.fname=fname
self.lname=lname
self.salary=salary
def increase(self):
#self.salary=int(self.salary * increment)
#self.salary=int(self.salary * Employee.increment)
self.salary=int(self.salary... |
6330d2af47c509182fcd6ae51036d7b4b8c20b62 | chrisgay/dev-sprint1 | /my_first_app/my_first_app.py | 1,724 | 3.90625 | 4 | # This is whre you can start you python file for your week1 web app
# Name:
from flask import Flask, flash #import Flask class (classes are templates for creating objects through inheritance, e.g., an child object inherits the traits (functions and attributes) of its parent class)
import flask.views
import os
app = ... |
039d4124c652cf19f0bfc667fd87da0f795cb411 | rockingrohit9639/pythonBasics | /generatorss.py | 883 | 4.21875 | 4 | """
Iterable - __iter__() or __getitem__()
Iterator - __next__()
Iteration - Process of Iterator and Iterable
"""
def fibo(m):
n1 = 1
n2 = 1
for i in range(m):
n3 = n1
n1 = n2
n2 = n1 + n3
yield n3
def facto(n):
n1 = 1
for i in range(1,n+1):
n1 *= i
... |
ba7dd5e6f508fc5654bf7705b174497f3a038cb1 | xiesong521/my_leetcode | /链表/双指针/快慢指针/#141_环形链表.py | 1,216 | 3.828125 | 4 | #!/user/bin/python3
#coding:utf-8
"""
Author:XieSong
Email:18406508513@163.com
Copyright:XieSong
Licence:MIT
"""
class ListNode:
def __init__(self,x):
self.val = x
self.next = None
#计数法
class Solution:
def hasCycle(self,head):
hashset = []
while(head):
... |
0afd84094197e2a6b594920d95c2dc402ce77aac | Ruknin/Day-13 | /Practice/review1.py | 1,075 | 4.0625 | 4 | strings = "This is Python"
char = "C"
multiline_str = """This is a multiline string with more than one line code."""
unicode = u"\u00dcnic\u00f6de"
raw_str = r"raw \n string"
print(strings)
print(char)
print(multiline_str)
print(unicode)
print(raw_str)
fruits = ["apple", "mango", "orange"] #list
numbers ... |
4b03a4979bf4443709b4de8e804fa3b4ba41d804 | gallonp/TumorKiller | /datastorage.py | 7,938 | 4.3125 | 4 | """Methods for storing and retrieving files in the database."""
import cPickle
import sqlite3
# Name of file for SQLite database.
# Note: In-memory database (":memory:") is erased after closing the connection.
SQLITE_DATABASE_FILE = 'database.db'
# Name of table containing brain scan data.
TABLE_NAME_BRAINSCANS = '... |
78907035c1a8f6a33e085f7915835fd8c5d72f5e | LishuaiBeijing/OMOOC2py | /_src/om2py2w/2wex0/main_3.py | 1,116 | 3.65625 | 4 | # -*- coding:utf-8 -*-
# title:简单日记软件
# description: 支持日记写入,支持日记输出
# layout: 主界面是日记显示界面,按钮1--写入日记,点击后弹出对话框,写入日记,点击确定后保存,按钮2--退出软件
# extention:
# 1.支持简单的版本控制,可以回溯此前的N个版本
# 2.直接改造成一个界面,与记事本类似,显示已有日记,并直接续写,设置保存和回退按钮(这跟记事本不是一样了? )
import Tkinter as tk
class Diary:
def __init__(self , master):
frame =... |
675dc08ab210bc45d09847d35a79ecd88fee9c1d | danielaloperahernandez/holbertonschool-higher_level_programming | /0x0B-python-input_output/7-save_to_json_file.py | 295 | 4 | 4 | #!/usr/bin/python3
"""Module for save_to_json_file method"""
import json
def save_to_json_file(my_obj, filename):
"""
Method that writes an Object to a
text file, using a JSON representation
"""
with open(filename, "w") as write_file:
json.dump(my_obj, write_file)
|
66bd10f0c5157714f2ed1ce86f3a8b4ead3a2ffb | gsudarshan1990/PythonSampleProjects | /Random/random_example.py | 128 | 3.5625 | 4 | import random
values=[1,2,3,4,5]
for i in range(0,5):
print(random.choice(values))
random.shuffle(values)
print(values)
|
2a2b39f0bbb03d3b72a69bbe4a49c3584b0131ad | iankorf/elvish | /elvish.py | 2,557 | 3.6875 | 4 | #!/usr/bin/env python3
import sys
import fileinput
import random
import json
random.seed(1)
# you may need to add more
puncs = '.,1?!:;-*"_()[]{}<>/1234567890—“”’‘–$«»\'=#@%&+'
spaces = ' ' * len(puncs)
wordcount = {}
for rawline in fileinput.input():
# convert to lowercase
lower = rawline.lower()
# convert ... |
22b375fdc5890ca2f365bab4455fc7e66775b761 | Dtaylor709/she_codes_python | /loops_playground.py | 2,074 | 4.375 | 4 | # HAYLEYS LOOP COURSE EXAMPLES
# num = number. You can actualy use any word you wnat
# use range() instead of [0:10]. range =up to number so range (10) only prints 0 to 9 as it prints 10 items but te list starts with 0
# # for loop starts with 'for'
# for num in range(10):
# print(num)
# # (1, 11) means start a... |
88e5cc9fd9822eab7345fb675f3e10c4eb272f14 | young31/TIL | /startCamp/02_day/csv_handling/csv_read.py | 431 | 3.640625 | 4 | #read csv
# 1. split
# with open('dinner.csv', 'r', encoding='utf-8') as f:
# lines = f.readlines()
# for line in lines:
# print(line.strip().split(',')) # ','기준으로 문자열 split
# 2. csv reader
import csv
with open('dinner.csv', 'r', encoding='utf-8') as f:
items = csv.reader(f)
#print(items) # 이렇... |
bc54ac59d0b5016a0a169d94b70606489ebdf5d5 | sahkal/dynamic-programming | /003_Longest Palindromic Sequence.py | 2,251 | 3.796875 | 4 | #%% Imports and functions declarations
def matrix_constructor(string_col: str, string_row: str) -> list:
"""
Construct a matrix suited for lcs
:param string_col: string occupying the columns position
:param string_row: string occupying the rows position
:return: matrix on the proper format
... |
02498cd9d9507090390f1f56014b866ff89f7e5f | Bandita69/TFF | /Event.py | 4,417 | 3.859375 | 4 | from _datetime import datetime
preparation_time = 30
donation_time = 30
class EventData(object):
# @Nori
# Definition explanation comes here...
@staticmethod
def get_event_date():
global ev_date
isvaild = False
while not isvaild:
data = input("Enter your Event da... |
3cc47bd3173415aad33f83187b36ce24833904c4 | turamant/ToolKit | /PyQt_ToolKit/Layout/box_layout_1.py | 1,049 | 3.609375 | 4 | """
Контейнер коробка либо один столбец или строку виджетов.
Меняется динамически в зависимости от количество виджетов
Подобен GridLayout
"""
from PyQt5.QtWidgets import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
layout ... |
fb69b302f7847eb8a3c4a621c131642b930b96a8 | mingchia-andy-liu/practice | /daily/solved/1_easy_sum_k_in_an_array_COMPLETED/test.py | 3,418 | 3.875 | 4 | import unittest
class Answer():
def __init__(self, k, arr):
self.k = k
self.arr = arr
self.dict = {}
def solve(self):
if (len(self.arr) < 2):
return False
for element in self.arr:
diff = self.k - element
self.dict[diff] = True
for element in self.arr:
if (element i... |
4e5032b8f64f6d3e5b155ca31e2e245cf74a117b | mavega998/python-mintic-2022 | /TALLER3/diaSemana.py | 1,063 | 3.90625 | 4 | semana = [
{"id": 0,"name": 'domingo'},
{"id": 1,"name": 'lunes'},
{"id": 2,"name": 'martes'},
{"id": 3,"name": 'miercoles'},
{"id": 4,"name": 'jueves'},
{"id": 5,"name": 'viernes'},
{"id": 6,"name": 'sabado'},
]
opcionValor = input("1. Buscar el número del día por nombre.\n2. Buscar el nom... |
ae82e77f65b0a099e9e28a48578b13b80705bf65 | svdmaar/tkinter1 | /basics.py | 652 | 3.96875 | 4 | import tkinter as tk
def OnButtonClick():
#print(entry.get())
#entry.delete(0,tk.END)
#entry.insert(0, "Python")
#print(text_box.get("1.0", tk.END))
#text_box.delete("1.0", tk.END)
text_box.insert(tk.END, "Put me at the end!")
window = tk.Tk()
greeting = tk.Label(
text="Hello, Tkinter!",
... |
1d4e4e92312cf922ca8574afc55540cff65d7004 | wszeborowskimateusz/cryptography-exam | /ciphers_podstawieniowe.py | 882 | 3.765625 | 4 | alphabet = "AĄBCĆDEĘFGHIJKLŁMNŃOÓPQRSŚTUVWXYZŹŻ"
def przesuwajacy(plain, k):
cipher = ""
for c in plain:
if c in alphabet:
cipher += alphabet[(alphabet.find(c) + k) % len(alphabet)]
else:
cipher += c
return cipher
def vigenere(plain, k):
cipher = ""
ke... |
1154b10df64aec04468a891e966b86b342a6bb60 | RiyazShaikAuxo/datascience_store | /2.numpy/FindRandomValues.py | 250 | 3.6875 | 4 | import numpy as np
nrand=np.random.random()
print(nrand)
#Printing random value from 2 to 50
somevariable1=50*np.random.random()+2
print(somevariable1)
#Creating a matrix with random values
somevariable2=np.random.random([3,2])
print(somevariable2) |
9c823eb8750c14c5bcd236c9db4f71e446f17028 | janosgyerik/advent-of-code | /2018/day11/part2.py | 1,492 | 3.8125 | 4 | #!/usr/bin/env python
import sys
class Computer:
def __init__(self, serial):
self.serial = serial
def power(self, row, col):
rack_id = row + 10
return self.hundreds((rack_id * col + self.serial) * rack_id) - 5
def hundreds(self, n):
return (n // 100) % 10
def print_... |
0fd9f4bf61a7857a2d06fc02b440ebfca578c112 | haijiwuya/python-collections | /base/9.exception/introduce.py | 687 | 4.125 | 4 | """
异常:程序在运行过程当中,不可避免的会出现一些错误,这些错误,称其为异常。
程序在运行过程中,一旦出现异常会导致程序立即终止,异常以后的代码不会被执行
"""
try:
print(10 / 1)
except NameError as e:
print('参数不存在', e, type(e))
except ZeroDivisionError as e:
print('出错了', e, type(e))
else:
print('程序执行完成')
finally:
print('方法调用完成')
# raise抛出异常,raise语句后需要跟一个异常类
def add(a, b)... |
5411d553baced57db79465ad88f8ca5a7f4909c9 | palakbaphna/pyprac | /print function/print Numbers/3PrintNumbers.py | 384 | 4.125 | 4 | print("*Multiplication Example*")
print("a = ")
a= int(input())
print("b = ")
b = int(input())
print("c = ")
c = int(input())
answer = a * b * c
print( 'The answer of a*b*c = ' , answer )
if( answer > 100): #or if( a * b * c > 100)
print( "Answer is greate... |
b972f1541906f8fbc71fb7e031cca0c1c00dd99b | MSaaad/Basic-python-programs | /Leap year.py | 409 | 4.03125 | 4 | print('\tLEAP YEAR!')
year='string'
while True:
year=int(input('Enter the year: '))
if len(str(year))!=4:
print('Please enter a four digit input!')
break
if year%4==0:
print('This is a leap year')
elif year%400==0:
print('This is a Leap year')
elif year%100... |
e8d82e06c8b7bc60e5fd4d83d13cddccbd8510af | cpatrasciuc/algorithm-contests | /hackercup/2012/qualification/auction.py | 1,845 | 3.5 | 4 | def lcm(a,b):
gcd, tmp = a,b
while tmp:
gcd,tmp = tmp, gcd % tmp
return a*b/gcd
def isBetter(A, B):
return (A[0] < B[0] and not A[1] > B[1]) or (A[1] < B[1] and not A[0] > B[0])
def solve(line):
N, P1, W1, M, K, A, B, C, D = tuple([int(x) for x in line.split()])
LCM = lcm(M, K)
#p... |
4349cea2e2653bbbb9e6610b8060af52251295e6 | hojunee/20-fall-adv-stat-programming | /sol8/ex17-5.py | 603 | 3.796875 | 4 | class Point():
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return ("점 ({}, {})".format(self.x, self.y))
def __add__(self, other):
if isinstance(other, Point):
return self.point_add(other)
elif isinstance(other, tuple):
... |
e9f5bab0dd2dfff9a442594b0de53e642a98c870 | kimtk94/test1 | /025.py | 216 | 3.546875 | 4 | #25 문자열 n씩 건너뛰며 출력하기
seq1 = "ATGTTATAG"
Ans = []
for i in range(0,len(seq1), 3):
Ans.append(seq1[i])
print(Ans)
#강사님 답안
for i in range(0, len(seq1),3):
print(i, seq1[i])
|
67201135a55281c1fb08080e1e839a8c92fc3908 | pisceskelsey/class-work | /chapter 7.py | 3,916 | 4.21875 | 4 | people = input("How many people are in your party?" )
people = int(people)
if(people > 8):
print("There may be some delays.")
else:
print("Your table is ready.")
number = input("Give me a number. ")
number = int(number)
if number % 10 == 0:
print("\nThe number " + str(number) + " is a multiple of 10.")
els... |
5b0546838cf01fa00c20ccd4ef6fd8d36cc325c5 | Kuomenghsin/my-learning-note | /HW3/binary_search_tree_06111306.py | 3,624 | 3.90625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[16]:
class TreeNode(object):
def __init__(self,x):
self.val=x
self.left=None
self.right=None
class Solution(object):
#新增
def insert(self,root,val):
#root空
if root == None:
N_node = TreeNode(val)
... |
376d3a72f63754dea7e56c03976d9d8213752e01 | theJMC/codeProjects | /Python/MIsc/ProductInventorySystem.py | 541 | 3.921875 | 4 | import sqlite3
from employee import Employee
conn = sqlite3.connect('employee.db')
c = conn.cursor()
# c.execute("""CREATE TABLE employees (
# first text,
# last text,
# pay integer
# )""")
emp_1 = Employee('John', 'Doe', 80000)
emp_2 = Employee('Tom', 'Smit... |
aceb6a8e8345755d90401ca892be0271d85adfb3 | sjogden/Bones-of-the-Earth | /camera.py | 1,735 | 3.59375 | 4 | import pygame
class Background():
"""Background image that can scroll infinitely"""
def __init__(self):
self.image = pygame.image.load("data/background/Background.png")
self.x1 = 0
self.x2 = 1000
def update(self, screen):
#if about to scroll off the screen, move b... |
c9f25aca7ea58e7d82edaf38b8d9782de2a92b87 | orangepips/hackerrank-python | /artificialintelligence/botbuilding/bot_saves_princess2.py | 873 | 3.5 | 4 | #!/bin/python
from operator import sub
# https://www.hackerrank.com/challenges/saveprincess2
_bot = 'm'
_princess = 'p'
def nextMove(n,r,c,grid):
bot_loc = (c, r)
princess_loc = (None, None)
for lineIdx, line in enumerate(grid):
for cIdx, c in enumerate(line):
if c == _princess:
... |
ccdc4db9344138446c252e7d0d887cdc1b3b0b95 | SUMANTHTP/launchpad-assignment | /p2.py | 93 | 3.671875 | 4 | a = [1,1,2,3,5,8,13,21,34,55,89]
b = []
for i in a:
if i < 5:
b.append(i)
print(b); |
527e9d076eaaf15c0ff3fca037d088f84fd86037 | AlexSopa/Python | /CommentedTutorialScripts/SecondProject/LearningNumpy.py | 1,133 | 4.28125 | 4 | import numpy as np
a = np.arange(15).reshape(3, 5)
#What does this look like?
print(a)
#How many axis does this have?
print('There is %d axis' % a.ndim)
print(('The shape of a is {}').format(a.shape))
#Creating a zero array
zeros = np.zeros((10,10), dtype=np.int16) #dtype decides what kind of number it is(int16 is an i... |
48033675cfcbd3596218c7a6cdaa4d197ddc1a9f | DeepakMulakala/my-files | /happy.py | 282 | 3.625 | 4 | n=int(input())
temp=0
i=0
k=n
while n:
r=n%10
n=n//10
i=i+pow(r,2)
if n==0 and i>=10:
n=i
print(n)
i=0
if i<10:
print (i)
if i==1:
print(k,"is a happy number")
else:
print(k,"is not a happy number")
|
65d2d8ad77e3d01bfb69216caf5be601c5b42350 | xuedong/hacker-rank | /Tutorials/10 Days of Statistics/Day 7/spearman_rank_correlation.py | 620 | 3.59375 | 4 | #!/bin/python3
def get_rank(arr):
n = len(arr)
rank = [0 for i in range(n)]
for i in range(n):
rank_i = 0
for j in range(n):
if arr[j] > arr[i]:
rank_i += 1
rank[i] = rank_i + 1
return rank
def spearman(rank1, rank2, n):
total = 0
for i in ... |
b20de2a69ac0602069305f11b08338b1089c9905 | Mia416/PythonPratices | /chentestPython1/ListExample/ListExample2.py | 156 | 3.671875 | 4 | '''
Created on May 23, 2017
@author: chenz
'''
items = ["1","2","3","4"]
[int(item) for item in items]
for item_value in items:
print (item_value)
|
3be70e8cdceffb51e28747b42804ec3b1e1f2c10 | r-azh/TestProject | /TestPython/test_lambda_map_filter_reduce/test_filter.py | 484 | 3.953125 | 4 | __author__ = 'R.Azh'
# filter(function, sequence)
# offers an elegant way to filter out all the elements of a sequence "sequence",
# for which the function function returns True.
fibonacci = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
print(fibonacci)
odd_numbers = list(filter(lambda x: x % 2, fibonacci))
print(odd_number... |
fcbf00154a07283b4e7fce5bd3d33bd9fe3e9854 | RicardoMart922/estudo_Python | /Exercicios/Exercicio019.py | 445 | 3.96875 | 4 | # faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo, calcule e mostre o comprimento da hipotenusa.
from math import hypot
catetooposto = float(input('Informe o comprimento do cateto oposto: '))
catetoadjacente = float(input('Informe o comprimento do cateto adjacent... |
273ad71cc3482fac24489d1c67cc8021e376d3f7 | pmkhedikar/python_practicsRepo | /concepts/class/opps_1.py | 9,911 | 4.375 | 4 | ## Class
# class phone():
#
# def __init__(self, ram, memory):
# self.ram = ram
# self.memory = memory
#
# def config(self, ram, memory):
# print( 'config is :', self.ram, self.memory )
#
#
# phone1 = phone('2','32gb')
# phone1.config('2','32gb')
## Self & Constructor
## Self repres... |
e3332df1f6d90a6fe18046ce55614a9f2934f632 | epersike/py-simple-structs | /queue.py | 1,530 | 3.8125 | 4 |
class SimpleQueueDequeueException(Exception):
pass
class SimpleQueueItem:
def __init__(self, obj=None, prev=None, nxt=None):
self.obj = obj
self.prev = prev
self.next = nxt
def __str__(self):
return str(self.obj)
class SimpleQueue:
def __init__(self):
self.len = 0
self.first = None
self.q = None
... |
8e64a982c51e2fa487239581b8210e69611a0dae | emmassr/MM_python_quiz | /week2_exercise.py | 2,519 | 4.53125 | 5 | # For this exercise you will need the Pandas package. You can import this using:
#Q1: Create a Pandas dataframe with 3 columns: User, Fruit and Quantity.
#Insert Junaid, Tom, Dick, Harry as Users.
#Insert Apple, Oranges, Bananas, Mango as Fruit
#Insert 4, 3, 11, 7 as Quantity
#Each user should have their own row, this... |
3143a93e7964b09a65770f893960771ac70c6fbf | qmnguyenw/python_py4e | /geeksforgeeks/python/medium/17_12.py | 4,834 | 4.21875 | 4 | GridLayouts in Kivy | Python
Kivy is a platform independent as it can be run on Android, IOS, linux and
Windows etc. Kivy provides you the functionality to write the code for once
and run it on different platforms. It is basically used to develop the Android
application, but it does not mean that it can not b... |
c49e1ac865a378daf4877c5f0438d04a4483dcc6 | Sheepsftw/attack-cities-v2 | /logic.py | 1,965 | 3.578125 | 4 |
import math
import play_board
class Path:
def __init__(self, city_array):
self.path = city_array
def add(self, city):
self.path.append(city)
def to_string(self):
ret = ""
for c in self.path:
ret += str(c.hash) + " "
return ret
def clear(self):
... |
40cd76a18d4938c6d71b846488dc65039b00f972 | samuelvgv/122 | /Ex_3_8.py | 337 | 3.875 | 4 | dia = int( input('Introduce un día de la semana (entre 1 y 7) : ') )
print('El día es ... ', end='')
if dia == 1:
print('lunes')
elif dia == 2:
print('martes')
elif dia == 3:
print('miércoles')
elif dia == 4:
print('jueves')
elif dia == 5:
print('viernes')
elif dia == 6 or dia == 7:
print('festivo')
else:
print(... |
c15e68f4a0fe1eccfa6636047b8fe3d63cb97af7 | MikeOcc/MyProjectEulerFiles | /Euler_8_356.py | 1,927 | 3.703125 | 4 | from math import cos
from decimal import Decimal
def newt(n):
roots = []
b = float(2**n)
bp = 2*b
d = float(n)
A0=-1
A=A0
while 1:
#print A
#if A==0:A=1
for x in xrange(1000):
A -= (A**3 -b*A**2 + d)/(3.*A**2 -bp*A )
#A -= (A*A)*(A**3 -b*A**2 + d)/(3.*A**2 -bp*A )
... |
20f9849db6e62466f651162888f610db71d51ea6 | phaniteja1/PythonWorks | /python_works/pixel_transformations.py | 537 | 3.71875 | 4 | __author__ = 'phaniteja'
# This file is to apply operations on each pixel of the file
# Import the modules to perform operations on Image - PIL is used for operations
from PIL import Image
try:
# Load an image from the hard drive
original = Image.open("steve.jpg")
except FileNotFoundError:
print("Unabl... |
b2c799c723e3c4fbd96fc34035546b6c3445ef1a | jihoonyou/problem-solving | /Educative/bfs/example4.py | 1,085 | 3.75 | 4 | """
Problem Statement
Given a binary tree, populate an array to represent the averages of all of its levels.
"""
from collections import deque
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
def find_level_averages(root):
result = []
nodes = deq... |
3f39c74a5bf2aeaf06d59e4039f93c5262fdef8f | Anshul-GH/youtube | /archive/pandas/dataframe101.py | 2,102 | 4.09375 | 4 | # # # # select * from table where
# # # # column_name = some_value
# # # import pandas as pd
# # # import numpy as np
# # # df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
# # # 'B': 'one one two three two two one three'.split(),
# # # 'C': np.arange(8), 'D': n... |
73c98b59c7c77878318782cbb66c247715207f82 | gdfelt/competition | /advent_of_code/advent_2020/day_05/day_05.py | 1,358 | 3.578125 | 4 | class Day05(object):
def __init__(self):
self.passes = []
with open("advent_2020/day_05/day_05.dat", "r") as data:
for l in data:
self.passes.append(l.strip())
def calc_seat(self, seat_string, seat_range):
# print(seat_string, seat_range)
lower, upper... |
43a92c6ded640d75ec2a8d6f610b5bf2ebab68ab | okeonwuka/PycharmProjects | /ThinkPython/swampy-2.1.5/mycircle.py | 674 | 3.796875 | 4 | # Exercise 4.3
# 4.3.4
from math import *
from TurtleWorld import *
# For some reason we need to initialise TurtleWorld() otherwise
# error
world = TurtleWorld()
bob = Turtle()
# Speed things up by reducing delay
bob.delay = 0.1
# Refined polygon description
def polygon(thing, lengthOfSide, numberOfSides):
thi... |
977c4015a95d1784e92b9df84982f3c60f795a35 | rehassachdeva/UDP-Pinger | /UDPPingerServer.py | 834 | 3.546875 | 4 | import random
import sys
from socket import *
# Check command line arguments
if len(sys.argv) != 2:
print "Usage: python UDPPingerServer <server port no>"
sys.exit()
# Create a UDP socket
# Notice the use of SOCK_DGRAM for UDP packets
serverSocket = socket(AF_INET, SOCK_DGRAM)
# Assign IP address and port num... |
04d6088fa694599b5e634cae6ac37a87bcd5c34f | niketanmoon/Programming-in-Python | /DataStructure/Array/reversal_array_rotate.py | 995 | 4.25 | 4 | """
This is a GeekForGeeks Problem on Array Rotaion using Reversal
Here's the link to the problem:
geeksforgeeks.org/program-for-array-rotation-continued-reversal-algorithm/
"""
#Function for reversing. This is the main logic
def reverseArray(arr,s,e):
while s<e:
temp = arr[s]
arr[s] = arr[e]
... |
69fd8f5cf68cbbb4e786e486515e8883d3fed568 | maroro0220/maroroPython | /day8_test.py | 1,286 | 3.65625 | 4 | class Student:
def __init__(self,ID, name, major)
self.id=ID
self.name=name
self.major=major
def common(self):
class MajorPoint(Student):
def __init__(self,ID,name,major, clist):
super().__init__(self,ID,name,major)
s... |
03440310c95988947c99d3032fe6e54dc48a0513 | inovei6un/SoftUni-Studies-1 | /FirstStepsInPython/Fundamentals/Exercice/Dictionaries/More Exercises/05. Dragon Army.py | 1,825 | 3.828125 | 4 | incoming_dragons = int(input())
dragons_den = {}
while incoming_dragons:
dragon_spawn = input()
# {type} {name} {damage} {health} {armor}
rarity, name, damage, health, armor = dragon_spawn.split(" ")
# default values: health 250, damage 45, and armor 10
if damage == "null":
damage = "45"
... |
62a72b06520039a88a143a016bbad0dbcb445f1a | mtoricruz/code_practice | /misc/isSubTree4.py | 453 | 3.796875 | 4 | def isSubTree(t1, t2):
if t1 is None:
return t2 is None
if t2 is None:
return True
if isEqual(t1, t2):
return True
return isSubTree(t1.left, t2) or isSubTree(t1.right, t2)
def isEqual(t1, t2):
if t1 is None:
return t2 is None
if t2 is None:
retu... |
a4401ea546d5b15ac4d3ad651e8fa057691c5a5d | yunusemree55/PythonBTK | /functions-methods/lambda.py | 228 | 3.6875 | 4 |
def square(number) : return number**2
numbers = [1,2,3,4,5,6,7,8,9,10]
result = list(map(square,numbers))
print(result)
check_even = lambda number : number % 2 == 0
result = list(filter(check_even,numbers))
print(result)
|
09ebbeabfb1de92ea5cf40873787ee6c8050568c | Vakicherla-Sudheethi/Python-practice | /fact.py | 387 | 4.03125 | 4 | #Scope variables
"""local variable--global variable"""
s=int(input("enter number: "))#global variable
def factorial(num):
fact=1#local variable and scope is limited to factor
for i in range (1,num+1):
fact=fact*i
print("fact of %d is %d "%(s,fact))#s is global is used
#call the function
fac... |
90003c7f04c2bc55d5d4e2539415765521f7f0a2 | KeoneShyGuy/DailyProgrammer | /medium/SingleSymbolSquares.py | 3,124 | 3.609375 | 4 | #!/usr/bin/env python3
#https://www.reddit.com/r/dailyprogrammer/comments/9z3mjk/20181121_challenge_368_intermediate_singlesymbol/
#compiled with python 3.5.3
from random import choice
from time import clock
def createGrid(gridSize):
gridOG = [['U'] * gridSize for j in range(gridSize)]
for j in range(l... |
10855c232ba401f5eb169c6ab7e563067b1fbc8b | cuent/comp551 | /practice/linear_regression/main.py | 2,625 | 3.609375 | 4 | from utils import *
from linear import *
import matplotlib.pyplot as plt
def more_points(n):
f = lambda x: 2 * x + 3
x, y = generate_1d_data(f, n, 30)
# Execute LR
lr = LinearRegressionMSE()
lr.fit(x, y)
y_pred = lr.pred(x)
fig, ax = plot_data(x, y, y_pred)
# ax.plot([np.min(x), np.m... |
72f8cb2859697c496ccdc692b2a0f424c4afbbdc | 54lihaoxin/leetcode_python | /src/CopyListWithRandomPointer/solution.py | 1,520 | 3.84375 | 4 | # Copy List with Random Pointer
#
# A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
#
# Return a deep copy of the list.
from CommonClasses import * # hxl: comment out this line for submission
debug = True
debug = Fal... |
5e6303e8b24601b4d6a367dabdceaa655b3bfd53 | hoangcaobao/Learning-Python-in-1-month | /Week1/sol_inclass1.py | 1,007 | 4 | 4 | #Exercise 1: Assign value 10 to variable x and print x
x=10
print(x)
#Exercise 2: Assign value "Vietcode academy" to variable x and print x
x="Vietcode academy"
print(x)
#Exercise 3: Assign value 10 to varibale a and value 5 to variable b and print sum of a and b
a=10
b=5
print(a+b)
#Exercise 4: Assign sum of a and ... |
f1d29adaa2ed265e743032a3e65c109d4b03f5cf | sineczek/Automated-Software-Testing-with-Python | /Python Refresher/30_type_hinting.py | 1,104 | 3.6875 | 4 | from typing import List # Tuple, set etc.
def list_avg(sequence: List) -> float: # przyjmuje liste -> a zwraca float
return sum(sequence) / len(sequence)
list_avg(123)
class Book:
TYPES = ("hardcover", "paperback")
def __init__(self, name: str, book_type: str, weight: int): # hinting, czyli podpow... |
879cb5cfd4b8dc9b6b288aa69e668e453690cfbf | Banehowl/MayDailyCode2021 | /DailyCode05032021.py | 683 | 3.5 | 4 | # ------------------------------------------------------
# # Daily Code 05/03/2021
# "Among Us Imposter Formula" Lesson from edabit.com
# Coded by: Banehowl
# ------------------------------------------------------
# Create a function that calculates the chance of being an imposter. The formula for the chance... |
94ae8a89ea97fda10cda5177058161bf244f808b | kernellmd/100-Python-examples | /example074.py | 446 | 3.546875 | 4 | #!/usr/bin/env python3
#-*- coding: utf-8 -*-
############################
#File Name: example074.py
#Author: kernellmd
#Created Time: 2018-05-23 12:21:47
############################
"""
题目描述:连接两个链表。
"""
#原始程序
if __name__ == '__main__':
arr1 = [3,12,4,8,9]
arr2 = [1,2,4]
arr3 = ['I','am']
arr4 = ['hero']
... |
76a0f67ba2943e097eeb65825643c922ec646b17 | amaguri0408/AtCoder-python | /ABC162/c.py | 461 | 3.671875 | 4 | import math
def gcd(a, b, c):
tmp = math.gcd(a, b)
tmp = math.gcd(tmp, c)
return tmp
K = int(input())
K += 1
ans = 0
for i in range(1, K):
for j in range(i, K):
for k in range(j, K):
if i == j == k:
ans += gcd(i, j, k)
elif i == j or j ==... |
4aa645198601271d83f779815a3402ce50bb3456 | muxueChen/pythonPractice | /IO.py | 985 | 3.8125 | 4 | #文件读写
# 读取文件
# 读取单个文本文件
import os
import os.path
# 遍历文件
# 深层遍历
rootdir = "./"
# for parent, dirnames, filenames in os.walk(rootdir):
# # for dirname in dirnames:
# # print("{}".format(dirname))
# for filename in filenames:
# print("{}".format(filename))
# 单层遍历
for filename in os.listdir(rootdi... |
2ca8e19e2447a2b4809a012ece25512c50a69e82 | EJTTianYu/DL3_RNN | /src/model.py | 2,489 | 3.546875 | 4 | import torch
import torch.nn as nn
class LMModel(nn.Module):
# Language model is composed of three parts: a word embedding layer, a rnn network and a output layer.
# The word embedding layer have input as a sequence of word index (in the vocabulary) and output a sequence of vector where each one is a word em... |
d2f633cfa4b79fafd6bc81521a4dfd777957d13f | Jordan-Floyd/python-day-3 | /hw_module.py | 599 | 4.03125 | 4 | # 2) Create a Module in VS Code and Import It into jupyter notebook
# Module should have the following capabilities:
# 1) Has a function to calculate the square footage of a house
# Reminder of Formula: Length X Width == Area
# 2) Has a function to calculate the circumference of a circle
# Program in Jupyter Noteboo... |
b9f61e0836917fabb07e4f30802783d3af514e32 | sselinkurt/bilimsel-hesaplama | /2003.py | 795 | 3.6875 | 4 | #girilen baslangic ve bitis tahminleri arasinda denklemin kokunu bulan program
#orta nokta bularak gitmek iyi bir yontem cunku aralik ne kadar buyuk olursa olsun ikiye bolerek cok cabuk kisaltiyoruz
def f(x):
return(x**2-4*x+3)
x1 = int(input("Baslangic tahmini giriniz: "))
x2 = int(input("Bitis tahmini: "))
if(f... |
ba47abb8bf0e6aecaf26acc13e669de3756aad44 | KrisAsante/Unit-8-02 | /car_program.py | 613 | 4 | 4 | # Created by: Chris Asante
# Created on: 6-May-2019
# Created for: ICS3U
# Unit 8-02
# This main program will create a car object
from car import *
#create a vehicle
car1 = Car()
car2 = Car()
print("Speed: " + str(car1.speed))
car1.accelerate(100)
print("Speed: " + str(car1.speed))
car1.license_plate_... |
b2a0449e71ad18337831b05c3e5797d3f61666ec | vijay6781/Python_Tutrials | /python_tutorials/RegularExpression.py | 121 | 3.5 | 4 | import re
line = "cats are smater then dogs dogs dogs"
line = print(re.sub("dogs", "cats",line ))
print(line)
|
e2eef70b3b806c23b93051ee86afd0bc88077413 | charlesreid1/probability-puzzles | /scripts/newton_helps_pepys.py | 1,394 | 4.40625 | 4 | # Isaac Newton Helps Samuel Pepys
# Pepys wrote Newton to ask which of three events is more likely:
# that a person get (a) at least 1 six when 6 dice are rolled,
# (b) at least 2 sixes when 12 dice are rolled, or (c) at least 3
# sixes when 18 dice are rolled. What is the answer?
#
# From: Fifty Challenging Problems i... |
5e40f10e299104484aad00104d51df73693f20fb | Gergana-Madarova/SoftUni-Python | /Programming-Basic-Python/For_Loop_Lab/03_Even_powers_of_2.py | 94 | 3.640625 | 4 | import math
end = int(input())
for n in range(0, end + 1, 2):
print(int(math.pow(2, n))) |
ad42b8d75b1cba7bd07c255b376e54aa6a2e732c | leclm/CeV-Python | /PythonDesafios/desafio79.py | 817 | 4.15625 | 4 | ''' Crie um programa onde o usuário possa digitar vários valores numéricos e cadastre-os em uma lista. Caso o número já
exista lá dentro ele não será adicionado. No final serão exibidos todos os valores únicos digitados, em ordem crescente.'''
resp = ' '
numeros = []
while resp != 'N':
n = int(input('Digite um... |
0321cd8da230aaee8c048ca46d1565eba005d924 | kaelynn-rose/Earthquake_Detection | /LSTM_scripts/seismic_LSTM.py | 14,807 | 3.609375 | 4 | '''
This script contains two LSTM model classes, which can be used to run regression or classification RNN models. See below each class for examples of how to use each class.
This script:
1. Calculates signal envelopes from raw signal data
2. Contains the ClassificationLSTM Class to perform classification usi... |
6cbc312c1b83f6d2ea4e2d98e559d76c857b7383 | santiagomariani/Six-Degrees-of-Kevin-Bacon-Python | /pila.py | 723 | 3.90625 | 4 | class Pila:
def __init__(self):
"""Crea pila vacia"""
self.items = []
def esta_vacia(self):
"""Devuelve True si la lista esta vacia"""
return len(self.items) == 0
def apilar(self,x):
"""apila elemento x"""
self.items.append(x)
def __str__(self):
re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.