blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1a732e4f27a0967237098fc8655de3dcbc03c847 | JiJibrto/lab_rab_7 | /individual/ind_task_1.py | 705 | 3.765625 | 4 | # !/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# 12. Ввести список А из 10 элементов, найти сумму элементов,
# больших 2 и меньших 20 и кратных 8, их количество и вывести результаты на экран.
if __name__ == '__main__':
A = tuple(map(int, input("Enter 10 items separated by a space> ").split(" ")))
... |
82e4a0906d1d64ba067f5c2b4bf5583d4706e40a | geekyteacher/the-simple-quiz | /_Quiz_Original_test/quiz_0.3.py | 3,476 | 3.875 | 4 | # =============================================================================
# Multiple Choice Quiz
# Mr. Farren - May 2021
#
# A MC quiz game about computing.
# The game requires a text file called questions.txt to load up the game data.
# =======================================================================... |
85305071d9088376b745d27ea9f56bed0d0dcabb | cloudbuy/charm-flannel | /lib/charms/flannel/common.py | 912 | 3.59375 | 4 | from time import sleep
def retry(times, delay_secs):
""" Decorator for retrying a method call.
Args:
times: How many times should we retry before giving up
delay_secs: Delay in secs
Returns: A callable that would return the last call outcome
"""
def retry_decorator(func):
... |
0a55a04b6d44e25f6359b76046fa944ed15a4c11 | drpeterallan/esp | /pysrc/creating_lists.py | 2,986 | 3.78125 | 4 | from __future__ import division, print_function # python 2 to 3 compatibility
import time
import numpy as np
import sys
def get_execution_time(start_time):
return time.time() - start_time
def get_list_properties(input_list):
print((sys.getsizeof(input_list)), "bytes", type(input_list))
def run_list_creat... |
404e42f4c7fc9974b4790fe7346b7b6250229033 | drpeterallan/esp | /pysrc/utils/array_functions.py | 2,718 | 3.6875 | 4 | """
----------------------
Array Functions
----------------------
Brief description of script
:Date: 05/04/2019
"""
from __future__ import division, print_function # python 2 to 3 compatibility
import numpy as np
import matplotlib.pyplot as plt
from esp.pysrc.utils.matplotlibrc_setup import set_rc_params
def line... |
f7743136f23dd3625a66ffe73d558f4f6c4a497c | Joon-Jeremy-Chun/My_Python_Summary | /Code03-04.py | 1,445 | 3.65625 | 4 | ## 함수
def add_data(friend) : # 함수 = Function = 기능
katok.append(None)
kLen = len(katok)
katok[kLen - 1] = friend
def insert_data(position, friend) :
katok.append(None)
kLen = len(katok)
for i in range(kLen-1, position, -1 ) :
katok[i] = katok[i-1]
katok[i-1] = None
katok[pos... |
2709b22f29b8c8b13e6661b603e3ef547bcdb22c | Joon-Jeremy-Chun/My_Python_Summary | /Code03-02.py | 898 | 3.78125 | 4 | ## 리스트 삽입과 삭제
## 함수
def add_data(friend) : # 함수 = Function = 기능
katok.append(None)
klen = len(katok)
katok[klen-1] = friend
def insert_data(position, friend) :
katok.append(None)
klen = len(katok)
for i in range(klen-1, position, -1) :
katok[i] = katok[i-1]
katok[i-1] = None... |
55d6e96210566f657ff4c7f1f110a6aafb066e4b | nummada/nummada-HW1-Computer-systems-architecture | /skel/tema/marketplace.py | 4,366 | 4.15625 | 4 | """
This module represents the Marketplace.
Computer Systems Architecture Course
Assignment 1
March 2021
"""
from threading import Lock
class Marketplace:
"""
Class that represents the Marketplace. It's the central part of the implementation.
The producers and consumers use its methods concurrently.
"... |
862c4f9f72587622335c590c89ae99e8e47c201b | aseligmann/UsefulMachineLearning | /scripts/checkDuplicates.py | 1,254 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script used for checking for duplicate fileNAMES in two given directories.
Optionally delete the files in one directory.
Author: Albert Seligmann - 26/06/2019
"""
import os
import glob
import fileinput
import sys
import argparse
def checkDir(thisdir, otherdir, exte... |
1fb8d7d28a2f804bd12fa968b0d638b08c40f924 | mattinamano/Big-Data-Analytics | /Locker Problem and Mersenne prime Python solution | 4,390 | 3.875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[16]:
# To find which lockers will be open among the 1000 lockers,
# as a sample lets consider 10 lockers (L1-L10) and 10 students(S1-S10) toggling the lockers
# where the S1 toggles all lockers and Sn toggles every nth locker
# L1 # L2 # L3 # L4 # L5 # L6 #... |
dcfadc83c8e9d127a6c531b735e045014efc65ec | kavgaut/NewYork-Subway-Data-Analysis | /P2-plots&code.py | 1,668 | 3.6875 | 4 | import pandas as pd
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import statsmodels.api as sm
from ggplot import *
%matplotlib inline
%pylab inline
cd python/p2
data=pd.read_csv('turnstile_weather_v2.csv')
#P2 - visualization 1 - stacked histogram
plt.figure()
data[data['rain']==0]['ENTR... |
7ef88ef5da33514687cbfc31b5d9694464eea537 | jki14/competitive-programming | /2016/atcoter.jp/abc044/prod.py | 268 | 3.71875 | 4 | def func(b, n):
if n<b:
return [n]
else:
return func(b, n/b)+[n%b]
n = int(raw_input())
for b in range(2, n+2):
foo=func(b, n)
while len(foo)<10:
foo=[0]+foo
print 'f('+str(b)+','+str(n)+') = '+str(foo)+' = '+str(sum(foo))
|
b577ad61d9ac1fa978758c6dd5c80946964b3b5f | jki14/competitive-programming | /2018/atcoder.jp/abc/109/proa.py | 290 | 3.609375 | 4 | def solution(a, b):
if (a & 1) == 1 and (b & 1) == 1:
return True
else:
return False
def main():
a, b = [int(i) for i in raw_input().strip().split()]
if solution(a, b):
print 'Yes'
else:
print 'No'
if __name__ == '__main__':
main()
|
bd72a3e1e2c08f8a19f8be1e807847376901b4fa | tommady/Hackerrank | /Algorithms/implementation/caesar_cipher.py | 501 | 3.71875 | 4 | #https://www.hackerrank.com/challenges/caesar-cipher-1
def rotate(s_num, k):
if s_num >= ord('A') and s_num <= ord('Z'):
s_num += k
if s_num > ord('Z'): s_num -= 26
elif s_num >= ord('a') and s_num <= ord('z'):
s_num += k
if s_num > ord('z'): s_num -= 26
return... |
9fd5b579637722170a546ae215ab03aabe16b3dd | tommady/Hackerrank | /Algorithms/strings/bigger_is_greater.py | 634 | 3.75 | 4 | # http://www.nayuki.io/page/next-lexicographical-permutation-algorithm
def next_permutation(arr):
i = j = len(arr) - 1
# Find non-increasing suffix
while i > 0 and arr[i-1] >= arr[i]:
i -= 1
if i <= 0:
return False
# Find successor to pivot
while arr[j] <= arr[i-1]:
... |
814c4df0ead8ed949845fd39c171afc03001955b | tommady/Hackerrank | /Algorithms/implementation/modified_kaprekar_numbers.py | 522 | 3.734375 | 4 | #https://www.hackerrank.com/challenges/kaprekar-numbers
p = int(input())
q = int(input())
answer = list()
for number in range(p, q+1):
power_str = str(number ** 2)
power_len = len(power_str)
if power_len & 1 != 0:
power_str = power_str.zfill(power_len+1)
power_len = len(power_str)
... |
edc17174f4dfe613269ae6e2133d9e5fc805546e | alexshenyuefei/python- | /python/继承,多继承/super.py | 1,069 | 4.25 | 4 | """
super().方法和父类没有实质性的关联
super()按照当前对象的MRO 列表顺序,遍历查找要调用的方法.
"""
"""
super原理
def super(类名, self或者cls):
mro = self或者cls.__class__.mro() 查找cls或者self的mro列表
return mro[mro.index(类名) + 1],返回下一个mro列表中的要调用对象
"""
# 案例
"""
继承关系
Base
/ \
/ \
A B
\ /
\ /
C
"""
class Base... |
c069e09415f1defdc8d01514c6fd17aa75e89705 | alexshenyuefei/python- | /python/python的类方法使用.py | 535 | 3.75 | 4 | # python的类充当js里对象,是基本的数据结构,可以存储属性.
class calculator(object):
operand1 = 1
operand2 = 2
@classmethod
def add(cls):
# 全局变量在程序之中始终有定义的,局部变量在它的函数体内,以及嵌套的函数内始终有定义的.
# 这里的变量operand1,opearand2在函数外,需要通过解释器传入的cls,指定外部对象(这里是calculator)访问
cls.result = cls.operand1 + cls.operand2
calculat... |
40e0380a8b575a3ef90d7290604983a9888f862a | alexshenyuefei/python- | /python/迭代/生成器.py | 213 | 3.5 | 4 |
def fib(n):
prev, curr = 0, 1
while n > 0:
n -= 1
yield curr
prev, curr = curr, curr + prev
a =fib(12) # 生成器只能用一次
for i in a:
print(i)
for i in a:
print(i) |
1f1354f3ce0fd86fec22c21d866146c5e0e09e2a | alexshenyuefei/python- | /python/迭代器.py | 1,139 | 4.03125 | 4 | """
可迭代对象就是用于迭代操作(for 循环)的对象
它像列表一样可以迭代获取其中的每一个元素,任何实现了 __next__ 和__iter__方法 (python2 是 next)的对象都可以称为可迭代对象。
它与列表的区别在于,构建迭代器的时候,不像列表把所有元素一次性加载到内存,而是以一种延迟计算(lazy evaluation)方式返回元素
因为它并没有把所有元素装载到内存中,而是等到调用 next 方法时候才返回该元素
按需调用 call by need 的方式,本质上 for 循环就是不断地调用迭代器的next方法
"""
print('hello world')
print('hello world')
clas... |
3d6da0a1750402077cfe797c54f5b3623122b259 | SamWaggoner/125_HW3_Computation-For-While | /Waggoner_hw3b.py | 940 | 3.921875 | 4 | # File: hw3b.py
# Author: Sam Waggoner
# Date: 10/04/2020
# Section: 1006
# E-mail samuel.waggoner@maine.edu
# Description:
# We print out numbers descending from 101 to 1, and replace printing the number
# with a written statement if it meets certain parameters.
# Collaboration:
# I did not collaborate with a... |
397c78275adb472e64595af3b997d41cae21b6e2 | BramTech/Second-attempt | /20 Questions.py | 953 | 4.28125 | 4 | # Design a program that asks the user to enter a series of 20 numbers.
# The program should store the numbers in a list and then display the
# following data:
# • The lowest number in the list
# • The highest number in the list
# • The total of the numbers in the list
# • The average of the numbers in the list
# ... |
b4571fd1957c0912ad2d558594cd1a9825257056 | balaji38738/Python-Programmes | /Desktop/Python-Programmes/tic_tac_toe.py | 9,167 | 4.15625 | 4 | import numpy as np
import random
print("-------Tic Tac Toe-------")
user_char = "x"
comp_char = "o"
filled_cells = 0
TOTAL_COLUMNS = 3
TOTAL_ROWS = 3
USER = 0
COMP = 1
board = np.empty((3,3), dtype=str)
class TicTacToe:
#Starts a fresh board
def reset_board(self):
print("\nNew game starts")
... |
e962d582f81dfffce8648b15f59ba3e458e516da | balaji38738/Python-Programmes | /Desktop/Python-Programmes/list_operations.py | 1,182 | 4.0625 | 4 | primes = [2, 3, 5, 7, 11]
print("Sum of", primes, "=", sum(primes))
print("Maximum of", primes, "=", max(primes))
print("Minimum of", primes, "=", min(primes))
print("Addding 13 to", primes, end=" = ")
primes.append(13)
print(primes)
print("Extending", primes, end=" = ")
primes.extend([17, 19, 23, 29])
print(prime... |
35aff76463677a5f5141476f89287c9117533359 | flosopher/floscripts | /genutils/DeleteLinesUnequalNumberOfColumns.py | 936 | 3.890625 | 4 | #!/usr/bin/python
import sys
import os
def usage():
print """Script to read in a file and delete all the lines from it that don't have the same number of columns as the first line."""
CommandArgs = sys.argv[1:]
if len(CommandArgs) < 2:
usage()
sys.exit()
infile = ''
for arg in CommandArgs:
if ar... |
87997feaf1d5be8792bfb9b98667536fedd27a98 | edagner/mynotes | /matplotlibNotes.py | 12,338 | 4 | 4 | import matplotlib as mpl
import matplotlib.pyplot as plt
# create a new figure
plt.figure()
# plot the point (3,2) using the circle marker
plt.plot(3, 2, 'o')
# get the current axes
ax = plt.gca()
# Set axis properties [xmin, xmax, ymin, ymax]
ax.axis([0,6,0,10])
#SCATTER PLOT
# create a new figure
plt.figure()
... |
ff1e85be57dd1d88e80dead677704fd7a846d8be | alexandrefcoalmeida/Logica-de-Programacao-e-Algoritmos | /aula_04.py | 6,147 | 3.859375 | 4 | #ESTRUTURAS DE REPETIÇÃO
x = 1
print(x)
x = 2
print(x)
x = 3
print(x)
x = 4
print(x)
x = 5
print(x)
print('-------------------')
#SIMPLIFICADO: (em looping)
x = 1
print(x)
x = x + 1
print(x)
x = x + 1
print(x)
x = x + 1
print(x)
x = x + 1
print(x)
print('--------------------')
# ESTR... |
2270ce443bee7f072044dcb25d500e1b431621ed | rafo2001/ToDo_List | /Problems/Dating App/task.py | 330 | 3.6875 | 4 | def select_dates(potential_dates):
people = None
for names in potential_dates:
if names['age'] > 30 and 'art' in names['hobbies'] and names['city'] == 'Berlin':
if people is None:
people = names['name']
else:
people += ", " + names['name']
retu... |
320d8033ca077481f878312e2212fff2aea3d26d | ishg-153/weekly-challenges | /week-3/Subham_Patel/wallpaperChanger.py | 1,247 | 3.53125 | 4 | import schedule
import ctypes
import random
import time
import os
# path to the folder containing the images to be used as wallpapers
path = os.path.join(os.getcwd(), 'week-3/Subham_Patel/wallpapers')
# initializing the list of images
images=[]
# creating a list of all the images in the folder
files = os.listdir(path... |
6cd3120338427c6d21f6eba084c81f57d70d596d | momochang/animate-database | /show.py | 1,255 | 3.796875 | 4 | #select all tables of database
def list_table(cursor, mysqldb):
cursor.execute("show tables")
#using for loop to fetch all of database tables.
#Why using table[0], Not table? Because table result is ('table_name',),
#but I want ('table_name') that I'm using table[0] to fetch ('table_name')
... |
f3737640d1e91d17d460f7b1bb1b290805cf02f5 | rohilla-aditya/Machine-Learning-Data-Science-Scripts | /Linear_Regression_Implementation.py | 995 | 3.703125 | 4 | import numpy as np
import pandas as pd
#Importing data using pandas
train_data = pd.read_csv("training_data.csv")
train_labels = pd.read_csv("training_labels.csv")
test_data = pd.read_csv("testing_data.csv")
test_labels = pd.read_csv("testing_labels.csv")
# Adding a row of 1 to our data for adding intercep... |
c301cc2cfffcd91064aa15dbcb3232a18855cc06 | chivalrousS/Leetcode | /ToLowerCase.py | 617 | 4.21875 | 4 | #coding:utf-8
'''
实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。
示例 1:
输入: "Hello"
输出: "hello"
示例 2:
输入: "here"
输出: "here"
示例 3:
输入: "LOVELY"
输出: "lovely"
'''
def toLowerCase(str):
"""
:type str: str
:rtype: str
"""
res = ''
for i in str:
if ord(i) >= 65 and ord... |
3727a1a074560c86e8dd6d5d29d63cff8d50f91e | jenniferpen430/portfolio-page | /thaliaturtle.py | 701 | 4.09375 | 4 | from turtle import *
import math
# Variables boi.
t = Turtle()
#User inputs
num_side = int(input("How many sides do you want? "))
side_len = int(input("How long should the shape be?"))
color = input("What color do you want? ")
thicc = input("How thicc do you want it? (10-50 pls) ")
# Set Up your screen and starting... |
bd7b179b1815214509248cfb3e95eef9b2209c03 | AnderSon277/DEBER_3 | /Nombre.py | 2,953 | 3.671875 | 4 | import turtle
t=turtle.Pen()
t.penup()
t.forward(-100)
#LETRA A
for x in range(1,4):
if(x==3):
t.penup()
else:
t.pendown()
t.left(120)
t.forward(200)
t.pendown()
t.left(180)
t.forward(50)
t.penup()
t.forward(150)
t.left(180)
t.pendown()
t.forward(50)
t.penup()
t.forward(100)
for x in r... |
118e95b759e26743658357fb8932dbaa14912084 | ShyamV11/My-Learnings | /List.py | 476 | 4.40625 | 4 | List = []
print("Blank List")
print(List)
List.append(1)
List.append(2)
List.append(10)
print("\nList after adding three elements: ")
print(List)
for i in range(11, 19):
List.append(i)
print("\nList after adding elements through iterator: ")
print(List)
List.append((21, 22))
print("\nList a... |
265b3ed37730f211ab1a5facaf2ccb397928615f | qiaob/py | /InputDemo.py | 311 | 3.859375 | 4 | # _*_ coding :UTF-8 _*_
# author : momo
# DATE : 2019-06-06 22:23
# desc : input
import datetime
str = input("name:")
print("name is:",str)
year = int(input("出生年份:"));
print("年龄:",datetime.datetime.now().year - year +1)
if (year >= 18):
print("已成年")
else:
print("未成年")
|
6957e50fd5d8fc86450474fd61c795bc15fbeb90 | Ignis17/CS140 | /Labs/Assignment_36.py | 531 | 3.90625 | 4 | # Author: Joel Turbi
# Assignment: Lab Assignment 36
# Course: CS140
def seasons_fun(user_input):
if user_input in seasons:
months = seasons[user_input]
for user_input in months:
print(user_input, end= " -- ")
print()
seasons = {"Spring":["March", "April", "June"], "Summer":["June", "July", ... |
2816e45a5687c4d3afe331bcecd4eacccc1d4873 | Ignis17/CS140 | /Labs/Assignment_30.py | 216 | 3.84375 | 4 | # Author: Joel Turbi
# Assignment: Lab Assignment 30
# Course: CS140
user_input = int(input("Enter a number: \n"))
if user_input%2 == 0:
print(user_input, "is even.")
else:
print(user_input, "is odd.")
|
781fd6cb7d444e7a0563271b05e45b90de9d17a2 | Ignis17/CS140 | /Labs/Assignment_33.py | 238 | 3.59375 | 4 | # Author: Joel Turbi
# Assignment: Lab Assignment 33
# Course: CS140
def perfect_squares(max):
for i in range(1, max):
if i%2== 0:
print(i**2, end=",")
a = int(input("Enter a number:\n"))
perfect_squares(a)
|
c826fd48f95339494862724c93edc1840407aa0e | Ignis17/CS140 | /Labs/Assignment_25.py | 471 | 3.78125 | 4 | # Author: Joel Turbi
# Assignment: Lab Assignment 25
# Course: CS140
def chorus(number):
for number in range(10, 0, -1):
if (number ==1):
print(number, '''bear in the bed and the little one said, "You know what? I'm lonely."''')
else:
print(number, '''bears in the bed... |
2537f8519b831492c23a4c7de2db42e298861bf8 | ashtonchiang/hello-world | /HW1/cooking_converter.py | 1,169 | 4.125 | 4 | lemon_juice = int(input('Enter amount of lemon juice (in cups):\n'))
h20 = int(input('Enter amount of water (in cups):\n'))
agave_nectar = float(input('Enter amount of agave nectar (in cups):\n'))
servings = int(input('How many servings does this make?\n'))
print('')
print('Lemonade ingredients - yields {:.2f} serving... |
f55553e7ef5aec0a5ec70158ed8073094c6fdcfc | gaelwjl/Leetcode-Solution | /solutions/0823-split-array-with-same-average/split-array-with-same-average.py | 1,045 | 3.859375 | 4 | # In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)
#
# Return true if and only if after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.
#
#
# Example :
# Input:
# [1,2... |
45beeb289f97fbb8f768a62343448f0b543269eb | gaelwjl/Leetcode-Solution | /solutions/0037-sudoku-solver/sudoku-solver.py | 3,300 | 3.875 | 4 | # Write a program to solve a Sudoku puzzle by filling the empty cells.
#
# A sudoku solution must satisfy all of the following rules:
#
#
# Each of the digits 1-9 must occur exactly once in each row.
# Each of the digits 1-9 must occur exactly once in each column.
# Each of the digits 1-9 must occur exactly once in ... |
e02fd25a9271d23d7af95cd01e259ac29d404922 | gaelwjl/Leetcode-Solution | /solutions/1764-maximum-repeating-substring/maximum-repeating-substring.py | 1,385 | 3.984375 | 4 | # For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.
#
# Given strings sequence and ... |
d6f83cc5079a670ed65d1510dd6e4439d9710804 | gaelwjl/Leetcode-Solution | /solutions/1732-minimum-one-bit-operations-to-make-integers-zero/minimum-one-bit-operations-to-make-integers-zero.py | 1,634 | 4 | 4 | # Given an integer n, you must transform it into 0 using the following operations any number of times:
#
#
# Change the rightmost (0th) bit in the binary representation of n.
# Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.
#
#
# Retu... |
12860fa37b1ec617847a69f89b332f65d5ebad8e | sylvain-01/Python_Games | /rock_paper_scissors/rock_paper_scissors.py | 3,610 | 4.15625 | 4 | import tkinter
from tkinter import *
from random import randint
# initialize window where game will be played
root = tkinter.Tk()
root.geometry("1500x300")
root.title("Rock, Paper, Scissors")
root.config(bg="white smoke")
# Define top label name
label_top = tkinter.Label(root, text="Rock, Paper, Scissors Game: selec... |
f84f7534641c690202e5b917809b36e54f1d65b1 | tracierenea/samples | /Python/ex3_davis_staircase.py | 1,544 | 4.1875 | 4 | #!/usr/bin/env python
#
# Author : Tracie Conn
# Created : Jan 6, 2018
#
# Tested with Python v3.5.2
#
######## Instructions
# Davis has staircases in his house and he likes to climb each
# staircase 1, 2, or 3 steps at a time. Being a very precocious
# child, he wonders how many ways there are to reach the... |
117dc8e47b8fe7a2b301637a92d398bc7b5ace9b | xiaonah/amazon-sagemaker-examples | /workshop/lec1/gradient_descent_solution.py | 6,743 | 3.8125 | 4 | # Adapted from Avinash Kaitha for CSE591 taught by Ragav Venkatesan at ASU.
from analytical_solution import regressor
import numpy as np
from IPython import display
import matplotlib.pyplot as plt
class gd(regressor):
"""
This is a sample class for GD.
Args:
data: Is a tuple, ``(x,y)``
... |
4684b8d03ba09aaed25ebcbbf5989f82be7ca4d3 | WojciechKaluzinski/pwr-sem4 | /python/lista6/neural_network.py | 2,053 | 3.546875 | 4 | import numpy as np
def sigmoid(x):
return 1.0 / (1 + np.exp(-x))
def sigmoid_derivative(x):
return x * (1.0 - x)
def relu(x):
return np.maximum(0, x)
def relu_derivative(x):
return 1. * (x > 0)
class NeuralNetwork:
def __init__(self, x, y, activator1="sigmoid", activator2="sigmoid"):
... |
3d22b8fd8ee46cc6025d5cc544763e62a1dbac16 | WojciechKaluzinski/pwr-sem4 | /python/lista3/zad5.py | 484 | 3.859375 | 4 | #!/usr/bin/python3
#pierwsza metoda - składnia funkcjonalna
def allsubsets1(tab):
return list(map(lambda i: list(map(lambda k: tab[k],filter(lambda j: i & (1 << j),range(len(tab))))),range(1 << len(tab))))
#druga metoda - listy składane
def allsubsets2(tab):
subsets =[]
for i in range(1<<len(tab)):
subsets += [... |
953d0388005f3736cea595609acad43d4aa1200e | yaronin/DevOps_Course | /MemoryGame.py | 1,632 | 4.1875 | 4 | # The purpose of memory game is to display an amount of random numbers to the users for 0.7
# seconds and then prompt them from the user for the numbers that he remember. If he was right
# with all the numbers the user will win otherwise he will lose
import random
import os
from time import sleep
# Will gene... |
7c0c5fc6bf0521e7832e9add1980913de294cc6f | engr-hasanuzzaman/pyschool-practice | /variabl_and_data_types.py | 2,534 | 3.953125 | 4 | # 1: Using Integer
a = 5
b = 6
c = a + b
# Using Float
#Compute the area and perimeter of a circle with radius = 3
pi = 3.14
radius = 3
area = pi * radius**2
perimeter = 2 * pi * radius
# Integer And Float
# Change the type of the variable x to float
# Change the type of variable y to integer
x = 123446754336788543... |
d3363c8f42b147949987f251a4befdff507e31b4 | CezaryDobrenko/wspec | /lab02/zadanie2.py | 1,919 | 3.546875 | 4 | # Recursion
# # złożoność czsowa: Powyższy algorytm wymaga n operacji przypisania oraz n-1 operacji odejnowania i n - 1 operacji dowania. Złożoność czasowa jest rzędu O(2n).
# # złożoność pamięciowa: Wymagana jest zmienna do przechowywania wartości sumowania. Złożoność pamięciowa jest rzędu O(1).
# Iteration
# # złoż... |
f9444609ade2032b728e97363d843256868ae81c | ryuji0123/algorithm-library | /tree.py | 661 | 3.59375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
# time: O(V^2)
# space: O(V)
class Solution:
def constructFromPrePost(self, pre: List[int], post: List[int]) -> TreeNode:
if... |
214d01de7dabd65aa9c132aba5cb3608f1931b66 | adamchau/goagent_localupdate | /zipunzip.py | 1,931 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 24 17:01:16 2014
@author: zhaoyd
"""
#coding=utf-8
#甄码农python代码
#使用zipfile做目录压缩,解压缩功能
import os,os.path
import zipfile
def zip_dir(dirname,zipfilename):
filelist = []
if os.path.isfile(dirname):
filelist.append(dirname)
else :
... |
9bdde880a55513fdbe472ad018d88d43ae9e5d48 | chrischae2020/Google-Automation-Course | /course4 | 1,952 | 4.15625 | 4 | #!/usr/bin/env python3
import csv
import datetime
import requests
import operator
FILE_URL="http://marga.com.ar/employees-with-date.csv"
def get_start_date():
"""Interactively get the start date to query for."""
print()
print('Getting the first start date to query for.')
print()
print('The date ... |
10b6e38865c9bea75dbb5d1e3119536c88b51d39 | flymperopoulos/Robot-Game | /checkerPiece.py | 16,631 | 3.828125 | 4 | from checkers import *
class CheckerPiece(object):
"""
checkerPiece that determines has an attribut if it is white or B and returns all possible moves
"""
def __init__(self, color, position, number):
self.color = color
self.name = color + number
self.position = position
self.isKing = False
self._possib... |
5c615561922aa8a1318402f290eff353af5813f7 | oguzhan-yuksektepe/pythonn | /dakikayi_saate_cevirme.py | 242 | 3.5625 | 4 | girilen_dakika = input('Dakika girin : ')
girilen_dakika = int(girilen_dakika)
saat = (girilen_dakika // 60)
dakika = girilen_dakika % 60
print(str(girilen_dakika) + ' ==> ' + str(saat) + ':' + str(dakika) + ' dakikaya eşittir.') |
b5e0a20984158aab3cb1a5243689f5cb4eb47534 | JoshuaRocksGh/Joshua-Tetteh-Python | /MObileMOney.py | 2,223 | 3.875 | 4 | import sys
class momo:
def __init__(self,pin,balance,deposit,withdrawal):
self.pin = pin
self.balance = balance
self.deposit = deposit
self.withdrawal = withdrawal
balance = 3000,
def pin():
correct_pin = 1234
number_of_tries = 1
pin = int(input("Enter Pin: "))
max... |
159db3d735a77d2e572d4a0d60378605ed9714fe | vitaly-efremov/py-algorithms | /tim_sort.py | 1,599 | 3.828125 | 4 | from insertion_sort import insertion_sort_v1
from merge_sort import merge_parts
def get_min_run(n):
r = 0
while n >= 64:
r |= n & 1
n >>= 1
return n + r
def tim_sort(array):
def cmp(a, b):
return (a > b) - (a < b)
n = len(array)
if n < 2:
return array
mi... |
84eddb5dd9ba79b446c9e8fa3d166d2a52d0f958 | takupaku/pythonCrashCourseCptrNine | /OrderedDict_Rewritten.py | 899 | 3.859375 | 4 | from collections import OrderedDict
glossarySec=OrderedDict()
glossarySec['list']='python list helps to store information in one variable'
glossarySec['tuple']='tuple is similar to list except the fact that it is immutable and one cannot alter the values but can insert new values'
glossarySec['slice']='slice is... |
0ab997d00d69ca02157b9ffd7bc84464e0ad4f03 | aneesh27/Projects | /Pre Release for summative.py | 1,304 | 4.09375 | 4 | #Task 1
best_emp_name = 0
best_emp = 0
p = 0
hpay = 0
pay1 = 0
pay2 = 0
pay3 = 0
pay4 = 0
pay5 = 0
for i in range (1,31):
emp_name = input("Enter Your Name: ")
emp_num = int(input("Enter Number: "))
hrs = int(input("Enter Number of hours worked: "))
#Task 2
if hrs < 5:
p=0
pay1 = pay1 ... |
82dbb69cf5e8ecb0c90b476ee24f406910b26898 | JCHasrouty/CSIS-151-Python | /Chapter 3 Lab/Ch3LabQ2.py | 1,085 | 4.15625 | 4 | # Chapter 3 Lab Question 2
# Programmer: Jean Claude Hasrouty
# Instructor: Zare Agazaryan
# CSIS 151
# Date Created: 3/6/18
user_input = input("Please enter a number 1..10: \n")
if int(user_input) == 1:
print("The roman numeral for " + user_input + " is I.")
elif int(user_input) == 2:
print("The roman numera... |
4ac156c44fa258a1bc5f6bdbce286c37ec38e9bf | JCHasrouty/CSIS-151-Python | /Chapter 9 Homework/Part 3/Employee.py | 2,166 | 3.609375 | 4 | class Employee():
## def __setitem__(self, key, item):
## self.__dict__[key] = item
##
## def __getitem__(self, key):
## return self.__dict__[key]
##
## def __delitem__(self, key):
## del self.__dict__[key]
##
## def clear(self):
## return self.__dict__.clear()
##
## def copy... |
9495b7c344a6c55b5b1a6f1d610c3e3d9466cca7 | Zhakir/pythontraining | /codekata/positivenegative.py | 203 | 3.796875 | 4 | def main(N):
a=N
if(a>0):
print"Number is POSITIVE"
elif(a<0):
print"Number is NEGATIVE"
elif(a==0):
print"Number is ZERO"
if __name__ == '__main__':
main(1)
|
b1efbd043cb00b13bb3584cb6125eaafaa0deac1 | kujoukaren/Python-File-Search | /File Search.py | 6,263 | 3.78125 | 4 | ## Mengqi Li 92059150
## ICS 32
import os
import shutil
## required functions
def search_by_name() -> list:
''' Search files/folders that have exact name as user types '''
key = input("Enter a file name (ex)filename.doc: ")
result = []
result.extend(search_by_name2(os.getcwd(), key))
return re... |
313cd3a2b4350236a715bfdf4e8cfc4d1acbed63 | lierfengmei/pyworks | /sum2.py | 889 | 3.515625 | 4 | def count():
fs = []
for i in range(1,4):
def f():
return i*i
fs.append(f)
return fs
#再创建一个函数,用该函数的参数绑定循环变量当前的值,
#无论该循环变量后续如何更改,已绑定到函数的值不变
def count2():
def f(j):
def g():
return j*j
return g
fs = []
for i in range(1,4):
fs.append(f(i)) #f(i)立即被执行了
return fs
还是以map()函数为例,计算f(x)=x2时,除了定义一个f(x... |
9f7bf856a31fb601d51f95d3345f91c0acd0d801 | lierfengmei/pyworks | /WordLower.py | 523 | 4.0625 | 4 | # 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,
# 其他小写的规范名字。输入:['adam', 'LISA', 'barT'],
# 输出:['Adam', 'Lisa', 'Bart']:
# 函数:输入字符串,将每个word变成首字母大写,其他字母小写的word
def normalize(name):
return name.capitalize()
# return name.lower()
# name[0] = name[0] -32
#name[0]=toUpper(name[0])
# def toUpper(ch):
# return ch-32
L1 = ['adam',... |
5b3c1ad7e357736f6b361692f67549014807945a | lierfengmei/pyworks | /calc.py | 1,153 | 3.625 | 4 |
#calc.py
'''
def calc(seq):
maximum = 0
max_item = []
for i in seq:
product = (i[0]*100+i[1]*10+i[2])*(i[3]*10+i[4])
if product>maximum:
maximum = product
max_item = i
elif product== maximum:
max_item += "," + i
return max_item,maximum
seq = [[5,6,7,8,9],[5,6,7,9,8]]
max_item,maximum = calc(seq... |
01e841d869baf9693eeb162b1571db8c6a838868 | njerigathigi/learn-python | /sorted_function.py | 915 | 4.4375 | 4 | # The sorted() function returns a sorted list of the specified iterable object.
# You can specify ascending or descending order. Strings are sorted
# alphabetically, and numbers are sorted numerically.
# You cannot sort a list that contains BOTH string values AND numeric values.
# sorted(iterable, key=func, reverse=... |
501c93fc473b45f7cd547f6c46c0bcec8ae82508 | njerigathigi/learn-python | /list_comprehension.py | 1,835 | 4.8125 | 5 | # List comprehension offers a shorter syntax when you want to create
# a new list based on the values of an existing list.
# Based on a list of fruits, you want a new list, containing only
# the fruits with the letter "a" in the name.
# Without list comprehension you will have to write a for statement with
# a cond... |
39308cdb78c2867bc68744cef37412f37673206c | njerigathigi/learn-python | /operator_functions.py | 2,992 | 4.53125 | 5 | # Python has predefined functions for many mathematical, logical, relational, bitwise
# etc operations under the module “operator”. Some of the basic functions are :
import operator
a = 4
b = 3
#add
#add(a, b) :- This functions returns addition of the given arguments.
# Operation – a + b.
print('The addition of... |
1eb99024017401b5f7c39c0a85e81c634a84e9a8 | njerigathigi/learn-python | /pow.py | 422 | 4 | 4 | # The pow() function returns the value of x to the power of y
# If a third parameter is present, it returns x to the power of y, modulus z.
# Syntax
# pow(x, y, z)
# Parameter Values
# Parameter Description
# x A number, the base
# y A number, the exponent
# z Optional. A number, the modulus
# Return... |
1481c0afd93e86b0a333c351c61b219b0df42412 | njerigathigi/learn-python | /booleans.py | 1,105 | 4.34375 | 4 | # When you run a condition in an if statement, Python returns True or False:
a = 5
b= 10
if b > a:
print('b is greater')
else:
print('a is greater')
# Evaluate Values and Variables
# The bool() function allows you to evaluate any value, and give you True or False in return
# Almost any value is evaluated to ... |
7d1382533ddbeef7f9694ec8018eed42005c7bab | njerigathigi/learn-python | /split.py | 1,098 | 4.21875 | 4 | # The split() method splits a string into a list.
# You can specify the separator, default separator is any whitespace.
# Syntax
# string.split(separator, maxsplit)
# When maxsplit is specified, the list will contain the specified number of elements plus one.
# Parameter Values
# Parameter Description
#
# sepa... |
43426020e0225c7119921402f88a24cd3c38a784 | JeremySilverTongue/Chord | /ButtonMath.py | 1,519 | 3.671875 | 4 | from scipy.special import binom
buttons = 3
rockers = 2
def enumerate_chords(buttons, rockers):
for fingers in range(1, buttons + rockers + 1):
print "{}: {}".format(fingers, chords_per_finger_count(buttons, rockers, fingers))
def chords_per_finger_count(buttons, rockers, fingers):
# print "How ... |
351386480e77be14fa4142efde49c5dccf7f25eb | swtcpro/jingtum-lib-python | /jingtum_python_baselib/datacheck.py | 1,203 | 4.40625 | 4 | # Data functions used to check the valid data types.
import re
CURRENCY_NAME_LEN = 3
CURRENCY_NAME_LEN2 = 6
TUM_NAME_LEN = 40
# return True if the code is 3 letters/numbers
def is_currency(in_code):
if isinstance(in_code, str):
if in_code and len(in_code) >= CURRENCY_NAME_LEN and len(in_code) <= CURRENCY... |
a5a835860c305d5425e00a00ff091ca9aa0c5252 | kevin-samson/grade-12-practicles | /exp5.py | 332 | 3.65625 | 4 | """
remove all the a
"""
lines_without_letter_a = []
with open('texts.txt', 'r') as f:
the_lines = f.readlines()
for i in the_lines:
if 'a' not in i:
lines_without_letter_a.append(i)
with open('No letter a.txt', 'w') as f:
print("file created")
for i in lines_without_letter_a:
f.write(... |
b87cbc296915b2994da5b27d1ff848a52b6069ce | agricolamz/iconicity_in_SL_site | /check_urls.py | 1,578 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: Anna Klezovich
# e-mail: belkannkl@gmail.com
# date: 23.09.17
'''
This program checks validity of list of urls from the file.
'''
import urllib.request as url_mod
import csv
def urls(file):
'''
This function gets all urls from the data... |
7df0ffe88dab0b06a0c43456928c76e77e61e708 | Nikhil483/py-1BM17cs052 | /8_databse.py | 2,776 | 3.90625 | 4 | import sqlite3
import sys
def establish_connection(filename) :
conn=None
try :
conn=sqlite3.connect(filename)
print("Datbase",filename,"succesfully created .!!!!")
except Exception as e :
print("unable to create database")
return conn
def create_table(conn,tablename) :
try :
c=conn.cursor()
... |
6fc5187b4aede78aa5ce9a518ba19cf58bebeed8 | AndrewPau/interview | /kthLargestElem.py | 1,274 | 3.96875 | 4 | """
Given a binary tree, find the k-th largest element in the binary tree.
"""
class Tree:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
currNode = 0
# Finds the k-th largest element by scanning the right, middle, and left.
def kthLargestElem(node, k):
glob... |
b513064d4303be4663db7de20dce6f11db49a803 | johnPertoft/various-programming-problems | /misc/sum-to-100.py | 931 | 3.546875 | 4 |
"""
Problem: Output all possible ways to put +, -, or nothing between
numbers 1 to 9 to get 100 as result. I.e. 1 + 2 - 34 + ... = 100
Idea: Basic recursion, small data -> no need for memoize or dp
1 + combinations_of(2 to 9),
1 - combinations_of(2 to 9),
combinations_of(12, 3 to 9)
"""
def solve_rec(numbers, targe... |
42d6bebfe309a27d10f68d9f4ebe608b0e0adf53 | johnPertoft/various-programming-problems | /hackerrank/data-structures/arrays/sparse-arrays/sparse-arrays.py | 244 | 3.546875 | 4 | from collections import Counter
if __name__ == "__main__":
N = int(raw_input())
strings = [raw_input() for _ in range(N)]
counts = Counter(strings)
Q = int(raw_input())
for _ in range(Q):
print(counts[raw_input()])
|
75cf8b071bcb3b0ae53c349942fd8e60155f7e3e | Pranavan135/ProjectEulerSolutions | /036.py | 459 | 3.828125 | 4 | def change_num_to_base_k(num, k):
numeric_str = ''
while num >= k:
numeric_str = str(num % k) + numeric_str
num //= k
numeric_str = str(num % k) + numeric_str
return numeric_str
def check_palindrome(num):
return num == num[::-1]
nk = input().split()
N, K = int(nk[0]), int(nk[1... |
7f0978d54d328b5194984c750727799b8d8bb65c | Pranavan135/ProjectEulerSolutions | /030.py | 386 | 3.90625 | 4 | # brute force way of writing the program, still passes all the test cases.
def power_sum(num, n):
num_str = str(num)
s = 0
for i in range(len(num_str)):
s += pow(ord(num_str[i]) - 48, n)
return s == num
N = int(input())
n_th_power = 0
for i in range(2, 10**6): # upper bound can be reduced
... |
3137c05a6ce1b50ae0fb1247a712e1c1dd63a4d3 | vivid-ZLL/tedu | /part_01_python_base/python_core/day7/exercise01.py | 558 | 3.84375 | 4 | # list01 = ["无忌", "赵敏", "周芷若"]
# dict01 = {}
# for item in list01:
# dict01[item] = len(item)
# print(dict01)
list01 = ["无忌", "赵敏", "周芷若","灭绝师太"]
result = [101, 102, 103, 101]
# dict01 = {}
# for i in range(len(list01)):
# dict01[list01[i]] = list02[i]
# print(dict01)
dict01 = {list01[i]: result[i] for i in r... |
a9353847a9e34333434c84dd80002431d8c4c91e | vivid-ZLL/tedu | /part_01_python_base/python_core/day4/exercise10.py | 252 | 3.765625 | 4 | input_str = input("请输入字符串:")
print(input_str[0])
print(input_str[-1])
print(input_str[-3])
print(input_str[0:2])
print(input_str[::-1])
str_len = len(input_str)
code_mid = str_len // 2
if str_len % 2 == 1:
print(input_str[code_mid])
|
300a12e1e49e6056831684ef5d0aaac532aa2ff2 | vivid-ZLL/tedu | /part_01_python_base/python_pro/day14/exercise02.py | 420 | 3.75 | 4 | class Vector1:
def __init__(self, x):
self.x = x
def __str__(self):
return "一维向量的分量是:" + str(self.x)
def __sub__(self, other):
return Vector1(self.x - other)
def __mul__(self, other):
return Vector1(self.x * other)
def __rsub__(self, other):
return Vector1... |
83088a823687b286d9f0fe96f581e4c4c930a1d7 | vivid-ZLL/tedu | /part_02_system_programming/part_2_4_re/re_test.py | 2,571 | 3.5 | 4 | import re
s = "Alice: alice@gensoko.cn"
c = re.findall("\w+@", s)
print(c)
# 字符集
c = re.findall("[Aa]", s)
print(c)
c = re.findall("[A-z]", s)
print(c)
c = re.findall("[poas5-p]", s)
print(c)
# 字符集取反
c = re.findall("^[a5-p]", s)
print(c)
c = re.findall("^[A]", s)
print(c)
# "或"关系
c = re.findall("Al|a", s)
print(c)
... |
0581a5ad5da6a0aedea3bd8951ee87ed9468caa7 | vivid-ZLL/tedu | /part_02_system_programming/part_2_1_data_base/day2/squeue.py | 912 | 4.15625 | 4 | """
squeue.py 队列的顺序存储
思路分析:
1. 基于列表完成数据存储
2. 通过封装规定数据操作
3. 先确定列表的哪一段作为队头
"""
# 自定义队列异常
class QueueError(Exception):
pass
# 队列操作
class SQueue:
# 初始化
def __init__(self):
self._elems = []
# 判断队列是否为空
def is_empty(self):
return self._elems == []
# 入队
def enqueue(self, val):... |
81d461fd4c89620208a1a0b33f763174c8933ac9 | vivid-ZLL/tedu | /part_01_python_base/python_core/day2/homework05.py | 727 | 3.78125 | 4 | # 温度
# 摄氏度 = (华氏度 - 32) / 1.8
# 华氏度 = 摄氏度 * 1.8 + 32
# 开氏度= 摄氏度 + 273.15
# (1)在控制台中获取华氏度,计算摄氏度。
# (1)在控制台中获取开氏度,计算华氏度。
# (1)在控制台中获取摄氏度,计算开氏度。
fahrenheit = float(input("请输入华氏度:"))
kelvin = float(input("请输入开氏度:"))
centigrade = float(input("请输入摄氏度:"))
centigrade_result = (fahrenheit - 32) / 1.8
fahrenhei... |
f266e0da84357613865f73827e7bd72baa668071 | vivid-ZLL/tedu | /part_02_system_programming/part_2_4_re/exc_test_ex.py | 599 | 3.828125 | 4 | """
需求:编写接口函数,从终端输入端口名称获取端口运行状态中的地址值
"""
import re
with open("exc.txt", "r") as file_exc:
data = file_exc.read()
target = input("port:")
c = re.search(r"\b%s\b is.*" % target, data)
print(c.group())
def read_data_line():
global data
data = [file_exc.readline()]
data = [s.strip() for s in dat... |
2afdf541d92b04357805df46d6b9106a849d4957 | vivid-ZLL/tedu | /part_01_python_base/python_pro/day16/exercise03.py | 762 | 3.78125 | 4 | class Employee:
pass
class EmployeeManager:
def __init__(self):
self.person = []
def add_emp(self, emp):
self.person.append(emp)
def __iter__(self):
return EmployeeIterator(self.person)
class EmployeeIterator:
def __init__(self, target):
self.target = target
... |
da3ce3980e261c305fd1b6dc64007e980813c7b6 | vivid-ZLL/tedu | /part_01_python_base/python_core/day8/demo06.py | 970 | 3.625 | 4 | """
函数参数
形式参数
"""
"""
# 缺省(默认)参数:如果实参不提供,可以使用默认值
def fun01(a=None, b=None, c=0, d=0):
print(a)
print(b)
print(c)
print(d)
# 关键字实参 + 缺省形参 : 调用者可以灵活传递参数
fun01(a=1)
# 位置形参
def fun01(a, b, c, d):
print(a)
print(b)
print(c)
print(d)
# 3.星号元组形参: *将所有实参合并为一个元组
# 作用:让实参个数... |
480a900f0fde4d12f32fa9102b3350aa3a690a6d | vivid-ZLL/tedu | /part_01_python_base/python_oo/day10/homework04.py | 1,888 | 4.0625 | 4 | """
4. 定义敌人类
-- 数据:姓名,血量,基础攻击力,防御力
-- 行为:打印个人信息
创建敌人列表(至少4个元素),并画出内存图。
查找姓名是"灭霸"的敌人对象
查找所有死亡的敌人
计算所有敌人的平均攻击力
删除防御力小于10的敌人
将所有敌人攻击力增加50
"""
class Enemy:
def __init__(self, name, hp, atk, defence):
self.name = name
self.hp = hp
self.atk = atk
self.defence =... |
b34d3794d2057d7554784b57d2470107e4e83eee | vivid-ZLL/tedu | /part_01_python_base/python_pro/day18/exercise05.py | 902 | 3.6875 | 4 | tuple01 = ([1, 1, 1], [2, 2], [3, 3, 3, 3])
re = max(tuple01,key= lambda item:len(item))
print(re)
class Enemy:
def __init__(self, name, hp, atk, defence):
self.name = name
self.hp = hp
self.atk = atk
self.defence = defence
def __str__(self):
return "名字:%s, hp:%s, atk:%... |
1d07cfc1773dc233ddc168e277b48578c78678de | vivid-ZLL/tedu | /part_01_python_base/python_core/day3/exercise 03.py | 749 | 3.953125 | 4 | # code_1 = float(input("请输入数字"))
# operator = input("请输入运算符")
# code_2 = float(input("请输入数字"))
#
# if operator == "+":
# print(code_1 + code_2)
# elif operator == "-":
# print(code_1 - code_2)
# elif operator == "*":
# print(code_1 * code_2)
# elif operator == "/":
# print(code_1 / code_2)
# else:
# ... |
fadb95e5dea0526d22d7692ebf134a87c222707a | vivid-ZLL/tedu | /part_04.2_spider/day01/04_parse_baidu.py | 845 | 3.625 | 4 | from urllib import request
from urllib import parse
# 1.拼接url地址函数:
def get_url(word):
baseurl = 'http://www.baidu.com/s?'
# 编码 + 拼接
params = parse.urlencode({'wd': word})
url = baseurl + params
return url
# 2.请求 + 保存
def write_html(url, word):
# 拿到响应内容
req = request.Request(
ur... |
1f0b6cac9441590c0f45d831c9fe021b3316c412 | vivid-ZLL/tedu | /part_01_python_base/python_core/day5/exercise05.py | 184 | 3.75 | 4 | list01 = []
while True:
str_input = input("请输入任意字符串:")
if str_input == "":
break
list01.append(str_input)
result = "".join(list01)
print(result)
|
fbaa5a9132010fe7ad742379af1801311342e82d | vivid-ZLL/tedu | /part_01_python_base/python_core/day6/homework03.py | 260 | 3.640625 | 4 | list01 = []
for year in range(1970,2051):
if year % 4 == 0 and year % 400 != 0 or year % 400 == 0:
list01.append(year)
print(list01)
list01 = [year for year in range(1970,2051) if year % 4 == 0 and year % 400 != 0 or year % 400 == 0]
print(list01) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.