blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
07a2b70ca25f20852834cf6b5451951ad90e4a33 | psyde26/Homework1 | /assignment2.py | 501 | 4.125 | 4 | first_line = input('Введите первую строку: ')
second_line = input('Введите вторую строку: ')
def length_of_lines(line1, line2):
if type(line1) is not str or type(line2) is not str:
return('0')
elif len(line1) == len(line2):
return('1')
elif len(line1) > len(line2):
return('2')
... | true |
45b08672f5802bd07e54d45df20b24c1538a2673 | jxthng/cpy5python | /Practical 03/q7_display_matrix.py | 383 | 4.4375 | 4 | # Filename: q7_display_matrix.py
# Author: Thng Jing Xiong
# Created: 20130221
# Description: Program to display a 'n' by 'n' matrix
# main
# import random
import random
# define matrix
def print_matrix(n):
for i in range(0, n):
for x in range (0, n):
print(random.randint(0,1), end=" ")
... | true |
02f76ae07d4bb429bf6a8319cce2aba0cb80ef58 | jxthng/cpy5python | /compute_bmi.py | 634 | 4.59375 | 5 | # Filename: compute_bmi.py
# Author: Thng Jing Xiong
# Created: 20130121
# Modified: 20130121
# Description: Program to get user weight and height and
# calculate body mass index (BMI)
# main
# prompt and get weight
weight = int(input("Enter weight in kg:"))
# prompt and get height
height = float(input("Enter heigh... | true |
723f43c5f3555576fb2f01526ac4924675e93c5f | jxthng/cpy5python | /Practical 03/q2_display_pattern.py | 515 | 4.40625 | 4 | # Filename: q2_display_pattern.py
# Author: Thng Jing Xiong
# Created: 20130221
# Description: Program to display a pattern
# main
# define display pattern
def display_pattern(n):
prev_num = []
for i in range(1, n + 1):
prev_num.insert(0, str(i) + " ")
length = len("".join(prev_num))
prev_num... | false |
1b40fd6dfbc67682a85fed5140d9f1d16a810286 | Usuallya/python | /class-object/c4.py | 1,727 | 4.1875 | 4 | #python类的封装、继承和多态
#import people
from people import People
#1、继承的写法
class Student(People):
# sum = 0
# def __init__(self,name,age):
# self.name=name
# self.age = age
# self.__score=0
# self.__class__.sum+=1
#派生类的构造函数需要传入父类需要的参数,然后调用父类的构造函数来完成初始化
def __init__(self,school,nam... | false |
3c144e821443e44da6317169ecdc9992134a34fc | DevJ5/Automate_The_Boring_Stuff | /Dictionary.py | 1,184 | 4.28125 | 4 | import pprint
pizzas = {
"cheese": 9,
"pepperoni": 10,
"vegetable": 11,
"buffalo chicken": 12
}
for topping, price in pizzas.items():
print(f"Pizza with {topping}, costs {price}.")
print("Pizza with {0}, costs {1}.".format(topping, price))
# There is no order in dictionaries.
print('che... | true |
0bb5501ebf856a20a70f2ec604495f21e10a4b0c | MachFour/info1110-2019 | /week3/W13B/integer_test.py | 399 | 4.25 | 4 | number = int(input("Integer: "))
is_even = number%2 == 0
is_odd = not is_even
is_within_range = 20 <= number <= 200
is_negative = number < 0
if is_even and is_within_range:
print("{} passes the test.".format(number))
# Else if number is odd and negative
elif is_odd and is_negative:
print("{} passes the test.... | true |
bf86e2e9ac26825248273684b72b95427cc26328 | MachFour/info1110-2019 | /week6/W13B/exceptions.py | 778 | 4.25 | 4 | def divide(a, b):
if not a.isdigit() or not b.isdigit():
raise ValueError("a or b are not numbers.")
if float(b) == 0:
# IF my b is equal to 0
# Raise a more meaningful exception
raise ZeroDivisionError("Zero Division Error: Value of a was {} and value of b was {}".format(a,b))
... | true |
b9d7faf00bcac19f2e292331e9800c05b4b489fa | MachFour/info1110-2019 | /week11/W13B/fibonacci.py | 923 | 4.1875 | 4 | def fibonacci(n):
if n < 0:
raise ValueError("n can't be negative!")
# just for curiosity
print("fibonacci({:d})".format(n))
# base case(s)
if n == 0:
return 0
elif n == 1:
return 1
# else
return fibonacci(n-1) + fibonacci(n-2)
def fibonacci_iterative(n):
if ... | false |
02930644ec3cd051b1416e2860a002da5d374224 | MachFour/info1110-2019 | /week5/R14D/control-flow-revision.py | 354 | 4.25 | 4 | a = 123
if a == "123":
print("a is 123")
if a > 0:
print("a is greater than 0")
else:
print("a is less than or equal to 0???")
a = 123
while True:
if a == 123:
print("Hello from inside the while loop")
a = a - 1
elif a > 122 or a < 0:
break
else:
a = a - ... | false |
70514719b85a8c73f1881ae521606a66466b215c | aarthymurugappan101/python-lists | /append.py | 289 | 4.1875 | 4 | numbers = [2,3,5,7,89] # List Datatype
# print("Before",numbers)
numbers.append(100)
# print("After",numbers)
numbers.append(33)
# print(numbers)
numbers.insert(2, 66)
# print(numbers)
print(numbers)
numbers.pop()
print(numbers)
numbers.pop(1)
print(numbers)
numbers.sort()
print(numbers) | false |
da7b7caea279a8444cd63c43cabe65240ca21b57 | Jyun-Neng/LeetCode_Python | /104-maximum-depth-of-binary-tree.py | 1,301 | 4.21875 | 4 | """
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Note: A leaf is a node with no children.
Example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its depth = 3.... | true |
6e784b269099a926400bc136e6810610a96a88ed | Jyun-Neng/LeetCode_Python | /729-my-calendar-I.py | 2,328 | 4.125 | 4 | """
Implement a MyCalendar class to store your events.
A new event can be added if adding the event will not cause a double booking.
Your class will have the method, book(int start, int end).
Formally, this represents a booking on the half open interval [start, end),
the range of real numbers x such that start <= x ... | true |
4038b6ca7e62b6bd3b5ba7ef3cf01de2d3e8ee84 | rishabh2811/Must-Know-Programming-Codes | /Series/Geometric.py | 751 | 4.3125 | 4 | # Geometric.py
""" Geometric takes the first number firstElem, the ratio and the number of elements Num, and returns a list containing "Num" numbers in the Geometric series.
Pre-Conditions - firstElem should be an Number.
- ratio should be an Number.
- Num should be an integer >=1.
Geometric(firstElem=... | true |
24eb50260ff182ad58f58665b2bbbe609a713f6b | manansharma18/BigJ | /listAddDelete.py | 1,280 | 4.34375 | 4 | def main():
menuDictionary = {'breakfast':[],'lunch':[], 'dinner':[]}
print(menuDictionary)
choiceOfMenu = ''
while choiceOfMenu != 'q':
choiceOfMenu = input('Enter the category (enter q to exit) ')
if choiceOfMenu in menuDictionary:
addOrDelete= input('Do you want to list, a... | true |
d6f7a02cd03634786a3bf5168094e7560044cd18 | alexisanderson2578/Data-Structures-and-Algorithms | /SortingAlgorithms.py | 1,400 | 4.125 | 4 | def InsertionSort(alist):
for i in range(1,len(alist)):
key = alist[i]
currentvalue = i-1
while (currentvalue > -1) and key < alist[currentvalue]:
alist[currentvalue+1]= alist[currentvalue]
currentvalue =currentvalue-1
alist[currentvalue+1] = key
... | false |
0ab1712df48bd99d3e5c744138caaea015ca12e1 | Rupam-Shil/30_days_of_competative_python | /Day29.py | 496 | 4.1875 | 4 | '''write a python program to takes the user
for a distance(in meters) and the time was
taken(as three numbers: hours, minutes and seconds)
and display the speed in miles per hour.'''
distance = float(input("Please inter the distance in meter:"))
hour, min, sec = [int(i) for i in input("Please enter the time taken... | true |
48ded77911e4f9e63e254d4cc5265e02f8f593e1 | BrimCap/BoredomBot | /day.py | 1,010 | 4.3125 | 4 | import datetime
import calendar
def calc_day(day : str, next = False):
"""
Returns a datetime for the next or coming day that is coming.
Params:
day : str
The day you want to search for. Must be in
[
"monday"
"tuesday"
"wedn... | true |
ad1ae0039c48c95c13268cfd96241e93a858d57b | papri-entropy/pyplus | /class7/exercise4c.py | 710 | 4.15625 | 4 | #!/usr/bin/env python
"""
4c. Use the findall() method to find all occurrences of "zones-security".
For each of these security zones, print out the security zone name
("zones-security-zonename", the text of that element).
"""
from pprint import pprint
from lxml import etree
with open("show_security_zones.xml") as ... | true |
e0e0d097adba29f9673331887f6527caa5b3d2ad | fr3d3rico/python-machine-learning-course | /study/linear-regression/test4.py | 2,734 | 4.53125 | 5 | # https://www.w3schools.com/python/python_ml_polynomial_regression.asp
# polynomial regression
import matplotlib.pyplot as plt
x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
plt.scatter(x, y)
plt.show()
import numpy as np
import matplotlib.pyplot... | true |
02e08da64766c262406de320027d2d53b5e3dfa2 | Fanniek/intro_DI_github | /lambda.py | 1,305 | 4.53125 | 5 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 19:20:40 2019
@author: fannieklein
"""
#Exercise 1:
mylist =[" hello"," itsme ","heyy "," i love python "]
mylist = list(map(lambda s: s.strip(), mylist))
#print(mylist)
#Explanattion of Exercise 1:
#This function should use map function --> ma... | true |
fe4952c3cadc4c1f541a10d18a8a39f75cfdd42f | ivov/fdi | /FDI/3_9.py | 605 | 4.125 | 4 | # Leer un número correspondiente a un año e imprimir un mensaje indicando si es
# bisiesto o no. Se recuerda que un año es bisiesto cuando es divisible por 4. Sin
# embargo, aquellos años que sean divisibles por 4 y también por 100 no son bisiestos,
# a menos que también sean divisibles por 400. Por ejemplo, 1900 no... | false |
8ad71cb6e4e52fc454528ad87e4ecf657a6e406f | userddssilva/ESTCMP064-oficina-de-desenvolvimento-de-software-1 | /distances/minkowski.py | 513 | 4.125 | 4 | def minkowski(ratings_1, ratings_2, r):
"""Computes the Minkowski distance.
Both ratings_1 and rating_2 are dictionaries of the form
{'The Strokes: 3.0, 'Slightlyt Stoopid: 2.5}
"""
distance = 0
commonRatings = False
for key in ratings_1:
if key in ratings_2:
distance += ... | true |
9ad2e6f1e44f976b5a34b08705420da4ee5598b5 | nihal-wadhwa/Computer-Science-1 | /Labs/Lab07/top_10_years.py | 2,524 | 4.21875 | 4 | """
CSCI-141 Week 9: Dictionaries & Dataclasses
Lab: 07-BabyNames
Author: RIT CS
This is the third program that computes the top 10 female and top 10 male
baby names over a range of years.
The program requires two command line arguments, the start year, followed by
the end year.
Assuming the working directory is set... | true |
6f2539ffb11dc17d1f277f6cbe7e7ed2b10377a1 | loyti/GitHubRepoAssingment | /Python/pythonPlay/bikePlay.py | 1,065 | 4.15625 | 4 | class Bike(object):
def __init__ (price,maxSpeed,miles):
self.price = "$Really$ Expen$ive"
self.maxSpeed = maxSpeed
self.miles = 0
def displayInfo(self):
print "A little about your Bike: $Price: {}, {} max kph & {} miles traveled".format(str(self.price), int(self.maxSpeed), str(s... | true |
9bcc9a4088f6081d67388d517bc7d0ef80154e3e | securepadawan/Coding-Projects | /Converstation with a Computer/first_program_week2.py | 2,283 | 4.125 | 4 | print('Halt!! I am the Knight of First Python Program!. He or she who would open my program must answer these questions!')
Ready = input('Are you ready?').lower()
if Ready.startswith('y'):
print('Great, what is your name?') # ask for their name
else:
print('Run me again when you are ready!')
exit()
m... | true |
f4f8dfb4f59a722fd628f0634654aca2ba592a5e | NguyenLeVo/cs50 | /Python/House_Roster/2020-04-27 import.py | 1,569 | 4.1875 | 4 | # Program to import data from a CSV spreadsheet
from cs50 import SQL
from csv import reader, DictReader
from sys import argv
# Create database
open(f"students.db", "w").close()
db = SQL("sqlite:///students.db")
# Create tables
db.execute("CREATE TABLE Students (first TEXT, middle TEXT, last TEXT, house TEXT, birth NU... | true |
7bab4b14a82a9e79dd6dd2ebc52f6a1c315d9176 | JASTYN/30dayspyquiz | /exam/spaces.py | 253 | 4.1875 | 4 | """
Write a loop that counts the number of words in a string
"""
space = ' '
count = 0
sentence = input("Enter a sentence: ")
for letter in sentence:
if letter == space:
count = count + 1
print(f'Your sentence has {count + 1} words')
| true |
d29b0a47e7fe7df6a7906e8c96e7e43492c8ccd9 | JASTYN/30dayspyquiz | /exam/hey/finalav.py | 980 | 4.1875 | 4 | def getNumberList(filename):
f = open(filename,'r')
#opening the file
line = f.readline()
#reading the file line by line
numbers = line.split(',')
#The split() method splits a string into a list.
numberList = []
#An array to store the list
for i in numbers:
numberL... | true |
2e4e0012235649961b56e64101e1b417ef98738e | hemanthkumar25/MyProjects | /Python/InsertionSort.py | 409 | 4.21875 | 4 | def insertionSort(list):
for index in range(1,len(list)):
currentvalue = list[index]
position = index
while position > 0 and list[position-1]>currentvalue:
list[position] = list[position -1]
position = position -1
list[position] = currentv... | true |
a72bec9020e351bc3ef6e30d72aa3202021f2eab | severinkrystyan/CIS2348-Fall-2020 | /Homework 4/14.11 zylab_Krystyan Severin_CIS2348.py | 790 | 4.125 | 4 | """Name: Krystyan Severin
PSID: 1916594"""
def selection_sort_descend_trace(integers):
for number in range(len(integers)):
# Sets first number of iteration as largest number
largest = number
for i in range(number+1, len(integers)):
# Checks for number in list that is larger ... | true |
89d058658ca383637a76dc63c1156e98c90d5be4 | Vincent1127/Waste-Self-Rescue-Scheme | /雨初的笔记/备课/实训/day04/string3.py | 868 | 4.1875 | 4 | #coding:utf-8
#可以将字符串改为元组或者列表输出
la = 'python'
print(tuple(la))
print(list(la))
#得到字符对应的ASCII ord(str)得到ASCII码 chr(ASCII)得到字符串 ??如何随机的十位a-z的字符串??
print(ord('中'))
print(ord('a'))
#得到ASCII代指的字符
print(chr(20013))
print(chr(65))
#得到字符中某个字符的下标
print(la.index('t'))
print('y' in la)
#.strip()去除字符串中首尾的空格
strA = ' aaBcd... | false |
fbeaf00fea7890184e40e34f3e403b2121f6b289 | BriannaRice/Final_Project | /Final_Project.py | 1,201 | 4.125 | 4 | '''
I already started before I knew that they all had to go together
so some of it makes sense the rest doesn't
'''
# 3/11/19 Final Project
# Brianna Rice
print('Pick a number between 1 and 30', "\n")
magic_number = 3
guess = int(input('Enter a number:', ))
while guess != magic_number:
print('Guess again', "\n")
... | true |
b4faf014046390f8f5807217a159d0bda12d79c8 | jankovicgd/gisalgorithms | /listing25.py | 993 | 4.53125 | 5 | # 2.5 Determining the position of a point with the respect to a line
# Listing 2.5: Determining the side of a point
# Imports
from geometries.point import *
def sideplr(p, p1, p2):
"""
Calculates the side of point p to the vector p1p2
Input:
p: the point
p1, p2: the start and end points of... | false |
858fd9f1634b03d69550a3202c2f12a7295d568b | hutbe/python_space | /8-Decorators/decorators.py | 1,017 | 4.34375 | 4 | # Decorator
# Using a wrap function to add extra functions to a function
def my_decorator(fun):
def wrap_fun():
print(f"==== Function: {fun.__name__}")
fun()
return wrap_fun
@my_decorator
def say_hi():
print(f"Hello everyone, nice to be here!")
say_hi()
@my_decorator
def generator_even_odd():
result_list = [... | true |
9a6cd4518c1bb000496a8aef48336b7b5179f809 | hutbe/python_space | /13-FileIO/read_file.py | 1,054 | 4.34375 | 4 |
test_file = open('Test.txt')
print("File read object:")
print(test_file)
print("Read file first time")
print(test_file.read()) # The point will move to the end of file
print("Read file second time")
test_file.seek(0) # move the point back to the head of file
print(test_file.read())
print("Read file third time")
p... | true |
d5c8b082ed261c2e01b595bbe3eb2eb6b4366300 | LinLeng/xiaoxiyouran_all | /python2/20180718零基础学习python/Python-From-Zero-to-One/unmd/课时038 类和对象 继承/review002.py | 599 | 4.15625 | 4 | # Summary:定义一个点(Point)类和直线(Line)类,使用getLen方法可以获得直线的长度
# Author: Fangjie Chen
# Date: 2017-11-15
import math
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def getX(self):
return self.x
def getY(self):
return self.y
class Line(Point):
def __init__(s... | false |
ed8e8f7646b93809bf53f84dc4654ecc61ffbac7 | Omkar2702/python_project | /Guess_the_number.py | 887 | 4.21875 | 4 | Hidden_number = 24
print("Welcome to the Guess The Number Game!!")
for i in range(1, 6):
print("Enter Guess", int(i), ": ")
userInput = int(input())
if userInput == Hidden_number:
print("Voila! you've guessed it right,", userInput, "is the hidden number!")
print("Congratulations!!!!! You too... | true |
7fbdcfad250a949cb0575167c87d212f376e4d98 | vaish28/Python-Programming | /JOC-Python/NLP_Stylometry/punct_tokenizer.py | 405 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Punctuation tokenizer
"""
#Tokenizes a text into a sequence of alphabetic and non-alphabetic characters.
#splits all punctuations into separate tokens
from nltk.tokenize import WordPunctTokenizer
text="Hey @airvistara , not #flyinghigher these days we heard? #StayingParkedStayingSa... | true |
0290746b9b476109ea203930c5ccaaf2ec98bf31 | qwatro1111/common | /tests/tests.py | 1,917 | 4.125 | 4 | import unittest
from math import sqrt
from homework import Rectangle
class Test(unittest.TestCase):
def setUp(self):
self.width, self.height = 4, 6
self.rectangle = Rectangle(self.width, self.height)
def test_1_rectangle_perimeter(self):
cheack = (self.width+self.height)*2
res... | true |
8c44895f64d1161588c25e339ff6b23c82d8290e | KhaledAchech/Problem_Solving | /CodeForces/Easy/File Name.py | 2,425 | 4.375 | 4 | """
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the s... | true |
33290292667e0df5ef32c562b2320933446a118e | KhaledAchech/Problem_Solving | /CodeForces/Easy/Helpful Maths.py | 1,112 | 4.21875 | 4 | """
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough fo... | true |
df968f4a057fb8d98111729759b1ef5ddb2eb2b2 | dirtypy/python-train | /cn/yanxml/hello/firstStep.py | 265 | 4.125 | 4 | #!/usr/bin/python3
#coding=utf-8
#Python3 编程第一步
#Python3 first step of programming
#Fabonacci series
a,b=0,1
while b < 10:
print (b)
a,b=b,a+b;
i=265*256
print ("i 's value is : ", i);
a,b=0,1
while b<1000:
print(b,end=",")
a,b=b,a+b | false |
afebc658717b8f3badb5ee990c9d9e48ef32bc0e | makyca/Hacker-Rank | /Power-Mod_Power.py | 286 | 4.25 | 4 | #Task
#You are given three integers: a, b, and m, respectively. Print two lines.
#The first line should print the result of pow(a,b). The second line should print the result of pow(a,b,m).
a = int(raw_input())
b = int(raw_input())
m = int(raw_input())
print pow(a,b)
print pow(a,b,m)
| true |
e0f20d297d8816da124a9f4e8a41a23e680e95b7 | makyca/Hacker-Rank | /Sets-Symmetric_Difference.py | 719 | 4.28125 | 4 | #Task
#Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates
#those values that exist in either M or N but do not exist in both.
#Input Format
#The first line of input contains an integer, M.
#The second line contains M space-separated integers... | true |
8f6a0b68353c38fad53150c779444b96abc1b8e5 | levi-terry/CSCI136 | /hw_28JAN/bool_exercise.py | 1,284 | 4.15625 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: bool_exercise.py
# Purpose: This program is comprised of several functions.
# The any() function evaluates an array of booleans and
# returns True if any boolean is True. The all() function
# evaluates an array of booleans and returns True if all
# are True.
# Function to eval... | true |
1c73961f953b4686742f415bc9aaf2fe389f8d14 | levi-terry/CSCI136 | /hw_30JAN/recursion_begin.py | 1,860 | 4.15625 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: recursion_begin.py
# Purpose: This program implements two functions.
# The first function accepts an int array as a parameter
# and returns the sum of the array using recursion. The
# second function validates nested parentheses oriented
# correctly, such as (), (()()), and so o... | true |
7868d39dfc5a0e63481d605c23d303303c851bb9 | levi-terry/CSCI136 | /hw_28JAN/three_true.py | 912 | 4.34375 | 4 | # Author: LDT
# Date: 27JAN2019
# Title: three_true.py
# Purpose: This program implements a function which returns
# True if 1 or 3 of the 3 boolean arguments are True.
# Function to perform the checking of 3 booleans
def three_true(a, b, c):
if a:
if b:
if c:
return True
... | true |
f9646e355ca1ee3d740e122152613929508bb03d | theprogrammer1/Random-Projects | /calculator.py | 342 | 4.34375 | 4 | num1 = float(input("Please enter the first number: "))
op = input("Please enter operator: ")
num2 = float(input("Please enter the secind number: "))
if op == "+":
print(num1 + num2)
elif op == "-":
print(num1 - num2)
elif op == "/":
print(num1 / num2)
elif op == "*":
print(num1 * num2)
else:
print(... | false |
66afd8353ae48aa03ac42674765b59b18884d19a | wjwainwright/ASTP720 | /HW1/rootFind.py | 2,848 | 4.28125 | 4 | # -*- coding: utf-8 -*-
def bisect(func,a,b,threshold=0.0001):
"""
Bisect root finding method
Args:
func: Input function that takes a single variable i.e. f(x) whose root you want to find
a: lower bound of the range of your initial guess where the root is an element of [a,b]
b... | true |
fe0e8af3b6d088f25a8726e32abe1ab08c03b8c3 | vickyjeptoo/DataScience | /VickyPython/lesson3a.py | 381 | 4.1875 | 4 | #looping - repeat a task n-times
# 2 types :for,while,
#modcom.co.ke/datascience
counter = 1
while counter<=3:
print('Do Something',counter)
age=int(input('Your age?'))
counter=counter+1 #update counter
# using while loop print from 10 to 1
number=11
while number>1:
number=number-1
print(number... | true |
e9a0af2257266fa452fddf4b79e1939784bca493 | vickyjeptoo/DataScience | /VickyPython/multiplication table.py | 204 | 4.21875 | 4 |
number = int(input("Enter a number to generate multiplication table: "))
# use for loop to iterate 10 times
for i in range(1, 13):
print(number, 'x', i, '=', number * i)
#print a triangle of stars | true |
32bdec09e8dc8ef94efd14ff0ab50b7585fdda7d | vickyjeptoo/DataScience | /VickyPython/lesson5.py | 1,511 | 4.25 | 4 | #functions
#BMI
def body_mass_index():
weight=float(input('Enter your weight:'))
height=float(input('Enter your height:'))
answer=weight/height**2
print("Your BMI is:",answer)
#body_mass_index()
#functions with parameters
#base&height are called parameters
#these parameters are unknown,we provide them... | true |
6c29609d8a5ab1027cdff8124b794110b5a9e7fa | Aamecstha/pythonClass | /functionPart3.py | 1,132 | 4.1875 | 4 | # def main():
# def inner_func():
# print("i am inner function")
#
# def outer_func():
# print("i am outer function")
#
# return inner_func,outer_func
#
# print(main())
# inf,onf=main()
# inf()
# onf()
# def main(n):
# def add(a,b):
# return a+b
# def sub(a,b):
# ... | false |
a4322a82e093af0b6a1a4acdfcbb5540b7084db5 | PragmaticMates/python-pragmatic | /python_pragmatic/classes.py | 675 | 4.25 | 4 | def get_subclasses(classes, level=0):
"""
Return the list of all subclasses given class (or list of classes) has.
Inspired by this question:
http://stackoverflow.com/questions/3862310/how-can-i-find-all-subclasses-of-a-given-class-in-python
Thanks to: http://codeblogging.net/blogs/1/... | true |
bbf2d3478a74caf1156c2a174a2674366244857c | Code-JD/Python_Refresher | /02_string_formatting/code.py | 731 | 4.21875 | 4 | # name = "Bob"
# greeting = f"Hello, {name}"
# print(greeting)
# name = "Ralph"
# print(greeting)
# ---------------OUTPUT-------------
# Hello, Bob
# Hello, Bob
# name = "Bob"
# print(f"Hello, {name}")
# name = "Ralph"
# print(f"Hello, {name}")
# ---------------OUTPUT-------------
# Hello, Bob
# Hello, Ralph
... | false |
b09b2657f56cb03fae84b598ce256753b6eb4571 | prashant523580/python-tutorials | /conditions/neg_pos.py | 336 | 4.4375 | 4 | #user input a number
ui = input("enter a number: ")
ui = float(ui) #converting it to a floating point number
#if the number is greater then zero
# output positive
if ui > 0:
print("positive number")
#if the number is less then zero
#output negative
elif ui < 0:
print("negative number")
#in all other case
else:
... | true |
6d8d75053d9d281db48f32327598b55e1010ee78 | deepak1214/CompetitiveCode | /InterviewBit_problems/Sorting/Hotel Booking/solution.py | 1,298 | 4.34375 | 4 | '''
- A hotel manager has to process N advance bookings of rooms for the next season.
His hotel has C rooms. Bookings contain a list A of arrival date and a list B of departure date.
He wants to find out whether there are enough rooms in the hotel to satisfy the demand.
- Creating a function hotel which will take 3 ... | true |
4eb966b642158fd2266ae747d4cd6fcf694acfe2 | deepak1214/CompetitiveCode | /LeetCode_problems/Invert Binary Tree/invert_binary_Tree.py | 1,436 | 4.125 | 4 | from collections import deque
class TreeNode:
def __init__(self,val):
self.val = val
self.left = None
self.right = None
def insert(root,node):
if root is None:
root = node
else:
if root.val < node.val:
if root.right is None:
... | true |
d4cc2c4c13be0e76bb0b78f50f32dacef61b63ee | deepak1214/CompetitiveCode | /Hackerrank_problems/counting_valleys/solution.py | 1,605 | 4.125 | 4 |
# Importing the required Libraries
import math
import os
import random
import re
import sys
# Fuction For Counting the Valleys Traversed. Takes the number of steps(n) and The path(s[D/U]). Returns the Number.
def countingValleys(n, s):
count = 0
number_of_valleys = 0 # Initialized Variables... | true |
26614f5cbe266818c5f34b536b9f921c922a18d2 | WSMathias/crypto-cli-trader | /innum.py | 2,012 | 4.5625 | 5 | """
This file contains functions to process user input.
"""
# return integer user input
class Input:
"""
This class provides methods to process user input
"""
def get_int(self, message='Enter your number: ', default=0, warning=''):
"""
Accepts only integers
"""
hasInputN... | true |
b76b9aaa2581473624e311da1306aff5bedc5e0d | luckcul/LeetCode | /algorithms/Implement Queue using Stacks/ImplementQueueUsingStack.py | 1,276 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-11-30 21:13:57
# @Author : luckcul (tyfdream@gmail.com)
# @Version : 2.7.12
class Queue(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.stack = []
def push(self, x):
"""
... | false |
20191d04dad06de1f7b191ed7538828580eac557 | jeremycross/Python-Notes | /Learning_Python_JoeMarini/Ch2/variables_start.py | 609 | 4.46875 | 4 | #
# Example file for variables
#
# Declare a variable and initialize it
f=0
# print(f)
# # # re-declaring the variable works
# f="abc"
# print(f)
# # # ERROR: variables of different types cannot be combined
# print("this is a string" + str(123))
# Global vs. local variables in functions
def someFunction():
glo... | true |
6ec438602e86c1eeebbab11746d4445b84e0187a | jeremycross/Python-Notes | /Essential_Training_BillWeinman/Chap02/hello.py | 365 | 4.34375 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
x = 42
print('Hello, World. %d' % x) #you can use ''' for strings for '"' for strings, either works
# above line is legacy from python 2 and is deprecated
print('Hello, world. {}'.format(x))
# format is a function of the string object
print(f'Hello, world... | true |
6a2928e4bfce469b9681a4f263dd43d95b0d5c7f | AmiMunshi/mypythonprojects | /semiprime | 1,014 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 5 15:16:46 2019
@author: maulik
"""
def prime(num):
for i in range(2,num):
if num % i ==0:
#print("Not prime")
return False
break
else:
return True
#print("prime")
def semiprime(... | false |
9fbd24524c7fbeec9a79c7f6a2ecdc1d6992ab08 | Crewcop/pcc-exercises | /chapter_three_final.py | 822 | 4.21875 | 4 | # 3-8
# list of locations
destinations = ['london', 'madrid', 'brisbane', 'sydney', 'melbourne']
print(destinations)
# print the list alphabetically without modifying it
print('\nHere is the sorted list : ')
print(sorted(destinations))
# print the original order
print('\nHere is the original list still :')
print(dest... | true |
8b93a72a07be2865330628e84d8255718bf838d0 | aakash19222/Pis1 | /p.py | 351 | 4.1875 | 4 | def rotate(s, direction, k):
"""
This function takes a string, rotation direction and count
as parameters and returns a string rotated in the defined
direction count times.
"""
k = k%len(s)
if direction == 'right':
r = s[-k:] + s[:len(s)-k]
elif direction == 'left':
r = s[k:] + s[:k]
else:
r = ""
print... | true |
c8c3de51f3c5828ac8ce280924f83c7d8474b3c0 | PrinceCuet77/Python | /Extra topic/lambda_expression.py | 824 | 4.3125 | 4 | # Example : 01
def add(a, b) :
return a + b
add2 = lambda a, b : a + b # 'function_name' = lambda 'parameters' : 'return_type'
print(add(4, 5))
print(add2(4, 5))
# Example : 02
def multiply(a, b) :
return a * b
multiply2 = lambda a, b : a * b
print(multiply(4, 5))
print(multiply2(4,... | true |
bd802c4bae44b75a820c70349a5eab4221bac821 | PrinceCuet77/Python | /Tuple/tuple.py | 1,323 | 4.3125 | 4 | example = ('one', 'two', 'three', 'one')
# Support below functions
print(example.count('one'))
print(example.index('one'))
print(len(example))
print(example[:2])
# Function returning tuple
def func(int1, int2) :
add = int1 + int2
mul = int1 * int2
return add, mul
print(func(2, 3)) ... | true |
553c0af65afd7d80a9ebfca8a1bc80f1ab660726 | PrinceCuet77/Python | /List/list_comprehension.py | 1,520 | 4.28125 | 4 | # List comprehension
# With the help of list comprehension, we can create a list in one line
# Make a list of square from 1 to 10
sq = [i**2 for i in range(1, 11)]
print(sq)
# Create a list of negative number from 1 to 10
neg = [-i for i in range(1, 11)]
print(neg)
# Make a list where store the first character fro... | true |
712f46fc65f3c6d3c8ca8154748f9a942c6781f2 | cnaseeb/Pythonify | /queue.py | 815 | 4.125 | 4 | #!/usr/bin/python
class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items ==[] #further conditions implementation needed
def enqueue(self, item):
return self.items.insert(0, item) #further checks needed if queue already contains i... | true |
3b66cd079d10af6018cc90c45eacac8e52c053a6 | sporttickets/Portfolio-programming | /deciding.py | 212 | 4.25 | 4 | #learning about if statements
number = int(raw_input("enter your age\n"))
if number < 15:
print "you still are in middle school"
else:
print "you know everthing"
if number < 5:
print "you are not in school"
| false |
2d7308d13f713b7c98492c3a8aa0a95a2aad0903 | charliepoker/pythonJourney | /simple_calculator.py | 876 | 4.25 | 4 |
def add(x,y):
return x + y
def Subraction(x,y):
return x - y
def Multiplication(x,y):
return x * y
def Division(x,y):
return x / y
operation = input('''
Please type in the math operation you would like to complete:
+ for addition
- for subtraction
* for multiplication
/ for division
''')
num_1 = ... | true |
77f5fe9c0172c1eecc723b682a3d2c82eda2918d | charliepoker/pythonJourney | /lists.py | 2,340 | 4.40625 | 4 | #list is a value that contains multiple values in an ordered sequence.
number = [23, 67, 2, 5, 69, 30] #list of values assigned to number
name = ['mike', 'jake', 'charlie', 'tim', 'dave', 'jane'] #list of values assigned to name
print(name[2] + ' is ' + str(number[5]) + ' years old.')
#lis... | true |
0211c3fa0ff36391c2394f1ea8973d07d4555c87 | bodawalan/HackerRank-python-solution | /cdk.py | 2,845 | 4.3125 | 4 | # Q.1
#
# Write a function that takes as input a minimum and maximum integer and returns
# all multiples of 3 between those integers. For instance, if min=0 and max=9,
# the program should return (0, 3, 6, 9)
#
# A
# you can type here
def func(min, max):
for in xrange(min, max):
if (i % 3 == 0)
... | true |
07969f835c57729793df401fc7e367e4e6d399a6 | dodieboy/Np_class | /PROG1_python/coursemology/Mission32-CaesarCipher.py | 1,288 | 4.71875 | 5 | #Programming I
####################################
# Mission 3.2 #
# Caesar Cipher #
####################################
#Background
#==========
#The encryption of a plaintext by Caesar Cipher is:
#En(Mi) = (Mi + n) mod 26
#Write a Python program that prompts user to enter ... | true |
03396cc7b38b7a779ca33d376a6ccb33720289b0 | dodieboy/Np_class | /PROG1_python/coursemology/Mission72-Matrix.py | 1,081 | 4.25 | 4 | #Programming I
#######################
# Mission 7.1 #
# MartrixMultiply #
#######################
#Background
#==========
#Tom has studied about creating 3D games and wanted
#to write a function to multiply 2 matrices.
#Define a function MaxtrixMulti() function with 2 parameters.
#Both parameters are in ... | true |
c3ba57ea7ad83b5819851bafb7e88d62cd267c8d | jason-neal/Euler | /Completed Problems/Problem 5-smallest_multiple.py | 641 | 4.15625 | 4 | """Smallest multiple
Problem 5
2520 is the smallest number that can be divided by each of the numbers from 1 to
10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers
from 1 to 20?
"""
import numpy as np
def smallest_multiple(n):
"""Smallest multiple of numbe... | true |
cbc97978dbafa655d385b6741d6c046cb648cff4 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Basics/4_Conditional_Statements/fruit_or_vegitable.py | 386 | 4.34375 | 4 | product_name = input()
if product_name == 'banana' or product_name == 'apple' or product_name == 'kiwi' or product_name == 'cherry' or \
product_name == 'lemon' or product_name == 'grapes':
print('fruit')
elif product_name == 'tomato' or product_name == 'cucumber' or product_name == 'pepper' or product_nam... | true |
0569f8f4243c3694a236fd8daf00171893d8666c | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Fundamentals/03_Basic_Syntax_Conditions_Loops/maximum_multiple.py | 397 | 4.1875 | 4 | '''
Given a Divisor and a Bound, find the largest integer N, such that:
N is divisible by divisor
N is less than or equal to bound
N is greater than 0.
Notes: The divisor and bound are only positive values. It's guaranteed that a divisor is found
'''
divisor = int(input())
bound = int(input())
max_num = 0
for i in ra... | true |
5b3145219fbf8802f747d84079e0c4ca2099a4a8 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Basics/4_Conditional_Statements/number_100_200.py | 587 | 4.15625 | 4 | """
Conditional Statements - Lab
Check: https://judge.softuni.bg/Contests/Practice/Index/1012#0
06. Number 100 ... 200
Condition:
Write a program that reads an integer entered by the user and checks if it is below 100,
between 100 and 200 or over 200. Print messages accordingly, as in the examples below:
Sample input a... | true |
fc8c286f691360c9b96b4c91fa3fabeccade2aac | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Fundamentals/04_Lists/bread_factory.py | 2,805 | 4.3125 | 4 | """
As a young baker, you are baking the bread out of the bakery.
You have initial energy 100 and initial coins 100. You will be given a string, representing the working day events. Each event is separated with '|' (vertical bar): "event1|event2|event3…"
Each event contains event name or item and a number, separated b... | true |
b4bb635ae844e30f8fd58d64eeab5adda17726b2 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Fundamentals/04_Lists/04.Search.py | 1,153 | 4.3125 | 4 | """
Lists Basics - Lab
Check your code: https://judge.softuni.bg/Contests/Practice/Index/1724#3
SUPyF2 Lists Basics Lab - 04. Search
Problem:
You will receive a number n and a word. On the next n lines you will be given some strings.
You have to add them in a list and print them.
After that you have to filter out only ... | true |
5fc56d9d02475b497d20988fbe8a244faec680e9 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Basics/2_simple_calculations/Projects_Creation.py | 762 | 4.3125 | 4 | """
Simple Operations and Calculations - Lab
05. Creation Projects
Check: https://judge.softuni.bg/Contests/Compete/Index/1011#2
Write a program that calculates how many hours it will take an architect to design several
construction sites. The preparation of a project takes approximately three hours.
Entrance
2 lines a... | true |
b0e20c859c4c65478d955ee75ec04bbf2c0a370a | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Fundamentals/04_Lists/number_filter.py | 1,173 | 4.1875 | 4 | """
Lists Basics - Lab
Check your code: https://judge.softuni.bg/Contests/Practice/Index/1724#4
SUPyF2 Lists Basics Lab - 05. Numbers Filter
Problem:
You will receive a single number n. On the next n lines you will receive integers.
After that you will be given one of the following commands:
• even
• odd
• negative
• p... | true |
eec96339c928ff8c2148957172c237c2cb015a2f | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Basics/2_simple_calculations/Fish_Tank.py | 582 | 4.1875 | 4 | # 1. Read input data and convert data types
lenght = int(input())
width = int(input())
height = int(input())
percent_stuff = float(input())
# 2. Calculating aquarium volume
acquarium_volume = lenght * width * height
#3. Convert volume (cm3) -> liters
volume_liters= acquarium_volume * 0.001
#4. Calculating litter tak... | true |
73ca29ffb697d7e08b72cbc825a7a7672d989dd4 | happyandy2017/LeetCode | /Rotate Array.py | 2,287 | 4.1875 | 4 | # Rotate Array
# Go to Discuss
# Given an array, rotate the array to the right by k steps, where k is non-negative.
# Example 1:
# Input: [1,2,3,4,5,6,7] and k = 3
# Output: [5,6,7,1,2,3,4]
# Explanation:
# rotate 1 steps to the right: [7,1,2,3,4,5,6]
# rotate 2 steps to the right: [6,7,1,2,3,4,5]
# rotate 3 steps ... | true |
ab4b0424777999fbe22abb732279e9f3de3efeb3 | happyandy2017/LeetCode | /Target Sum.py | 2,048 | 4.125 | 4 | '''
Target Sum
Go to Discuss
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.
Find out how many ways to assign symbols to make sum of integers equal to target S.
Example 1:
Input: ... | true |
1e458d8bbd986b4b838f784b15ed9f6aaf5eccfc | mblue9/melb | /factorial.py | 928 | 4.1875 | 4 | import doctest
def factorial(n):
'''Given a number returns it's factorial e.g. factorial of 5 is 5*4*3*2*1
>>> factorial(0)
1
>>> factorial(1)
1
>>> factorial(3)
6
'''
if not type(n) == int:
raise Exception("Input to factorial() function must be an integer")
if n <... | true |
a000ab576b9eefeb3be6565177102dea660a1b74 | TrafalgarSX/graduation_thesis_picture- | /lineChart.py | 678 | 4.4375 | 4 | import matplotlib.pyplot as pyplot
# x axis values
x = [1,2,3,4,5,6]
# corresponding y axis values
y = [2,4,1,5,2,6]
# plotting the points
pyplot.plot(x, y, color='green',linestyle='dashed', linewidth=3, marker='*',markerfacecolor='blue',markersize=12, label = "line 1")
x1 = [1,2,3]
y1 = [4,1,3]
# plotting the line ... | true |
992e6ee0179e66863f052dce347c35e0d09b9138 | rowaxl/WAMD102 | /assignment/0525/factorial.py | 316 | 4.25 | 4 | def fact(number):
if number == 0:
return 1
if number == 1 or number == -1:
return number
if number > 0:
nextNum = number - 1
else:
nextNum = number + 1
return number * fact(nextNum)
number = int(input("Enter a number for calculate factorial: "))
print(f"{number}! = ", fact(number))
| true |
4b52d601646ac88a58de8e75d09481e65d758fa5 | seriousbee/ProgrammingCoursework | /src/main.py | 2,452 | 4.125 | 4 | def print_welcome_message():
print('Welcome to Split-it')
def print_menu_options():
menu_dict = {'About\t\t': '(A)', 'CreateProject\t': '(C)',
'Enter Votes\t': '(V)', 'Show Project\t': '(S)',
'Quit\t\t': '(Q)'}
for k, v in menu_dict.items():
print(f'{k} {v}') # not 100% w... | true |
d60ce1dada99b234ac9eaf94e2e59826656e048b | Abhirashmi/Python-programs | /Faulty_calculator.py | 934 | 4.3125 | 4 | op = input("Enter the operator which you want to use(+,-,*,/):")
num1 = int(input("Enter 1st Number:"))
num2 = int(input("Enter 2st Number:"))
if op == "+":
if num1 == 56 or num1 == 9:
if num2 == 9 or num2 == 56:
print("Addition of", num1, " and", num2, " is 77")
else:
print(... | false |
18c271cc6a83f2402125fe692919b625e2af5265 | shants/LeetCodePy | /225.py | 1,627 | 4.125 | 4 | class MyStack(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.q1 = []
self.q2 = []
self.isFirst = True
def push(self, x):
"""
Push element x onto stack.
:type x: int
:rtype: void
"""
... | false |
be4579851af7ea20e3ed8cfeeeb0e493426273c4 | mayankkuthar/GCI2018_Practice_1 | /name.py | 239 | 4.28125 | 4 | y = str(input(" Name "))
print("Hello {}, please to meet you!".format(y))
def reverse(s):
str = ""
for i in s:
str = i + str
return str
s = y
print ("Did you know that your name backwards is {}?".format(reverse(s))) | true |
72bbfab5a298cda46d02758aae824188c0703f8c | josan5193/CyberSecurityCapstone | /CapstoneMain.py | 859 | 4.1875 | 4 | def main():
while True:
Test1Word = input("What's your name?: ")
try:
Test1Num = int(input("Please choose one of three presidential candidates: \n 1. Donald Trump \n 2. Joe Biden \n 3. Bernie Sanders \n"))
if Test1Num >= 1 and Test1Num <= 3:
print("Congratulations," , Test1Word, ", you have voted!")
... | true |
49d2f9a2183b3fc93c29d450ae3e84923ceefea8 | python-packages/decs | /decs/testing.py | 907 | 4.4375 | 4 | import functools
def repeat(times):
"""
Decorated function will be executed `times` times.
Warnings:
Can be applied only for function with no return value.
Otherwise the return value will be lost.
Examples:
This decorator primary purpose is to repeat execution of some test fu... | true |
9279ba88a2f2fd3f7f3a5e908362cb0b0449c97d | KendallWeihe/Artificial-Intelligence | /prog1/main[Conflict].py | 1,477 | 4.15625 | 4 | #Psuedocode:
#take user input of number of moves
#call moves ()
#recursively call moves() until defined number is reached
#call main function
import pdb
import numpy as np
#specifications:
#a 0 means end of tube
#1 means empty
red_tube = np.empty(6)
red_tube[:] = 2
green_tube = np.empty(5)
gre... | true |
14709bc0146ea083df29d1d42f0c23abeae1d0d8 | HBlack09/ICTPRG-Python | /Examples/upperlower.py | 225 | 4.375 | 4 | # upper/lower case example
txt = "Hello my friends"
txt2 = txt.upper()
print(txt)
print(txt2)
txt3 = txt.lower()
print(txt3)
t1 = "aBc"
t2 = "AbC"
print("t1: ", t1)
print("t2: ", t2)
print(t1 == t2)
print(t1.upper() == t2.upper())
| false |
cc315e7aa80c04128721d665deb4c1eadf081d8f | YaqoobAslam/Python3 | /Assignment/Count and display the number of lines not starting with alphabet 'A' present in a text file STORY2.TXT.py | 863 | 4.53125 | 5 | Write a function in to count and display the number of lines not starting with alphabet 'A' present in a text file "STORY.TXT".
Example:
If the file "STORY.TXT" contains the following lines,
The rose is red.
A girl is playing there.
There is a playground.
An aeroplane is in the sky.
Numbers are not allowed in the pass... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.