blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
a324132733af3c04834f57109f470c403a47556b | sanadhis/code-practice | /nov2017/linkedList.py | 1,460 | 4.0625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add(self, data):
node = Node(data)
if self.head == None:
self.head = node
else:
current_node = self.hea... |
aa49e54950f552058444b70b8c3385321018ae7f | Astrolopithecus/PalindromeChecker | /palindromeChecker.py | 1,088 | 4.21875 | 4 | # Miles Philips
# prog 260
# 7-10-19
# Palindrome Detection program
from stack import Stack
#Implement this function that checks whether the input string is a palindrome:
# (a string where the characters of the string read the same when read backward
# as forward. E.g. racecar, mom)
def palindromeCheck(mystr)... |
ceb2848b33f3aa25dae4299491a3d21617ab910e | Lew9s/Python_learn | /InversionNumber.py | 445 | 3.640625 | 4 | n = int(input("Enter a number: "))
m = n
s = 0
while n != 0:
s = s * 10 + n % 10
# 例如n=123时,s在每一轮循环的变化为3,3*10+2=32,32*10+1=321
n //= 10
# n不断截尾,例如当n=123时,循环从123变化为12,1,0
print("reversed({:d}) = {:d}".format(m, s))
# 字符串的format()方法中参数输出的位置和格式等由其前面字符串中的{}位置和格式(d表示十进制整数)决定
|
e9db845ccbce1013d419a385c46d98b983c0657b | MurrayT/SMCHomeworkGeneration | /stub_assignment | 3,251 | 3.578125 | 4 | #! /usr/bin/env python
import sys
import os
target_assignment = sys.argv[1]
number_of_problems = int(sys.argv[2])
top_stub = """# Loading
load('../necessary_functions.py')
# Name your homework set
this_is = '{}'
info = [this_is]
assignment = [info,[],[],[],[],[],[],[],[]]
# ----------------------------------------... |
b21e2244e37beb3f9bc394c372ba49ab1bde10f0 | zakerias91/uppercase-keywords-sql | /python/uppercase_keywords.py | 511 | 3.8125 | 4 | import sys
def uppercase_keywords(text):
global f
# Get keywords
keywords = open('keywords.txt').read()
# Create array
keywords = keywords.split(',')
# If keyword found, uppercase
for word in keywords:
if word in f:
f = f.replace(word, word.upper())
return f
... |
e25b58b51cb528818d879dd5120ce376525a8864 | bobur554396/PPII2021Summer | /w1/L2/4.py | 298 | 3.6875 | 4 | # Dictionary
a = {
'id': 123,
'name': 'Student 1',
'age': 20,
}
print(type(a))
b = dict()
b['a'] = 1
b['b'] = 1
print(b)
print(type(b))
print(a.keys())
print(a.values())
# for i in a.items():
# print(i[1])
for key, val in a.items():
print(f'{key} ====> {val}')
a.pop('id')
print(a) |
3db070c80f992e3b9519e3df2633a365aa2b6912 | bobur554396/PPII2021Summer | /last/8.py | 1,299 | 3.578125 | 4 | import pygame
# Initialize pygame program
pygame.init()
# Surface
SCREEN_WIDTH, SCREEN_HEIGHT = 500, 500
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("First game")
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
runnin... |
be1e5a53e3ee8d6d1384d683cd662167b9f3c28f | bobur554396/PPII2021Summer | /last/10.py | 2,048 | 3.71875 | 4 | import pygame
import random
# Initialize pygame program
pygame.init()
# Surface
SCREEN_WIDTH, SCREEN_HEIGHT = 500, 500
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("First game")
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0... |
59535de4c6da4453033664a4e5c25b08dc47c86a | bobur554396/PPII2021Summer | /w1/L3/8.py | 686 | 3.875 | 4 | class Counter:
def __iter__(self):
self.a = 1
return self
def __next__(self):
if self.a > 10:
raise StopIteration
x = self.a
self.a += 1
return x
c = Counter()
it = iter(c) # will call __iter__ method inside of the class
# print(next(it)) # will call __next__ method inside of the... |
7dceb1aa7979c57e2df57b9ebb50ebff8dfafa0a | bobur554396/PPII2021Summer | /w1/L1/4.py | 244 | 3.609375 | 4 | # type casting
a = 123
b = str(a)
print(type(a))
print(type(b))
a = 15.4
b = int(a)
print(a, type(a))
print(b, type(b))
try:
a = "123a"
b = int(a)
except Exception as e:
print('error: '+ str(e))
print(a, type(a))
print(b, type(b))
|
e06a176aa1095918e5cb089bacc6df5c03533e7e | wernicka/learn_python | /example_prgms/pw.py | 561 | 3.953125 | 4 | #! python3
# pw.py - An example insecure password locker program from Automate the Boring Stuff Chapter 6
PASSWORDS = {'email': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6',
'locker': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
'luggage': '2819'}
import sys, pyperclip
if len(sys.argv) < 2:
print('Usage: pytho... |
97c704e2c22f4846a7f9de5d963bf7babda5dd1e | wernicka/learn_python | /original_code/experiments/transit_expenses_calculator_v6.py | 4,793 | 4.375 | 4 | # TODO Apply PEP8
# These are error messages for the Validate function
NOT_NUMBER = "Invalid: not a number"
TOO_SMALL = "Invalid: number too small"
TOO_LARGE = "Invalid: number too large"
# These are clarifications to follow error messages in the Validate function
MONTHS_CLARIFICATION = "Please enter a number between... |
d796fa0e2daf167745ac995e14b6f6ea65a30425 | wernicka/learn_python | /example_prgms/ex6.py | 1,071 | 4.5625 | 5 | # set variable types_of_people to an integer: 10
types_of_people = 10
# set variable x to a string: sentence about types_of_people.
x = f"There are {types_of_people} types of people"
# unnecessarily set values of binary and do_not to strings
binary = "binary"
do_not = "don't"
# set variable y to another string which h... |
191362f0e7bd2ab6bbe104b1d65304e373dafc3f | wernicka/learn_python | /original_code/Algorithms/2_integer_array.py | 1,233 | 4.375 | 4 | # You are given an array (which will have a length of at least 3, but could be very large) containing integers.
# The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single
# integer N. Write a method that takes the array as an argument and returns N.
# For example... |
da6b403fbf2aaf15a4d137a4e051cd4565a1b7d8 | wernicka/learn_python | /original_code/jc_tutorial_challenges/1_truncate.py | 631 | 4.03125 | 4 | # Joe Costlow Tutorial Challenges
# Write a function called chop(). Chop receives two parameters: data, and length
# It returns data after truncating it to length.
# E.g. chop("Joseph", 3) returns 'Jos'
# E.g. chop("Sean", 4) returns 'Sean'
# E.g. chop("cmoses@eab.com", 10) returns 'cmoses@eab'
# E.g. chop(123456789,... |
d0f3d3baee17880718e6344f06404c04ceeff8dc | mutemibiochemistry/Biopython | /Assignment-1/question4.py | 440 | 4.03125 | 4 | m=int(raw_input("Enter m: ")) #prompt user from user
b=int(raw_input("Enter b: ")) #prompt user from user
print "The results for the linear equation Y=mX+b with m=",m,"and b=",b,"are:" #print title
print "X","\t","Y" #print header titles
if m != ' ': #exclude space from equation
for X in ran... |
f7f9673891d5d09f932e6164e2e36b9b0e8e09f2 | mutemibiochemistry/Biopython | /exercise8/trial2.py | 180 | 3.796875 | 4 | x = int(raw_input("Enter x: "))
y = int(raw_input("Enter y: "))
if (x < 4) and (y < 4):
i= x + ((y*5)+1)
if i==5:
print " ",
else:
print "#",
if i%5 == 0:
print ' '
|
79e5ea2362ed8db2f8ffdcd219fa7b8a59eedf47 | mutemibiochemistry/Biopython | /exercise10dictionaries/question7.py | 784 | 3.796875 | 4 | #7a=d = {"Hitchhiker's Guide to the Galaxy": 1,"The Restaurant at the End of the Universe": 2,"Life, the Universe, and Everything": 3,"So Long, and Thanks for all the Fish!": 4,"Mostly Harmless": 5}
#7b= d["The Restaurant at the End of the Universe"]
'''d = {"Hitchhiker's Guide to the Galaxy": 1,"The Restaurant at the... |
2095ebcca22314f164825f79ccbd82fe427d5666 | mutemibiochemistry/Biopython | /exersice4/question11.py | 260 | 3.703125 | 4 | number = int(raw_input("nos")
if (number%1==0):
print 1
if number%2==0:
print 2
if nos%3==0:
print 3
if nos%4==0:
print 4
if nos%5==0:
print 5
if nos%6==0:
print 6
if nos%7==0:
print 7
if nos%8==0:
print 8
if nos%9==0:
print 9
if nos%10==0:
print 10
|
e2b029a70231d60abb74d730e81372904909f7eb | mutemibiochemistry/Biopython | /exercise11functions/question4.py | 394 | 4.21875 | 4 | #Write a function that accepts a single integer parameter, and returns True if the number is prime, otherwise False.
a=int(raw_input("Enter number: "))
def isprime(a):
#return True if the number is prime, false otherwise
if (a == 1) or (a == 2):
return "is True"
else :
for i in range(2, a ):
if a%i == 0:
... |
6c1d9fdfb857e58aa9c816802b7456e82b543c7e | mutemibiochemistry/Biopython | /exersice4/question8.py | 144 | 4.125 | 4 | year = raw_input("year1")
def leapyear(year1):
if year1%4 == 0:
print "leap year"
else:
print "not leap year"
test1 = leapyear(int(year))
|
eb4fc53fed6bbdc185ae2d743a6c3e863879c973 | mutemibiochemistry/Biopython | /exercise11functions/question7.py | 228 | 3.921875 | 4 | #Write a function that accepts a list of numbers, and returns their mean.
def mean_mylist(nos):
if len(nos) == 0:
return
else:
total = sum(nos)
ave = 1.0*total/len(nos)
return ave
print mean_mylist ( [1,2,3,4,5,6] )
|
0c7faa1a84483918796097fa8b70c3d5fb60f208 | mutemibiochemistry/Biopython | /exercise5/question9.py | 242 | 4.28125 | 4 | #enters sequence of nos ending with a blank line then prints the smallest
nos = raw_input("Enter numbers: ")
smallest = nos
while nos != '':
if int(nos) < int(smallest):
smallest = nos
nos = raw_input("Enter numbers: ")
print smallest
|
61384f67002a6256b882b894811b99af940350c4 | yaswanth1593/lab-1 | /continue.py | 109 | 3.6875 | 4 |
for i in range(1,11):
if i==5:
continue
print i
print "\nUsed contine to skip printing the value 5" |
8e6d5d9cfe49d9434c35a4cbf31c560039d3ba8f | yaswanth1593/lab-1 | /descen.py | 270 | 3.828125 | 4 | a=input("enter the number")
b=input("enter the number")
c=input("enter the number")
if(a>b and a>c):
if(b>c):
print a,b,c
else:
print a,c,b
if(b>a and b>c):
if(a>c):
print b,a,c
else:
print b,c,a
if(c>a and c>b):
if(a>b):
print c,a,b
else:
print c,b,a
|
9f963166fd23136774fa6559437b6eec30a52dbe | Megg44/Python_Bootcamp | /Activity_12.py | 568 | 3.953125 | 4 | def input_number():
s = input()
return list(map(int, s.split()))
def greatest(my_list):
if my_list[0] > my_list[1] & my_list[0] > my_list[2]:
return my_list[0]
elif my_list[1] > my_list[2]:
return my_list[1]
else:
return my_list[2]
def display(my_list, great... |
efc2e06da8e7f7f74c2a4d62f207f6f43120ad15 | Megg44/Python_Bootcamp | /Activity_13.py | 495 | 3.953125 | 4 | def input_number():
return int(input("Enter an integer: "))
def prime(number):
for i in range(2, number):
if number % i == 0:
return 0
break
else:
return 1
def display(number, flag):
if flag:
print(f"{number} is a prime number.")... |
c715f3e2594043fa3c5d33147f9760ac1e3abe43 | stephanRavelo/StephanDrugProject | /utils.py | 9,686 | 3.71875 | 4 | import pandas as pd
import json
import numpy as np
from typing import TextIO
from typing import Union
PATH_PROJECT = 'input/'
OUTPUT_PATH = 'output/'
def load_csv(filename: str) -> pd.DataFrame:
""" Create a pandas dataframe based on the csv file. """
try:
df = pd.read_csv(filepath_or_buffer=PATH_PR... |
fc39977ce45c2bb134aa4cdc46e5aeb84dbba669 | wenbinhuang9/travel-sales-man-solver | /simplehillclimbing.py | 1,786 | 3.578125 | 4 | import random
from util import fillgraph, drawHist, mean, median
from data import graph1
def hillClimbing(graph):
cityNum, row, col = len(graph), len(graph), len(graph[0])
curState = getRandomSequence(cityNum)
while True:
nextState = climb( curState , graph)
if nextState == None:
## we have got ... |
d981b1f0bf529307d8053f8d324d87d5132a8977 | MCNANA12/pycharmdupdated | /Hello World.py | 732 | 4.4375 | 4 | # Basic string Operation
str = 'Hello World, this is a string!'
print(len(str)) # Get the length
print(str * 3) # Repeat
print(str.replace('Hello', 'Hola')) # Replace
print(str.split(',')) # Split
print(str.startswith('H')) # starts with
print(str.endswith('!'))
print(str.lower())
print(str.upper())
# slicing - o... |
57c3cbfa79238cea470c98154c2346ca90daac91 | NeilBryant/pfc | /dev/appscale-tests/tasks-test/primes.py | 564 | 4.0625 | 4 | import sys
import math
print "Prime numbers"
#Asks user how many numbers he wants to calculate.
a = int(raw_input("Start?: "))
b = int(raw_input("End?: "))
if (a < 0) :
print "Error: Invalid number. It must be greater than zero"
sys.exit
if (a < 2) : # Discard 0 and 1 as primes
a = 2 # Primes(0,10) == ... |
f44fab479f74725cf95a9bbc99f9bd3788d033fd | rajivtanna/Python_Learn | /ex15.py | 605 | 4.03125 | 4 | from sys import argv
script, filename = argv
text1 = open(filename) #imports the data from the file into the variable text
text2 = open(filename) #imports the data from the file into the variable text
text_read = text1.read()
text_list = text2.readlines()
print "Here's your file %r" % filename
print text_read # Prin... |
6ac20a9d5683dd73de9843af12475e530490ed4a | kwohl/python-functions | /cash-to-coins.py | 1,107 | 3.734375 | 4 | dollarAmount = 8.69
piggyBank = {
"pennies": 0,
"nickels": 0,
"dimes": 0,
"quarters": 0
}
# Your magic Python code here
def calc_coins(cash):
original_amount = cash
piggyBank["quarters"] = int(cash//.25)
if piggyBank["quarters"] != 0:
cash = float('%.2f' % (cash%.25))
# pr... |
f9765623e0b33467cd76e4f439b29f077985b1a2 | FstRms/basic-python | /BMI.py | 610 | 4.34375 | 4 | """ Script to calculate Body Mass Index"""
print("Hi there!!!\nWelcome to the Body Mass Index Calculator tool!!!\n")
height = float(input("Please enter your height in m:\n"))
weight = float(input("Please enter your weight in kg:\n"))
bmi = int(weight / (height ** 2))
if bmi < 18.5:
print (f"Your BMI is {bmi}. You... |
8352dc184c8b7ec37aceec25065ca675d2886a0f | Ezzahhh/turtle-crossing-game | /car_manager.py | 1,202 | 3.671875 | 4 | from turtle import Turtle
from random import choice, randint
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
MOVE_INCREMENT = 10
UPDATE_SPEED = 0.1
class Car_Manager(Turtle):
def __init__(self):
super().__init__()
self.penup()
self.hideturtle()
self.car_list = []
... |
c478650cb8831bd4cc1d0511b6b41fc0ecfa8294 | Riceps/cp1404_practicals | /exam_practice/loops.py | 375 | 3.796875 | 4 | # For loop
names = ["Patrick", "is", "a", "fuckwhit"]
for i, name in enumerate(names):
print("{} {}".format(i, name), end=" ")
print(" ")
# While loop
your_number = 69
my_number = int(input("What is my number? "))
while my_number != your_number:
print("WRONG YOU'RE SHIT!!")
my_number = int(input("Guess aga... |
761dee0913c11def9e5eb5574602917184325c1d | Riceps/cp1404_practicals | /prac_02/exceptions_demo.py | 754 | 4.25 | 4 | """
CP1404/CP5632 - Practical
Answer the following questions:
1. When will a ValueError occur?
2. When will a ZeroDivisionError occur?
3. Could you change the code to avoid the possibility of a ZeroDivisionError?
"""
try:
numerator = int(input("Enter the numerator: "))
denominator = int(input("Enter the denomi... |
24d30d8684bac301c0752b6531f78dfa23353942 | Riceps/cp1404_practicals | /exam_practice/ch_07.py | 220 | 3.84375 | 4 | user_name = input("What is your name? ")
vowels = "bcdfghjklmnpqrstvwxyz"
number_of_vowels = 0
for i in range(len(user_name)):
if user_name[i].lower() in vowels:
number_of_vowels += 1
print(number_of_vowels)
|
7a1d6919281d2a8ef58faa4ab2ad5ef27cf8b831 | Riceps/cp1404_practicals | /prac_01/loops.py | 526 | 4.21875 | 4 | "Prints all numbers between 1 and 20 inclusive, with a step of 2 (i.e. all odd numbers)"
for i in range(1, 21, 2):
"prints number i and a space TODO:(question what (end) does)"
print(i, end=' ')
print()
for i in range(0, 101, 10):
print(i, end=' ')
print()
for i in range(20, 0, -1):
print(i, end=' ')
... |
0630dd5fb3b671748d9a3051b55c26238580351a | reedcwilson/programming-fundamentals | /lessons/2/homework/fibonacci.py | 804 | 4.25 | 4 |
# import some modules so that we get some extra functionality
# ask for the option they would prefer (nth number or number <= n)
# if you recognize their choice then continue
# ask for the n
# keep track of the current first and second numbers
# if we are option number 1 do the nth number algorithm
... |
f742893c2653e448d90d8d7dbe12e8f48ab1b24a | reedcwilson/programming-fundamentals | /lessons/1/homework/tip_calculator.py | 561 | 3.515625 | 4 |
# Ask for the server's name (collect the response in a variable)
# Ask for how much the meal was (this should be an integer)
# Ask for how much the tax is (this should be a floating point)
# Ask for what the percentage of the tip is (this should be an integer) (NOTE:
# percentages are typically represented as numbe... |
c6dbebc222ac5564ea1022bdeabba33c10ccce6d | acgis-dai00035/gis4107-day06 | /countdown.py | 976 | 3.890625 | 4 | #-------------------------------------------------------------------------------
# Name: countdown.py
#
# Purpose:
#
# Author: David Viljoen
#
# Created: 29/09/2019
#-------------------------------------------------------------------------------
def get_countdown_as_text_using_for(start_value=10):
"""Given a s... |
61559698a5a2fd8e65d4b4d29841091354dc7f27 | LEMateo/WebProgrammingTwilioProject | /Reminder_2.py | 510 | 3.515625 | 4 | import datetime
class Reminder2:
time = ""
message = ""
id_number = 0
def __init__(self, time, message):
try:
test_time = datetime.datetime.strptime(time, "%H:%M:%S")
self.time = time
self.message = message
self.reminder = {self.time: self.messa... |
9749be719df1b7443fb87735f99ee9fb25e0e4fb | mxteries/A-Small-Trip | /moving_object.py | 2,063 | 3.59375 | 4 | import pygame
# a class for any object that moves in shopping.py
class MovingObject:
# to do: decide on public / private attributes
def __init__(self, xpos, ypos, spd, width, height):
self.objX = xpos
self.objY = ypos
self.objSpeed = spd
self.objWidth = width
self.obj... |
462fdf8481d146fbc52cd60dc629b0efb85d5a95 | gideonromm/battleship | /battleship/main.py | 8,867 | 3.90625 | 4 | import sys
import uuid
from random import randint
class Ship:
def __init__(self, length, name):
self.hits = 0
self.length = length
self.name = name
class Fleet:
def __init__(self):
self.ships = []
self.ships.append(Ship(2, "Mini"))
self.ships.append(Ship(3, "Su... |
20d2a60ed5cdba448ee0c5213808071dfe5b99f1 | openpencil/pythonic | /python_syntax_runthrough.py | 14,302 | 3.953125 | 4 | # This is a comment
""" This is a
multiline comment
"""
# Calculations
# Set count_to equal to the sum of two big numbers
count_to = 1000 + 8000
print(count_to)
# Exponentiation
eggs = 10 ** 2
# Modulo operator
spam = 4 % 3
# Sometime function adds on (if function adds on to the class)
# i.e if there is a method th... |
bb660ff5c6f1ed4b80c0e2a65fea2cb5c5e977d7 | signalsecret/pythonstudy | /week1/var_string.py | 248 | 3.765625 | 4 | # 자료형 - 문자
# int == integer
# str == string
# 작은따움표, 큰따움표로 감싸면 문자열
a = "Hello "
b = "python"
c = 3
print(a+c)
# 메이플 설치
# 하드디스크 <-비휘발성 메모리
# 램 <- 휘발성
# 경량화
|
7c400ab79f4039c61601c27e6a8003d98464d00f | signalsecret/pythonstudy | /week1/exam/q2.py | 235 | 3.75 | 4 | # 사용자 13 -> 홀수
# 사용자 6 -> 짝수
number = int(input())
# 조건이 명확한 경우에는 elif 가지고 확실히 조건을 작성
if number % 2 == 0:
print("짝수")
elif number % 2 == 1:
print("홀수")
|
370707f5da6c457ed71bbf830892dd9b6a3cc48f | Kosyka/Learning-python | /inventary2.py | 2,214 | 4.21875 | 4 | #Продолжение изучения кортежа
inventary = (
"Меч",
"Щит",
"Кольчуга",
"зелье лечения"
)
print("В вашем распоряжении: ")
for item in inventary:
print(item)
input("Для того, чтобы узнать размер вашего инвентаря нажмите Enter...")
print("Размер инвентаря: {0} предмета/ов".format(len(inventary)))
#про... |
d9afe168f646afd3dcbb9788027a8a35c275265c | ironlota/python-bootcamp | /day-3/class.py | 2,043 | 4.03125 | 4 | # mesin
# roda
# dashboard
# warna
# maju / mundur .... (vector)
# ngerem
class Car: # ini cetakan mobil, blm implementasi mobil nya
warna = 'merah-biru'
roda = 4
mesin = 'v8'
def maju(self):
self.printInfo()
print('mobil berwarna ' + self.warna + ' ini sedang melaju')
def print... |
24b22a11d42fe928633529bdc3f9c7fdc7cf7003 | nickaroot/pdsm04 | /ex00/benchmark.py | 1,187 | 4.21875 | 4 | #!/usr/bin/env python3
import timeit
def loop(emails):
gmails_loop = []
for email in emails:
if "@gmail.com" in email:
gmails_loop.append(email)
def comprehension(emails):
[email for email in emails]
def main():
emails = ['john@gmail.com', 'james@gmail.com', 'alice@yahoo.com', '... |
eacc7fb9dea7fc34148c629ddb4564d37511f521 | Jay-gupta/pycourse | /01_python/fun1.py | 785 | 3.890625 | 4 | import random
def numberlength(a,b,c,d=0,e=0,f=0,g=0):
"""asdfasdfasdfsdf
a: number
b: base
c: default count
return length
author: asdfasdf@asfasdf
revision:
version:
copyright: asdf
"""
print(d)
print(f)
return 10
def sort(list):
#sorts the list
lis... |
0d6a271fc3ee12c49765632be2e35ca706029e8b | premkrish/Python | /Lists/lists.py | 792 | 4.28125 | 4 | """ This script contains lessons for list """
#Instantitate a list
list1 = [1, 2, 3, 4, 5]
print(list1)
list2 = [6, 7, 8, 9, 10]
print(list2)
#concatenation - maintains order
print(f"List 1 + List 2: {list1 + list2}")
print(f"List 2 + List 1: {list2 + list1}")
#Add item to list
list1.append(6)
print(type(list1))
pr... |
2138d7d5205c8623fea526c66a778527935381ff | premkrish/Python | /Tuples/tuples.py | 1,478 | 4.65625 | 5 | """ This script contains lessons for tuples """
# List and Tuple have similar features
list1 = [1, 2, 3, 4, 5, 6]
tuple1 = (1, 2, 3, 4, 5, 6)
print(f"Length of list : {len(list1)}")
print(f"Length of tuple : {len(tuple1)}")
#Iterate and print the elements
for n in list1:
print(f"List element: {n}")
print(80*"-"... |
b98ed0177bbf14a0ab872fa9a67cafd8e80d4da1 | arcisd/TestEL-Definido | /test1.py | 1,072 | 3.65625 | 4 |
def palindrome(num):
string=str(num)
ind_L=0
ind_R=len(string)-1
while ind_L<ind_R: # analiza sólo la mitad de la palabra.
if string[ind_L]!=string[ind_R]: return 0
ind_L,ind_R=ind_L+1,ind_R-1
return 1
minn,maxx=100,999 # 3 cifras
# 999+999=1998
def max_palindrome(minn,maxx):... |
3ec901ccf0d84c42c37d1078d5cb40c6e06f798d | miguelcollette/FastPath | /node.py | 2,229 | 3.859375 | 4 | class node:
def __init__(self, coord_x, coord_y):
self.x = coord_x
self.y = coord_y
self.adj = []
self.c = 0
self.h = 0
self.in_opened = False
self.in_closed = False
self.n_from = None
self.r_from = None
# rich comparison m... |
13825f7e72fc4ad98b21b7179eda599a15922ee1 | ayush0477/pythonexperimt- | /squireelplay.py | 275 | 4.125 | 4 | temp = int(input("enter the temparure value\n"))
summer = str(input("enter the summer value true or false\n"))
if(temp>=60 and temp<=90 and summer=="false"):
print("true")
elif (temp>=60 and temp<=100 and summer=="true"):
print("true")
else:
print("false") |
98c4df06481581947e415593a11f16e435cdfbd5 | realDashDash/SC1003 | /Week4/Discussion2.py | 1,182 | 4.125 | 4 | # requirements:
# - more than 8 characters
# - at least one upper letter and lower letter
# - at least one number
# - at least one special character
# todo regular expression operations
def check_pw(password):
length = 0
upper = False
lower = False
number = False
special = False
n... |
7496e67768769206e12d9d39af1b4a4a4217d781 | realDashDash/SC1003 | /Week7/Tut.py | 1,843 | 3.890625 | 4 | # Base Function:
def reverse(str):
if (len(str) == 1):
return str
else:
new_str = reverse(str[1:]) + str[0]
return new_str
# Discussion 1
def reverseAndRepeat(str, num):
if (len(str) == 1):
return str * num
else:
new_str = reverseAndRepeat(str[1:], num) + str[0]*... |
3c0d51ffa37bf075cf1a91f0b03b5ce961bca8ad | realDashDash/SC1003 | /Week4/Discussion3.py | 420 | 3.890625 | 4 | # Method 1: oop - class
class Student:
def __init__(self, s_group = "", s_id = "", s_grade = 0):
self.group = s_group
self.ID = s_id
self.grade = s_grade
def printInfo(self):
print("Student group:", self.group, "id:", self.ID, "grade:", self.grade)
tim = Student("SC9",... |
3498b32dace8193e830609d9058d148c5b5b5cbf | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W6_Strings_Assignment2_spelling_corrector.py | 4,503 | 4.3125 | 4 | # Write a function named spelling_corrector that accepts two arguments. The first argument is a sentence (string) and the second argument is a list of words (correct_spells). Your function should check each word in the input string against all the words in the correct_spells list and return a string such that:
#
# If a... |
d29015ed62d062d408f27fed846ec277be23c029 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/w3_If_elif_Divisibilidad.py | 902 | 4.53125 | 5 | #Write a program which asks the user to enter a positive integer 'n' (Assume that the user always enters a positive integer) and based on the following conditions, prints the appropriate results exactly as shown in the following format (as highlighted in yellow).
#when 'n' is divisible by both 2 and 3 (for example 12)... |
012b37666aeb11b42bbf9deeae22a432b62760fa | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Dictionary_Assignment3_find_word_crossword_vertical.py | 1,700 | 4.1875 | 4 | # Part 2: Find a word in a crossword (Horizontal)
# 0.0/30.0 puntos (calificados)
# Write a function named find_word_vertical that accepts a 2-dimensional list of characters (like a crossword puzzle) and a string (word) as input arguments. This function searches the columns of the 2d list to find a match for the word. ... |
b15bada3961093e473af9bf4ddf8ef8241136475 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/buscar_en_cadena_con_if.py | 120 | 3.65625 | 4 | #Insert chain
cadena = input("Insert text")
if 'dog' in cadena:
print('yes')
else :
print('no')
|
59035219f7287bd7c84007bdc04021f5a2a2b253 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W6_Strings_lider_espacio_blanco.py | 614 | 4.3125 | 4 | # Write a function that accepts an input string consisting of alphabetic characters and removes all the leading whitespace of the string and returns it without using .strip(). For example if:
#
# input_string = " Hello "
# then your function should return a string such as:
# output_string = "Hello "
#
def funcion_... |
3ca7c865fabcca490d7b9bccd49a66e968bc0fa3 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W8_FileIO_E2_Function_leer_grabar_diccionario.py | 1,419 | 4.0625 | 4 | # File I/O Exercise 2
# 0 puntos posibles (no calificados)
# Write a function that accepts a filename(string) of a CSV file which contains the information about student's names and their grades for four courses and returns a dictionary of the information. The keys of the dictionary should be the name of the students an... |
874b4d47c1487bdae79ec5aa4fe35402a0eff88d | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/w3_Condicional_If_elif_numero.py | 467 | 4.3125 | 4 | #Write a program which asks the user to type an integer.
#If the number is 2 then the program should print "two",
#If the number is 3 then the program should print "three",
#If the number is 5 then the program should print "five",
#Otherwise it should print "other".
numero = input("Insert the number: ")
numero = in... |
6f94acdd9baac844cb8633d85502c84bed331182 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W6_Strings_suma_codigo_caracteres.py | 574 | 4.46875 | 4 | #Write a function that accepts an alphabetic string and returns an integer which is the sum of all the UTF-8 codes of the character in that string. For example if the input string is "hello" then your function should return 532
#
def funcion_suma_codigo_caracteres(caracteres):
suma=0
for x in caracteres:
... |
5b6e4eca927532afdf680a6d524f5b7002940e15 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/w3_Condicional_If_elif.py | 496 | 4.34375 | 4 | #Ask the user to type a string
#Print "Dog" if the word "dog" exist in the input string
#Print "Cat" if the word "cat" exist in the input string.
#(if bothj "dog" and "cat" exist in the input string, then you should only print "Dog")
#Otherwise print "None". (pay attention to capitalization)
cadena = input("Insert the ... |
b3f54800bd3faaee42ceb1cdf76c8d029f18bbbe | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W4_While_Calculo_Serie_3_n.py | 269 | 4.15625 | 4 | #Write a program using while loop, which prints the sum of every third numbers from 1 to 1001 ( both 1 and 1001 are included)
#(1 + 4 + 7 + 10 + ....)
numero = int(1)
suma = int(0)
while numero <= 1001:
suma = suma + numero
numero = numero + 3
print(int(suma))
|
f34ceee60cc001952bec5a15b56089be0ff2eb5f | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W6_Strings_E7_conteo_caracter_comun.py | 1,055 | 4.125 | 4 | # Write a function that takes a string consisting of alphabetic characters as input argument and returns the lower case of the most common character. Ignore white spaces i.e. Do not count any white space as a character. Note that capitalization does not matter here i.e. that a lower case character is equal to a upper c... |
4afda533e47431000384fa6f69b855d087701120 | ivanromanv/manuales | /Python/DataCamp/Intro to Python for Data Science/Excercises/E34_Baseball players BMI.py | 2,002 | 3.609375 | 4 | # The MLB also offers to let you analyze their weight data. Again, both are available as regular Python lists: height and weight. height is in inches and weight is in pounds.
# It's now possible to calculate the BMI of each baseball player. Python code to convert height to a numpy array with the correct units is alread... |
f121606b3c62d6bbf0a5bc792bcf28ce2f9744a1 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W6_Strings_entero_a_caracter.py | 358 | 4.15625 | 4 | # Write a function that accepts a positive integer n and returns the ascii character associated with it.
#
def funcion_entero_a_caracter(number):
return (chr(number))
# OJO SOLO FUNCION!!!
# Main Program #
number = int(input("Enter number: "))
evalua_funcion_entero_a_caracter = funcion_entero_a_caracter(number)
pr... |
eb44c62077ca925dda8752c8ac35ff5f97fe2562 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Dictionary_E10_Function_numero de palabras_II.py | 4,298 | 4.0625 | 4 | # Write a function that takes a 4 digit integer (from 1000 to 9999 both inclusive) as input argument and returns the integer using words as shown below:
#
# Sample Examples:
# if the input integer is 7000 then the function should return the string "seven thousand"
# if the input integer is 1008 then the function should... |
97269d02b35e0cefd0fb906d9d58207356c07d71 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Multidimensional_E9_Function_lista_2d_to_1d.py | 560 | 4.25 | 4 | # Write a function that accepts a 2-dimensional list of integers, and returns a sorted (ascending order) 1-Dimensional list containing all the integers from the original 2-dimensional list.
#
def list_covert_2d_to_1d_list(lista):
new_list = []
for data in lista:
new_list=new_list+data
new_list.... |
3b26de5482e886f97cf7e9fbd80f23b57a57f0cf | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/cadena_numero_divisible_con_if.py | 179 | 4.0625 | 4 | #Insert chain
numero = input("Please insert number: ")
numero = int(numero)
resultado = int(numero%3)
if resultado == 0 :
print('yes')
else :
print('no')
|
1b0163ec609f274d7a271d4b399d2ea2a665acea | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W5_Function_lista_divisores_n.py | 2,616 | 3.9375 | 4 | # Write a function that accepts a positive integer k and returns the list of all the divisors of k. Your list should include both 1 and k.
#
lista_divisores=[]
lista_divisores_extensa = []
lista_divisores_final = []
# Funcion principal que llama a todas en secuencia
def funcion_lista_divisores_n(number):
evalua_fun... |
d779832ff8ae87018cebf243c57b5a6b3a9e0e20 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Multidimensional_E1_Function_suma_lista_2d.py | 562 | 4.15625 | 4 | # Write a function which accepts a 2D list of numbers and returns the sum of all the number in the list You can assume that the number of columns in each row is the same. (Do not use python's built-in sum() function).
#
def sum_of_2d_list(lista):
total_sum=0
for data in lista:
for list_index in range(0... |
99cd1d31120e05ce4a2ae4cbd04bf84a00e49608 | ivanromanv/manuales | /Python/DataCamp/Intro to Python for Data Science/Excercises/COMO_IMPORTAR_DATOS.py | 2,033 | 3.671875 | 4 | # To subset both regular Python lists and numpy arrays, you can use square brackets:
# x = [4 , 9 , 6, 3, 1]
# x[1]
# import numpy as np
# y = np.array(x)
# y[1]
# For numpy specifically, you can also use boolean numpy arrays:
# high = y > 5
# y[high]
# The code that calculates the BMI of all baseball players is alread... |
29f5308510497013c9adb03646a89d47ff5578cf | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Multidimensional_E11_Function_verifica_multiplicacion_2_matrices.py | 1,075 | 4.4375 | 4 | # Write a function that accepts two (matrices) 2 dimensional lists a and b of unknown lengths and returns True if they can be multiplied together False otherwise. Hint: Two matrices a and b can be multiplied together only if the number of columns of the first matrix(a) is the same as the number of rows of the second ma... |
201e75cd77d36941fe1f29ffbfda2e1933a3741c | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W8_Q6_E5_Function_calculo_gastos.py | 2,146 | 4.125 | 4 | # Quiz 6, Part 5
# 0.0/20.0 puntos (calificados)
# Write a function named calculate_expenses that receives a filename as argument. The file contains the information about a person's expenses on items. Your function should return a list of tuples sorted based on the name of the items. Each tuple consists of the name of ... |
23d2e251b59414149095c587cf28b660fedaf6c8 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Dictionary_E5_Function_diccionario_conteo_letras.py | 937 | 4.375 | 4 | # Write a function that takes a string as input argument and returns a dictionary of letter counts i.e. the keys of this dictionary should be individual letters and the values should be the total count of those letters. You should ignore white spaces and they should not be counted as a character. Also note that a small... |
f148a68aacfd6a6803837740053704716887b4f3 | ivanromanv/manuales | /Python/DataCamp/Intermediate Python for Data Science/Excercises/E3_Line plot (3).py | 906 | 4.34375 | 4 | # Now that you've built your first line plot, let's start working on the data that professor Hans Rosling used to build his beautiful bubble chart. It was collected in 2007. Two lists are available for you:
# * life_exp which contains the life expectancy for each country and
# * gdp_cap, which contains the GDP per capi... |
89cf8a303d3b91925367105dab6cf8b7736be519 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W7_Dictionary_E2_Function_valores_ordenados.py | 528 | 4.3125 | 4 | # Write a function that accepts a dictionary as input and returns a sorted list of all the values in the dictionary. Assume that the values of this dictionary are just integers.
#
def dictionary_sorted_values(dictionary):
valores = dictionary.values()
valores = list(valores)
valores.sort()
return valore... |
60bb03fe89e076b0d92154de00078ef635704c71 | akshitasawhney3008/Reinforcement-Learning-QLearning | /QLearning.py | 3,170 | 3.578125 | 4 | import gym
import numpy as np
from gym.spaces import Discrete
import matplotlib.pyplot as plt
import os
env = gym.make("Taxi-v3")
print("Action Space {}".format(env.action_space))
print("State Space {}".format(env.observation_space))
assert isinstance(env.action_space, Discrete)
assert isinstance(env.obser... |
372270bd162eeb53f98f49b763195d23f387e3c4 | DamianSzczerba/selenium-test | /main1.py | 1,313 | 3.609375 | 4 | from selenium import webdriver
'''
Given I am on the homepage
When I select brand category from the header
Then I should see the list of brands
And I select DOLCE & GABBANA brand from the list
Then I should see the list of products from DOLCE & GABBANA
'''
driver = webdriver.Firefox()
driver.maximize_w... |
7a7b17926e7c5bd5c88899374ae5deb1938d0c73 | YuKaoriGenji/AlgorithmExp | /AlgorithmCourse/Exp1/quicktest.py | 2,901 | 4.21875 | 4 | import quicksort
import random
import numpy as np
import time
def random_int_list(start,stop,length):
start,stop=(int(start),int(stop)) if start<= stop else (int(stop),int(start))
length=int(abs(length)) if length else 0
random_list=[]
for i in range(length):
random_list.append(random.randint(... |
2d17431cebc1604dbe7e4497e73cfbf4a04d3fc1 | alfxavier/primeiropython | /aula12.py | 971 | 3.75 | 4 | """Elabore um algorotimo que leia as variáveis 'c' e 'n', respectivamente código e número de horas
trabalhadas de um operário. Calcule o salário sabendo-se que ele ganha R$ 10,00 por hora.
Quando o número de horas exceder a 50 calcule o excesso de pagamento armazenando-o na variáve 'e' .
Caso contrário zera tal vari... |
f0af0d85c8eeb7dacf814ea5eceef333c989b743 | alfxavier/primeiropython | /aula13.py | 775 | 3.921875 | 4 | # Desenvolva um algoritimo que:
# a) leia 4 (quatro) números:
# b) Calcule o quadrado de cada um:
# c) Se o valor resultante do quadrado do terceiro for >= 1000, imprimir e finalize;
# d) caso contrário, imprima os valores lidos e seus respectivos quadrados.
num1 = int(input("informe o primeiro número: "))
num2 = int(... |
ec15200763c8c79bbfc9727c1585ef8dd6292dee | dsementsov/python.cousrse.mitx | /week2_GuessMyNumber.py | 828 | 4.15625 | 4 | # guess my number
def guess_my_number ():
guess_low = 0
guess_high = 100
print ("Please think of a number between " + str(guess_low) + " and " + str(guess_high) + "!")
while True:
guess = int((guess_high + guess_low)/2)
print("Is your secret number " + str(guess) + "?")
guess... |
aed3fe6169903e52cd3dbe967eb88ca6690df98a | rpyne97/Code_Academy_worth_saving | /hammingsdistance.py | 1,201 | 4.21875 | 4 | # Input: Strings Pattern and Text along with an integer d
# Output: A list containing all starting positions where Pattern appears as a substring of Text with at most d mismatches
# This function matches a Pattern sequence to a Test sequence if there are less than or equal to d mismatches
def ApproximatePatternMatchin... |
2ba31e05a15a087b54ec850aee060bb1ddfb1154 | simsekonur/DeepLearningProject | /vectorization.py | 459 | 3.59375 | 4 | import numpy as np
import time
a = np.array([1,2,3,4])
print(a)
a = np.random.rand(1000000)
b = np.random.rand(1000000)
tic = time.time()
c = np.dot(a,b)
toc = time.time()
print (c)
print("The operation is done with vectorization at " + str(1000*(toc-tic)) + "ms")
c = 0
timeBefore = time.time()
for i in range(0... |
9fa74a7196a1dfbdeb8a7a901c38ab60ee52f627 | joroChie/PyLeetCodeSolution | /P0005_longest_palindrome.py | 512 | 3.890625 | 4 | '''
Project Description
'''
def longest_palindrome(s: str) -> str:
s = s.lower()
longest = s[0]
for idx, char in enumerate(s):
for idx2 in range(idx + 1, len(s)):
if char == s[idx2] and is_palindrome(s[idx:idx2 + 1]):
if len(longest) < len(s[idx:idx2 + 1]):
... |
c84d9b439dd03ea90bc20268120c17c55fd06efd | joroChie/PyLeetCodeSolution | /misc_decode_digit.py | 962 | 3.96875 | 4 | '''
Problem : Return how many ways a string can be decoded given that:
a -> 1
b -> 2
.
z -> 26
example:
data = "12" returns 2 since there are 2 ways these can be decoded, 'ab' or 'l'
Solution should be comply with O(n) time complexity
'''
# Using memoization
def num_ways_dp(data):
... |
66707f02425519ff3d9c877c0e9099da17f7a393 | tgaborit/surlyllabe | /python/syllabation_encoder.py | 886 | 4.3125 | 4 | # -*-coding:Utf-8 -*
"""
Programme réalisant la syllabisation d'un mot passé en paramètre, puis
encode le résultat pour donner un nombre dont les chiffres correspondent à la
taille des syllabes du mot.
"""
import argparse
from syllabes import *
# Gestion des arguments
parser = argparse.ArgumentParser(description="Pr... |
70fb2ea3ef7f858f984c2dfe5ff3ef5efa5df1c2 | DinoVinkovic/smartninja | /guess_the_secret_number.py | 487 | 3.75 | 4 | import random
def main():
hidden_number = random.randint(1, 100)
user_guess = 0
while not user_guess == hidden_number:
user_guess = int(raw_input("Guess the secret number between 0 and 100: "))
if user_guess == hidden_number:
print "That's right!"
elif user_guess < hid... |
06f59d004f62302b24f98282ea4849485208cadc | pbie42/python_tutorial | /projects/ipsum_gen.py | 613 | 3.71875 | 4 | from random import randint
ninja_words = [
'Aiki', 'Buyu', 'Chimonjutsu', 'Cho sen', 'Dojo', 'Gakusei', 'Haiboku',
'Jin', 'Kenshi', 'Obake ken', 'Rakusha', 'Sanmaru', 'Tekkon', 'Yoko'
]
def ninjarize(word):
random_pos = randint(0, len(ninja_words) - 1)
return f"{word} {ninja_words[random_pos]}"
paragraphs = int(... |
688d7d66e148c6470e32b8b3430226436ad06db6 | pbie42/python_tutorial | /lessons/decorators.py | 332 | 3.546875 | 4 | def cough_dec(func):
def func_wrapper():
# code before this function
print(f"*cough*")
func()
print(f"*cough*")
# code after the function
return func_wrapper
@cough_dec
def question():
print(f"Can you give me a discount on that?")
@cough_dec
def answer():
print(f"It's only $5 you cheapskate")
questio... |
7f5abc98bb045f92ced9606fa1b2f611ebad07e5 | DhruvinSoni30/Python-Solution | /p20-dict.py | 160 | 3.875 | 4 | #Unordered
dictionary = {
'a' : 10,
'b' : 20
}
print (dictionary['b'])
dictionary1 = {
'a' : [1,2,3],
'b' : 30
}
print (dictionary1['a'][0])
|
595c1edf7c8605f5d48f953b5e147d7684e3df1b | DhruvinSoni30/Python-Solution | /p11-removeeven.py | 143 | 3.921875 | 4 | name = raw_input("Enter the name:")
newname = ""
for i in range(len(name)):
if i % 2 != 0:
newname = newname + name[i]
print (newname)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.