blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d5b289b267760043e186dcc8c96a89302334537f | harshitaggarwal-1999/python | /reversin of a number.py | 142 | 3.953125 | 4 | n= int(input("enter the number which has to reversed :"))
rem=0
summ=0
while(n!=0):
rem=n%10
n=n//10
summ=summ*10+rem
print(summ)
|
64aa3f3c27d56cdbdab34a2fbd4b3871e1a72a46 | Gary2018X/python | /DesignPattern/code/Decorator.py | 1,411 | 4.09375 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Time : 2022/08/22 09:35:16
# @Author : Gary
# @Email : None
class Beverage():
name = ""
price = 0.0
type = "BEVERAGE"
def getPrice(self):
return self.price
def setPrice(self, price):
self.price = price
def getName(... |
1cfa63d5579d903938331aa15e7179d12a6b39ae | OrionSuperman/pylot-gold | /app/controllers/Ninja.py | 1,606 | 3.859375 | 4 | """
Sample Controller File
A Controller should be in charge of responding to a request.
Load models to interact with the database and load views to render them to the client.
Create a controller using this template
"""
from system.core.controller import *
import random
class Ninja(Controller):
def... |
94899f7b39c15ca26c711dcdd981793b80d3cc83 | mjd95/advent-of-code-2019 | /day12/sol.py | 1,346 | 3.5 | 4 | from math import gcd
def lcm(a, b):
return abs(a*b) // gcd(a,b)
def get_velocity(idx, coord, cur_vel, positions):
vel = cur_vel
for i in range(len(positions)):
if i == idx:
continue
if positions[idx][coord] < positions[i][coord]:
vel += 1
elif positions[idx]... |
6330736e35f89c546245950f96ab9a936d939330 | Shubhxotic/python-scripts | /MakeNotes.py | 390 | 3.75 | 4 | import pyperclip,sys
text=""
while True:
if(text!=pyperclip.paste()):
text=pyperclip.paste()
"""l=text.split('\n')
if(l.__contains__('')):
l.remove('')"""
f=open("Note.txt","a")
f.write('#')
f.write(text)
f.write('\n')
"""for i in l:
f.write(i)
f.write('\n')
f.close()
x=input("Newtext??Wis... |
c5b2feb58db8267c59d8d533e3d2406460e671b8 | ksh428/udacity-git | /digiclock.py | 384 | 3.8125 | 4 | from tkinter import *
import time
import sys
def currtime():
timenow=time.strftime("%H:%M:%S") #gets the current time in string format
clock.config(text=timenow) #.config is used to update any widget
clock.after(200,currtime)
root=Tk()
root.geometry("250x100")
clock=Label(root,font=("times",50,"bold"),bg=... |
c49e09885b16b9c4ef4f23fd0efbe0c927e3da6d | ola7-Ola/Number-system-calculator | /convert.py | 2,803 | 4.0625 | 4 | class Number_system:
"""
converts value of Number System from baseX to baseY provided baseX, baseY is >=2 and <= 36
"""
def __init__(self):
# accepted number range from, 0 - Z
self.legal_base_36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def base_validator(self, base):
... |
d90582ff11fc54070ccd4c973923ebf294c4a00c | doganzehra/firstTry | /basicLogIn.py | 609 | 4.21875 | 4 | username = "zehra"
password = "4568"
usernameTemp = input("Please enter your username: ")
passwordTemp = input("Please enter your password: ")
if(username != usernameTemp and password == passwordTemp):
print("Your username is wrong!)
elif(sername == usernameTemp and password != passwordTemp):
print("Your p... |
bc1313177c6cb7fca3547d2d6eacea8b3ff6732d | doganzehra/firstTry | /atm.py | 879 | 4.28125 | 4 | print("What do you want to do?\nIf you want to see your balance select 1\nIf you want to deposit money select 2\nIf you want to withdraw money select 3\nIf you want to exit select 4\n")
int(balance) = 2000
while True:
operation = input("Select the operation that you want to do:")
if (operation == "1"):
p... |
9feecda23d3a1e2e1fd622ca5331329d7fe6e280 | joelyustiz/POO-Python | /aproximacion.py | 369 | 3.921875 | 4 | objetivo = int(input('Escoge un número: '))
epsilon = 0.01
paso = epsilon**2
respuesta = 0.0
while abs(respuesta**2 - objectivo) >= epsilon and respuesta <= objetivo:
respuesta += paso
if abs(respuesta**2 - objectivo) >= epsilon:
print(f'No se encontró la Raiz cuadrada del objectivo')
else:
print(f'La rai... |
3b8f62e9602126149d8892afcd3dfe4e37b259c1 | riverszxc/riverplum | /pkm/lbld/530.二叉搜索树的最小绝对差.py | 1,603 | 3.578125 | 4 | #
# @lc app=leetcode.cn id=530 lang=python3
#
# [530] 二叉搜索树的最小绝对差
#
# https://leetcode.cn/problems/minimum-absolute-difference-in-bst/description/
#
# algorithms
# Easy (63.30%)
# Likes: 373
# Dislikes: 0
# Total Accepted: 134.1K
# Total Submissions: 211.9K
# Testcase Example: '[4,2,6,1,3]'
#
# 给你一个二叉搜索树的根节点 roo... |
ec8eec0d25d39cb994167a9795139337b416bdba | riverszxc/riverplum | /pkm/lbld/912.排序数组.py | 3,236 | 3.671875 | 4 | #
# @lc app=leetcode.cn id=912 lang=python3
#
# [912] 排序数组
#
# https://leetcode.cn/problems/sort-an-array/description/
#
# algorithms
# Medium (55.01%)
# Likes: 705
# Dislikes: 0
# Total Accepted: 460.8K
# Total Submissions: 838.4K
# Testcase Example: '[5,2,3,1]'
#
# 给你一个整数数组 nums,请你将该数组升序排列。
#
... |
3886579f0b17c4a90d0389e026a29d24e29d98cc | riverszxc/riverplum | /pkm/lbld/2.两数相加.py | 2,067 | 3.90625 | 4 | #
# @lc app=leetcode.cn id=2 lang=python3
#
# [2] 两数相加
#
# https://leetcode.cn/problems/add-two-numbers/description/
#
# algorithms
# Medium (42.12%)
# Likes: 8753
# Dislikes: 0
# Total Accepted: 1.5M
# Total Submissions: 3.6M
# Testcase Example: '[2,4,3]\n[5,6,4]'
#
# 给你两个 非空 的链表,表示两个非负的整数。它们每位数字... |
a2b471e09e6a7399ac1dfebabffb188158c738df | riverszxc/riverplum | /pkm/lbld/70.爬楼梯.py | 1,130 | 3.578125 | 4 | #
# @lc app=leetcode.cn id=70 lang=python3
#
# [70] 爬楼梯
#
# https://leetcode.cn/problems/climbing-stairs/description/
#
# algorithms
# Easy (53.98%)
# Likes: 2687
# Dislikes: 0
# Total Accepted: 980K
# Total Submissions: 1.8M
# Testcase Example: '2'
#
# 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
#
# 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬... |
745a9b65df7c40d10c211af9d135cd9c53f4c465 | riverszxc/riverplum | /pkm/lbld/448.找到所有数组中消失的数字.py | 1,258 | 3.5 | 4 | #
# @lc app=leetcode.cn id=448 lang=python3
#
# [448] 找到所有数组中消失的数字
#
# https://leetcode.cn/problems/find-all-numbers-disappeared-in-an-array/description/
#
# algorithms
# Easy (65.83%)
# Likes: 1102
# Dislikes: 0
# Total Accepted: 238.4K
# Total Submissions: 362.1K
# Testcase Example: '[4,3,2,7,8,2,3,1]'
#
# 给你一... |
4ed83521a9f0ffaf420d1e63d18823da9aa55e4c | riverszxc/riverplum | /pkm/lbld/76.最小覆盖子串.py | 2,107 | 3.53125 | 4 | #
# @lc app=leetcode.cn id=76 lang=python3
#
# [76] 最小覆盖子串
#
# https://leetcode.cn/problems/minimum-window-substring/description/
#
# algorithms
# Hard (44.78%)
# Likes: 2120
# Dislikes: 0
# Total Accepted: 340.9K
# Total Submissions: 761.3K
# Testcase Example: '"ADOBECODEBANC"\n"ABC"'
#
# 给你一个字符串... |
603504dec98798d8d223c6382822fbca8e06072c | Dharma01/321810305001-tup | /l10.py | 83 | 4.125 | 4 | word="Hello"
for index,letter in enumerate(word,1):
print(index,":",letter)
|
47c73d63b411ae3ec12b1d82a7242f125365451a | ThimLohse/Epidemic_Simulation_Complete | /src/Main.py | 10,678 | 3.734375 | 4 | from DataHandler import DataHandler
from Simulation import Simulation
import numpy as np
import csv
data_handler = DataHandler()
def read_random_seeds():
"""Reads in the random seeds from a csv file and sorts them in ascending order."""
random_seeds = []
with open('./final.csv') as data_file:
csvR... |
6fecf86b71bd356bca58772b1f94ce767f2e0abc | jspringer/hackerrank | /cracking_the_coding_interview/CtCI_Recursion-Fibonacci Numbers.py | 675 | 3.984375 | 4 | # WEBSITE: HackerRank
# EXERCISE: Recursion: Fibonacci Numbers (Cracking the Coding Interview)
# SOURCE: https://www.hackerrank.com/challenges/ctci-fibonacci-numbers
# LANGUAGE: Python 3
# RULES: Given n, complete the fibonacci function so it returns fibonacci(n).
#
# The first line contains an integer, p, denoting ... |
ac6d8f09eaf912c9c1cf19068f64c4d530330785 | jspringer/hackerrank | /cracking_the_coding_interview/CtCI_DP-CoinChange.py | 1,496 | 3.75 | 4 | # WEBSITE: HackerRank
# EXERCISE: DP: Coin Change (Cracking the Coding Interview)
# SOURCE: https://www.hackerrank.com/challenges/ctci-coin-change
# LANGUAGE: Python 3
# RULES: Given a number of dollars, n, and a list of dollar values for m distinct coins,
# C = {c0, c1, c2,…, cm-1}, find and print the number of dif... |
6b1ac256fed78999e75d58c7f4f57a90c770ed1b | jspringer/hackerrank | /algorithms/InsertionSortPt1.py | 1,564 | 4.25 | 4 | # Hacker Rank
# Insertion Sort Part 1
# https://www.hackerrank.com/challenges/insertionsort1
# Python 2.7
# RULES: Given a sorted list with an unsorted number e in the rightmost cell,
# can you write some simple code to insert e into the array so that it remains sorted?
#
# Print the array every time a value is shif... |
db3a8062c310be343d37fbb1a54b7e86480000ee | jspringer/hackerrank | /cracking_the_coding_interview/CtCI_LinkedLists-DetectACycle.py | 1,242 | 3.90625 | 4 | # WEBSITE: HackerRank
# EXERCISE: Linked Lists: Detect a Cycle (Cracking the Coding Interview Section)
# SOURCE: https://www.hackerrank.com/challenges/ctci-linked-list-cycle
# LANGUAGE: Python 3
# RULES: It has one parameter: a pointer to a Node object named head
# that points to the head of a linked list.
# Your f... |
b9fd1e0ad5691848456e53398231a9bb73f61add | Wellwick/AdventOfCode2020 | /asyncexperiment.py | 1,399 | 3.53125 | 4 | import time
import asyncio, concurrent, threading
class DoThing:
def __init__(self):
self.something = True
self.running = True
def start_async(self):
print("Starting async")
#self.thread = threading.Thread(target=self.do_the_loop)
#self.thread.start()
... |
a54ee60048f664f87ad665f65457b1ccf4497053 | Wellwick/AdventOfCode2020 | /day3.py | 891 | 3.65625 | 4 | # Does part 1 and 2!
inputs = []
with open("inputs/day3.input", "r") as i_file:
inputs = i_file.readlines()
# We're getting a bunch of newlines at the end of each line
map = []
for i in inputs:
map += [i.strip()]
# We could make classes which return true for tree, false for empty, but let's
# b... |
c3e2765f30d924c4b77b25323b05198b5c6dc8e7 | ishaqj/Adventure-Game-Python | /choices.py | 2,328 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
List of choices for room and objects
"""
def RoomChoices():
"""
List of choices that a player can do in a room
"""
print("\nList of choices you can do in a room\n")
print("(i, info) Displays description of the room.")
print("(h, ... |
296adaddea148e94f6802c2154c2e6b91c028322 | Ndohjapan/hello-world | /pong.py | 5,022 | 3.921875 | 4 | import turtle
from tkinter import *
import winsound
name = Tk()
name.geometry("400x120")
def destroy():
names = player1_name.get(), player2_name.get()
name.destroy()
win = turtle.Screen() # This is done make the window
win.title("DUAL PAD")
win.setup(width=800, height=600)
win.bg... |
4fe619be4b95d3741a11b9d82d6621a2e2c89932 | triinfotech-edu/Python3-Training | /projecteuler/problem16.py | 256 | 4.0625 | 4 | #!/usr/bin/python
# Power digit sum
# Problem 16
# 2**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
# What is the sum of the digits of the number 2**1000?
num, sum = 2**1000, 0
while num > 0:
sum += (num%10)
num //= 10
print(sum)
|
eb33dd44cf34c8fced7fa32679031347eb83d0b4 | charanreddy0/List | /1.py | 127 | 3.828125 | 4 | # list of numbers
print('enter the number')
a=[]
while len(a)<10:
b=int(input())
a.append(b)
print(a)
|
3688a86e87cf8467a4848094902cb5da350924f7 | charanreddy0/List | /9.py | 394 | 3.953125 | 4 | a=[1,2,3,4,5,6,7,8,9,10]
#using for loop:
sum=0
for i in a:
sum=sum+i
print('sum of elements:',sum)
print('average of elements:',sum/len(a))
print('max num',max(a))
print('min num',min(a))
# using while loop
add=0
count=0
while count<len(a):
add=add+a[count]
count+=1
print(add)
print('avg:',... |
84f6a985ba9097c8b2727da0cf5f9b2de03a164d | enikolakopoulou/practice | /epal6.py | 313 | 3.875 | 4 | hours=int(input("δωσε μου τις ωρες:"))
minutes=int(input("δωσε μου τα λεπτα:"))
seconds=int(input("δωσε μου τα δευτερολεπτα:"))
sec1=hours*3600
sec2=minutes*60
sec3=sec1+sec2+seconds
print("ο χρονος σε δευετερολεπτα ειναι:",sec3)
|
b41af9c00086a41213cc44f9498f66e50f36350a | SamuelPErickson/easy-practice-projects | /untitled/Random Dice.py | 263 | 4.0625 | 4 | roll = True
import random
print("Let's roll a dice")
while roll == True:
print (random.randint(1,6))
print ("Do you want to roll again? yes or no")
cont = input()
if cont == "yes":
roll = True
elif cont == "no":
roll = False
|
582a373992cd4fbc99b469dea767b9ff6f273076 | benedsmith/python-bbcsport-scraper | /pyLeagueTable.py | 4,297 | 3.5 | 4 | from bs4 import BeautifulSoup as bs
import urllib.request, urllib
def get_league_code(soup):
# Check league name is in league codes dict
try:
# Grab the body of the table
tbody = soup.find("tbody", attrs={"class": "gel-long-primer "})
# Take the value of the reactid
# This is n... |
9bdc1eb8fd82f0fab066b11157a3bff0c047f8a4 | imjustlazy/MorseCode | /others.py | 3,769 | 3.515625 | 4 |
def break_words(input, S, W, C):
while True:
if not input:
if W == C == '':
yield S
return
i, input = input[0], input[1:]
C += i
if not is_morse_prefix(C):
return
ch = DEMORSE.get(C, None)
if ch is None ... |
b4e0f675ec23512e25b43e0e95084b7f70b53d01 | danchouss/laba | /ex13.py | 837 | 3.609375 | 4 | import turtle
t = turtle.Pen()
t.shape('turtle')
t.color('black')
t.up()
t.goto (100, 0)
t.left(90)
t.down()
t.fillcolor('yellow')
t.begin_fill()
t.circle(100)
t.end_fill()
t.up()
t.goto(-30, 50)
t.down() ... |
6e426f989ebd8d47bde5acc3d1e3055c7ca230dd | rptr/one-filers | /firth.py | 2,084 | 3.75 | 4 | #!/bin/python3
class Op:
def __init__(self, f):
self.f = f
class BinOp(Op):
pass
class Word:
def __init__(self, name, values):
self.name = name
self.values = values
glossary = {
'+' : BinOp(lambda args: args[0] + args[1]),
'-' : BinOp(lambda args: args[0] - args[1]),
... |
c87953e245b75a90c1682c16e6be60aa852e9a4e | hhwjj/forgit | /quiz/정렬/2750_수정렬하기.py | 106 | 3.5625 | 4 | n=int(input())
s=list()
for i in range(n):
k=int(input())
s.append(k)
s.sort()
for j in s:print(j) |
018be9f0d164af0be20c89e35e0dd9f26a0088c9 | hhwjj/forgit | /quiz/기본수학1/1193.py | 216 | 3.59375 | 4 | iter=int(input())
n=0
Sn=0
while Sn<iter :
n+=1
Sn=n*(n+1)/2
#짝수일때
k=int(Sn)-iter
r1=""
if n%2==0 :
r1="{}/{}".format((n-k),(k+1))
#홀수일때
else :
r1="{}/{}".format((k+1),(n-k))
print(r1) |
31130ad348b33dd1a04985090725ac759edfd36d | hhwjj/forgit | /quiz/재귀/10872_팩토리얼.py | 109 | 3.578125 | 4 | def fact(n):
if n>1:
return n*fact(n-1)
else:
return 1
k=int(input())
print(fact(k)) |
75a371055112aab585acbc2a89dd04216207dac5 | hhwjj/forgit | /quiz/재귀/test.py | 143 | 3.515625 | 4 | n=int(input())
s='*'
while n>1:
t=[i*3 for i in s]
print("t=",t)
s=t+[i+' '*len(i)+i for i in s]+t
print("s=",s)
n//=3
print('\n'.join(s)) |
b65436be0336c9928ce5f8384779d171b983b8cb | hhwjj/forgit | /quiz/문자열(2)/10809.py | 122 | 3.59375 | 4 | #w1.find(인덱스)
w1=str(input())
r1=""
for i in range(97,123):
k=w1.find(chr(i))
r1+="{} ".format(k)
print(r1) |
e9dab54bf9758c1efa9e48c533f09c24b17774a0 | andrei-chirilov/ICS3U-6-04-Python | /2d.py | 1,434 | 4.53125 | 5 | #!/usr/bin/env python3
# Created by: Andrei Chirilov
# Created on: December 2019
# This program get's the average of all the numbers in a 2d list
import random
def calculator(dimension_list, rows, columns):
# this finds the average of all elements in a 2d list
total = 0
for row_value in dimension_list:... |
a8390fe533e6210954de8605ff1474b4f79619e3 | marektester/py_triangle | /triangle.py | 783 | 4.21875 | 4 | def check_triangle(x, y, z):
if not check_value(x) or not check_value(y) or not check_value(z) or (x + y <= z) or (x + z <= y) or (y + z <= x):
return "Error! Invalid data. Not a triangle."
elif x == y == z:
return "Equilateral Triangle"
elif x == y or y == z or z == x:
return "Isosc... |
6ae2513e6a25d1175a522c559824505b7a62a67b | schaedejo00/AoC2019 | /2019/2/T2A1.py | 1,336 | 3.546875 | 4 | def runProgramm(program):
programmCounter = 0
while (programmCounter < len(program)):
optCode = int(program[programmCounter])
if (optCode==99):
return program
else:
inputIndex1 = int(program[programmCounter + 1])
inputIndex2 = int(program[programmCount... |
c5f0a38561986871f228ca30e40c8f6106e22d31 | sjzhai/Leetcode_Python_version_old | /2.ReverseInteger.py | 1,245 | 4.34375 | 4 | '''
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only hold integers
within the 32-bit signed integer range. For the purpose of this p... |
6328cad04a301cbe625c9ac5cedd72f3562a2456 | silvermiguel96/pythonVentas | /exampls/string.py | 504 | 3.953125 | 4 | country = 'Colombia'
country[1] #o
country[-1] #a
country[-2] #i
len(country) # 8
second_letter = country[1]
print(second_letter)
id(second_letter) # Donde esta en nuestra memoria 4461106712
other_var = '0'
id(other_var) # Su espacio es en 4461106712
id('i') # 4461106714
country = 'Mexico' #4461106777
country += ... |
4dd55c336a563f237fab709d9a015fbfae7f004e | NkemOhanenye/CIS1101 | /Homework/Final/final.py | 1,385 | 4.28125 | 4 | """
Author: Nkem Ohanenye
Date: 12/12/18
Purpose: Answer the questions to the final exam
"""
#Question 1
'the functions works on user input'
def ozToIG(value = input("Input a value for Oz to IG: ")):
'calculates the inputed oz to imperial gallons'
value = int(value) * 0.0065
'rounds the number ... |
d6d1ac7e44d7f7fa21fc1ccb163c541bf504381e | mrinxx/Kata-Yahtzee | /yahtzee_refactorizado.py | 4,193 | 3.75 | 4 | #hacemos cambios en las variables _x y otros aspectos 06-05
#resolucion de problemas con self y @staticmethod
class Yahtzee:
"""
autor: Marina Ocaña / Sergio Moreno
"""
def __init__(self, d1, d2, d3, d4, d5):
"""Agrupacion de la inicializacion"""
self.dice = [d1, d2, d3, d4, d5]
... |
4b5a3d27ddd05c7148267d99439016f6f76f8ae8 | lidalei/youtube-8m | /log_reg.py | 9,437 | 3.5 | 4 | """
One-vs-all logistic regression.
Note:
1. Normalizing features will lead to much faster convergence but worse performance.
2. Instead, standard scaling features will help achieve better performance.
3. Initializing with linear regression will help get even better result.
4. Bagging is implemented as... |
92b60276d02680491dd2507bcb7949e68d56a0d5 | Nishantsingh70/Arth_task9.1_audio | /linux-operation.py | 3,873 | 3.71875 | 4 | import os
import speech_recognition as sr
while True:
print("\n")
os.system("tput setaf 2")
print("\t\t\t\t\t\t\t\t\tWELCOME TO LINUX MENU")
print("\t\t\t\t\t\t\t\t####################################")
print("\t\t\t\t\t\t\t\t####################################")
os.system("tput s... |
f78eb444cb66828f6d66ea62b6fae2fff999d053 | silverashashash/dsp | /python/markov_two.py | 5,319 | 4.3125 | 4 | #!/usr/bin/env python A
# Write a Markov text generator, [markov.py](python/markov.py). Your program should be called from the command line with two arguments: the name of a file containing text to read, and the number of words to generate. For example, if `chains... |
f54b50b945639c35d1ba86ce2aab648d9606397e | slgnovice/python-data_analysis | /6数据清洗(研究、匹配、格式化).py | 11,891 | 3.84375 | 4 | '''
数据清洗的好处: 让数据更容易存储,搜索,复用
'''
'''
数据清洗步骤:
1、观察数据字段
'''
# 1、找出需要清洗的数据
# 1)根据需求,替换标题
# from csv import DictReader # 每一行创建字典
# import csv
# # data_rdr=DictReader(open('surveys_catalogue.csv','rb'))
# data_csv=csv.DictReader(open('surveys_catalogue.csv','r'))
#
# info_data=[line for line in data_csv]
... |
9365eddb8db848ebdfce24bca00d5984750e3f13 | bossk-ig88/SecureSet-stuff | /Python/Labs/CRY100/02lab/cry100-2lab-perms.py | 976 | 4.3125 | 4 | #!/usr/bin/python3
# CRY 100-2 Lab - Permutation Cipher
# 1. Write a function that will alphabetize a string of characters.
indexList = [] # List of Index Values or sorted letters.
myword = "Have a nice day"
# Sort string into alphabetical order:
oldword=sorted(myword)
# 2. Create a list from the indices for each let... |
4a542ab718893ad8d367535a26cdede6c8248b54 | bossk-ig88/SecureSet-stuff | /Python/Labs/SSF/ssf100-lab8b_02try.py | 1,053 | 4.4375 | 4 | # # SSF100 Python Lab 8a
# # Base Lab
# Base10 to Base8
#!/usr/bin/python3
import math
# user number output to "string".
number=""
# User input:
# when user # is not a numeric.
# Will run/execute loop (ask user) until defined condition is met.
while(not(number.isnumeric())):
number = input("What is the decimal to... |
2afa63e737a8b52e3d0e8f9bae2d5eba97af1644 | bossk-ig88/SecureSet-stuff | /Python/Labs/SYS200/02labV2-inputValid.py | 1,857 | 4.25 | 4 | #!/usr/bin/python3
# SYS 200 - 02 LAB - Input Validation
# Check for alphabets, numbers, at least 1 special character.
# import getpass and punctuation
# Prompt the user for a password without echoing
from getpass import getpass
# String of ASCII characters which are considered punctuation characters
# in the C local... |
2e97b8a9d7925208b2a6735796f7a82d593b9b03 | bossk-ig88/SecureSet-stuff | /Python/Labs/SSF/ascii2.py | 722 | 3.8125 | 4 | lowercase = [] # List 1
uppercase = [] # List 2
for num in range(65,91):
c1 = chr(num) # convert to ASCII
ordinal = ord(c1) # get ordinal value
# have ASCII character and value in pairs inside of lowercase list.
lowercase.append(c1)
lowercase.append(ordinal)
for num ... |
d189b04a9825a7f6353218ebe6b426f6f405eebb | bossk-ig88/SecureSet-stuff | /Python/Labs/CRY100/01lab/CRY100-01Lab-decrypt.py | 1,401 | 4.1875 | 4 | ##Then write a corresponding DECRYPt ONLY script.
##Can you write one script that will do both?
##Can you write a script that will do any given rotation?
##print (25 % 3)
##myvar = 25 % 3
# 1. User input:
x = input("Plug in letter: ")
# Cipher key shift:
y = input("Plug in cipher key (numbers only): ")
# Shift dire... |
0aaa726cd62831071bd27daef461d796c47b56da | jlindow/SY301 | /lab6/oneWord.py | 2,170 | 3.78125 | 4 | # Lab 6, Part 2
# Author: Jacob A. Lindow
#
# SY301-9991
# Dr. Travis Mayberry
#
########## import classes ##############
import sys
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class TreeSet:
def __in... |
6aa03e8d58f519b28e7cd6c55806483abaa1f9fa | jlindow/SY301 | /project3/enc.py | 4,918 | 3.71875 | 4 | #!/usr/bin/python
#################################################################################
# Public - Private Key Encryption #
# Author: Jacob A. Lindow # ... |
41193aa26f28ce8b139cbfa4bc36ba137f1e1646 | devbelloni/Exercicios_em_python | /ex026.py | 301 | 3.75 | 4 | frase=input('Escreva uma frase...\n').lower().replace('á','a').replace('ã','a').replace('â','a').strip()
print("""A letra "a" aparece {} vezes,
sendo que aparece na primeira vez na
posição {} e na última vez, na
posição {}".""".format(frase.count("a"), frase.find("a")+1,frase.rfind("a")+1)) |
b2776a355a64b9b162e2dcb41ea920c387f37cad | devbelloni/Exercicios_em_python | /ex042.py | 1,108 | 3.890625 | 4 | # Refaça o DESAFIO 35 dos triângulos, acrescentando o recurso de mostrar que tipo de
# triângulo será formado:
# – EQUILÁTERO: todos os lados iguais
# – ISÓSCELES: dois lados iguais, um diferente
# – ESCALENO: todos os lados diferentes
l1 = float(input('\033[0;36;40mInsira o comprimento da primeira reta... '))
l2 = flo... |
f946c27ceab4b7cc5fed3b77dd83587e3f1a92d1 | devbelloni/Exercicios_em_python | /ex016b.py | 391 | 4.1875 | 4 | #Crie um programa que leia um numero real pelo teclado e mostre o seu inteiro
import math
r=float(input('Digite um número real... '))
r1 = math.ceil(r)
r2 = math.floor(r)
r3 = math.trunc(r)
print('O número {} tem a parte inteira {}'.format(r,r3))
print('O valor digitado foi {}.\nArredondando para cima: {}.\nArredondan... |
23a51df301d79708a9d43e03a6cdd70a71496373 | devbelloni/Exercicios_em_python | /ex006.py | 223 | 4.03125 | 4 | n=float(input('Digite um número para saber seu dobro, triplo e a raíz quadrada... '))
d=n*2
t=n*3
r=n**(1/2)
print('O número digitado foi {}, seu dobro é {}, seu triplo é {} e a raíz quadrada é {}.'.format(n,d,t,r)) |
984be4c96b8070fb4a66a017caccc09a517866c8 | devbelloni/Exercicios_em_python | /ex018.py | 563 | 4.09375 | 4 | # Lê um ângulo qualquer e mostra seno, cosseno e tangente.
import math
n=float(input('Digite um ângulo qualquer... '))
ang=n*math.pi/180
sen=math.sin(ang)
cos=math.cos(ang)
tg=math.tan(ang)
print('O seno do ângulo {}° é {}, o cosseno é {:.3f} e a tangente é {:.3f}'.format(n,sen,cos,tg))
# resposta do professor
n=floa... |
ce87282721cbe4ca31287cf153020eec00d87e30 | nanotech24/python-crash-course | /Chapter 9 - Classes/9-07 Admin.py | 1,568 | 4.09375 | 4 | # C9-07 p.178 Admin
# Starting with the User class I wrote in exercise 9-05
class User:
"""A class to model a user"""
def __init__(self, first_name, last_name, age, height, weight):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.height = height
... |
c534d6a25dd187d2bfd852da6c2408c5e9df4f91 | nanotech24/python-crash-course | /Chapter 8 - Functions/8-03 T-Shirt.py | 669 | 4.4375 | 4 | # C8-03 p.141 Write a shirt function that accepts size and text to be printed.
# Call the function using positional arguments to make a shirt.
# Call it again a second time using keyword arguments
def make_shirt(size, text):
"""Creates a shirt at desired size and text"""
print(
f'You ordered a size {s... |
9041aabca6b622ed517937787a9ca235c1fcfb44 | nanotech24/python-crash-course | /Chapter 9 - Classes/9-06 Ice Cream Stand.py | 1,595 | 4.34375 | 4 | # C9-06 p.178 Ice Cream Stand
class Restaurant:
"""A class to represent a restaurant"""
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
"""Describe the Restaurant"""
pr... |
46327d325a375392a5fbf6431945b0e8ee1bba29 | nanotech24/python-crash-course | /Chapter 6 - Dictionaries/6-05 Rivers.py | 718 | 4.625 | 5 | #6-05 p.108 make a dict containing 3 major rivers and the country it runs
#print a sentence about each river, then the river name, then the country
river_dict = {
'nile' : 'egypt',
'mississippi' : 'missouri',
'mackenzie' : 'canada',
}
#looping through keys and values with .items()
for river, country i... |
87c35f482289a271b2a9e6872157f467eb12f5b0 | nanotech24/python-crash-course | /Chapter 5 - if Statements/5-06 Stages Of Life.py | 439 | 4.09375 | 4 | #5-06 Write an if-elif-else statement as instructed on page 89
pAge = 1
if pAge < 2:
print('This person is a baby.')
elif pAge >= 2 and pAge < 4:
print('This person is a toddler')
elif pAge >= 4 and pAge < 13:
print('This person is a kid')
elif pAge >= 13 and pAge < 20:
print('This person is teena... |
efcec5f626e4e7f853d53c794b51423ab127b709 | nanotech24/python-crash-course | /Chapter 6 - Dictionaries/6-10 Favorite Numbers.py | 474 | 3.9375 | 4 | #C6-10 P.115 start with program from 6-02. make it so each person has
#multiple favorite numbers. print each name and number
fav_numbers = {
'richard' : ['24', '54', '69',],
'sarah' : ['69','28','18',],
'brandon' : ['54','666','45',],
'kayla' : ['18','23'],
'rebecca' : ['21', '22', '26',],
}... |
49b40f8c95cd429152ab2467b5c5aff5a22e9d32 | nanotech24/python-crash-course | /Chapter 5 - if Statements/5-08 Hello Admin.py | 352 | 3.828125 | 4 | #C5-08 page 93
#defining list of names and looping through list
#printing a special message for the admin
user_names = ['admin', 'chett','matt','bob','jason']
for n in user_names:
if n == 'admin':
print('Hello Admin! Would you like to see a status report?')
else:
print('Hello ' + n.title() + '... |
6b556e8f08093cd9f0178fa83bb040ff6d78194b | nanotech24/python-crash-course | /Chapter 4 - Working With Lists/4-01 Pizzas.py | 281 | 4.3125 | 4 | #C4-01 make a list of favorite kinds of pizza, then use a for loop to print each
pizzas = ['meat lovers', 'pepperoni', '3 cheese', 'italian', 'square', 'deluxe']
for p in pizzas:
print('I really like ' + p + ' pizza!\n')
#print a statement
print('I really do enjoy a bitta za!') |
b2edee28edfa1f4f16d4940f3fefa74a42534092 | nanotech24/python-crash-course | /Chapter 4 - Working With Lists/4-02 Animals.py | 472 | 4.09375 | 4 | #think of at least 3 animals with a comman charactaristic, store in list and print
animals = ['dog', 'cat', 'ferret', 'rat']
statement = [
' is an awesome pet, I love mine!',
' is a pretty good pet too!',
' might make a good pet, I would not know.',
' is fun, I have had them in the past!'
]
s = 0
for a i... |
414203c907a88d653e9fed7a5eb3a1ce35ef20d8 | nanotech24/python-crash-course | /Chapter 8 - Functions/8-09 Magicians.py | 274 | 3.671875 | 4 | # C8-09 p.150 make a list of magicians names, pass it to a function
# and print the name of each
def show_magicians(magicians):
for magician in magicians:
print(f"It's Magician {magician}.")
magicians = ['Marvin', 'Ganderf', 'Bleck']
show_magicians(magicians) |
360818ed6a155d9f962c653d00a9a4e5ccf99988 | Krupa092/Data-Structures-And-Algorithms_Python | /Trees/CreateBinaryTree/Trees_Create_a_binary_tree_task05.py | 1,625 | 4.125 | 4 | """
Task05: check if left or right child exist
Define functions has_left_child, has_right_child, so that they return true if the node has left child, or right child respectively.
"""
class Node:
#Define constructor function
def __init__(self, value = None ): #because the default value of "value" is Non... |
31a49a0ccc042d7fa67e91712114abc76b7f02a0 | Krupa092/Data-Structures-And-Algorithms_Python | /Arrays_and_Linkedlist/String_exercise.py | 4,732 | 4.375 | 4 | # Common string methods
str1 = "Krupa Dave"
#Changing Case
#krupadave
print(str1.lower())
#KRUPADAVE
print(str1.upper())
#Slicing
print(str1[1:6]) # rupa
print(str1[:6]) # Krupa. A blank index means "all from that end starting from beginning"
print(str1[1:]) # rupa Dave
#Strip
str2 = " KrupaD... |
f7611925115cfa424b5e7ea825d8b107d36a8b69 | Krupa092/Data-Structures-And-Algorithms_Python | /Data_Structures/Solution6_Union_and_Intersection.py | 4,121 | 4.0625 | 4 | class Node:
def __init__(self,value):
self.value = value
self.next = None
def __repr__(self):
return str(self.value)
class LinkedList:
def __init__(self):
self.head = None
def __str__(self):
cur_head = self.head
out_string = ""
wh... |
0d2147b98c95ac86cf612de5eb7b497870cb105a | Krupa092/Data-Structures-And-Algorithms_Python | /Data_Structures/Solution2_FileRecursion.py | 1,881 | 4.5 | 4 | import os
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
Args:... |
522bddd6eaafc65882d059037eda3ba2aa808be2 | Krupa092/Data-Structures-And-Algorithms_Python | /Greedy/Prim_s_Algorithm.py | 6,342 | 4.3125 | 4 | """
Connect Islands using Prim’s Algorithm
A. Problem Statements
In an ocean, there are n islands some of which are connected via bridges.
Travelling over a bridge has some cost attaced with it. Find bridges in such a way that all islands are connected with minimum cost of travelling.
You can assume that there is... |
10566234f0430da4bcdc22edab6c55f4aa1598ea | EndCho/PyDemo | /base/square.py | 292 | 3.921875 | 4 | #Author: lenovo
#Date: 2017/11/10
#coding=utf-8
height=int(input("please input height:"))
width = int(input("please input width:"))
num_height=1
while num_height<=height:
num_width=1
while num_width<=width:
print("#",end="")
num_width+=1
print()
num_height+=1 |
49a28bbac136f104ec9130af4c78ffc3f5017cf5 | EndCho/PyDemo | /base/lession_file.py | 1,670 | 3.53125 | 4 | #Author: lenovo
#Date: 2018/2/4
#_*_coding:utf-8_*_
#能调用方法的一定是对象
import sys
#data = open('你好', 'r',encoding='utf8').read()
#f = open('你好','a',encoding='utf-8')
#print(f.readline()) #后面换行符也打印出来
#print(f.readline())
#data=f.read()
#print(data)
# print(f.read(2))
# print(f.read(2))
# print(f.readlines())
#-------... |
865439b34ca02f4e3107f0100f936f06efeccdc0 | JonNData/Python-Skills | /fundamentals/histo.py | 936 | 3.75 | 4 | # Your code here
import re
def histogram(filename):
with open(filename) as f:
words = f.read()
words1 = re.sub('":;,.-+=/\[|]\{\}()*^&', "", words.replace("\n", " "))
word_list = words1.split() # no punct list
longest = "" # loop to find longest word
word_counts = {} # add all ... |
8557de363e2feb6d6d867a2daea4c1a6a60f1c9e | getstart1/practice_algorithms | /count_last.py | 358 | 3.796875 | 4 | #Count the length of the last word in a string
#https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da?tpId=37&tqId=21224&tPage=1&rp=&ru=/ta/huawei&qru=/ta/huawei/question-ranking
string = input()
for i in range(len(string)):
if (string[len(string)- i -1] != ' '):
count = i + 1
else:
... |
a65c5b449a40fa785d4c89f05ff806d847b9a491 | jcmissmeng/python | /owner/python第十一天/pythoneleven.py | 1,269 | 3.578125 | 4 | # 多进程
from multiprocessing import Process,Pool
import time,os,random
# 测试进程间通信,使用全局变量是不可以进行进程间通信的
num=100
# 创建多进程方式一:继承Process类
class SubProcess(Process):
def __init__(self,interval):
Process.__init__(self)
self.interval=interval
# 重写run方法
def run(self):
global num
print("%s子进程开始"%os.getpid())
num+=100
... |
79356fba4e9745b781c547d26640c4fe5c912fb0 | jcmissmeng/python | /owner/python第十天/pythonten.py | 799 | 3.96875 | 4 | # 内建函数 map 的使用
# 根据提供的函数对指定的序列做映射
# 一个序列映射
m=map(lambda x:x**2,[1,2,3])
# 两个序列映射
m=map(lambda x,y:x+y,[1,2,3],[4,5,6])
# 定义函数映射
def ysfun(x,y):
return (x,y)
m=map(ysfun,[1,2,3],["m","t","w"])
# 遍历map
print(type(m))
for i in m:
print(i,end=" ")
print()
# 内建filter函数
# 以匿名函数过滤
f=filter(lambda x:x%2==0,[1,2,3,4,5,6])... |
c7470d0eb68459d0886134a95bec9be7db3e934d | jcmissmeng/python | /owner/python第十三天/pythonA.py | 687 | 3.78125 | 4 | # Socket套接字
from socket import *
# 创建socket
# upSocket=socket(AF_INET,SOCK_DGRAM)
# 定义对方的地址
# sendAddr=("127.0.0.1",8080)
# 发送数据
# upSocket.sendto(b"hello world",sendAddr)
# 关闭连接
# upSocket.close()
# 发送、接收数据
# 创建socket
upSocket=socket(AF_INET,SOCK_DGRAM)
# 绑定端口号,否则是动态的
bindAddr=("",7788)
upSocket.bind(bindAddr)
# 定义对... |
9cc751e4320819c9d72c1a38e05c56616f8f83a7 | AppliedStatisticsNBI/AppStat2020 | /Week1/original/SimpsonsParadox/Simpsons_paradox_generate_data.py | 1,716 | 3.6875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 5 09:31:47 2018
@author: michelsen
"""
import numpy as np
import pandas as pd
def gen_data(N=50, sigma_x=1, sigma_y=8):
# set random seed
np.random.seed(42)
# define ranges for the x value (exercise)
ranges = [(0, 10), (2, 12),... |
13a886d2875f8626a8e94f9f9f3563913b955894 | 22Rahul22/Hackerrank | /Panagrams.py | 221 | 3.734375 | 4 | s = input()
s = s.lower()
a = []
flag = 1
for i in s:
if i not in a and i != " ":
a.append(i)
if len(a) == 26:
print('pangram')
flag = 0
break
if flag == 1:
print("not pangram") |
4f62bee64603461debfab5ae6ee9902b3b830cb6 | Michant-bit/UDM | /exercice_4.py | 1,110 | 4.125 | 4 | # Auteur : Antoine La Boissière
# Date : 1 octobre 2021
#
# Ce programme sert à afficher à la console une grille de tic-tac-toe de taille n
n = 3 # taille du tic-tac-toe
hauteur = n * 3 + 2 # hauteur du tic-tac-toe
largeur = (n * 2) * 3 + 2 # largeur du tic-tac-toe
caractereDesLignes = '#' # caractère utilisé pour aff... |
f1419dc191f68d642e26d0c35b8bb85946e2d90b | sd2020spring/GeneFinder-liloheinrich | /gene_finder.py | 7,272 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Gene Finder Project main file
Software Design Spring 2020
@author: Lilo Heinrich
"""
import random
from amino_acids import aa, codons, aa_table # you may find these useful
from load import load_seq
def shuffle_string(s):
"""Shuffles the characters in the input string
NOTE: ... |
ddc35c26a7ad4a5f941c5f6c7140decdcab4e961 | PaulSender/IrisFlowerClassification | /IrisClassification.py | 1,351 | 3.8125 | 4 | import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
import numpy as np
iris = load_iris()
# 75% 255 SPLIT: 75 TRAIN 25 TEST
#Returns 4 objects
#X_train - training set of data 75
#X_test - test set... |
de8dfac0279637781566882a017ac11330aa18a2 | schkolski/training_ground | /attacking_queens/tests/test_chess_board.py | 1,930 | 3.6875 | 4 | import unittest
from attacking_queens.board import BoardSize
from attacking_queens.board import ChessBoard
class ChessBoardTests(unittest.TestCase):
def setUp(self):
self.board = ChessBoard(size=5)
def test_chess_board_size(self):
self.assertEqual(self.board.size, 5)
def test_available... |
ef31dd82eed963d53b3124337b7e5da928062516 | 3207-Rhims/100days-of-code-challenge | /codechef/contest.py | 373 | 3.84375 | 4 | N=int(input())
count=0
if 1<= N <= 100000:
for i in range(N*2+2):
def isPrime(i):
if (i <= 1):
return False
for j in range(2, i):
if (i % i == 0):
return False
return True
if isPrime(i):
prin... |
12c6b6dead8dd653a28c47950ccdf18949c99a54 | moisesquintana57/python-exercices | /tema_10_modulos/ejer4.py | 589 | 4.03125 | 4 | # primero importaremos los modulos necesarios
from math import sqrt, pow
# cargaremos el valor entero
def cargar():
return int(input("Ingrese un valor entero: "))
# calcularemos la raíz cuadrada
def raiz(num):
return sqrt(num)
# calculamos el exponente
def exponente(num,exp):
return pow(num,exp)
# bloqu... |
2bcd04c5951d7ce4880e6336fdecdcf9312bd9d7 | moisesquintana57/python-exercices | /tema_9_porciones_indices/ejer3.py | 475 | 3.515625 | 4 | # primera función para cargar los valores
def cargar():
lista=[]
for x in range(10):
val=int(input("Ingrese un valor: "))
lista.append(val)
return lista
# función para retornar la mitad de la lista
def mitad(lista):
return lista[:(len(lista)//2)]
# función para imprimir una lista
def i... |
9d3d6cbe1d274944d4a9582af632ddb3e3c11df8 | moisesquintana57/python-exercices | /tema_11_poo/ejer4.py | 1,066 | 4.0625 | 4 | # creamos la clase
class Calculadora:
# iniciamos con el método __init__
def __init__(self):
self.valor1=int(input("Ingrese el primer valor: "))
self.valor2=int(input("Ingrese el segundo valor: "))
# función para sumar
def suma(self):
suma=self.valor1+self.valor2
print("El resultado de la suma de los valor... |
686eb1356690f0ef927867548eb883439f414cf1 | moisesquintana57/python-exercices | /tema_10_modulos/operaciones.py | 225 | 3.65625 | 4 | # crearemos una primera función para cargar un valor entero
def cargar():
return int(input("Introduce un valor entero: "))
# creamos una segunda funcion para sumar dos valores
def suma(num1,num2):
return num1+num2
|
8111135c9d3c4e4c63d62836e7ef9e3b42b1575c | moisesquintana57/python-exercices | /tema_7_estructura_tipo_tupla/ejer3.py | 522 | 3.671875 | 4 | # función para cargar el nombre y sueldo del empleado
def cargar():
nombre=input("Ingrese el nombre: ")
sueldo=float(input("Ingrese el sueldo: "))
return (nombre,sueldo)
# función para comprobar quien tiene un sueldo mayor
def sueldo_mayor(emp1,emp2):
if emp1[1]>emp2[1]:
print("El empleado con ... |
527c9813c72cc24cb17525fbf2fb91af4205dc43 | moisesquintana57/python-exercices | /tema_4_variables/ejemplo3.py | 251 | 3.921875 | 4 | #declaramos los dos string
nombre1=input("Introduce el primer nombre:")
nombre2=input("Introduce el segundo nombre:")
#comparamos si son iguales
if nombre1==nombre2:
print("Los nombres son iguales")
else:
print("Los nombres no son iguales")
|
36d1096ebc8489014edd9689e81f2717e4569467 | moisesquintana57/python-exercices | /tema_12_operadores_objetos/ejer1.py | 925 | 4.125 | 4 | # definimos nuestra clase lista
class Lista:
# inicializamos nuestra clase
# como atributo utilizaremos una lista
def __init__(self,lista):
self.lista=lista
# método para imprimir la lista
def imprimir(self):
print(self.lista)
# redefinimos la suma
def __add__(self,valor):
n=[]
for x in range(len(sel... |
b21e0196a2e6f9a9546410a750977a9617c65aef | moisesquintana57/python-exercices | /tema_5_estructura_tipo_lista/ejemplo1.py | 285 | 3.90625 | 4 | # una lista puede ser de distintos valores
lista1=[2, 4, 6, 8] # enteros
lista2=[3.14, 2.4, 6.78] # flotantes
lista3=["ana", "alma", "jack"] # strings
lista4=["jaime", 4, 3.2] # un poco de todo
# imprimimos la lista completa
print(lista1)
# o solo un valor de ella
print(lista2[0])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.