blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
178d7b40ee4c53ce244df147a5837396879f332f | 808basssrjj/Python-study | /05_高级数据类型/hm_04_列表排序.py | 271 | 3.5625 | 4 | name_list = ["张三", "李四", "王五"]
num_list = [1, 2, 8, 7, 4]
# 升序
# name_list.sort()
# num_list.sort()
# 降序
# name_list.sort(reverse=True)
# num_list.sort(reverse=True)
# 逆序
name_list.reverse()
num_list.reverse()
print(name_list)
print(num_list)
|
66b3e789d078f28df2237fba5ad72c0b15f909d2 | Ani6/Movie-Revenue-Rating-Prediction-System | /Anjana_Tiha_Data_Science_Project_IMDBMovie_Version1.7.8.py | 16,996 | 3.5 | 4 |
# coding: utf-8
# In[1]:
# Fundamentals of Data Science Project
# Part created by Anjana Tiha:
# Experimented with IMDB score with features from gross income prediction feature generation stage
# Dataset: https://www.kaggle.com/deepmatrix/imdb-5000-movie-dataset
# Features:
# Numerical Features: actor1 Facebook lik... |
ef05d75c2ba0e7e2ffffeb9fbe4a7a61a62a2f5f | ValMarie/secureSystems | /secured_sys.py | 3,886 | 4.28125 | 4 | import random
def select_random_codes(codes):
_list = []
i = 0
while i < 3:
#_list.append(codes[random.randint(0, len(codes) - 1)])
_list.append(random.choice(codes))
i = i + 1
return _list
print (f'''
================================
|| W... |
4e8b88b6deee82b736c59a869a23b9150ccbdb05 | amrutha-somayaji/Python-for-Everybody | /Getting Started with Python/Week-5/ex_05_01.py | 187 | 4.03125 | 4 | hrs= input("Enter hours: ")
rate= input("Enter rate: ")
h=float(hrs)
r=float(rate)
pay=r*h
if h>=40:
extra=h-40
nor=r*extra
total=1.5*nor+(40*r)
print(total)
else:print(pay) |
45ade59bfa9a18cca2ea8cd9f8aee842110ca9ac | likhith10/Machine-Learning-Algorithms- | /Linear Using Sklearn.py | 1,238 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 19 12:55:08 2017
@author: likhith
"""
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn import linear_model
from sklearn.model_selection import train_test_split
diabetes = datasets.load_diabetes() #loading the diabetes dataset
di... |
f8bbccadfe6dc9597e721b0d078e09ffe7265bf1 | elcidon/workana_automation | /common/utils.py | 770 | 4.09375 | 4 | from datetime import datetime
import math
def get_remaining_days_until_saturday(date=None):
''' Get remaining days until saturday '''
if date is not None:
assert isinstance(date, str), 'Date must be a string like: "2020-08-24"'
date = datetime.today() if date is None else datetime.strptime(date, ... |
0197b3ed277f3517b4f2d01ca6992ed622b0fb1f | apurvchaudhary/Dakiya | /response_processor.py | 981 | 3.5625 | 4 | from tkinter import messagebox
INFO_MESSAGE = {
"405": "405 wrong http method",
"404": "404 url was not found",
"allowed_method": "\n\nAllowed method : {allowed}"
}
class ResponseProcessor:
"""
processing http response
"""
@staticmethod
def show_error_box(title, error):
messag... |
bc2869076d0293ea0f0c84cdf603b4bd47e754f9 | abdul-talib/chat_phyton | /Client.py | 1,370 | 3.703125 | 4 | import socket
import sys
from threading import Thread
def receiving(sock):
while True:
#receive the data from the server
msg = sock.recv(1024).decode('utf-8')
if msg:
#print the message if there is message
print(msg)
print('Client Server...')
# Cr... |
493e597f72eb38644aa3223d4ca08353a7da683f | MissSheyni/HackerRank | /Python/Strings/capitalize.py | 171 | 4.09375 | 4 | # https://www.hackerrank.com/challenges/capitalize
def capitalize(string):
word_arr = string.split(" ")
return " ".join([word.capitalize() for word in word_arr])
|
5c6e0a682b1e9ccb58153f17be7de58fc5c5fe47 | MissSheyni/HackerRank | /Python/RegexAndParsing/introduction-to-regex.py | 179 | 4.0625 | 4 | # https://www.hackerrank.com/challenges/introduction-to-regex
import re
T = int(raw_input())
for _ in range(T):
print(bool(re.match(r'^[-+]?[0-9]*\.[0-9]+$', raw_input())))
|
96140faf034ff7869b328f21ff518ff47dbd9d46 | MissSheyni/HackerRank | /DataStructures/Arrays/arrays-ds.py | 204 | 3.59375 | 4 | # https://www.hackerrank.com/challenges/arrays-ds
import sys
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
print(' '.join(str(i) for i in list(reversed(arr)))) |
dba2ec352e0c5c7d9d07d58a28de804ae71b89f1 | MissSheyni/HackerRank | /Python/DateAndTime/calendar-module.py | 300 | 3.765625 | 4 | # https://www.hackerrank.com/challenges/calendar-module
import calendar
[month, day, year] = map(int, raw_input().split())
weekdayInt = calendar.weekday(year, month, day)
weekdays = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY",
"SUNDAY"]
print(weekdays[weekdayInt])
|
b5e1b39891faae6e5d260e9829215883f57be4aa | MissSheyni/HackerRank | /Python/BuiltIns/python-sort-sort.py | 467 | 3.890625 | 4 | # https://www.hackerrank.com/challenges/python-sort-sort
#!/bin/python
import sys
if __name__ == "__main__":
n, m = raw_input().strip().split(' ')
n, m = [int(n), int(m)]
arr = []
for arr_i in xrange(n):
arr_temp = map(int,raw_input().strip().split(' '))
arr.append(arr_temp)
k = i... |
c9f4dc79bb332acf9cc384368bdafc4931c26dfc | gdancik/CSC-301 | /data/notes/pokemon_api.py | 841 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
################################################################
# In Python, use json module to convert JSON objects to
# Python dictionaries
################################################################
import requests
import json
# use requests.get to submit a 'g... |
7178d9b672f639873238dbb6ef4436cf591aa9cf | ryanpurchase288/python-exercises | /programs/grade_calc.py | 437 | 4.21875 | 4 | mathsMark = int(input("Please Enter maths mark:"))
chemMark = int(input("Please Enter chemistry mark:"))
physMark = int(input("Please Enter physics mark:"))
average=(mathsMark+chemMark+physMark)/3
grade="You failed"
if average>=70 :
grade ="A"
elif average>=60 :
grade="B"
elif average>=50 :
grade="C"
elif... |
693b31ed27b8485771454dba3942b351c30cd20b | ryanpurchase288/python-exercises | /programs/Number2Words.py | 1,788 | 3.671875 | 4 | import number2wordsModule
numberList = list(str(input("Number: ")))
num = ""
num1 = ""
num2 = ""
num3 = ""
num4 = ""
num5 = ""
num6 = ""
num7 = ""
num8 = ""
num9 = ""
num10 = ""
num11 = ""
num12 = ""
num13 = ""
num14 = ""
while True:
if number2wordsModule.spec(numberList):
print(number2wordsModule.spec(numb... |
0b8bc1af29a74614b21cf76315c28f3d611fcebb | dhruv-chitkara27/practice-python | /domain.py | 150 | 3.53125 | 4 | email = input("Enter your email")
index_at = email.index("@")
username = email[:index_at:]
domain = email[index_at+1::]
print(username)
print(domain)
|
b241c5b56805a1c3b2741d0fb3251e691fc023c3 | kaashvi-jain/c-97 | /file.py | 414 | 3.75 | 4 | import os
import shutil
path = input("please enter the folder ")
lof=os.listdir(path)
#print(lof)
for file in lof :
name,ext=os.path.splitext(file)
ext=ext[1:]
if ext== '':
continue
if os.path.exists(path+'/'+ext):
shutil.move(path+'/'+file,path+'/'+ext+'/'+file)
else:
... |
5b849221486e2dce1376284f112f6b0629c1e758 | CollinLBauer/fal-2020 | /teaching/220L/Lab 4/src/lab4.py | 1,502 | 3.609375 | 4 | # Name: <your name>
# lab4.py
from graphics import *
def patterns():
print("Generates the first n elements of several patterns.")
num_elements = int(input("How many elements do you want to see? "))
functions = [pattern_a, pattern_b, pattern_c, pattern_d, pattern_e]
for func in functions:
func(num_elements)
d... |
8d2a1091baab666064a926f27856bc651a8f8445 | CollinLBauer/fal-2020 | /classes/csci-310/implementations/quicksort.py | 1,051 | 4.0625 | 4 |
def quicksort(arr):
quicksort_helper(arr, 0, len(arr) - 1)
def quicksort_helper(arr, low, high):
if low < high:
p_index = partition(arr, low, high)
quicksort_helper(arr, low, p_index-1)
quicksort_helper(arr, p_index+1, high)
def partition(arr, low, high):
#print(low, high, arr)
... |
3953aa6d5a9d195ea1689b6051f2b83f273b699b | marlos-tacio/Cursos | /Bioinformática/curso 1/semana 3/codigo.py | 607 | 3.765625 | 4 | '''
Função que encontra os motifs
'''
def motifEnumeration(dna, k, d):
patterns = set()
'''
Função que obtém os vizinhos imediatos de um padrão
'''
def neighbors(pattern, d):
if d == 0: return pattern
if len(pattern) == 1: return ['A', 'T', 'C', 'G']
neighborhood = []
sulfix = pat... |
79c612b62db76c58cb2fb05e1431c566055cf2fe | ashleymendia/lab12spring | /lab_12/tandon_league.py | 3,184 | 3.890625 | 4 | class Pokemon:
def __init__(self):
"""
The constructor of the Pokemon class.
:param pokemon_name: A string containing the Pokemon's name.
:param nickname: A string containing the Pokemon's name.
:param level: An int containing the Pokemon's level.
:param type1: A str... |
eb5a16ca3ddefa3223e037ef866fbdf0818da37e | neal-rogers/IS211_Assignment14 | /recursion.py | 384 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This program contains a set of recursive functions."""
def fibonacci(n):
if n == 0:
return 0
if n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
def gcd(a, b):
if b > a:
a, b = b, a
if a % b == 0:
... |
2b3ee5d89acdeb5acb8f116edc879043999c8656 | CobyHong/CPE-101-Cal-Poly-2017 | /lab6/loops/loops.py | 272 | 3.703125 | 4 | def for_version(items): #just counting down.
result = []
for i in range(len(items) - 1, -1, -1):
result.append(items[i])
return result
def while_version(items):
i = len(items)-1
result = []
while i >=0:
items.append(items[i])
i -= 1
return result
|
619f47f9e4e076725bd2d4cc50bbd179cd36658b | CobyHong/CPE-101-Cal-Poly-2017 | /lab6/groups/groups.py | 151 | 3.796875 | 4 | def groups_of_3(list1):
new_list = []
for i in range(0, len(list1),3): #jumping by 3
new_list.append(list1[i:i+3])
return new_list
|
786bcc4ec410bf39820d3101711686769c5083e9 | CobyHong/CPE-101-Cal-Poly-2017 | /lab3/logic/logic.py | 203 | 3.921875 | 4 | import math
def is_even(x):
return (x % 2 == 0) #x divided by 2 with remainder 0 means even #
def in_an_interval(x):
return (2 <= x < 9) or (47 < x < 92) or (12 < x <= 19) or (101 <= x <= 103)
|
d19243b2127e525ed68ee87ba2165dfdcdc2b5c4 | CobyHong/CPE-101-Cal-Poly-2017 | /lab5/map/map.py | 402 | 3.78125 | 4 | import point
import math
def square_all(list1):
square_list = []
for i in range(len(list1)):
square_list.append(list1[i]**2)
return square_list
def add_n_all(list2,n):
n_list = [list[i]+n for i in range(len(list2))]
return n_list
def distance_all(list3):
dist_list = [ math.sqrt( (list... |
e6f58655448938d01ebd54ad4d3b94d69e528cdf | DAChenScratch/QueenB-Battlesnake2018 | /tests/snakes/old_self/app/algorithms.py | 6,456 | 3.578125 | 4 | import time
import random
from functools import reduce
from math import floor
from copy import deepcopy
from collections import deque
from .utils import neighbours, surrounding, sub
from .constants import DIR_NAMES, DIR_VECTORS, SNAKE
def _rate_cell(cell, board, recurse=False):
""" rates a cell based on proximit... |
75683368fb186a388336e86b6c3cecbf26a76488 | lohith261201/UE19CS305-MI-LAB | /PES2UG19CS203 (7).py | 5,110 | 3.671875 | 4 | import numpy as np
import math
from sklearn.tree import DecisionTreeClassifier
"""
Use DecisionTreeClassifier to represent a stump.
------------------------------------------------
DecisionTreeClassifier Params:
critereon -> entropy
max_depth -> 1
max_leaf_nodes -> 2
Use the same parameters
"""... |
105afd93628ff45c63b15084cb7e39bf7fbed6f5 | lenboy11/TicTacToeGenetic | /tictactoeAgents.py | 10,420 | 3.625 | 4 | # TicTacToe Agents
import random
import math
## Classes
# TicTacToe Agents need __init__ for creation and
# _|_|_
# the function guess( self, [ _|_|_ ]) with the game as 9x1 array
# | |
## Class NeuralAgent with a neural network
# Not very useful since we use ... |
efb46be8ff8f4f480c9f84c971d75ce1cdc5a319 | meantheory/rpn | /rpnalt.py | 1,198 | 3.546875 | 4 |
# a more objecty version
class RPN:
@staticmethod
def parsenum(n):
if isinstance(n, str):
return float(n) if '.' in n else int(n)
elif isinstance(n, (int, float)):
return n
else:
raise ValueError('Unable to parse input.')
@staticmethod
def isoperator(op):
return op in ('+', '-', '*', '/')
@s... |
d5f15e2d149afbb17b043dc3cf953c6cf314d297 | mlnotes/cityai | /cityai.py | 2,901 | 3.59375 | 4 | from random import randint, random
import matplotlib.pyplot as plt
import math
def random_point():
x = randint(0, 1000)
y = randint(0, 1000)
return (x, y)
def random_points(n_points):
return [random_point() for i in xrange(n_points)]
def distance(p1, p2):
return (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2
def kmeans(... |
3af63a3236946263edacf52d3c433925eba4284e | pscx142857/python | /作业/Python基础第三天/06遍历.py | 245 | 3.65625 | 4 | # 用while循环遍历列表
ls = ["张3","李四"]
i = 0
while i < len(ls):
print(ls[i])
i += 1
# 用for循环遍历列表
for i in ls:
print(i)
# 嵌套循环遍历
ls2 = [[0,1],[2,3]]
for i in ls2:
for j in i:
print(j) |
1d83ddc253f7e6cde9329d4680104af059a4ba81 | pscx142857/python | /作业/Python高级第一天/package/filesys.py | 4,284 | 3.734375 | 4 | # 保存数据到data.txt
def save(cards):
ls2 = list()
# 打开文件
fp = open("data.txt", "w", encoding="utf8")
# 操作文件
for card in cards.ls:
ls2.append(
f"{card.name},{card.tel},{card.company},{card.job},{card.address}\n")
fp.writelines(ls2)
# 关闭文件
fp.close()
# 定义一个名片类
class Card(ob... |
73da3cf722b9e52282098df4a6fdf9faf9bac768 | pscx142857/python | /上课代码/Python基础第五天/04函数的注释.py | 237 | 3.5625 | 4 | def sum_2(a,b):
"""
这里描述功能,计算两个数的和
:param a: 形参的含义,第一个求和数
:param b: 第二个求和数
:return: 返回值的意义,返回两个数的和
"""
c = a+b
return c |
76ccc695eed3cfdce9101168045602eea72cbe7c | pscx142857/python | /作业/Python面向对象第二天/修改对象的属性.py | 261 | 4 | 4 | # 定义一个学生类,初始化时可以添加属性
class Student(object):
def __init__(self,name):
self.name = name
# 实例化一个学生对象
s = Student("张三")
print(s.name)
# 把name属性修改成李四
s.name = "李四"
print(s.name) |
45efeb7bebdc78fd2eb7215c0347203857d0cef2 | pscx142857/python | /作业/Python面向对象第一天/第四题.py | 529 | 4.09375 | 4 | # 4.新建一个文件,定义一个狗类,创建一个狗对象,调用上面的属性和方法
# 创建一个狗类
class Dog:
# 定义初始化方法,在创建对象的时候会自动执行,给这个对象添加属性
def __init__(self,color):
self.color = color
# 定义一个speak方法,这个方法里面通过self.属性名,来调用属性
def speak(self):
print(f"我的颜色是{self.color},汪汪汪")
# 实例化一个对象
dog1 = Dog("黄色")
# 调用狗类的方法
dog1.speak() |
3d9fcad440d6a7de1a3efccd1857a7df09171906 | pscx142857/python | /上课代码/Python基础第六天/05变量的作用域.py | 855 | 4.25 | 4 | """
变量的作用域:
变量的作用范围-->变量在哪个地方可以使用
全局变量:定义在函数外面的变量,就是全局变量,当代码执行完之后会被销毁
作用域:在代码的任意地方都能使用(函数内部和外部)
局部变量:定义在函数里面的变量就是局部变量,在函数调用执行之后自动销毁
作用域:只能在函数里面使用,在函数的外面无法使用
"""
name = "兮兮" # 全局变量
def show():
global name # 默认函数里面是不可以修改全局变量的,加上global后,就可以修改了
name = "丫丫"
age = 18 # 局部变量... |
480b1f3d14d144e221f6b933d271ef889dfe389a | pscx142857/python | /作业/Python基础第三天/03while循环的完整体.py | 358 | 3.984375 | 4 | # 当循环执行完成后,执行else里面的语句
# else一般配合break使用,如果执行了break,那么else里面的将不再执行
i = 1
while i < 10:
if i == 5:
break
print(f"这是第{i}次循环")
i += 1
# 当i等于5时,执行break,结束循环,else里面的语句不再执行
else:
print("循环已经结束,没有break") |
1f8d404b01cb45cf3e81059b7043597791520a38 | pscx142857/python | /作业/Python基础第四天/第六题.py | 351 | 4.03125 | 4 | # 写一个后期网络聊天项目的模块,用户不断从键盘输入,每次输入回车后,将打印用户输入的字符个数和内容,当用户输入'quit'后,退出该功能
while True:
str = input("请输入您想说的话:")
if str == "quiet":
break
print("本次总共说了",len(str),"个字")
print(str)
|
ffbb9fbfccec35d52f8f93646476fd0a9067e047 | pscx142857/python | /上课代码/Python面向对象02/06属性重写.py | 630 | 4.0625 | 4 | """
__init__方法的重写问题:
super().父类的方法名() ,在子类中调用父类的方法执行一次
"""
class Father(object):
def __init__(self,name,age):
self.name = name
self.age = age
def smoke(self):
print("我会抽烟")
class Sun(Father):
def __init__(self,name,age,sex):
# 调用一次父类的__init__方法就可以继承上面的属性了name,age
... |
faff4e624cfabb485eae7642f3032dbd9dcbd60f | pscx142857/python | /作业/5.3-5.5/第一题.py | 4,272 | 3.84375 | 4 | """
1. 将 字符串 列表 字典的课件中的相关语法敲一遍
"""
"""
字符串:
里面存储的是字符类型的不可变有序的容器
"""
# 转义字符\,可以将有意义的字符转成无意义的字符,也可以将无意义的字符转换成有意义的字符
# 无意义-->有意义
print("这是两个空格\t哦")
print("这是一个回车\n哦")
# 有意义-->无意义
print("这两个引号\"\"无意义了哦")
# 根据索引取值
st = "零一二三四五六七八九十"
print(st[0]) # 零
# 切片,取出部分字符
st_new = st[1:5:1]
print(st_new)
# while遍历字符
i = 0
while i ... |
16a7797304f86f95ff9608af60480b252e171453 | pscx142857/python | /作业/Python高级第三天/第一题/装饰器.py | 422 | 3.75 | 4 | """
装饰器:
在不修改原来函数代码的基础上,可以增加一些功能
"""
# 定义装饰器函数,让原始函数可以飞
def decorator(f):
def info():
f()
print("我现在可以起飞了")
return info # 返回的是info的内存地址
# 原始函数,只会跑
@decorator # 语法糖,直接@装饰器函数名
def show():
print("我只会跑")
# 函数名直接调用
show() |
06711f71d6e23d007edaa99a96309f779c4f42f0 | pscx142857/python | /作业/5.3-5.5/数据读取练习.py | 484 | 3.734375 | 4 | class Student(object):
def __init__(self,name,subjects):
self.name = name
self.subjects = subjects
def __str__(self):
return f"{self.name}\t\t{self.subjects}"
students = list()
# 打开文件
fp = open("data.txt","r",encoding="utf8")
# 操作文件
data = fp.read()
ls = data.strip("\n").split("\n")
for... |
13e774c8ebf4b948c17a3e9fe05770a8e61be18f | pscx142857/python | /作业/Python面向对象第三天/第四题.py | 332 | 4.21875 | 4 | """
4.定义一个函数模块
可以去除传入的字符串里面的所有空格,返回去除空格之后的字符串
"""
# 导入模块
import removespaces
# 定义一个有空格的字符串
st = " 1 2 3 4 5 6 7 8 "
# 调用模块中的函数,去除字符串中的空格
st_new = removespaces.stripspace(st)
print(st_new) |
1d412d6dfbae8d5319033802b53f1790e4ba2821 | pscx142857/python | /上课代码/Python面向对象03/03__new__方法.py | 583 | 3.9375 | 4 | """
__new__方法: 创建对象的时候自动调用执行
new方法在init方法的调用前面
new方法的作用:
1.开辟内存空间,将对象存放在内存空间中
2.将创建的对象和参数自动传递给inti方法使用
"""
class Student(object):
# 重写了__new__方法,调用一次父类里面的__new__方法,才能创建对象
def __new__(cls, *args, **kwargs):
print("创建对象")
return super().__new__(cls)
def __init__(self)... |
27f3aa11d696c0d53d92f0c6b904019923fe5d4b | pscx142857/python | /作业/Python基础第七天/第二题.py | 461 | 3.609375 | 4 | # 2. 读取一个py文件,显示除了以井号(#)开头的行以外的所有行
# 打开文件
fp = open("test.py","r",encoding="utf8")
# 操作文件
# 按行读取,得到一个列表
data = fp.readlines()
# 遍历这个列表
for i in data:
# 依次判断里面的元素是否以#开头的
if i.startswith("#"):
continue
# 显示除了以#号开头的以外的所有行
else:
print(i)
# print(data)
# 关闭文件
fp.close() |
b94fe0e685be1029da0e9347f083c808709d51ca | pscx142857/python | /上课代码/Python面向对象01/__init__方法.py | 1,119 | 4.09375 | 4 | """
魔法方法:__init__ __str__ __new__ __del__ __call__
__str__方法:在对象被打印的时候,自动调用执行
特点是名字固定,都会在某一个时机下,自动调用执行
__init__方法: 初始化方法
在创建对象的时候自动执行
"""
class Student:
# 有一个说话的方法
def __init__(self,name,age=18,sex="男",tel=13456789123):
self.name = name
self.age = age
s... |
18b4d87353ced1510aa0f308ee03a33ec5792a73 | shashi1997/python | /sum.py | 85 | 3.828125 | 4 | a=int(input("Enter a number:"))
b=int(input("Enter a number:"))
print("sum is:",a+b)
|
eb96ed6df773d97ff9407997db50048e0044e17b | ageraldo1/Python-bootcamp | /operators.py | 1,514 | 4.40625 | 4 | # range operator
'''
print ('Example 1 for range operator : defining a stop point')
for number in range(10):
print (number)
print ('\nExample 2 for range operator : defining a start and stop point')
for number in range(3, 10):
print (number)
print ('\nExample 3 for range operator : defining a start, stop and ... |
bb0d5d4edb8cf2ba5b64b799a67ae99990933499 | ageraldo1/Python-bootcamp | /datetime/examples2.py | 1,543 | 3.71875 | 4 | import datetime
d = datetime.date(2019,3,4)
t = datetime.date.today()
print (d)
print (t)
tdelta = datetime.timedelta(days=7)
print (t + tdelta)
print (t - tdelta)
# When
# add/sub date and timedelta => date
# add/sub date and date => timedelta
bday = datetime.date(2019,7,1)
till_bday = bday - t
print (t... |
669eb69d34f2b577ecefe00e10daa5f4f425be67 | ageraldo1/Python-bootcamp | /homework/milestone/01/tempCodeRunnerFile.py | 308 | 3.78125 | 4 | from game_libs import print_board
game_state = "new" # new, playing, ended
# main game loop
while game_state != "ended":
print_board()
if game_state == "new":
user_choice = input(" Type [S] to start or [E] for exit")
print ("User Choice...: {}".format(user_choice))
|
9f65c6528bc1accc149176dd46158c8449bc990c | ageraldo1/Python-bootcamp | /files.py | 531 | 3.515625 | 4 | myfile = open("G:/My Drive/Internal Notes/GPC/Self-Study/Python/source_code/myfile.txt")
print ( myfile.read())
myfile.seek(0)
print ( myfile.readlines())
myfile.close()
with open('G:/My Drive/Internal Notes/GPC/Self-Study/Python/source_code/myfile.txt') as my_new_file:
print (my_new_file.readlines())
with op... |
adb20501fc5b60a117d2c70a59ccf0d38a8e0560 | ageraldo1/Python-bootcamp | /if.py | 139 | 4 | 4 | if ( 1 == 1):
print ( "1 is equal to 1")
elif ( 2 != 2):
print ( "2 is different of 2")
else:
print ("Entered on else option")
|
e7579b9e3a53b134b38126d76eb839e75a30b510 | ageraldo1/Python-bootcamp | /GT/rand.py | 117 | 3.53125 | 4 | import random
print (random.randint(1,2))
my_list = ['a', 'b', 'c', 'd', 'e', 'f']
print (random.choice(my_list))
|
fc535933449602bd9fd875b0cce7e9df02348418 | ageraldo1/Python-bootcamp | /GT/in-class/07-03/in-class-03.py | 686 | 3.875 | 4 | candies = {
'0': 'Snickers',
'1': 'AirHeads',
'2': 'Cow Tales',
'3': 'Kit Kat',
'4': 'Chocolate'
}
allowance = 3
candyCart = []
for _ in range(allowance):
for k,v in candies.items():
print (f"[{k}] {v}")
user_input = input("\nPlease select a candy : ")
if user_input in ca... |
4fcb94e4bd27b4bda7929d77b665122518886c0c | ageraldo1/Python-bootcamp | /generators/generators.py | 1,176 | 4.34375 | 4 | def create_cubes(number):
result = []
for i in range(number):
result.append(i**3)
return result
print (create_cubes(10))
# example when you only need to value just one time instead of having the entire list in memory
# range function is a generator
# range(10)
# list(range(10))
for x in crea... |
e70152e67a3dfbf554dab4b7c1e14369cff224ce | ageraldo1/Python-bootcamp | /data_science/pandas/tutorial/dataframes/df.py | 1,129 | 4.125 | 4 | import pandas as pd
from pandas import DataFrame
df = pd.read_csv('weather_data.csv')
#print (df)
# print shape
#print (df.shape) # rows x columns
# slice
#print (df[2:5])
# min/max/mean/std
#print (df['temperature'].max())
#print (df.describe(include ='all'))
#print (df.info())
# filter
# select all rows in t... |
bd1a13397dcfa2fafe213d33a20294bd50e1c756 | ageraldo1/Python-bootcamp | /data_science/numpy/arrays/array_index.py | 1,021 | 3.828125 | 4 | import numpy as np
arr = np.arange(0,11)
# index access
print (arr[10])
# index range
print (arr[1:5])
print (arr[0:5])
# set values
arr[0:5] = 100
print (arr)
# reset array
arr = np.arange(0,11)
# slice
print ("\b\b")
slice_of_arr = arr[0:6]
print (f"Original array : {arr}")
print (f"Sliced array : {slice_of_a... |
a49993984122f494ac15260f7c0d930b0e3f1969 | ageraldo1/Python-bootcamp | /lambda.py | 987 | 4.3125 | 4 | # map function
# example 1
def square(number):
return number**2
my_list = [1,2,3,4,5]
# way 1
for item in map(square, my_list):
print (item)
# way 2
print (list(map(square, my_list)))
# filter function
# example 1
def check_even(num):
return ( num % 2 == 0)
my_numbers = [1,2,3,4,5,6]
print (list(... |
443f63f69400993c47ca76a7f6ebbfeef5bdea52 | kapilaramji/algorithms | /prime.py | 509 | 4.28125 | 4 | #IS IT A PRIME NUMBER?
import math
def check_prime(some_number):
if some_number <= 3:
return True;
elif (some_number % 2) == 0:
return False;
else:
for counter in range(3, int(math.sqrt(some_number)) + 1, 2):
if (some_number % counter) == 0:
return False
return True
print "Enter a number to check if ... |
ad5618f28e93a3cfe92a09120a5f034faaa315d4 | rika-project/fundamental-python | /fundamental1-konstruksi-dasar.py | 469 | 4.03125 | 4 | # konstruksi dasar python
# sequential : ekseskusi berurutan
print('Hello World!')
print('Rika Sahriana')
print('Tanggal 10 November 2020')
print('-' * 50)
#percabangan: eksekusi terpilih
ingin_cepat = False
if ingin_cepat :
print('jalan lurus aja bos!')
else :
print('muter aja bos!')
#Percabangan lebih dari ... |
fd960c7fcb0e1f45f70a23a367f81b58074a36dd | Asintesc/PROGRAMACION | /Práctica 7/Ej13.py | 894 | 3.78125 | 4 | #Práctica 7 Ej13
#Albert Sintes Coll
def primo_while(v):
if v == 2:
return True
if v % 2 == 0:
return False
i = 3
while i ** 2 <= v:
if v % i == 0:
return False
i = i + 2
return True
def primo_for(v):
for i in range(1, v+1):
if v... |
b7efec67ef81d32eec37d082460aa6a4b7a46abb | Asintesc/PROGRAMACION | /Práctica 7/Ej11.py | 282 | 3.78125 | 4 | #Práctica 7 Ej11
#Albert Sintes Coll
frase = str(input('Escribe una frase: '))
def capicua(f):
if f.replace(' ','') == f.replace(' ','')[::-1]:
print('%s es capicúa o palíndrome.'%(f))
else:
print('%s no es capicúa o palíndrome.'%(f))
capicua(frase)
|
4e82d7b2d42c8139782966e6bcc1a58440388f1c | Asintesc/PROGRAMACION | /Práctica 4/Ej1.py | 319 | 3.890625 | 4 | n1 = int(input('Escribe un número: '))
n2 = int(input('Escribe otro número: '))
n3 = int(input('Escribe otro número: '))
n4 = int(input('Escribe otro número: '))
n5 = int(input('Escribe otro número: '))
print('El número mayor es: ',max(n1,n2,n3,n4,n5))
print('El número menor es: ',min(n1,n2,n3,n4,n5))
|
336d5935c25e04386ce45c1d1533939d5cbb013b | Asintesc/PROGRAMACION | /Práctica 5/Ej10.py | 156 | 3.8125 | 4 | print('Práctica 5 Ej10')
print('Albert Sintes Coll')
n1 = int(input('Altura del triángulo: '))
for i in range (n1+1):
alt = n1-i
print(' '*alt+'* '*i)
|
3771ade7549ccd6a26aa677f8cce610e7e925abe | Asintesc/PROGRAMACION | /Práctica 6/Ej5.py | 364 | 3.765625 | 4 | #Práctica6 Ej5
#Albert Sintes Coll
lista=[]
n1 = int(input('Esccribe un número: '))
lista.append(n1)
n2 = int(input('Escribe un número mayor que %d: '%(n1)))
lista.append(n2)
while n2 > n1:
n1 = n2
n2 = int(input('Escribe un número mayor que %d: '%(n1)))
lista.append(n2)
print('Los números que ha... |
3f6055badfaa68b49a2bc654fe7d127fe88998d6 | evandrofr/Codigo-da-Depressao | /EP5ALT.py | 6,281 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 11 19:07:03 2018
@author: Lenovo
"""
import json
with open('arquivo5.json','r') as arquivo:
Estoque = json.loads(arquivo.read())
j=1
while j != 0:
print('''Controle de loja:
0 - Acessar uma loja
1 - Adicionar loja
2 - E... |
30405606ae93bf18d377b6386acac6f4bac538b7 | A1exanderW/Games | /Pokemon/s4318841_Pokemon.py | 10,498 | 3.984375 | 4 | #!/usr/bin/env python3
###################################################################
#
# CSSE1001/7030 - Assignment 1
#
# Student Username: s4318841
#
#
#
###################################################################
###################################################################
#
# The followin... |
61ba8762f32903998d3d32606ed34c338ca5e026 | gregsheu/python | /py_find_prime.py | 561 | 4.09375 | 4 | import math
def check_prime(n):
if n <= 1:
return False
elif n == 2:
return True
elif n > 2 and n%2 == 0:
return False
else:
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n%i == 0:
return False
return True
def main():
print(f"Is 2 pr... |
4395afca97bab63564d0c235fedd7247722a43a9 | Tasari/Problem-solving-challenges-SoloLearn | /Anadrome/Anadrome.py | 1,808 | 3.890625 | 4 | '''
Anadrome
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase.
For example, "Sool" is an anagram for "Solo".
A palindrome is a word or phrase which reads the same backward as forward, such as "madam".
An anadrome is a word or phrase if any of its anagrams form a palindrome... |
68f7206ad7bc72bbf0ff5e4ba45cfa350941d61a | supersieu/calculatrice | /calculatrice.py | 2,558 | 3.671875 | 4 | def cal_1_input(char):
list_char = [["I", 1], ["V", 5], ["X", 10], ["L", 50], ["C", 100], ["D", 500], ["M", 1000]]
val = 0
for i in range(len(list_char)):
if list_char[i][0] == char:
val = list_char[i][1]
return val
def cal_2_input_ide(char):
return cal_1_input(char[0]) * 2
d... |
2e6b8b2098783e1411708b815cadded130c7c85d | Forbzz/GoTicket | /db.py | 2,012 | 3.5625 | 4 | import sqlite3
def execute_single_record(data, db_file, insert_script):
try:
sqlite_connection = sqlite3.connect(db_file, timeout=10)
cursor = sqlite_connection.cursor()
cursor.execute(insert_script, (data,))
sqlite_connection.commit()
cursor.close()
sqlite_connecti... |
31e05a8a9c480c09a0ad1b575cf40fe6a8b90712 | tiiwii58/eduonix_project_1 | /main.py | 1,027 | 4.125 | 4 | import random
def input_number():
try:
number_choose = input('Select a random number between 1 - 25 : ')
number_choose = int(number_choose)
if(number_choose > 25 or number_choose < 1):
raise ValueError('You didn\'t select a number between 1 and 25')
retu... |
87ced0f8b41be88de89b342e08510e603ea54242 | gurpartb/play | /python/num_solver.py | 473 | 3.84375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 1 14:20:45 2019
@author: gurpartapbhatti
"""
def legal_n():
for i in range(1,10):
if i not in l:
return i
s = {1, 2, 3, 4, 5, 6, 7, 8, 9}
l = [1, 2, 5, 0, 5, 6, 7, 8, 9]
print(l)
# find the zero
for i in range(9):
if l... |
999cc905121d129403c0ba9660463fc1f0b6436b | dinishdevassy/python_assignment | /a1_q3.py | 176 | 3.828125 | 4 | import math;
n=int(input("Enter a number : "));
n1=int("%s" %n);
n2=int("%s%s" %(n,n));
n3=int("%s%s%s" %(n,n,n));
res=n1+n2+n3;
print("%d+%d+%d = %d" %(n1,n2,n3,res)); |
2af11090e59a5661b7cc1c7057feb0704e4ed3b9 | dinishdevassy/python_assignment | /a2_q3.py | 135 | 3.625 | 4 | str1=input("Enter a String : ")
n=len(str1)
#output=str1[n-1]+str1[1:n-1]+str1[0]
output=str1[-1:]+str1[1:-1]+str1[0]
print(output) |
a7fbfcb05853e0f0744e92a326f4a8497cc298d4 | 21350010/Session10 | /session10.1a.2.py | 974 | 3.84375 | 4 |
class Student():
def __init__(self,FirstName,LastName,StudentNo,Course):
self.first=FirstName
self.last=LastName
self.stdno=StudentNo
self.course=Course
def getfirst(self):
return self.first
def getlast(self):
return self.last
def getstdno(self):
... |
64a9cbceea1a94ebaadd6fdfeea92287fdcf77e9 | sjo91190/zoomzy | /ring_of_fire/game/config.py | 1,365 | 3.78125 | 4 |
def card_actions(card, name):
actions = {
"A": f"Waterfall! everyone drink and don't stop until {name} is finished!",
"2": f"{name} gets to choose someone to take a drink with",
"3": f"{name}... drink up, buddy",
"4": "LADIES! drink your drink!!",
"5": f"""{name} is now th... |
eb2bfd7cf0bc28f53cdfa308a4356b0b8b910341 | Johhnne/EP | /tarefa1.py | 3,627 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# Bibliotecas utilizadas
import math
import numpy as np
# Letra 'A1'
def a1(k,i,M,N,deltaT,deltaX,u_a1):
i = i + 1 # Como as fronteiras são nulas, não é preciso passar por i = 0
t = k*deltaT # Cálculo das variávies 't' e 'x'
x = i*deltaX
if i < N... |
fc15f01195637059261427ded9952518cba956f8 | csd-oss/investment-calculator | /app.py | 971 | 3.625 | 4 | import streamlit as st
initial_investment: float = st.sidebar.number_input(
'Initial investment',
value=10000.00)
years: int = st.sidebar.slider('Years', min_value=1, max_value=50, value=10)
return_rate: float = st.sidebar.number_input('Return rate', value=6.00)
compound_per_year: int = st.sidebar.slider(
... |
461245273d738017b472b660d74bb4ad2cf68d3f | worace/exercism | /python/word-count/wordcount.py | 359 | 3.59375 | 4 | from itertools import groupby
import re
def word_count(sentence):
sentence = sentence.lower()
sentence = (" ").join(sentence.split("_"))
words = re.findall("\w+", sentence) # [w for w in re.split(r"[\t\n!!&@$%^&_,.:]", sentence) if len(w) > 0]
groups = groupby(sorted(words))
return dict([(word,len(... |
b08345771cf45c57812a30ebca89327e0b6d2ff1 | iwenan/iOSUIRename | /rename_ui.py | 1,760 | 3.625 | 4 | #!/usr/bin/env python2.7
#coding:utf-8
# 需要重命名的文件放在Files文件夹中
import os
# UI文件夹的名称
ui_dir_name = 'assets'
def rename_files(files_path):
# 获取目录下所有的文件
file_names = os.listdir(files_path)
# print('所有文件%s' % file_names)
if len(file_names):
files_dir_name = os.path.basename(files_path)
pre_str = raw_input... |
dbd11012c09f0e625028eb1d0b6ef167b5875801 | Abhikarki/Algorithms | /Karatsuba Algorithm/karatsuba.py | 2,271 | 3.828125 | 4 | # KARATSUBA MULTIPLICATION ALGORITHM(BASE 10)
def main():
# Multiplying two large numbers.
karatsuba(1542256564751236452, 4523215642154352)
karatsuba(-2536415853, 215341562)
karatsuba(154225656475122536452, 45232152514642154352)
def karatsuba(a, b):
a1 = abs(a)
b1 = abs(b)
resul... |
7b9d3877238a7e7c984087ee20383ad7e8c017b2 | jonathanpan777/hashcode | /car.py | 254 | 3.546875 | 4 | class Car:
def __init__(self, length, path):
self.length = length
self.path = path
self.current = path[0]
self.path_length = 0
def car_sum(self,street_dict):
s = 0
for p in self.path:
s += street_dict[p].length
self.path_length = s
|
a638374ffc132a9465bf1b522e10793e645993da | delshawn-james/calculator.py | /INE calculator.py | 1,353 | 4.4375 | 4 | print("select a number for operation")
print("1 to add")
print("2 to subtract")
print("3 to multiply")
print("4 to divide")
print("5 to square")
print("6 for power")
print("7 for square root")
pass
operation = input()
pass
if operation == "1":
num1 = input("enter a number")
num2 = input("enter a number")
pr... |
6c5c068ffcb818539621898e0c347dcbcaf0306e | jreiher2003/code_challenges | /recursion/sum_odd.py | 420 | 4.1875 | 4 | # sum_odd(n): number -> number
# sum_odd(n) is the sum of odd numbers from 1 to N
def sum_odd1(n):
total = 0
for i in range(1,n,2):
total = total + i
return total
print sum_odd1(12)
def sum_odd2(n):
# if n == 0:
# return 0
if n < 2:
return 1
elif n % 2 ==... |
96a9ad0bf03c5212e9de026e874b97862a1bded1 | jreiher2003/code_challenges | /hackerrank/algorithms/warmup/plus_minus.py | 350 | 3.921875 | 4 | def plus_minus(nums):
plus = 0.
zero = 0.
minus = 0.
for n in nums:
if n == 0:
zero += 1
if n > 0:
plus += 1
elif n < 0:
minus += 1
# print plus,minus,zero
print plus/len(nums)
print minus/len(nums)
print zero/len(nums)
lst = [... |
bc487742e202ae39d5798ce81717555f2bdc4a49 | jreiher2003/code_challenges | /hackerrank/python/regex_and_parsing/validate_creditcards.py | 228 | 3.640625 | 4 | import re
pat = '(?=[4-6])[0-9]{4}(\-?[0-9]{4}){3}$'
repeat = '.*(\d)(\-*\1){3}'
string = '4123456789123456'
m1 = re.match(pat,string)
m2 = re.match(repeat, string)
if m1 and not m2:
print "Valid"
else:
print "Invalid" |
f22ac16019ccb69a5f853c3b85056a3559cd865b | jreiher2003/code_challenges | /project_euler/mult_3_5.py | 159 | 3.765625 | 4 | def multiple_3_5(n):
x = 0
for i in range(n):
if i % 5 == 0 or i % 3 == 0:
x += i
return x
print multiple_3_5(10)
print multiple_3_5(1000) |
de959aef7f56287636a7d8618410dec9caa8eae8 | jreiher2003/code_challenges | /hackerrank/python/itertools/permutations.py | 433 | 4 | 4 | from itertools import permutations
import textwrap
print list(permutations(["1", "2", "3"]))
print list(permutations([1, 2, 3]))
def perm(s, k):
lst = []
for letter in s:
lst.append(letter)
permy = sorted(list(permutations(lst, k)))
for p in permy:
print "".join(p)
... |
d7fc6f832673103c9694ba16c2c17e6b780ad91a | jreiher2003/code_challenges | /hackerrank/algorithms/sort/insertion_sort1.py | 243 | 4.03125 | 4 | def insertionSort(ar):
for i in range(1,len(ar)):
while i !=0 and ar[i] < ar[i-1]:
ar[i], ar[i-1] = ar[i-1], ar[i]
print ar
i -= 1
return ar
ar = [2,4,6,8,3]
print insertionSort(ar) |
a1d8bb18d1db714bf05810554a9c8983b94786ac | jreiher2003/code_challenges | /hackerrank/python/collections/order_dict.py | 223 | 3.640625 | 4 | from collections import OrderedDict
new_dict = OrderedDict()
new_dict["jeff"] = 36
new_dict["john"] = 33
new = sorted(new_dict.items(), key=lambda x: x[1])
print new
for k,v in new_dict.iteritems():
print k,v
|
3ffa56b515eed3d8ad9528d8158b47fcfc6f7dcf | jreiher2003/code_challenges | /interviewcake/queue_two_stacks.py | 635 | 3.90625 | 4 | # Implement a queue with 2 stacks.
# Your queue should have an enqueue
# and a dequeue function and it
# should be "first in first out"
# (FIFO).
class Stacks(object):
def __init__(self):
self.instack = []
self.outstack = []
def enqueue(self, element):
self.instack.append... |
c1720b5055274d5c8c00b03936f67ad878e10888 | jreiher2003/code_challenges | /project_euler/even_fibo.py | 212 | 3.78125 | 4 |
def even_fib(n):
count = 0
a,b = 1,1
for i in range(n-1):
a,b = b, a+b
if b % 2 == 0:
print b
count += b
return a, count
print even_fib(33) |
38c5b392158e4c5139ed26e21873b86a12a328b3 | jreiher2003/code_challenges | /hackerrank/python/numpy/arrays.py | 230 | 3.875 | 4 | import numpy
a = numpy.array([1,2,3,4,5])
b = numpy.array([1,2,3,4,5],float)
print a[1]
print b[1]
import numpy
arr = raw_input().split()
n_arr = numpy.array(arr,float)
reversed_arr = n_arr[::-1]
print reversed_arr |
5cfe15b8e2728142d84dc97ca5e8b496fd2a6df2 | jreiher2003/code_challenges | /hackerrank/30_days_of_code/linked_list.py | 561 | 3.9375 | 4 | class Node:
def __init__(self,data):
self.data = data
self.next = None
class Solution:
def display(self,head):
current = head
while current:
print current.data,
current = current.next
def insert(self,head,data):
if not head:
... |
cd74ae6d151cb42a0ec1b8f3f317286359a7f729 | jreiher2003/code_challenges | /hackerrank/30_days_of_code/exceptions_II.py | 235 | 3.875 | 4 | class Calculator(object):
def power(self,n,p):
if n < 0 or p < 0:
raise Exception("n and p should be non-negative.")
else:
return n**p
mycalc = Calculator()
print mycalc.power(3,4)
print mycalc.power(1, 4) |
2b5df7f2a8963bdbb517b2de49b0a2ab610d5deb | jreiher2003/code_challenges | /hackerrank/python/sets/intro_sets.py | 281 | 3.578125 | 4 | print set()
print set("HackerRank")
print set([1,2,1,2,3,4,5,6,0,9,12,22,3])
print set(set(['H','a','c','k','e','r','R','a','n','k']))
num_plants = 10
height_plants = [161,182,161,154,176,170,167,171,170,174]
print sum(set(height_plants))/float(len(set(height_plants)))
|
045b781943abbea6a138621d719a5cb14885d234 | 121710308016/asignment2 | /07_pascals_triangle (1).py | 2,121 | 3.734375 | 4 | # pylint: disable=invalid-name
"""
Pascal's triangle
Given an integer n, return the nth (0-indexed) row of Pascal's triangle.
Pascal's triangle can be created as follows: In the top row, there is
an array of 1. Subsequent row is created by adding the number above and
to the left with the number above and to the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.