blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
50f51dec6c99743130a92b9a8823fa31931016ed | reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python | /Sorting/BucketSort.py | 1,341 | 3.890625 | 4 | import math
# Allowed values from 0 to max_value.
def bucket_sort(arr, max_value) :
num_bucket = 5
bucket_sort_util(arr, max_value, num_bucket)
def bucket_sort_util(arr, max_value, num_bucket) :
length = len(arr)
if (length == 0) :
return
bucket = []
# Create empty buckets
fo... |
d4f9df20a01cd571986c5ce46b67fee7469fe2cd | mateusz-buczek/CheckiO-solutions | /house_password.py | 1,360 | 3.546875 | 4 | #!/usr/bin/env checkio --domain=py run house-password
# https://py.checkio.org/mission/house-password/
#
# END_DESC
def checkio(data): # step by step, readable solution
if len(data) >= 10:
result = []
else:
return False
for el in data:
... |
435a849ab0aefb55d2bf36de166aa3ef9a101587 | onooff/python_basic | /practice_class.py | 2,297 | 3.59375 | 4 | # # 스타크래프트를 예로 들어 설명함
# # 마린 : 공격 유닛, 군인, 총을 쏠 수 있음
# name = "marine" # 유닛 이름
# hp = 40 # 유닛 체력
# damage = 5 # 유닛 공격력
# print(f"{name} 유닛이 생성되었습니다.")
# print(f"체력 {hp}, 공격력 {damage}\n")
# # 탱크 : 공격 유닛, 탱크, 포을 쏠 수 있음, 일반/시즈모드
# tank_name = "tank" # 유닛 이름
# tank_hp = 150 # 유닛 체력
# tank_damage = 35 # 유닛 공격력
# pri... |
2840ff1aefe7524252a1d1fb39e138a6cb2d74bc | onooff/python_basic | /test.py | 479 | 3.96875 | 4 | # # 문자열 특정인덱스 교체 되는가
# string = "abcdefg"
# # string[2] = '%'
# print(string[2])
# print(string)
# # 문자열 특정 인덱스 없애기
# string = "abcdefg" # 길이7
# remove = 2
# string = string[:remove]+string[remove+1:]
# print(string)
# string = "abcdefg" # 길이7
# remove = 6
# string = string[:remove]+string[remove+1:]
# print(strin... |
d9540c56b5f9e72f37c62a91b991166a1e7a0791 | GeoffreySaxena/30-Days-of-Code---Python | /Day1.py | 424 | 3.71875 | 4 | i = 4
d = 4.0
s = 'HackerRank '
# Declare second integer, double, and String variables.
x = 0
y = 0
# Read and save an integer, double, and String to your variables.
x = int(input())
y = float(input())
z = input()
# Print the sum of both integer variables on a new line.
print(x + i)
# Print the sum of the double variab... |
5e56cc3cb731d05420874936bfdcf10962252f9f | Pythonyte/lc | /delete-node-in-a-bst.py | 1,242 | 3.609375 | 4 | https://leetcode.com/problems/delete-node-in-a-bst/description/
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def deleteNode(self, root: TreeNode, key: int) -> TreeNode:
def... |
2459414fd9135aa171b987c2a92cf0b23aed4441 | Pythonyte/lc | /subarray-maximum-sum-with-indexes.py | 1,150 | 3.625 | 4 | https://leetcode.com/problems/maximum-subarray/description/
https://www.geeksforgeeks.org/size-subarray-maximum-sum/
class Solution:
# def maxSubArray(self, nums: List[int]) -> int:
# import sys
# max_sum = -sys.maxsize
# max_ending_here = 0
# for i, item in enumerate(nums):
# ... |
d8f9c95e84b6080af11ac0ca0578ee7697b5d5c8 | Pythonyte/lc | /find-first-and-last-position-of-element-in-sorted-array.py | 1,557 | 3.734375 | 4 | https://www.geeksforgeeks.org/count-number-of-occurrences-or-frequency-in-a-sorted-array/
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/description/
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
def leftsearch(nums, start, end, tar... |
d1c8de098dfd977c5f10f1b0ababc102e1b4d919 | Pythonyte/lc | /misc/misc_codes/dist_between_two_nodes_binarytree.py | 1,880 | 3.890625 | 4 | """
A python program to find distance between n1
and n2 in binary tree
"""
# binary tree node
class Node:
# Constructor to create new node
def __init__(self, data):
self.val = data
self.left = self.right = None
# This function returns pointer to LCA of
# two given values n1 and n2.
def LCA(r... |
013a4a2106f6284cbe90bfdf5c88fe2c4e83cc6c | Pythonyte/lc | /insert-delete-getrandom-o1.py | 1,651 | 3.8125 | 4 | https://leetcode.com/problems/insert-delete-getrandom-o1/description/
class RandomizedSet:
def __init__(self):
"""
Initialize your data structure here.
"""
self.list = []
self.dict = {}
def insert(self, val: int) -> bool:
"""
Inserts a value to... |
6afa539379a1b4b751cf95d74649211625d52a62 | Pythonyte/lc | /binary_tree_max_path_sum.py | 828 | 3.8125 | 4 | https://leetcode.com/explore/interview/card/amazon/78/trees-and-graphs/2981/
Binary Tree Maximum Path Sum
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxPathSum(self, root: Tre... |
e769d04a0338c81a141f8f0e2f42a7f4afd2e9f7 | Pythonyte/lc | /kadane_algorithm.py | 1,178 | 3.921875 | 4 | The implementation handles the case when all numbers in array are negative.
def maxSubArraySum(a,size):
max_so_far =a[0]
curr_max = a[0]
for i in range(1,size):
# if a[i] is negative and making curr_max + a[i] negative that, then that would be the curr_sum
# once a positive... |
fff6866b1db9c878b91c22839405b4d89e616920 | Trias/aoc | /06/2.py | 1,148 | 3.828125 | 4 | input = open("input.txt","r").read().strip().split("\n")
planets = set()
satelliteToPlanet = {}
planetToSatellite = {}
for orbit in input:
planet, satellite = orbit.split(')')
satelliteToPlanet[satellite] = planet
if planet in planetToSatellite:
planetToSatellite[planet].add(satellite)
else:
... |
898c5c5f0ab09b4b37a6dcf871518ba3446684bc | zeeneddie/GamblerTest | /GamblerTest.py | 2,799 | 3.84375 | 4 | import random
import bisect
import statistics
# WeightedChoice function
# Returns a random value, considering the weights of each item.
class WeightedChoice(object):
def __init__(self, weights):
self.totals = []
self.weights = weights
running_total = 0
for w in weights:... |
2f659ac7de5c94fe9d14523a164fbd54939c9003 | RomSnow/Spellchecker | /spellchecker/conf.py | 576 | 3.5625 | 4 | """Содержит класс для работы с настройками"""
class Configuration:
"""Класс для хранения параметров программы"""
def __init__(self, text_name: str, dictation_name: str,
is_add_mode=False, is_create_mode=False,
items=None):
if items is None:
items = []
... |
fd1626fcc62623a4d2f436fed9de0b749620b44f | Clover0x29A/30days | /day4.py | 516 | 4.03125 | 4 | movie_tuple = ("Fear and Loathing in Las Vegas", 2001, "some director")
movie_input = []
temp = input("Movie Name? ")
movie_input.append(temp)
temp = input("Movie year? ")
movie_input.append(temp)
temp = input("Director? ")
movie_input.append(temp)
temp = input("Movie budjet? ")
movie_input.append(temp)
movie2_tup... |
439774d290b598148c2e1359517edd1bd35c2acd | tarunasolanki/python-programs | /patterns/right-right-angled-triangle.py | 255 | 4.21875 | 4 | #Program to print star pattern as per below
# *
# **
# ***
# ****
#*****
for i in range(1,6):
for j in range (i,i,-1):
print(" ",end="")
for k in range (1,i,1):
print("*",end="")
print("")
print("Happy coding!!!")
|
8f1ff52a58e5d230f95fbf1547c9e6c3f0dca8df | sntrenter/xpxx | /xpxx.py | 1,192 | 3.5 | 4 | import pandas as p
import random as r
import matplotlib.pyplot as plt
def op1():
#generate random floats and give each a color
L = generateFloats(x = 1000,y=3)
for i in L:
print(i)
df = p.DataFrame(L,columns = ["x","y","c"])
ax1 = df.plot.scatter(x = "x",y = "y",c="c",colormap="viridis... |
3fa0519737cad09f1e4cf94ecfe5b9f1c54dbcaa | joelgibson/joelbot | /lockoutbot.py | 2,499 | 3.75 | 4 | import re
import random
ERROR_MESSAGE = "Sorry, I didn't understand that"
TUTORS = ['Nicky', 'Tim', 'Seb', 'Owen']
# List of states used in the program. 'START' and 'END'
# are special, and used by the frontends.
STATES = ['START', 'ASK_WHERE', 'SEND_HELP', 'END']
# Each action takes in the current context, and retu... |
cb75cf7a7b979c973d8df63034b1a3ec78ec6123 | kdpujie/epython | /python-e/modue/dataguru/condition_sentence.py | 1,427 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 06 16:05:26 2016
条件控制语句
@author: pujie
"""
'''1:
if condition_1:
执行语句
elseif conditon_2:
执行语句2
elseif condition3:
执行语句3
eles:
默认执行语句(pthon基础语言包不支持switch)
'''
flag = False
name = 'python'
if name == 'python':
flag = True
print('welcome boss.')
else:
... |
dbd38b46c993cb9962b1d8046a8721ea560ba5ac | kdpujie/epython | /python-e/modue/first.py | 970 | 3.796875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'rtb 服务的模拟client'
print('1','请输入一个数字')
index = int(input())
if index > 0:
print("index 的绝对值:",index)
else:
print("index 的绝对值:",-index)
'小明身高1.75,体重80.5kg。请根据BMI公式(体重除以身高的平方)帮小明计算他的BMI指数,并根据BMI指数:'
#•低于18.5:过轻
#•18.5-25:正常
#•25-28:过重
#•28-32:肥胖
#•高于32:严重肥胖3
hei... |
283d4a95a6ef97506bca2747272b554c04344b12 | kdpujie/epython | /python-e/modue/dataguru/function_inner.py | 3,024 | 3.84375 | 4 | # -*- coding: utf-8 -*-
'''
常用内置函数
'''
#向量相加-(Python实现)
def pythonsum(n):
a = range(n)
b = range(n)
c = []
for i in range(len(a)):
a[i] = i ** 2
b[i] = i ** 3
c.append(a[i] + b[i])
return c
#向量相加-(NumPy实现)
import numpy
import numpy as np
def numpysum(n):
a = numpy.arang... |
a53ea17b1748373e13be77f79e6adddb89159aec | timbo112711/analysishelper | /StatsHelper/data_transformations.py | 2,679 | 3.859375 | 4 | '''
Data Transformations
Version: 1.1
This module is used for transforming your data.
'''
# Libs needed
import math
import datetime
import pandas as pd
import numpy as np
from patsylearn import PatsyTransformer
def dates(start_date, end_date):
'''
Generates a list of dates for the specified range
start_... |
8276ac0cbfea130de72b790942eb0fe01373899b | NuriaSF/ProjectAgileDataScience | /Model/lasso.py | 1,583 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import warnings
warnings.simplefilter('ignore')
from sklearn.linear_model import Ridge, RidgeCV, ElasticNet, LassoCV, LassoLarsCV
from sklearn.model_selection import cross_val_score
... |
e08f89d6640aea02e6c42e1324577810003852c4 | jeromepatel/Quantum-Computing-for-Computer-Scientists | /Programming_drill_4_2_1.py | 4,064 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 30 17:47:02 2021
@author: jyotm
"""
import numpy as np
from math import sqrt
import math
test = True
# this is an exercise which simulates simple quantum system
# Imagine the system as a particle in a straight line of discrete points
# so, the possible states show its... |
85289261a57179f0b20ba569f241721ed2527c6d | GauravRoy48/Python-Basics | /TempConversion.py | 143 | 3.9375 | 4 | def tempConvert(c):
return c*9/5+32
temp = 37
print("\n"+str(temp)+" degree Celcius is "+str(tempConvert(temp))+" degree Fahrenheit.") |
35f5993915cb882544714dee5cad9d7a84615068 | AmberRosanne/HelloYou | /Nieuwkomer.py | 19,098 | 3.8125 | 4 | import os
import time
def restart():
restart = input("Wil je dit avontuur nog een keer doen? Type Y/N: ").upper()
if restart == "Y":
main()
elif restart == "N":
print("Oke")
else:
print("Verkeerde invoer, alleen Y of N")
main()
def einde1():
print("EINDE1:")
... |
a2f618f80be956c3f57b2bdba65ec83ccfb85b60 | NewTAs/deep-learning-from-scratch | /ch1/practice_numpy.py | 809 | 3.65625 | 4 | import numpy as np # numpy를 np라는 이름으로 가져옴
x = np.array([1.0, 2.0, 3.0])
y = np.array([1.0, 2.0, 3.0])
print(x+y) # 산술연산 가능
z = x+y
print(type(z))
# 브로드캐스트
print(x / 20)
# 넘파이 N차원 배열
A = np.array([[1, 2], [2, 3]])
print(A)
print(A.shape) # 2X2 행렬의 형상
print(A.dtype) # 원소의 자료형
B = np.array([[5, 2], [3, 3]])
print(A + ... |
6dc188a7dec9e18a731eb3852f507861ac2bd6ce | BAHTIYOR1992/Dictionaries-in-Python | /DICTIONARY.py | 1,447 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
menu=["osh", "samosa", "manti", "shavla", "dolma", "soup", 'mastava'] # "Uzbek cuisines"
food=input("What would you like to eat?\n>>>")
if food.lower() in menu:
print("The order accepted.")
else:
print("So sorry, we dont have this food at present.")
# In[6]:
... |
616b49f34797f0b50c2f6605549723dfdc40099f | pedromfnakashima/codigos_versionados | /Cursos e Vídeos/Python/Corey Schafer (Youtube)/List, Dictionary e Set Comprehensions, Generator Expressions.py | 3,168 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 30 16:54:48 2020
@author: pedro
Comprehension:
Montando Listas, Dicionários e Sets de forma não verbosa.
"""
# https://www.youtube.com/watch?v=3dt4OGnU5sM
globals().clear()
nums = [1,2,3,4,5,6,7,8,9,10]
# I want 'n' for each 'n' in nums
my_list = []
for n in nums:
... |
a3d0832c3d23c785928c7630afeb8c75156ac834 | pedromfnakashima/codigos_versionados | /Cursos e Vídeos/Python/Corey Schafer (Youtube)/OOP Tutorial/04 Inheritance - Creating Subclasses.py | 10,623 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 29 19:32:25 2020
@author: pedro
"""
# https://www.youtube.com/watch?v=RSl87lqOXDE&list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc&index=4
globals().clear()
class Employee:
# variável de classe:
raise_amt = 1.04
def __init__(self,first,last,pay): # roda se... |
2c3ab965c10efb6e1abc9030762318dff141a8e6 | pedromfnakashima/codigos_versionados | /Cursos e Vídeos/Python/Corey Schafer (Youtube)/Programming Terms/05 Combinations and Permutations.py | 1,049 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 29 14:28:44 2020
@author: pedro
"""
import itertools
my_list = [1,2,3]
combinations = itertools.combinations(my_list,2)
permutations = itertools.permutations(my_list,2)
for c in combinations:
print(c)
for p in permutations:
print(p)
#########################... |
6816501b2ffd51827378a947eb41bb4c97585e26 | samtaaghol/NEA2019 | /learnPython/scripts/HashingAlgorithm.py | 572 | 4.15625 | 4 | import string
def hash_string(to_hash):
"""
This function hashes a string.
"""
chars = string.printable
hashed = ""
total = 1
counter = 1
for letter in to_hash:
total *= (chars.index(letter) * counter * len(to_hash)*13)
counter += 1
if counter%3 == 0:
... |
2035d31ddf8aa574432869096a4ea505ef71d4fc | joshua-meyer/projecteuler | /9.py | 606 | 3.953125 | 4 | """
https://projecteuler.net/problem=9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
solution = []
done = False
for a in range... |
a96e90f4f685a236722c602158b6bb28d433e514 | VickyPrakash/CrackingTheCodingInterviewPython | /chapter2.py | 3,356 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 18 09:19:38 2019
@author: vicky
"""
class digits:
def __init__(self, dataval = None):
self.dataval = dataval;
self.nextval = None;
class SLinkedList:
def __init__(self):
self.headval = None;
def listprint(self):
printval ... |
8a5a0806a8a4949c263ebdeda24df17f9d8a4197 | javlonbekNormurodov/Multiplication | /yandexconstest.py | 209 | 3.859375 | 4 | # MULTIPLICATION
b = int(input("Nechagacha sonlarning ko'paytmasini ko'rmoqchisiz: "))
a = 1
for j in range(1,b+1):
for i in range(1,11):
print(f'{a} * {i} = {a * i}')
print("\t")
a += 1
|
53d1637a826c42bbf04d09217b695b3aa7b4c35a | learnin-python/Playground | /main.py | 1,099 | 4.28125 | 4 | import datetime
while True:
city = input("Enter city: ")
current_time = datetime.datetime.now()
hour = current_time.hour - 3
## Because of timezone GMT + 3 (Nairobi)
minute = current_time.minute
second = current_time.second
if city == "Boston":
hour = hour - 4
elif city == ... |
759116dcaff5e39492aeeaa979d04d4c226145b7 | mqharris/533_lab2 | /quickscreen/summary/summary_stats.py | 3,442 | 3.71875 | 4 | # summary_stats.py
import pandas as pd
from quickscreen.summary.summary_classes import *
def missing_summary(df, type="columns"):
"""
Outputs the count and percent of null values in a Pandas Dataframe for each column or row.
Parameters
----------
df : pandas.DataFrame
Pandas Dataframe to... |
ff79ebf014a65009b8248da268cb6dbf0e0515d4 | lxforever/lxprojects | /monitor/m_server/conf/1.py | 477 | 3.796875 | 4 | #!/usr/bin/env python
class tem:
interval=30
ll=[1,2,3]
def __init__(self):
self.name='liangxu'
self.test=['lll','mm']
liangxu='***27033'
class tem1(tem):
leixue='5499'
a=tem()
a.interval=40
print "tem tem1 interval"
print a.interval
print a.ll,a.name
a.ll.append(77)
print a.test
a... |
6c4bdffb7d8a1036faaa810a2ab946b14d668292 | PhoenixSG/CS154_Labs | /Lab 10/python-preliminaries/18membership.py | 111 | 3.78125 | 4 | l = [1,2,3,4]
l2 = [3,4,5,6]
for e in l:
if e in l2:
print (e)
s = "hello world"
for c in s:
print (c)
|
6e6246171e89c9c6552d61696220599d8c5f824a | PhoenixSG/CS154_Labs | /Lab 10/python-preliminaries/6for-ranges.py | 157 | 3.921875 | 4 | r = range(10)
for n in r:
print (n)
print ("------")
r2 = range(3,7)
for n in r2:
print (n)
print ("-------")
r3 = range (3,21,5)
for n in r3:
print (n)
|
bb6c486eb0a0c262e4b3225b297c40621a034a4e | PhoenixSG/CS154_Labs | /Lab 10/python-preliminaries/4for-lists.py | 75 | 3.546875 | 4 | l = [1,2,3]
sum = 0
for n in l:
sum = sum + n
print (n)
print (sum)
|
a90aed49849a0e2de92b4a1577f6698fafdac562 | PhoenixSG/CS154_Labs | /Lab 10/Lab/5a.py | 595 | 3.515625 | 4 | def word_counter_better(f):
occurence = {};
for x in f:
#print(x)
y = re.split(',|.| |_|-|!|\n', x)
#print(y)
for i in y:
if i in occurence:
occurence[i] += 1
else:
occurence[i] = 1
for x in occurence:
print(x + ' ' + str(occurence[x]))
def word_counter_normal(f):
occurence = {};
for x in... |
e7332cd28c5dc7706794529c48468305c37c32ca | obiakoifezue/SE604 | /Smart_Water_Tracker_V1.py | 571 | 3.703125 | 4 | import matplotlib.pyplot as plt
import numpy as np
import csv
x = np.linspace(1979, 2018, 25)
#y = np.linspace(800, 2000, 25)
data = np.loadtxt("NYC_Water.csv", unpack = True, delimiter = ",")
plt.plot(x, x, label = "Water Consumption (MGD)")
#plt.plot(x, x**2, label = "NYC Population")
#plt.plot(x, x**3, label = "P... |
92323c7d41ab65036b0b19a1a794a8b8bc66a8c1 | ahlamjaved/python-data-representations | /week 4/program1.py | 1,551 | 4.0625 | 4 | """This is the final program for coursera python data representation"""
IDENTICAL = -1
def multiline_diff(lines1, lines2):
"""Returns a three line formatted string showing the location
of the first difference between line1 and line2."""
line1 = lines1
line2 = lines2
if singleline_diff(line1, li... |
4d9a777d7858820f21122bfe6da811deec66c66a | ranganmostofa/NFL-Roster-Optimization | /AssignmentProblem/MinimumVertexCover.py | 2,544 | 3.515625 | 4 | from AssignmentProblem import AssignmentProblem
from DepthFirstTraversal import DepthFirstTraversal
class MinimumVertexCover:
"""
Class containing implementation of algorithm which utilizes Konig's Theorem to determine a solution
to the minimum vertex cover problem (O(n^3) runtime complexity)
"""
... |
5bfeb3f9fdb1bfe5a964272cf2b6b8075da38c2d | pecholi/jobeasy-python-course | /tests/homework_3_2.py | 2,941 | 3.75 | 4 | # PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DON'T CHEAT
# PLEASE, DO... |
8eeafb22620d2c1bf9778713f01902eac94ca6a6 | jwash0d/python | /vowel.py | 91 | 3.796875 | 4 | s = 'bobboob'
print("Number of times bob occurs is: {}".format(s.count('b' + 'o' + 'b')))
|
250d1a9cd05fe9b331168f3a68754ae00a7bb1ee | awalhadi/Problem-solving-python | /hackar rank problem solving/h_listChanged.py | 233 | 3.671875 | 4 | def mutable_change(string, position, character):
l = list(string)
l[position] = character
string = ''.join(l)
return string
s = "Natora"
z = "5 e"
i, p = z.split()
string = mutable_change(s, int(i), p)
print(string) |
b7854c551d4a579b24e58bcd531521ea50733995 | awalhadi/Problem-solving-python | /uri problem solving/uri_1019.py | 146 | 3.640625 | 4 | second = int(input())
h = int(second/3600)
rest = int(second % 3600)
m = int(rest / 60)
s = (rest % 60)
print("{h}:{m}:{s}".format(h=h, m=m, s=s)) |
19fba17df379ce7033ee1b8ab3027d7325482eb3 | Confuzerpy/practice | /sqlite.py | 467 | 3.71875 | 4 | import sqlite3
bd, first, second, third = input(), input().split(), input().split(), input().split()
con = sqlite3.connect(bd)
cur = con.cursor()
result = cur.execute("""SELECT * FROM towage
WHERE ? ? ? AND ? ? ?""", (first[0], first[1],
first[2], second[0], second[1], ... |
420861411019c9074034752ec2841ebcd0c58448 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 09/Ch_09_Project_01_Rectangle_Class.py | 1,029 | 4.5 | 4 | '''
(The Rectangle class)
- Two data fields named width and height.
- A constructor that creates a rectangle with the specified width and height.
The default values are 1 and 2 for the width and height, respectively.
- A method named getArea() that returns the area of this rectangle.
- A method named getPerimeter() tha... |
96fd49f794ef631f4b3104dd0b36cc4f2b1282b0 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 16/Same_Number_Subsequence.py | 1,601 | 4.125 | 4 | '''
(Same-number subsequence)
Write an O(n) program that prompts the user to enter a sequence of integers in
one line and finds longest subsequence with the same number.
Sample Run
Enter a series of numbers: 2 4 4 8 8 8 8 2 4 4 0
The longest same number sequence starts at index 3 with 4 values of 8
'''
def main():... |
a9db18934d633b32cf51a5e19f01a634f38eb7fe | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 16/GCD_Euclid.py | 394 | 4.03125 | 4 | def gcd(m: int, n: int) -> int:
# base case, if m % n is 0, the gcd is n
if m % n == 0:
return n
else:
# Otherwise, gcd(m, n) is gcd(n, m % n)
return gcd(n, m % n)
def main():
m = int(input("Enter the first integer: "))
n = int(input("Enter the second integer: "))
prin... |
4f150ccdcb41e9115d2450a21a361fcf5a7b6e38 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 04/Ch_04_Project_05.py | 456 | 4.40625 | 4 | '''
(Hex to binary)
Write a program that prompts the user to enter a hex digit and displays its corresponding binary number.
'''
import sys
hex_digit = input("Enter a hex digit: ")
try:
hex_digit_to_decimal = int(hex_digit, 16) # Convert hex to decimal
binary = bin(hex_digit_to_decimal)[2:] # Conv... |
856966bcc149b5a16f51e281b51635433d175040 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 02/Example_Compute_Distance_Graphics.py | 895 | 4.40625 | 4 | # Example_Compute_Distance_Graphics.py - Calculates the distance between 2 points and
# graphs it using turtle module.
import turtle
# Prompt user for inputing 2 points
x1 = float(input('Enter x-coordinate for Point 1: '))
y1 = float(input('Enter y-coordinate for Point 1: '))
x2 = float(input('Enter x-coordinate for ... |
45cd63b19251cf543c947b137a90493b660637fa | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 01/Exercise01_02.py | 158 | 4.03125 | 4 | """
(Display the same message five times)
Write a program that displays Welcome to Python five times.
"""
for i in range(5):
print('Welcome to Python')
|
6bc410d20d2a109dce703b4dd204dff2fbd7c29a | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 11/PopupMenuDemo.py | 1,295 | 3.640625 | 4 | from tkinter import *
class PopupMenuDemo:
def __init__(self):
window = Tk()
window.title("Popup Menu Demo")
# Create a pop up menu
self.menu = Menu(window, tearoff=0)
self.menu.add_command(label="Draw a line", command=self.display_line)
self.menu.add_command(label... |
bf309af5b9ce47d3f332d842e43dedb770aafe54 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 05/Ch_05_Project_03.py | 1,357 | 4.21875 | 4 | '''
(Find the two highest scores)
Write a program that prompts the user to enter the number of students and each
student’s name and score, and finally displays the student with the highest
score and the student with the second-highest score. Assume that the number
of students is at least 2.
'''
num_of_students = int(... |
9876b00fc1ee94e3adb9d8d0a379be71027e3060 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 01/Exercise01_07.py | 1,869 | 3.671875 | 4 | """
(Approximate π)
Write a program that displays the result of
4×(1−1/3+1/5−1/7+1/9−1/11) and
4×(1−1/3+1/5−1/7+1/9−1/11+1/13−1/15)
So calculating the value at each sequence is:
π = 4 * (1/((2 * n - 1) * ((-1) ** (1 - n))),
where n is the nth term of the sequence
For example: n = 8 should show 4 * (- 1 / 15)
-> 4 * ... |
acd0ae50858fffbd6c7908a9c6a67dba232c097e | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 02/Exercise_02_15.py | 346 | 4.40625 | 4 | '''
(Geometry: area of a hexagon)
Write a program that prompts the user to enter the side of a hexagon and
displays its area.
Formula:
Area= (3 * (3 ** 0.5)) / 2 * s ** 2
s = length of side
'''
side = float(input('Enter the side length of the hexagon: '))
area = (3 * (3 ** 0.5)) / 2 * side ** 2
print(f'The area o... |
022aebdc11a907e6ca85dbbb9e939b7215aad030 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 05/Ch_05_Project_06.py | 1,080 | 4 | 4 | '''
(Business: check ISBN-13)
ISBN-13 is a new standard for indentifying books.
It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13 .
The last digit d13 is a checksum, which is calculated
from the other digits using the following formula:
10-(d1+ 3*d2 + d3+ 3*d4 + d5 + 3*d6 + d7 + 3*d8 + d9 + 3*d10 + d11 + 3*d12)%10
If ... |
6ae051a22b33e5685feb7a06f6b6815372117fbf | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 06/Ch_6_Project_01.py | 392 | 3.9375 | 4 | '''
(Sum series)
Write a function to compute the following series:
m(i) = 1/2 + 2/3 + ... + i/(i+1)
Write a test program that displays the following table:
i m(i)
1 0.5000
2 1.1667
...
19 16.4023
20 17.3546
'''
def m(num: int) -> float:
return sum((i/(i + 1)) for i in range(num + 1))
def main():
pr... |
2c3d80e88acbf5cd119257cab4e587095b5b594e | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 02/Exercise_02_08.py | 766 | 4.28125 | 4 | '''
(Science: calculate energy)
Write a program that calculates the energy needed to heat water from an
initial temperature to a final temperature. Your program should prompt
the user to enter the amount of water in kilograms and the initial and
final temperatures of the water.
Formula:
Q = M * (finalTemperature – ini... |
5445343a0a2b247921cf230d7a8e90046b76ef73 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 15/RecursivePalindromeHelper.py | 662 | 4.09375 | 4 | def is_palindrome(s: list) -> bool:
return is_palindrome_helper(s, 0, len(s) - 1)
def is_palindrome_helper(s: list, low: int, high: int) -> bool:
# exhausted list
if high <= low:
return True
elif s[low] != s[high]:
return False
else:
return is_palindrome_helper(s, low + 1, ... |
a82d73bb284762d9efff9147820d908628676f09 | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 16/Count_Vowels_Consonants.py | 1,231 | 3.953125 | 4 | '''
(Count vowels and consonants)
Write a program that prompts the user to enter a string and displays the
number of vowels and consonants in the string. The same vowels or consonants
are counted only once. The letters are case-insensitive. The letters for
vowels are A, E, I, O, and U. Implement it in O(1) time.
Hint... |
0e9784b34241f7c470cc36dd2d7bc36798cc81bc | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 16/StringMatching_BruteForce.py | 887 | 4.09375 | 4 | def main():
text = input("Enter a text: ")
pattern = input("Enter a string pattern: ")
index = match(text, pattern)
if index > 0:
print("matched at index", index)
else:
print("unmatched")
def match(text, pattern):
# len(text) - len(pattern) so we don't get IndexError
for i... |
e2b971725a0cd511d35cdf07662a4fbaa9cf15ee | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 15/RecursiveGCD.py | 614 | 4.1875 | 4 | '''
(Compute greatest common divisor using recursion)
The gcd(m, n) can also be defined recursively as follows:
If m % n is 0, gcd(m, n) is n.Otherwise, gcd(m, n) is gcd(n, m % n).
Write a recursive function to find the GCD. Write a test program that prompts
the user to enter two integers and displays their GCD.
'''... |
9561c77b36458e6de5dadc25cfd0f05a0a2ad63a | CUGshadow/Python-Programming-and-Data-Structures | /Chapter 07/Ch_07_Project_01_Assign_Grades.py | 967 | 4.0625 | 4 | '''
(Assign grades)
Write a program that reads a list of scores separated by a space in one line
and then assigns grades based on the following scheme:
The grade is A if score is >= best – 10.
The grade is B if score is >= best – 20.
The grade is C if score is >= best – 30.
The grade is D if score is >= best – 40.... |
90f5cec8823c7ab4b14275285b762123cb9a4e6c | zsc/kid-programming | /d003-list.py | 121 | 3.53125 | 4 | 'Hello world'[0]
'Hello world'[10]
'Hello world'[-1]
list(enumerate('Hello world'))
# Find the index of space character.
|
285c0e6c3619a39c60caf13680056567fdb2f6c6 | alyssadicarlo/algo_practice | /Python/sort.py | 454 | 4.09375 | 4 | def bubble_sort(list):
sorted_count = 0
while sorted_count != len(list)-1:
sorted_count = 0
for i in range(len(list)-1):
if list[i] > list[i+1]:
swap(list, i, i+1)
else:
sorted_count += 1
return list
def swap(list, index1, index2):... |
988369e7537ebc9646493e73c787602e9f43275a | xulongjun/Leetcode | /May-LeetCoding-Challenge/03-Ransom-Note/Ransom-Note.py | 1,303 | 3.5625 | 4 | class Solution1:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
if ransomNote == magazine:
return True
else:
for r in ransomNote:
if r in magazine:
magazine = magazine.replace(r, '', 1)
else:
... |
d3968c213c9c00b5048d2c0ac204ab9031381583 | somedayiamold/head-first-design-patterns | /templatemethod/simple.py | 1,102 | 3.71875 | 4 | class Coffee:
def prepare_recipe(self) -> None:
self.boil_water()
self.brew_coffee_grinds()
self.pour_in_cup()
self.add_sugar_and_milk()
def boil_water(self) -> None:
print('Boiling water')
def brew_coffee_grinds(self) -> None:
print('Dripping Coffee through... |
828bc07ad92128b9c1fd9b812ba0c114c6cd4c23 | somedayiamold/head-first-design-patterns | /state/gumball.py | 4,080 | 3.765625 | 4 | from enum import Enum
class State(Enum):
SOLD_OUT: int = 0
NO_QUARTER: int = 1
HAS_QUARTER: int = 2
SOLD: int = 3
class GumballMachine:
def __init__(self, count: int) -> None:
self.state = State.SOLD_OUT
self.count: int = count
if count > 0:
self.state = State... |
351d07bf8c611bf2979916e770ae56e304b86667 | TheCoderIsBibhu/SEPTOCODE | /BibhudenduDwibedi_Day20.py | 141 | 3.75 | 4 | t=int(input())
for i in range(t):
n=int(input())
if(n%2==0):print("2 "*int(n/2))
else:
print("2 "*int((n-3)/2) +"3") |
d7a264ba676635f086416d33d23b8a3f882cdd83 | doankhue/Python_Basic | /list.py | 476 | 3.984375 | 4 | list1 = [1,5,3,21,8,91]
#indexing return the item
print(list1[1])
print(list1[-1])
#slicing return new list
print(list1[3:])
#oparator + in list
list2 = list1 + [4,5,6,7]
#replace a value of list
list1[0] = 0
print(list1[0])
#function append in list
list1.append(30)
print(list1[-1])
#replace some value
l... |
80bef80aa6ab5373905f9a2918596fc2a378e821 | kylemorelock/photo-downloader | /scripts/url_download.py | 3,826 | 3.5 | 4 | """
Script to download and organize files from a csv file. The csv file has a column containing
urls to the images and scids.
"""
import csv, logging, os, shutil, urllib.request
from datetime import datetime
def construct_file_name(ext, *args):
"""
Acquire the extension as the first argument, and use *args in... |
555fa78f29502c3a5fa163364ec4d6fbcf3c0859 | finder-ls/python | /python循环/while循环计算.py | 563 | 3.5 | 4 | # 定义一个计数器,从0 开始计数,计算1-10的和。
i = 0
t = i
while i <= 9:
t += i
i += 1
print('第%d次循环,和为%d' % (i, t + i))
#######
# 计算 0 ~ 100 之间所有数字的累计求和结果
# 0. 定义最终结果的变量
result = 0
# 1. 定义一个整数的变量记录循环的次数
i = 0
# 2. 开始循环
while i <= 100:
print(i)
# 每一次循环,都让 result 这个变量和 i 这个计数器相加
result += i
# 处理计数器
i += 1... |
bb596af4bd9c696cffa802d830ad7b4447177a6e | finder-ls/python | /python判断/elif练习.py | 415 | 4.03125 | 4 | # 定义一个节日变量,判断节日变量执行不同的语句。
# 注意条例中需要用到逻辑运算等于,不是赋值符号。
holiday = '平安夜'
if holiday == '平安夜':
print('今天是%s,我们去:' % (holiday))
print('吃苹果')
print('看电影')
elif holiday == '圣诞节':
print('看电影')
print('吃大餐')
elif holiday == '生日':
print('买蛋糕')
|
9f221e7d4f6c1b00915c728c57470bf1ed68b63d | finder-ls/python | /python函数/sum函数.py | 117 | 3.65625 | 4 | def sum_2_num(num1, num2):
return num1 + num2
result = sum_2_num(10, 20)
print("计算结果是 %d" % result)
|
b7c42d9bd150f72fb07b0f3956b09cb9b744aa07 | finder-ls/python | /python函数/eval函数.py | 2,574 | 4.28125 | 4 | '''
python内置函数
eval()函数将字符串str当成有效的表达式来求值并返回计算结果也可以用于把list,tuple,dict和string相互转化
eval(<字符串>) 能够以Python表达式的方式解析并执行字符串,并将返回结果输出。
eval()函数将去掉字符串的两个引号,将其解释为一个变量。
单引号,双引号,eval()函数都将其解释为int类型;三引号则解释为str类型。
需求如下:
从csv文件中通过readline函数提取表头获得一个字符串格式如下:
"database_name","table_name","index_name","last_update","stat_name","stat_va... |
35c4241c683758e4b8fc9845d7f16e22265a455e | finder-ls/python | /python循环/循环遍历-列表.py | 715 | 3.828125 | 4 | import keyword
# for 循环内部使用的变量名字 in 列表
for name in keyword.kwlist:
# 循环内部针对列表的每个变量做的操作
# print(name)
# print(name + "这是关键字")
# title()方法返回"标题化"的字符串,就是说所有单词都是以大写开始,其余字母均为小写(见 istitle())。
# print(name.title() + "这是关键字")
# istitle() 方法检测字符串中所有的单词拼写首字母是否为大写,且其他字母为小写。
# 如果字符串中所有的单词拼写首字母是否为大写,且其他字... |
d1df502baa190db222b8085bbb52e922bad7f7fe | finder-ls/python | /python判断/综合练习-加入随机数.py | 455 | 3.84375 | 4 | # 在石头剪刀布的基础 上增加电脑随机数
# 在python中要使用随机数,就要导入随机数的模块
import random
p = input('请输入要出拳的数字-石头(1)/剪刀(2)/布(3):')
c = int(random.randint(1, 3))
if p == c:
print('平局')
elif ((p == '1' and c == '2') or
(p == '2' and c == '3') or
(p == '3' and c == '1')):
print('电脑%s你赢了' % c)
else:
print('电脑%s赢了' % c)
|
8c39034b7cf7e84970768c15b7ef514862411322 | finder-ls/python | /python循环/while循环.py | 241 | 3.890625 | 4 | # 定义一个重复计数器i
i = 1
# 使用while 判断条件
while i < 5:
print('hello world') # 要重复执行的代码
# 处理计数器i
i += 1
print('循环结束后i=%d' % i) # 循环结束后,计数器i让然有效
|
94367d5b1a0afb20725ca768d2dae098238ad66c | yjw0216/Samsung-MultiCampus-python-edu | /py_basic/p12.py | 1,691 | 3.515625 | 4 | # 파이썬 기초 순서
'''
1. 단일 데이터 관련
- 수치형(정수,부동소수,8~10~16진수)
- 문자열("",'')
'''
print('='*20)
# 수치형 값 변수에 담기
a = 10
print(a)
# 파이썬은 문자의 끝에 아무것도 쓰지 않는다 ( 타 언어는 ; 를 사용)
# 예외적으로 사용할때는 여러문자를 한줄에 표현할때 이다.
# a라는 변수에 10을 담아라 -> 10은 객체다 -> a라는 변수는 10이라는 객체의 주소를 가르키고 있다
a= 1.1
print(a , type(a))
a= '점심시간'
print(a, type(a))
## 타입추론으로... |
96429ee883563a9aecf9ceae232faff2083736fe | ihsandedec/PythonApps | /Uygulama11/logical.py | 2,718 | 3.96875 | 4 | # 1- Girilen bir sayının 50-100 arasında olup olmadığını kontrol edeceğim
sayi = int(input('sayı: '))
sonuc = (sayi > 50) and (sayi<=100)
print(f"{sayi}, 50 ile 100 arasındadır: {sonuc}")
# 2- Girilen bir sayının pozitif tek sayı olup olmadığını kontrol edeceğim.
sayi = int(input('sayı: '))
sonuc = (sayi > 0) an... |
0603cec03082d24f527ca240c8a59223cf9b7154 | ihsandedec/PythonApps | /Uygulama10/comparison.py | 1,327 | 3.921875 | 4 | # 1- Girilen 2 sayıdan hangisi büyüktür ?
# sayi1 = int(input('sayı 1:'))
# sayi2 = int(input('sayı 2:'))
# sonuc = (sayi1 > sayi2) # True, False
# print(f"{sayi1} {sayi2} den büyüktür: {sonuc}")
# 2- Girilen bir sayının tek mi çift mi olduğunu yazdırın.
# sayi = int(input('sayı: '))
# sonuc = (sayi % 2 == 0)
# prin... |
e5eb78ebe748d2c9b3c650ce0d4eebfe2b14b2c1 | Lockers/Sprint-Challenge--Data-Structures-Python | /names/names.py | 5,035 | 4.15625 | 4 | import time
import os
class BinarySearchTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Insert the given value into the tree
def insert(self, value):
# check if new nodes value is less than our current nodes value
if value < ... |
d844a7fdb6c071bf3d869f97f8ce2668d2c6c2d9 | MiguelIslasH/LeetCode-Problems | /993. Cousins in Binary Tree.py | 1,361 | 3.78125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def __init__(self):
self.xHeight = 0
self.yHeight = 0
self.haveSameParent = False
def isCousins(s... |
a9d7e3455fe44d8a317036f96ed7234c343069cb | MiguelIslasH/LeetCode-Problems | /669. Trim a Binary Search Tree.py | 1,402 | 3.921875 | 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
class Solution:
def __init__(self):
self.trimedTree = None
def trimBST(self, root: TreeNode, L: int, R:... |
a21d18c7dda6584dd617f818ca3269237b905116 | MiguelIslasH/LeetCode-Problems | /1051. Height Checker.py | 421 | 3.640625 | 4 | """
Time:
O(nlogn) n = lenght of my list
Space:
O(n) n = lenght of my list
"""
class Solution:
def heightChecker(self, heights: List[int]) -> int:
sortedHeights = sorted(heights)
movements = 0
for index, height in enumerate(sortedHeights):
if sort... |
7a7e428491c49c6084cb654298d09b3ceaa20bb4 | MiguelIslasH/LeetCode-Problems | /1486. XOR Operation in an Array.py | 753 | 3.546875 | 4 | class Solution:
def xorOperation(self, n: int, start: int) -> int:
operations = None
nums = []
for index in range(n):
nums.append(start+(2*index))
for element in nums:
if operations == None:
operations = element
else:
... |
9a3e3f678dac5179bec8abe35836b84cce39a5bd | hishamaborob/python-cli-csv-sql | /util/csv_reader.py | 388 | 3.578125 | 4 | import csv
def get_csv_header(file_path) -> list:
with open(file_path, 'r') as read_obj:
reader = csv.reader(read_obj)
return next(reader)
def csv_to_list_of_list(file_path, with_header=False) -> list:
with open(file_path, 'r') as read_obj:
reader = csv.reader(read_obj)
if no... |
ee23b702fea2bbb88254f9e8b4bab7003c3aace4 | sarsatis/PythonMasterClass | /3_list_and_tuples/2_immutable_mutable.py | 1,227 | 4.5 | 4 | # When an object is described as immutable that means it cannot be changed
#
# Following are the immutable types built into python
#
# 1) int
# 2) float
# 3) bool
# 4) str
# 5) tuple
# 6) frozenset
# 7) bytes
result = True
another_result = result
print(id(result))
print(id(another_result))
result = False
print(id(res... |
c8f255682a43bd73bc74bd796a0ef32a49dbd0d9 | sarsatis/PythonMasterClass | /2_program_flow/4_in_and_notin.py | 385 | 4.09375 | 4 | # https://docs.python.org/3/library/stdtypes.html#string-methods
parrot = "Norwegian Blue"
letter = input("Enter a character: ")
if letter in parrot:
print("{} is in {}".format(letter, parrot))
else:
print("I don't need that letter")
activity = input("What would you like to do today? ")
if "cinema" not in ... |
ccf461ba78fd7fc0009dbb548dd52946eca201a3 | sarsatis/PythonMasterClass | /5_dictionary/1_dictionary_basics.py | 2,802 | 4.3125 | 4 | fruit = {"orange": "a sweet, orange, citrus fruit",
"apple": "good for making cider",
"lemon": "a sour, yellow citrus fruit",
"grape": "a small, sweet fruit growing in bunches",
"lime": "a sour, green citrus fruit"}
print(fruit)
while True:
dict_key = input("Please enter a fruit... |
32c47a178338283dbc9cbc1262768a9329af91fc | ArnoldAndres/Projects | /SELECTING.py | 225 | 4.0625 | 4 | def only_lower(s):
lower_chars = ""
for char in s:
if char.islower():
lower_chars += char
return lower_chars
print (only_lower("I neEd To cOmpLy ThIs eXErCises tO pasS thIs SubjeCt"))
|
8c41b0c401b2c14d35f425893656df41ab20b8a5 | anzhihe/learning | /python/practise/learn-python/python_basic/none_and_range.py | 2,381 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@FileName: none_and_range.py
@Function: python None & range
@Author: Zhihe An
@Site: https://chegva.com
@Time: 2021/6/21
"""
"""一、对象None"""
"""
1、什么是对象None
对象None用于表示数据值的不存在
对象None是占据一定的内存空间的,它并不意味着"空"或"没有定义"
也就是说,None是"somet... |
e5d0cdadc8332108b12aed339db08544630078f6 | anzhihe/learning | /python/practise/PlaneWar/bullet.py | 1,115 | 3.671875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@FileName: bullet.py
@Function: 定义子弹
@Author: Zhihe An
@Site: https://chegva.com
@Time: 2021/8/3
"""
import pygame
from pygame.sprite import Sprite
class Bullet(Sprite):
"""子弹类"""
def __init__(self, window, my_plane):
"... |
a6a26348ce61c9761085e25360345e14c3661fd6 | anzhihe/learning | /python/practise/learn-python/python_advanced/file_operations2.py | 4,858 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@FileName: file_operations2.py
@Function: python文件操作之写文件、关闭文件,文件指针
@Author: Zhihe An
@Site: https://chegva.com
@Time: 2021/7/20
"""
"""一、写文件"""
"""
写文件之前,必须先打开文件。
可以调用内置函数open()并以只写方式、追加方式或读写方式打开文件。这样,返回的文件对象有两个
用于写文件的方法:
1. wri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.