blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c866045f8650d004b4541b8a06365930eddc9b5c | SiddharthandTiger/Sid | /P5.py | 570 | 4.1875 | 4 | a= float(input("Enter your height 'ONLY NUMERICAL VALUE':-"))
b= input("Enter your height unit (i.e. the value you have given above is in cm or m or feets or inches):-")
c= float(input("enter your weight in KG:-"))
if(b=='cm'):
print('your BMI is',c/((a/100)**2))
elif(b=='m'):
... | true |
3facb7b380373a4c610f4e795b52395c5268fb75 | paulobonfim/praticando-python | /calculadora.py | 1,031 | 4.25 | 4 | print("")
print("**************Python Calculator*****************")
print("")
print("Selecione o número da operação desejada:")
print("")
print("1 - Soma")
print('2 - Subtração')
print('3 - Multiplicação')
print('4 - Divisão')
def soma(num1,num2):
return num1 + num2
#essa opção com a função soma eu usei o retunr pq... | false |
f30e704333cd8ce32839e928a993fca50a3cdc01 | Leandro-Kogan/python_script | /herencia.py | 1,818 | 4.125 | 4 | """La herencia hace referencia a dos clases, una padre y la otra clase hija
como por ejemplo podemos decir que hay una clase llamada persona, donde tenemos
las caracteristicas pertenecientes a cualquier persona y luego tenemos una clase
llamada empleado, donde se le adjudicaran atributos especificos pertenecientes
a... | false |
aa9168455b376a7e4ff03366b971f4de63a16bc9 | gurpsi/python_projects | /python_revision/11_tuple.py | 1,039 | 4.34375 | 4 | '''
List a = [1,2,3]
List occupies more space as we have more number of methods available with it and it is mutable.
i.e. Add, Remove, Change data.
Tuple b = (1,4,6,9)
Occupies less memory as we have less number of methods available with it, and it is immutable.
i.e. Cannot be changed.
'''
import sys
import timeit
#... | true |
9579290c232afeaa6b436a5de107239a35697fee | jyotikasingh133/Jyotika-Singh | /hello.py | 1,484 | 4.34375 | 4 | #dictionary data type in python
>>> student={"name":"jyotika", "age":19} #NAME,AGE: KEYS & JYOTIKA,AGE ARE VALUES#
>>> student
{'name': 'jyotika', 'age': 19}
>>> student["name"]
'jyotika'
>>> student["age"]=21 #AGE IS UPDATED FROM 19 TO 21
>>> student
{'name': 'jyotika', 'age': 21}
>>> student["colle... | false |
49ae693e992687dc0034379a74e4a6c072b758f6 | csfx-py/hacktober2020 | /fizzBuzz.py | 392 | 4.34375 | 4 | #prints fizzz if number is divisible by 3
#prints buzz if number is divisible by 5
#prints fizzbuzx if divisible by both
def fizzbuzz(number):
if(number%3 == 0 and number%5 == 0):
print("fizzbuzz")
elif(number%3 == 0):
print("fizz")
elif(number%5 == 0):
print("buzz")
else:
... | true |
76cfbd5e7ea13120b5c46dff5febce0b24e6988d | csfx-py/hacktober2020 | /python-programs/data-visualization-matplotlib-pandas/retail_visualize.py | 2,685 | 4.21875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
if __name__ == '__main__':
retail_csv = pd.read_csv("BigMartSalesData.csv")
# 1. Plot Total Sales Per Month for Year 2011. How the total sales have increased over months in Year 2011.
df = retail_csv.query("Year == 2011").filter(["Mon... | true |
cc90a561902bfc788ade5a2925905bba658db3cd | MJ702/pythonprogamming | /cryptography/method/caesar_cipher.py | 430 | 4.21875 | 4 | def encrypt(text, key):
result = ""
for i in range(len(text)):
char = text[i]
if char.isupper():
result += chr((ord(char) + key - 65) + 65)
else:
result += chr((ord(char) + key - 97) + 97)
return result
text = str(input("Enter your string to encrypt data: "... | true |
27bdbaddd1b0b3dd7092969aa78fada7b29992e2 | MJ702/pythonprogamming | /pyton/oparators/bitwise.py | 1,290 | 4.5 | 4 | # bitwise operators are used to compare binary number
# &, | , ^ ,~ , << , >>
# bitwise AND
print("\nAND")
print(10 & 4)
"""
Returns 1 if both the bits are 1 else 0.
a = 10 = 1010 (Binary)
b = 4 = 0100 (Binary
a & b = 1010
&
0100
= 0000
= 0 (Decimal)... | false |
a220e724eaa168abd6b75365c1dfe4c2a8866f53 | doa-elizabeth-roys/CP1404_practicals | /prac_3/password_check.py | 440 | 4.125 | 4 | MIN_LENGTH = 8
def main() :
password = get_password(MIN_LENGTH)
print_asterisks(ACTUAL_LENGTH)
ACTUAL_LENGTH = len(password )
if ACTUAL_LENGTH < MIN_LENGTH :
print ( "Enter a password with atleast {} characters".format ( MIN_LENGTH ) )
password = input ( "Enter password: " )
else :
print_asterisk(A... | false |
d24086a0e9a5e5ddf882e0b5d3b829d304041e23 | doa-elizabeth-roys/CP1404_practicals | /prac_05/word_occurrences.py | 440 | 4.40625 | 4 | user_input = input("Text:")
word_count_dict = {}
words = user_input.split()
print(words)
for word in words:
word_count_dict[word] = word_count_dict.get(word,0) + 1
words = list(word_count_dict.keys())
words.sort()
# use the max function to find the length of the largest word
length_of_longest_word = max((len(word) fo... | true |
607fa56c3bbec30c64ed08ef5c1b06cdac2e2410 | whdesigns/Python3 | /1-basics/6-review/2-input/1-circle.py | 399 | 4.53125 | 5 | import math
# Read radius from user
print("Please enter radius")
radius = float(input())
# Calculate area and circumference
area = math.pi * (radius * radius)
# alternative
# math.pi * (radius ** 2)
# math.pi * pow(radius, 2) # Best for more advanced code
circumference = 2 * math.pi * radius
# Display result
print(... | true |
36f6cc335f53c4c86fd0de9576278e9c38367115 | maread99/pyroids | /pyroids/lib/physics.py | 418 | 4.15625 | 4 | #! /usr/bin/env python
"""Physics Functions.
FUNCTIONS
distance() Direct distance from point1 to point2
"""
import math
from typing import Tuple
def distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float:
"""Return direct distance from point1 to point2."""
x_dist = abs(point1[0] - point2[0])
... | true |
3f56f4b41784ae7476834a851926d9e578501808 | AndreeaEne/Daily-Programmer | /Easy/239.py | 1,266 | 4.125 | 4 | # Back in middle school, I had a peculiar way of dealing with super boring classes. I would take my handy pocket calculator and play a "Game of Threes". Here's how you play it:
# First, you mash in a random large number to start with. Then, repeatedly do the following:
# If the number is divisible by 3, divide it by 3.... | true |
43a6204ab7f836ebf6c5b97403fc6df968a1aafc | laplansk/learnPythonTheHardWay | /ex6.py | 1,041 | 4.40625 | 4 | # These declare and instantiate string variables
# in the case of x, %d is replaced by 10
# in the case of y, the first %s is replaced by the value of binary
# and the second is replaced by the value of do_not
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those w... | true |
ef5407467b1a7da16a79c927729f4d157f042499 | nishantml/Data-Structure-And-Algorithms | /recusrion/program-1.py | 261 | 4.1875 | 4 | def fun1(x):
if x > 0:
print(x)
fun1(x - 1)
print('completed the setup now returning')
fun1(3)
"""
In Above First printing was done the recursive call was made
Printing was done at calling time that before the function was called
""" | true |
0281244f624f9d6c3d83e1a2294d327a000132d7 | nishantml/Data-Structure-And-Algorithms | /startup-practice/get_indices.py | 596 | 4.15625 | 4 | """
Create a function that returns the indices of all occurrences of an item in the list.
Examples
get_indices(["a", "a", "b", "a", "b", "a"], "a") ➞ [0, 1, 3, 5]
get_indices([1, 5, 5, 2, 7], 7) ➞ [4]
get_indices([1, 5, 5, 2, 7], 5) ➞ [1, 2]
get_indices([1, 5, 5, 2, 7], 8) ➞ []
Notes
If an element does not exist i... | true |
f92c49b214c64a797c8e6276ffd068f3e6ac5478 | nishantml/Data-Structure-And-Algorithms | /Hash/keyword-rows.py | 1,270 | 4.21875 | 4 | """
Given a List of words, return the words that can be typed using letters of alphabet on only one row's
of American keyboard like the image below.
Example:
Input: ["Hello", "Alaska", "Dad", "Peace"]
Output: ["Alaska", "Dad"]
Note:
You may use one character in the keyboard more than once.
You may assume the... | true |
3da81d30e6f07bceff071f6b48da10100f2cf4b8 | nishantml/Data-Structure-And-Algorithms | /complete-dsa/array/maxSubArray.py | 849 | 4.15625 | 4 | """
53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Example 2:
Input: nums = [1]
Output: 1
Exampl... | true |
207b15ac6ca59619d6a17eab2ad4064d111f39b2 | nishantml/Data-Structure-And-Algorithms | /basics-data-structure/queue/implementQueueUsingLinkedList.py | 1,735 | 4.21875 | 4 | class Node:
def __init__(self, data=None):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.first = None;
self.last = None;
self.length = 0;
def enqueue(self, data):
new_node = Node(data)
if self.first is None:
sel... | true |
b03744213e17b2f45a3990ec4cb803c1ef49fb77 | nishantml/Data-Structure-And-Algorithms | /basics-data-structure/queue/implementQueueUsingArray.py | 1,714 | 4.125 | 4 | class Queue:
def __init__(self):
self.array = []
self.length = 0
# adding the data to the end of the array
def enqueue(self, data):
self.array.append(data)
self.length += 1
return
# popping the data to the start of the array
def dequeue(self):
poped ... | true |
40dcadcd7aa500001b2a52db747ee1bf3f340ef8 | andrewar/primes_challenge | /primes/primes.py | 1,562 | 4.15625 | 4 | import sys
def print_primes(n):
"""Print out the set of prime numbers, and their multiples"""
primes_list = get_primes(n)
mult_table = {}
# Get the largest val for the formatting fields
cell_size = len(str(primes_list[-1]**2))
print(" %*s"%(cell_size, " "), end=" ")
for i in range(len... | true |
33cbd8235d4731b0497356f6768effe36034cca3 | datadave/machine-learning | /brain/converter/calculate_md5.py | 1,348 | 4.4375 | 4 | #!/usr/bin/python
'''@calculate_md5
This file converts an object, to hash value equivalent.
'''
import hashlib
def calculate_md5(item, block_size=256*128, hr=False):
'''calculate_md5
This method converts the contents of a given object, to a hash value
equivalent.
@md5.update, generate an md5 che... | true |
0fc21bdcf2ef872f72b86a5b581289533e34eba6 | mevans86/rosalind | /signed_permutations.py | 978 | 4.125 | 4 | import itertools
import math
def list_of_signed_permutations(n):
"""Lists all possible signed permutations of +-1, 2, 3, ..., n."""
ret = [ ]
for mult in list(itertools.product([-1, 1], repeat=n)):
for perm in list(itertools.permutations(range(1, n+1))):
ret.append(tuple([x * y for x, y in zip(list(mult), perm... | true |
aa9cce79ad87722276485c7f47d71dfd922d7de6 | PFSWcas/CS231n_note | /python/Assignment2/test_as_strided.py | 1,153 | 4.125 | 4 | import numpy as np
def rolling_window(a, window):
"""
Make an ndarray with a rolling window of the last dimension
Parameters
----------
a : array_like
Array to add rolling window to
window : int
Size of rolling window
Returns
-------
Array that is a view of the... | true |
c4acc908848a00d733add4aca3f199abfcb01f90 | AmeerCh/programs | /python/product.py | 361 | 4.40625 | 4 | print('To find the product of three numbers, ',end = '')
Number1 = int(input('enter the first number:'))
Number2 = int(input('Enter the second number:'))
Number3 = int(input('Enter the third number:'))
Product = Number1 * Number2 * Number3
print('The product of ' + str(Number1) + ', ' + str(Number2) + ' and ' + st... | true |
a380c16b83a1955e6177f5d9c58219a28e0c37fe | CardinisCode/CS50_aTasteOfPython | /loops.py | 444 | 4.34375 | 4 |
statement = "Hello world!"
# Lets print a statement 10x
# Using a While loop:
# i = 0
# while i < 10:
# print(statement)
# i += 1
# # Using a for loop
# for i in range(0, 10):
# print(i + 1, ":", statement)
# Lets take user input to know how many times we should repeat our statement:
# repeat = int(i... | true |
10de18333ff1f9ae2d56a1a4fa32190dd3e61b73 | Th3Av1at0r/CIS106-Avi-Schmookler | /Assignment 7/Activity 2.py | 2,604 | 4.1875 | 4 | # this program takes your age
# in years and gives it back
# in months, days, hours, or seconds
def get_years():
variable = 0
while variable == 0:
print("how many years old are you?")
years = input()
if years.isdigit():
return float(years)
else:
... | true |
fbd01ecb2d1feced945e6b8571262954aa9522c2 | Th3Av1at0r/CIS106-Avi-Schmookler | /Assignment 5/Activity 7.py | 735 | 4.125 | 4 | def get_dog_name():
print("What's your dog's name?")
dog_name = (input())
return dog_name
def display_result(dog_name, dog_age):
print(str(dog_name) + " is " + str(dog_age) + " years old in dog years")
def get_human_dog_age():
print("How many years old is your dog?")
human_dog_age =... | true |
65747b4d5abe06171304fa704489c60e1b3b74b6 | hernu123/-2020-2021-Spring-Term---Assignment-iv | /main.py | 392 | 4.21875 | 4 | number = int(input("Enter a natural number : "))
if number < 1:
print("Number needs to be greater than 1")
elif number == 1:
print(number, " is neigher prime nor composite")
else:
for divisor in range(2, (number//2)+1):
if (number % divisor) == 0:
print(number,"is a Composite Number")
... | true |
2b759b41c93f550b08eaece0cd0cb90665d88a1c | AthishayKesan/Python-is-Easy-Pirple.com- | /main.py | 2,902 | 4.21875 | 4 |
"""
Pirple.com : Python is Easy
Chapter 1 : Variables
Homework#1
"""
Song = "Dance Monkey" #String
Genere = "Electropop" #String
LyricistFirstName = "Toni"#String
LyricistLastName = "Watson" #String
LyricistFullName = LyricistFirstName + " " + LyricistLastName #String combine
Producer = "Konstantin Kerst... | false |
66325e151b3f2faa5330e7c81b540fbeba460a05 | natelee3/python2 | /largest_number.py | 239 | 4.34375 | 4 | #Largest Number
#Create a list of numbers and print the largest number.
simple_list = [3, 4, 5, 455, 7, .5]
largest = 0
for num in simple_list:
if num > largest:
largest = num
print("The largest number is " + str(largest))
| true |
70b64bb3ed106042aaeef9725e63c45b6c6597ab | aliciamorillo/Python-Programming-MOOC-2021 | /Part 2/13. Alphabetically in the middle.py | 277 | 4.25 | 4 | letter1 = input("1st letter:")
letter2 = input("2nd letter:")
letter3 = input("3rd letter:")
word = letter1 + letter2 + letter3
def sortString(str):
return ''.join(sorted(str))
sortedWord = sortString(word)
print("The letter in the middle is", sortedWord[1]) | true |
166c104c7ebe8887d9024c1f9c38c48cf097c351 | aliciamorillo/Python-Programming-MOOC-2021 | /Part 1/10. Story.py | 438 | 4.28125 | 4 | #Please write a program which prints out the following story.
# The user gives a name and a year, which should be inserted into the printout.
name = input("Please type in a name: ")
year = input("Please type in a year: ")
print(name +" is valiant knight, born in the year " + year + ". One morning " + name + " wok... | true |
b104fd468a1d78cc3fd81dff7447034a121aa80c | aliciamorillo/Python-Programming-MOOC-2021 | /Part 1/14. Times five.py | 239 | 4.28125 | 4 | #Please write a program which asks the user for a number.
# The program then prints out the number multiplied by five.
number = int(input("Please type in a number:"))
plusNumber = number * 5
print(f"{number} times 5 is {plusNumber}") | true |
4381ba344238c7ef2e13b41bc46a376ea263283d | lvamaral/RubyAlgorithms | /Dynamic Programming/ways_to_make_change.py | 918 | 4.1875 | 4 | # Print a single integer denoting the number of ways we can make change for n dollars using an infinite supply of "coins" types of coins.
def make_change(coins, n, index = 0, memo = {}):
if n == 0:
return 1
if index >= len(coins):
return 0
#Save the current amount being considered and the ... | true |
c62b31e26706cd226cae4272f1cf605aa4be4449 | limahseng/cpy5python | /compute_bmi.py | 420 | 4.375 | 4 | # Filename: compute_bmi.py
# Author: Lim Ah Seng
# Created: 20130221
# Modified: 20130221
# Description: Program to get user weight and height and
# calculate body mass index
# main
# prompt and get weight
weight = int(input("Enter weight in kg: "))
# prompt and get height
height = float(input("Enter height in m: ")... | true |
21f60b7d94eba832b6ebcc239e36ccf3e9659420 | sivamu77/upGrade_assignment3 | /assignment_3.py | 1,020 | 4.40625 | 4 | import numpy as np
#1 Create a numpy array starting from 2 till 50 with a stepsize of 3.
arr=np.arange(2,50,3)
print(arr)
#2 Accept two lists of 5 elements each from the user. Convert them to numpy arrays. Concatenate these arrays and print it. Also sort these arrays and print it.
ip1=np.array([int(input()) ... | true |
b4db2715ae8bcc60054ac33698703d5549e71410 | shadydealer/Python-101 | /Solutions/week02/simplify_fraction.py | 854 | 4.15625 | 4 | def gcd(a,b):
if b == 0:
raise ZeroDivisionError("Cannot mod with zero.")
t = 0
while b != 0:
t = b
b = a% b
a = t
return a
def simplify_fraction(fraction):
if fraction[1] == 0:
raise ZeroDivisionError("Denominator cannot be zero.")
greatest_common_divid... | true |
58d9fa137a59df449b58aaedc1e97d1365efdd36 | Jainesh-roy/guess-the-number | /guess the number.py | 644 | 4.15625 | 4 | # exercise 3
# guess the number
import random
rand_num = random.randint(0,20)
guesses = 0
print("welcome to the game - Guess the number")
print("you have only 9 chances to guess the number\n")
while guesses < 9:
inp = int(input("Enter a number: "))
if inp > rand_num:
print("\nenter a smaller number")
... | true |
7befe78ab3db0f80d82bdd423d442075f46dd168 | Spiritual-Programmer/Python-Course | /working_strings.py | 720 | 4.40625 | 4 | #working with strings and functions
phrase = "Giraffe Academy"
#can use \ to add " or other texts
#\n starts text on next line
#concatenation(adding or appending on) with strings
print(phrase + " is cool, plus me concatening strings")
#functions
print("converting string into uppercase letter")
print(phrase.upper)
... | true |
356efc42abb2c8fd6e16f5d9ceb478ea15c0c63f | akuppala21/Fundamentals-of-CS | /lab4/loops/cubesTable.py | 1,454 | 4.28125 | 4 |
def main():
table_size = get_table_size()
while table_size != 0:
first = get_first()
inc = get_increment()
show_table(table_size, first, inc)
table_size = get_table_size()
# Obtain a valid table size from the user
def get_table_size():
size = int(input("Enter number of rows in table (... | true |
3281bd5d113b45083483cd808da405bf3d6882e0 | dTenebrae/Python | /lesson2/lesson2_2.py | 1,092 | 4.1875 | 4 | # Для списка реализовать обмен значений соседних элементов, т.е.
# Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д.
# При нечетном количестве элементов последний сохранить на своем месте.
# Для заполнения списка элементов необходимо использовать функцию input().
listA = []
while True:
list_value = ... | false |
f8f61ab1a1037adb9cfa8d5fe038ef4c884a8370 | Liam-Hearty/ICS3U-Assignment-6B-Python | /triangle_perimeter_calculator.py | 1,222 | 4.25 | 4 | #!/usr/bin/env python3
# Created by: Liam Hearty
# Created on: October 2019
# This program calculates perimeter of a triangle.
def calculate_perimeter(L1, L2, L3):
# calculate perimeter and return perimeter
import math
# process
perimeter = L1 + L2 + L3
return perimeter
def main():
# thi... | true |
1a957a9416beb42eda2655006589afc595ed5086 | honeywang991/test01 | /python9/class_0721_list_tuple_dict/class_list.py | 931 | 4.21875 | 4 | __author__ = 'zz'
#列表 list 标识符[]
#特性: 1:他可以包含任何类型的数据,数据之间用逗号隔开
#2:元组取值的方式: 列表名[索引的值]
#3: 他的索引是从0开始的
#4:列表可以进行增删改
list_1 = [1,'hello',8.6,(1,2,3,4),[5,6,9,10]]
#出一个小题目:把(1,2,3,4)里面的3 替换成‘Python9’
# list_1[3][2]='python9' #不能改
# print(list_1)
# print(list_1[3][2])
list_1[3]='python9'
print(list_1)
#取[5,6,9,10]中的5
# pr... | false |
28b5ede7a2a33bffdc8457344eeb32ee53cb01d7 | shoredata/dojo-python | /dojo-python-misc/fn_basic_2.py | 2,074 | 4.34375 | 4 | # Functions Basic II
# ====================
# Objectives
# --------------------
# Learn how to create basic functions in Python
# Get comfortable using lists
# Get comfortable having the function return an expression/value
# Countdown - Create a function that accepts a number as an input.
# Return a new array that c... | true |
3689b5598cb5d4e686f99c9eb2f9423b19203ef6 | RAHULMJP/impact_assignment | /attendence_assignment.py | 1,484 | 4.15625 | 4 | ## Question
# In a university, your attendance determines whether you will be allowed to attend your graduation ceremony.
# You are not allowed to miss classes for four or more consecutive days.
# Your graduation ceremony is on the last day of the academic year, which is the Nth day.
# Your task is to determi... | true |
d558701ef05d2344550e741e04efb3970153c9ca | neerajkumar0/firstPython | /TrialPythonProgram/test.py | 1,647 | 4.28125 | 4 | #!/usr/bin/python
print ("Hello, Python!");
class familyMember:
'Details of family member'
def __init__(self,name,age,sex,memberType):
self.name = name
self.age = age
self.sex = sex
self.memberType = memberType
def DisplayMember(self):
print ("\nName : ", self.name, " Age : ", self.age, " Sex : ", self... | false |
07bb532beaf548f1e074fcb8c4fa601c3433b6f4 | rpryzant/code-doodles | /interview_problems/2019/pramp/drone.py | 997 | 4.125 | 4 | """
drone flight planner
minimum amount of energy for drone to complete flight
burns 1 per ascend
gains 1 per descend
sideways is 0
given
route: array( triples )
e.g. route = [ [0, 2, 10],
[3, 5, 0],
[9, 20, 6],
[10, 12, 15],
[10, 10... | true |
30e568bd8619ad5385f961ad0529b9c6ba3f7f9a | rashonmitchell/projeto-algoritmos | /1_introducao/19_this_self.py | 304 | 4.1875 | 4 | """
Nesta implementação em Java, o objetivo é ilustrar o uso do objeto 'this'. Em
Python, o objeto equivalente é 'self'.
"""
class Conta:
def __init__(self, saldo):
self.saldo = saldo
if __name__ == "__main__":
conta_teste = Conta(123.45)
assert conta_teste.saldo == 123.45
| false |
6201b019816bde69b2c679f0715585154c7443a8 | Jardon12/dictionary | /dictionaryoperator.py | 586 | 4.75 | 5 | # empty dictionary
d={}
print(f"my dictionary is {d}")
students = {1: "John", 2: "Valentina", 3: "Beatriz"}
students_list = {"John", "Valentina", "Beatriz"}
# add a new student
students[7] = "Carlos"
print(f"my students are: {students}")
# In a dictionary the order is not important, because you have keys to access th... | true |
e442ff2b09bedaf9ce8a69d3bee8bd565f849375 | omkar6644/Python-Training | /Assignment/2.py | 514 | 4.1875 | 4 | #the below program takes 3 inputs from the user and finds a quadratic equation.
#import square root function from math module
from math import sqrt
a = float(input("a=: "))
b = float(input("b=: "))
c = float(input("c=: "))
#Quadratic function
def quadEqu(a, b ,c):
d = b**2-4*a*c
if d > 0:
x... | true |
d246141eb7b825492dd658c0de99fed57fe9d12d | omkar6644/Python-Training | /encapsulation.py | 1,616 | 4.375 | 4 | #encapsulation of private methods
#encapsulation is a process of binding the data and code together or it is the process of providing controlled access to the private members of the class.
class Car:
def __init__(self):
self.__updateSoftware()
def drive(self):
print('driving')
d... | true |
eb207182c7235e1b63aa899e387e833a429dbe8f | kinalee/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/3-say_my_name.py | 541 | 4.4375 | 4 | #!/usr/bin/python3
"""
3-say_my_name
that prints "My name is " and two given arguments
Contains one module: say_my_name
"""
def say_my_name(first_name, last_name=""):
"""
first_name and last_name should be strings
"""
try:
print("My name is {:s} {:s}".format(first_name, last_name))
except:... | true |
d6057b286992e14e2fdd09d65fcc64c4fd09a7b8 | StephenPrivette/Project-Euler | /Euler Problem 14.py | 1,050 | 4.15625 | 4 | ##The following iterative sequence is defined
##for the set of positive integers:
##
##n → n/2 (n is even)
##n → 3n + 1 (n is odd)
##
##Using the rule above and starting with 13,
##we generate the following sequence:
##
##13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
##It can be seen that this sequence
##(start... | true |
938adaab2d7f01cf3a5f38f96baa3310ac409ef1 | vivekbishwokarma99/Lab_Project | /LabFour/Qn_Three.py | 282 | 4.125 | 4 | '''
3.Write a Python program to guess a number between 1 to 9.Note :User is prompted to enter a guess.
If the user guesses wrong then the prompt appears again until the guess is correct, on successful guess,
user will get a "Well guessed!" message, and the program will exit.
''' | true |
2974b099406508d4dfe83937b9d532a94e89f3d7 | kroze05/Tarea_2 | /T2Funciones/1_ejercicio.py | 356 | 4.125 | 4 | #1) Realiza una función llamada area_rectangulo() que devuelva el área del rectangulo a partir de una base y una altura. Calcula el área de un rectángulo de 15 de base y 10 de altura.}
def area_rectangulo(base,altura):
res=base*altura
print(f"El area del rectangulo de base {base} y de altura {altura} es igual a... | false |
cca9b7e9503372777d4e6ac612e433c2f2c2dcfc | cesarm9/PythonExercises | /function_sum_2_numbers.py | 302 | 4.125 | 4 | def sum(a, b): #names the function as sum and takes parameters a and b
total = a + b #saves the sum of a and b in the total variable
return total #returns total as the result of the function
print(sum(2, 3)) #prints the value of return according to the parameters given to the sum function | true |
ff2a4d85240db1fabf1ca8e938f115b900fb6770 | veryamini/Competitive-Programming | /GeeksForGeeks/DynamicProgramming/tiling.py | 440 | 4.125 | 4 |
# Q: https://www.geeksforgeeks.org/tiling-problem/
# count(n) = count(n-1) + count(n-2)
# count(n) = n if n = 1, n = 2
# converts in fibbonacci series with different starting numbers
def fib(n):
a = 1
b = 2
if n == 0:
print("WRONG INPUT!")
elif n == 1 or n == 2:
return n
else:
for i in range(2, n):
c ... | false |
7a6d13483d43d23e51ae6ea11d9521afaedf4720 | NguyenDuyCuong/Learning | /Python/whileloop.py | 558 | 4.28125 | 4 | i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
else:
print("i is no longer less than 6")
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
for x in "banana":
print(x)
for x in range(6):
print(x)
# The range() function defaults to increment the sequence by 1, h... | true |
af17172772fd42b3a09b0686f8f254de6b2e3398 | NguyenDuyCuong/Learning | /Python/myscope.py | 852 | 4.21875 | 4 | # A variable created inside a function belongs to the local scope of that function, and can only be used inside that function.
# The local variable can be accessed from a function within the function:
def myfunc():
x = 300
def myinnerfunc():
print(x)
myinnerfunc()
myfunc()
# A variable created in the main ... | true |
222aed1628d593bb583a5999a76eca65c24cd499 | iamdanielchino/wejapa20wave1 | /Lab1of2.py | 855 | 4.34375 | 4 | #Quiz: Calculate
#In this quiz you're going to do some calculations for a tiler.
#Two parts of a floor need tiling. One part is 9 tiles wide by 7 tiles long, the other is 5 tiles wide by 7 tiles long. Tiles come in packages of 6.
#1. How many tiles are needed?
#2. You buy 17 packages of tiles containing 6 tiles each. ... | true |
2fb38524c9050f84d9edc3e9285cfcb08cb8af21 | peguin40/cpy5p1 | /q3_miles_to_kilometre.py | 376 | 4.21875 | 4 | #q3_miles_to_kilometre.py
#miles to kilometre calculator
#Welcome Message
print("Welcome to Miles to Kilometre calculator, \n Please input the following value(s)")
#get input variable(s)
miles = float(input("Miles:"))
#compute kilometre value
kilometres = float(1.60934 * miles)
#display results
print("{0} miles in ... | false |
df3b46c7a5582d882d4abb8c4178de62a4f68a2a | hunthunt2010/CompilersGroup2 | /ToTheAST/namespace.py | 884 | 4.15625 | 4 | #!/usr/bin/env python
#Taylor Schmidt
#ToTheAST group assignment
#namespace implementation
class Namespace:
def __init__ (self):
self.nameString = ''
def addName(self, newName):
"takes a new name string as an arg and returns a tuple with its index and length in the global string"
nameLength = len(newName... | true |
401917d8f5f1028ca7163f1c29fc8bf252cf3655 | cmulliss/gui_python | /challenges/oop_syntax.py | 1,405 | 4.3125 | 4 | class Student:
def __init__(self, name, grades):
self.name = name
self.grades = grades
def average(self):
return sum(self.grades) / len(self.grades)
student = Student("Bob", (90, 90, 93, 78, 90))
student2 = Student("Rolf", (100, 89, 93, 78, 100))
print(student.name)
print(student.grad... | true |
383e729b72c0c31f1d137206bba33d2d8ce5b763 | cmulliss/gui_python | /challenges/lambda.py | 515 | 4.34375 | 4 | # lambda fns dont have a name and only used to return values.
print((lambda x, y: x + y)(5, 7))
# def double(x):
# return x * 2
# list comprehensions
sequence = [1, 2, 3, 4, 5]
# doubled = [double(x) for x in sequence]
doubled = [(lambda x: x * 2)(x) for x in sequence]
print(doubled)
# if you want to use la... | true |
27bd9ff92a28e481101e751b7abb5646a4c89fb9 | HorseBackAI/PythonBlockchain | /6_标准库/6-standard-library-assignment/assignment.py | 413 | 4.125 | 4 | import random
import datetime
# 1) Import the random function and generate both a random number
# between 0 and 1 as well as a random number between 1 and 10.
rn1 = random.random()
rn2 = random.randint(1, 10)
print(rn1, rn2)
print()
# 2) Use the datetime library together with the random number
# to generate a rando... | true |
e5790aa876fa2089b5c3fb568031e407447d036b | andrezzadede/Curso_Guanabara_Python_Mundo_3 | /Mundo 3 - Exercícios/83Exercicio.py | 529 | 4.125 | 4 | #Crie um programa onde o usuario digite uma expressao qualquer que use paratenses. Seu aplicativo deverá analisar se a expressao passada está com os paratenses abertos e fechados na ordem correta.
expressao = str(input('Digite a expressao: '))
pilha = []
for simb in expressao:
if simb == '(':
pilha.append('(')
e... | false |
d872e611e08f88b8ecc0eccfb20ced6534406140 | Azevor/My_URI_Reply | /beginner/1006.py | 433 | 4.15625 | 4 | '''
Read three values (variables A, B and C), which are the three student's grades.
Then, calculate the average, considering that grade A has weight 2, grade B has
weight 3 and the grade C has weight 5. Consider that each grade can go from 0
to 10.0, always with one decimal place.
'''
m_N1 = float(input())*2
m_N2 = fl... | true |
176e5fddfb93a10aa9a3775878d24bf69ebf1416 | khanaw/My-Python-practice | /Fibonacci+Sequence+Generator.py | 1,647 | 4.59375 | 5 |
# coding: utf-8
# # Fibonacci Sequence Generator
#
# ### Enter a number and generate its Fibonacci Number to that number
# The limit is set to 250. You can increase the limit but may get errors. Use recursion to obtain better results at higher numbers. If you wanted to find 1500, it would be better to run the numb... | true |
2d95b0d05e10b25907ad90e44da69b3eb854dd4e | pythonerForEver/EZ-Project | /guess_number.py | 2,096 | 4.15625 | 4 | #! /usr/bin/python3.6
import random
def game_help(minimum=0, maximum=100):
print("""
you have 5 chance to guess number in our mind that
is between {min_}<number<{max_}.
""".format(min_=minimum, max_=maximum))
def guess_number():
maximum = 100
minimum = 0
... | true |
3629b979e2f3bef3ddd7554ce77b88f43ffebfc8 | inventsekar/LinuxTools-Thru-Perl-and-Python | /linux-wc-command-implementation-Thru-Python.py | 779 | 4.1875 | 4 | #!/usr/bin/python
# inventsekar 5th march 2018
# python implementation of Linux tool "wc"
line1 = raw_input("Please enter line1:");
line2 = "A quite bubble floating on a sea of noise. - The God of Small Things - Arundhati Roy";
line3 = "Hello, How are you";
#-------------------------------------#
# Finding number of... | true |
f696510ab7ff2a945d649c4ca397c637f5d1c3e9 | CurroValero05/TIC-2-BACH | /Contrasena_2.py | 268 | 4.15625 | 4 | #Escribe un programa que genere una contrasena
#con 3 letras de tu nombre y 3 del aellido
def contrasena_2():
nombre=raw_input("Introduce el nombre: ")
apellido=raw_input("Introduce el apellido: ")
print nombre[-3:]+apellido[-3:]
contrasena_2()
| false |
5c342d84049215a42fb64986ecbdff53baf62da8 | vanessa617/Dev_2017 | /tuples.py | 531 | 4.46875 | 4 | #creating a tuple
t1 = ('a','b','c')
print type(t1)
#create an empty tuple
t2 = ()
print t2
print type(t2)
#you have to use a comma even if the tuple has one element
t2 = (1,)
print t2
#getting the first element
print t1[0] #output = a
#getting the last element
print t1[-1] #output = c
#getting elements using slic... | true |
f03a785fce0b9814e652bd587bb824d64588adaa | cpe202spring2019/lab1-JackBeauche | /lab1.py | 2,132 | 4.1875 | 4 |
def max_list_iter(int_list): # must use iteration not recursion
# finds the max of a list of numbers and returns the value (not the index)
# If int_list is empty, returns None. If list is None, raises ValueError
# Check if list is None:
if (type(int_list) == type(None)):
raise ValueError
# Ch... | true |
554a6913036341f20d00e1d6341c98a411331869 | abhiunix/python-programming-basics. | /forloop.py | 1,152 | 4.875 | 5 | #forLoop
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities:
print(city)
print("Done!")
#Using the range() Function with for Loops
for i in range(3):
print("Hello!")
#range(start=0, stop, step=1)
#Creating and Modifying Lists
#In addition to extracting information from li... | true |
506f053a5695a697513ed9599f28d76c70069869 | abhiunix/python-programming-basics. | /enumerate.py | 745 | 4.5 | 4 | #Enumerate
#enumerate is a built in function that returns an iterator of tuples containing indices and values of
#a list. You'll often use this when you want the index along with each element of an iterable in a loop.
letters = ['a', 'b', 'c', 'd', 'e']
for i, letter in enumerate(letters):
print(i, letter)
#Quiz:... | true |
85ad6a8a91801ca457548e5ec62eacd5090c9c14 | RileyWaugh/ProjectEuler | /Problem5.py | 1,103 | 4.125 | 4 | #Problem: 2520 is the smallest number divisible by 1,2,3,...10.
# What is the smallest number divisible by 1-20 (more generally, 1-n)?
import math
def greatestLesserPower(x,y):
#findsthe greatest power of x less than or equal to y
if x > y:
return 0
product = 1
while product <= y:
product *= x
return prod... | true |
b2b71150f3d13bfd8de9d35a6fd26f500dcb409c | josenavarro-leadps/class-sample | /teamManager.py | 1,426 | 4.28125 | 4 | #made a class that contains the goals, age, and name.
#"self" is always being needed
class player(object):
def __init__(self, goals, age, name):
self.goals = goals
self.age = age
self.name = name
#now I made a function in my class
def playerstats(self):
print("name" +... | true |
f00047a3067e5bf47b9cc47d2b93e63d83a8451a | AlexVillagran/curso-basico-python | /Ej3-Variables.py | 1,322 | 4.15625 | 4 | # coding=utf-8
name = "Fazt"
print(10+10)
print (name)
#En una variable podemos guardar un numero, un decimal,
#un entero, booleano , una dubla,lista , diccionario un None
x = 100
# Case Sensitive : sensible a distinguir entre letras mayusculas y minusculas
libro = "Mi libro de Historia"
Libro = "Mi otro libro de ... | false |
3cfeda8a19cc9e5e490fa862e0744ab1122fb419 | 14masterblaster14/PythonTutorial | /P11_tryexception.py | 1,142 | 4.125 | 4 | #############################
#
# 21# Try Except :
# - The try block lets you test a block of code for errors.
# - The except block lets you handle the error.
# - The finally block lets you execute code, regardless of the result
# of the ... | true |
c54ad499a961fab6567a02703e0d48f6a67afe82 | Katherinaxxx/leetcode | /557. Reverse Words in a String III.py | 574 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2020/8/18 下午9:47
@Author : Catherinexxx
@Site :
@File : 557. Reverse Words in a String III.py
@Software: PyCharm
"""
class Solution:
def reverseWords(self, s: str) -> str:
res = ''
sl = s.split()
def helper(s):
res = ''... | false |
74c8e37b1aee8458ec2a85dd3cc3f8912b0796bd | 95ktsmith/holbertonschool-machine_learning | /math/0x06-multivariate_prob/0-mean_cov.py | 863 | 4.34375 | 4 | #!/usr/bin/env python3
""" Mean and Covariance """
import numpy as np
def mean_cov(X):
"""
Calculates the mean and covariance of a data set
X is a numpy.ndarray of shape(n, d) containing the data set
n is the number of data points
d is the number of dimensions in each data point
Return... | true |
17ed305f38dc835d83d6661db0de6a9ba8cca688 | njcssa/summer2019_wombatgame | /student_assessment/student_assessment1.py | 2,990 | 4.1875 | 4 | # To do with instructors:
# create 5 variables which all hold different types of data
# at least 1 should hold an int
# at least 1 should hold a double
# at least 1 should hold a boolean
# at least 1 should hold a string
# 1 variable can hold whatever you want
# then print out what one variable holds
# make a progr... | true |
85ba0c5919184a9376bb29b59c5e60123c53d60c | mat105/enviame-backend-test | /Ejercicio-3/main.py | 1,532 | 4.15625 | 4 | SAMPLE_STRING = 'afoolishconsistencyisthehobgoblinoflittlemindsadoredbylittlestatesmenandphilosophersanddivineswithconsistencyagreatsoulhassimplynothingtodohemayaswellconcernhimselfwithhisshadowonthewallspeakwhatyouthinknowinhardwordsandtomorrowspeakwhattomorrowthinksinhardwordsagainthoughitcontradicteverythingyousaidt... | false |
e214dfe2f5ee9b8bbf23bbe42daf9a62bbb4c316 | varunkudva/Programming | /dynamic_programming/balanceParenthesis.py | 722 | 4.21875 | 4 | """
Given n pairs of parentheses, find all possible balanced combinations
Solution:
1. Start with clean slate and add left parenthesis.
2. Add right parenthesis only if there are more left parenthesis than right.
3. Stop if left count == n or right count > left count.
"""
def add_parenthesis(n, left, right, idx, res)... | true |
e76a4f77828e4af880bfc6de8bc99e6a86f58bd7 | RocqJones/python3x_mega | /1.0Basics_Recap/1.8whileLoopRecap.py | 924 | 4.1875 | 4 | # The program will allow a user to create username n password & store in a list then verify the password.
# create user
user_name = input("Enter User Name: ")
user_password = input("Enter new password:")
user_db = []
user_db.append(user_name)
user_db.append(user_password)
# test db
# print(user_db)
# Break
for symbo... | true |
88e9d79d5194b389f295f37e2a4b7d6264bbd817 | stdout-se/tenant | /random_utils.py | 1,042 | 4.125 | 4 | import random
def from_dungeon_level(table, dungeon_level: int):
for (value, level) in reversed(table):
if dungeon_level >= level:
return value
return 0
def random_choice_from_dict(choice_dict: dict):
"""
Provided a dictionary, will return a randomly selected key string. The key... | true |
8b13f5f6647438ba94bba082bcbdeb8d87e2f8ae | SzymonSauer/Python-basics | /BMI_Calculator.py | 412 | 4.21875 | 4 | print("Enter your height: ")
height = float(input())
if height >=3.00:
print("Wow! You are the world's highest man! ;)")
print("Enter your weight: ")
weight = float(input())
bmi = weight/(height**2)
print("BMI:"+str(bmi))
if bmi<18.5:
print("You are too thin!")
elif bmi>=18.5 and bmi <25:
p... | true |
4b74595fb181c56249a3674c9810745b01b26057 | arrancapr/Clases | /Python1ArrancaPr/Samples/dict.py | 469 | 4.21875 | 4 | #define a dictionary
fruitsByColor = {"red": "apple", "blue": "berry"}
#retrieve the values
name =""
print(fruitsByColor["blue"])
while( name != "-done"):
print("Enter student name to get their hobbies")
name= input()
HobbiesByPerson = {"Aaron":["Photography","Spelunking"],
"Sarah":["Cli... | false |
00c8d588b17af0b3faa11ab875504abffbda571d | sillyer/learn-python-the-hard-way | /ex33.py | 402 | 4.15625 | 4 | numbers = []
#while i<6 :
# print "at the top i is %d" % i
# numbers.append(i)
# i = i+1
# print "Number now: ", numbers
# print "At the bottom i is %d" % i
def add_list(elem_range, num_list):
i=0
while(i<elem_range):
print "add %d to %r" % (i,numbers)
num_list.append(i)
print "then the list is:", numbers
i... | false |
ba80abfcae511a6681c294525ebc1caea40f5681 | birsandiana99/UBB-Work | /FP/Laboratory Assignments/Sapt 1/Assignment 1/pb8.py | 1,389 | 4.125 | 4 | def prim(x):
'''
Input: x-integer number
Output: sem (0 if the number is not prime, 1 if the number is prime)
Determines if the number given is prime or not by verifying if it has any divisors other than itself
'''
sem=1
'special case if the value given is 1 or is a multiple of 2'
if x==... | true |
a2bfd8ddd0c0c484fcfa54807d770d2527a57d6e | birsandiana99/UBB-Work | /FP/Laboratory Assignments/Sapt 1/first 1.py | 260 | 4.125 | 4 | def sum(a,b):
'''
Adds two numbers.
Input: a, b -integer numbers
Output: the sum of a and b (integer)
'''
return a+b
x=int(input("Give me the first number: "))
y=int(input("Give me the first number: "))
print("The sum is: ", sum(x,y))
| true |
8823f2aa3f984cb92582136b0560acc089c7803b | y281473724/Py-base | /元类type().py | 760 | 4.40625 | 4 | #动态语言和静态语言最大的不同,就是函数和类的定义
#不是编译时定义的,而是运行时动态创建的
#type()函数既可以返回一个对象类型,又可以创建出新的类型
#比如我们可通过type()函数创建一个Hello类而无需通过class Hello(object):...的方法
def fn(self,name = 'world'):#先定义函数
print('Hello,%s.' %name)
#创建一个class对象,type()函数依次传入3个参数:
#1.class的名称;
#2.继承的父类集合,如果只有一个父类,要注意tuple单元素的写法;
#3.class的方法名称与函数绑定,这里把函数fn绑定到... | false |
5d31c9047b9c34c18a894b1fcceba1cb3d531a5a | DhirendraBhatta/Jupyter | /rpsgame.py | 977 | 4.34375 | 4 | #Assignment of Rock Paper Scissor Game by Dhirendra Bhatta
import random
comp = random.randint(1,3)
print("Computer's generated input is: ",comp)
user = int(input('Enter 1 for rock,2 for paper and 3 for scissor '))
while user not in [1,2,3]:
user = int(input('Enter 1 for rock,2 for paper and 3 for scissor '... | true |
fd63741c194d59c392125be8f8553e610c616b0d | Xenocide007/Python-Projects | /3.py | 1,009 | 4.1875 | 4 | #3 in a row
import random
names = []
gameBoard = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]]
def inputNames():
name1 = raw_input("Enter first player's name here: \t")
name2 = raw_input("Enter second player's name here: \t")
return name1, name2
def first(name1, name2):
num1 = int(raw_input("%s, guess a numb... | true |
4dfb1a39f65da88252968ef388cb29817dcc14ee | gabrielSSimoura/ReverseWordOrder | /main.py | 556 | 4.40625 | 4 | # Write a program (using functions!) that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
# For example, say I type the string:
# My name is Gabriel
# Then I would see the string:
# Gabriel is name My
# shown back to me... | true |
e9bc436baa593405e732b1cb59db5d72945be174 | chanyoonzhu/leetcode-python | /708-Insert_into_a_Sorted_Circular_Linked_List.py | 1,215 | 4.125 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val=None, next=None):
self.val = val
self.next = next
"""
"""
- two pointers
- O(n), O(1)
"""
class Solution:
def insert(self, head: 'Optional[Node]', insertVal: int) -> 'Node':
if not head:
node = Node(insertVal)
... | true |
f9e731280039de962fbd886d3603f04ee5a2bff1 | chanyoonzhu/leetcode-python | /319-Bulb_Switcher.py | 418 | 4.21875 | 4 | """
- Math logic
- intuition: light bulbs that are left on are switched odd number of times. Divisors come in pairs 12 = 2 * 6 = 3 * 4, only exception is when n is a square number like 16 = 4 * 4 (one single divisor).
So only square numbers will be on at the end. Find all square numbers equal to or less than n.
- O... | true |
96fcc3eecfd5be51af858e83e8dd064ff390a2d5 | AidanH6/PythonBeginnerProjects | /higherlower.py | 990 | 4.46875 | 4 | """
Create a simple game where the computer randomly selects a number between 1 and 100 and the user has to guess what the number is.
After every guess, the computer should tell the user if the guess is higher or lower than the answer.
When the user guesses the correct number, print out a congratulatory message.
""... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.