blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
dadbdd33b087e16ffcbb985b8b28e1e215f5fc53 | Sandro37/Introducao_ao_python-CURSO-Digital_Innovation-One | /aula02.py | 1,172 | 4.25 | 4 | #O que são variáveis e como manipulá-las através
# de operadores aritméticos e interação com o osuário
valorA = int(input("Entre com o primeiro valor: "))
valorB = int(input("Entre com o segundo valor: "))
soma = valorA + valorB
subtracao = valorA - valorB
multiplicacao = valorA * valorB
divisao = valorA / valorB
re... | false |
4f532cd9216766b1dfdb41705e9d643798d70225 | Sandro37/Introducao_ao_python-CURSO-Digital_Innovation-One | /aula05.py | 1,138 | 4.125 | 4 | #como organizar os dados em uma lista ou tupla
# e realizar operações com elas
lista = [12,20,1,3,5,7]
lista_animal = ['cachorro', 'gato', 'elefante']
# print(lista_animal[1])
soma = 0
for x in lista:
soma += x
print(soma)
print(sum(lista))
print(max(lista))
print(min(lista))
print(max(lista_animal))
print(m... | false |
db0efc096311e8d2bd40a9f845af2a4ee2a38caf | mhelal/COMM054 | /python/evennumberedexercise/Exercise4_6.py | 525 | 4.3125 | 4 | # Prompt the user to enter weight in pounds
weight = eval(input("Enter weight in pounds: "))
# Prompt the user to enter height
feet = eval(input("Enter feet: "))
inches = eval(input("Enter inches: "))
height = feet * 12 + inches
# Compute BMI
bmi = weight * 0.45359237 / ((height * 0.0254) * (heigh... | false |
b37520ed33b2fef924c8ea17c96d34799b78cc37 | TimKillingsworth/Codio-Assignments | /src/dictionaries/person_with_school.py | 306 | 4.34375 | 4 | #Create dictionary with person information. Assign the dictionary to the variable person
person={'name':'Lisa', 'age':29}
#Print out the contents of person
print(person)
#Add the school which Lisa attends
person['school'] = 'SNHU'
#Print out the contents of person after adding the school
print(person) | true |
5dff174f4164bb5933de55efcf58c74152287e51 | TimKillingsworth/Codio-Assignments | /src/dictionaries/list_of_dictionary.py | 336 | 4.59375 | 5 | #Create a pre-populated list containing the informatin of three persons
persons=[{'name':'Lisa','age':29,'school':'SNHU'},
{'name': 'Jay', 'age': 25, 'school': 'SNHU'},
{'name': 'Doug', 'age': 27, 'school': 'SNHU'}]
#Print the person list
print(persons)
#Access the name of the first person
print(per... | false |
47f7f996f21d85e5b7613aa14c1a6d2752faaa82 | zaidjubapu/pythonjourney | /h5fileio.py | 1,969 | 4.15625 | 4 | # file io basic
'''f = open("zaid.txt","rt")
content=f.read(10) # it will read only first 10 character of file
print(content)
content=f.read(10) # it will read next 10 character of the file
print(content
f.close()
# must close the file in every program'''
'''f = open("zaid.txt","rt")
content=f.read() # it will read a... | true |
014987c11429d51e6d1462e3a6d0b7fb97b11822 | zaidjubapu/pythonjourney | /enumeratefunction.py | 592 | 4.59375 | 5 | '''enumerate functions: use for to easy the method of for loop the with enumerate method
we can find out index of the list
ex:
list=["a","b","c"]
for index,i in enumerate(list):
print(index,i)
'''
''' if ___name function :
print("and the name is ",__name__)# it will give main if it is written before
if __name__ =... | true |
50e523c196fc0df4be3ce6acab607f623119f4e1 | zaidjubapu/pythonjourney | /h23abstractbaseclassmethod.py | 634 | 4.21875 | 4 | # from abc import ABCMeta,abstractmethod
# class shape(metaclass=ABCMeta):
# or
from abc import ABC,abstractmethod
class shape(ABC):
@abstractmethod
def printarea(self):
return 0
class Rectangle(shape):
type= "Rectangle"
sides=4
def __init__(self):
self.length=6
self.b=7
... | true |
dfc07a2dd914fa785f5c9c581772f92637dea0a7 | zaidjubapu/pythonjourney | /h9recursion.py | 1,167 | 4.28125 | 4 | '''
recursive and iterative method;
factorial using iterative method:
# using iterative method
def factorialiterative(n):
fac=1
for i in range(n):
print(i)
fac=fac*(i+1)
return fac
# recusion method which mean callingthe function inside the function
def factorialrecursion(n):
if n==1:
... | false |
22773f2a2796ae9a493020885a6e3a987047e7f8 | Pegasus-01/hackerrank-python-works | /02-division in python.py | 454 | 4.125 | 4 | ##Task
##The provided code stub reads two integers, a and b, from STDIN.
##Add logic to print two lines. The first line should contain the result of integer division, a// b.
##The second line should contain the result of float division, a/ b.
##No rounding or formatting is necessary.
if __name__ == '__mai... | true |
139d9c55627188c10bc2304695fd3c66c700ceb2 | shudongW/python | /Exercise/Python40.py | 507 | 4.25 | 4 | #-*- coding:UTF-8 -*-
#笨办法学编程py3---字典
cities ={'CA':'San Francisco','MI':'Detroit','FL':'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
def find_city(themap, state) :
if state in themap:
return themap[state]
else:
return "Not found."
cities['_find'] = find_city
while Tru... | false |
a0c6ea7a8f1310a36a81b72c6edf4214def0ae62 | BarunBlog/Python-Files | /14 Tuple.py | 468 | 4.375 | 4 | tpl = (1, 2, 3, "Hello", 3.5, [4,5,6,10])
print(type(tpl)," ",tpl,"\n")
print(tpl[5]," ",tpl[-3])
for i in tpl:
print(i, end=" ")
print("\n")
#converting tuple to list
li = list(tpl)
print(type(li),' ',li,"\n")
tpl2 = 1,2,3
print(type(tpl2)," ",tpl2)
a,b,c = tpl2
print(a," ",b," ",c)
t = (1)
print(type(t))
t1... | false |
5a4c0c930ea92260b88f0282297db9c9e5bffe3f | BarunBlog/Python-Files | /Learn Python3 the Hard Way by Zed Shaw/13_Function&Files_ex20.py | 1,236 | 4.21875 | 4 | from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
def rewind(f):
f.seek(0)
'''
fp.seek(offset, from_what)
where fp is the file pointer you're working with; offset means how many positions you will move; from_what defines your point of reference:
0: means your reference point is... | true |
b6fefcbd7ae15032f11a372c583c5b9d7b3199d9 | BarunBlog/Python-Files | /02 String operation.py | 993 | 4.21875 | 4 | str1 = "Barun "
str2 = "Hello "+"World"
print(str1+" "+str2)
'''
To insert characters that are illegal in a string, use an escape character.
An escape character is a backslash \ followed by the character you want to insert.
'''
str3 = 'I don\'t think so'
print(str3)
print('Source:D \Barun\Python files\first project.... | true |
047dd0b26413c4e4130f551a9aec46fafafd753f | AnkitAvi11/100-Days-of-Code | /Strings/union.py | 973 | 4.1875 | 4 | # program to find the union of two sorted arrays
class Solution :
def find_union(self, arr1, arr2) :
i, j = 0, 0
while i < len(arr1) and j < len(arr2) :
if arr1[i] < arr2[j] :
print(arr1[i], end = " ")
i+=1
elif arr2[j] < arr1[i] :
... | false |
6c727ec6706b42ea057f264ff97d6f39b7481338 | AnkitAvi11/100-Days-of-Code | /Day 11 to 20/MoveAllnegative.py | 798 | 4.59375 | 5 | """
python program to move all the negative elements to one side of the array
-------------------------------------------------------------------------
In this, the sequence of the array does not matter.
Time complexity : O(n)
space complexity : O(1)
"""
# function to move negatives to the right of the array
def... | true |
9f076e1b7465ff2d509b27296a2b963dd392a7f9 | kishoreramesh84/python-75-hackathon | /filepy2.py | 523 | 4.28125 | 4 | print("Reading operation from a file")
f2=open("newfile2.txt","w")
f2.write(" Hi! there\n")
f2.write("My python demo file\n")
f2.write("Thank u")
f2.close()
f3=open("newfile2.txt","r+")
print("Method 1:")
for l in f3: #Method 1 reading file using loops
print(l,end=" ")
f3.seek(0) #seek is used to place a pointer to... | true |
492503ce1d085ca365be4934606c8746e41c9d3e | rodrikmenezes/ProjetoEuler | /4 LargestPalindromeProduct2.py | 1,041 | 4.1875 | 4 | # =============================================================================
# A palindromic number reads the same both ways. The largest palindrome made
# from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
# ========================... | false |
5a91c22b5ee87704cc8991bd6dab3eb2b2684d8b | ivanvi22/repository_name | /HelloWorld.py | 323 | 4.1875 | 4 | # программа для вывода "Hello World"
car_color = 'wite'
car_type = 'masda'
car_count = 2
print("Укажите цвет машины:")
car_color = input()
print("Укажите тип машины:")
car_type = input()
print("You have " + str(car_count) + ' ' + car_color + ' ' + car_type)
print(2 ** 3)
| false |
5bbce3aaa6c5a5d38b2a2848ce856322107a8c91 | mirsadm82/pyneng-examples-exercises-en | /exercises/06_control_structures/answer_task_6_2a.py | 1,788 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Task 6.2a
Make a copy of the code from the task 6.2.
Add verification of the entered IP address.
An IP address is considered correct if it:
- consists of 4 numbers (not letters or other symbols)
- numbers are separated by a dot
- every number in the range from 0 to 255
If the ... | true |
86fc4bc0e652ee494db883f657e918b2b056cf3e | mirsadm82/pyneng-examples-exercises-en | /exercises/04_data_structures/task_4_8.py | 1,107 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Task 4.8
Convert the IP address in the ip variable to binary and print output in columns
to stdout:
- the first line must be decimal values
- the second line is binary values
The output should be ordered in the same way as in the example output below:
- in columns
- column width 10 charact... | true |
b3cfe1ba6b28715f0f2bccff2599412d406fd342 | n001ce/python-control-flow-lab | /exercise-5.py | 670 | 4.40625 | 4 | # exercise-05 Fibonacci sequence for first 50 terms
# Write the code that:
# 1. Calculates and prints the first 50 terms of the fibonacci sequence.
# 2. Print each term and number as follows:
# term: 0 / number: 0
# term: 1 / number: 1
# term: 2 / number: 1
# term: 3 / number: 2
# term: 4 / nu... | true |
061aa64d7b81d640feac402dd1840ec8e80b1c7c | advancer-debug/Daily-learning-records | /数据结构与算法记录/习题解答记录/链表/offero6_test.py | 2,482 | 4.125 | 4 | # -*- coding = utf-8 -*-
# /usr/bin/env python
# @Time : 20-11-28 下午2:02
# @File : offero6_test.py
# @Software: PyCharm
# 输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。
# 方法一递归法
# 利用递归: 先走至链表末端,回溯时依次将节点值加入列表 ,这样就可以实现链表值的倒序输出。
# python算法流程
# 递推阶段: 每次传入 head.next ,以 head == None(即走过链表尾部节点)为递归终止条件,此时返回空列表 [] 。
# 回溯阶段: 利用 Py... | false |
8d980ed029b0dc74e4dc6aa0e7785d6af0f95fa7 | NiharikaSinghRazdan/PracticeGit_Python | /Code_Practice/list_exercise.py | 512 | 4.21875 | 4 | # Convert string into list
mystring="This is the new change"
mylist = []
for letter in mystring:
mylist.append(letter)
print(mylist)
# Change string into list with different convert format and in one line
mystring1="Hi There"
mylist1 =[letter for letter in mystring1]
print(mylist1)
# Check other usage of this new... | true |
bc76d2ae44f894254a3e24c0b53c61db5039f4ff | NiharikaSinghRazdan/PracticeGit_Python | /Code_Practice/arbitary_list.py | 1,556 | 4.1875 | 4 | #retrun the list where the passed arguments are even
def myfunc(*args):
mylist=[]
for item in args:
if item%2==0:
mylist.append(item)
else:
continue
print(mylist)
print(myfunc(-2,4,3,5,7,8,10))
# return a string where every even letter is in uppercase and every odd l... | true |
37b1dce3bcbe2da05065e677491797983588c285 | dankolbman/NumericalAnalysis | /Homeworks/HW1/Problem1.py | 520 | 4.21875 | 4 | import math
a = 25.0
print("Squaring a square-root:")
while ( math.sqrt(a)**2 == a ):
print('sqrt(a)^2 = ' + str(a) + ' = ' + str(math.sqrt(a)**2))
a *= 10
# There was a rounding error
print('sqrt(a)^2 = ' + str(a) + ' != ' + str(math.sqrt(a)**2))
# Determine the exponent of the float
expo = math.floor(math.log10(a... | true |
33d08154e946264256f7810254cd09f236622718 | bravacoreana/python | /files/08.py | 409 | 4.34375 | 4 | # if <condition> :
# when condition is true
if True:
print("it's true")
if False:
print("it's false")
number = input("input a number >>> ")
number = int(number)
if number % 2 == 0:
print("even")
if number % 2 != 0:
print("odd")
if number < 10:
print("less than 10")
elif number < 20:
pr... | false |
bfc1710b45ac38465e6f545968f2e00cd535d2dc | Tarun-Rao00/Python-CodeWithHarry | /Chapter 4/03_list_methods.py | 522 | 4.21875 | 4 | l1 = [1, 8, 7, 2, 21, 15]
print(l1)
l1.sort() # sorts the list
print("Sorted: ", l1)
l1.reverse() #reverses the list
print("Reversed: ",l1)
l1.reverse()
print("Reversed 2: ",l1)
l1.append(45) # adds to the end of the list
print ("Append", l1)
l2 = [1,5, 4, 10]
l1.append(l2) # l2 (list) will be added
print("Append 2"... | true |
0ab24f03f7919f96e74301d06dd9af5a377ff987 | Tarun-Rao00/Python-CodeWithHarry | /Chapter 2/02_operators.py | 548 | 4.125 | 4 | a = 34
b = 4
# Arithimatic Operator
print("the value of 3+4 is ", 3+4)
print("the value of 3-4 is ", 3-4)
print("the value of 3*4 is ", 3*4)
print("the value of 3/4 is ", 3/4)
# Assignment Operators
a = 34
a += 2
print(a)
# Comparision Operators
b = (7>14)
c = (7<14)
d = (7==14)
e = (7>=14)
print(b)
print(c)
print(d... | true |
d31f727127690b2a4584755c941cd19c7452d9e4 | Tarun-Rao00/Python-CodeWithHarry | /Chapter 6/11_pr_06.py | 221 | 4.15625 | 4 | text = input("Enter your text: ")
text1 = text.capitalize()
num1 = text1.find("Harry")
num2 = text1.find("harry")
if (num1==-1 and num2==-1):
print("Not talking about Harry")
else:
print("Talking about Harry") | true |
406ad197c1a6b2ee7529aaa7c6ea5a86e10114de | carrenolg/python-code | /Chapter12/optimize/main.py | 896 | 4.25 | 4 | from time import time, sleep
from timeit import timeit, repeat
# main
def main():
"""
# measure timing
# example 1
t1 = time()
num = 5
num *= 2
print(time() - t1)
# example 2
t1 = time()
sleep(1.0)
print(time() - t1)
# using timeit
print(timeit('num = 5; num *= 2'... | true |
c5333727d54b5cb7edff94608ffb009a29e6b5f4 | nikita5119/python-experiments | /cw1/robot.py | 1,125 | 4.625 | 5 | # A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:
# UP 5
# DOWN 3
# LEFT 3
# RIGHT 2
# The numbers after the direction are steps. Please write a program to compute the distance ... | true |
6e468bf7c8d0d37233ee7577645e1d8712b83474 | TameImp/compound_interest_app | /test_calc.py | 929 | 4.125 | 4 | '''
this programme test the compound interest calculator
'''
from calc import monthly_compounding
def test_tautology():
assert 3 == 3
#test that investing no money generates no returns
def test_zeros():
#initialise some user inputs
initial = 0
monthly = 0
years = 0
annual_rate = 0
#calcu... | true |
e0ee6d13b199a167c7cf72672876ff5d4b6e1b99 | LuisPereda/Learning_Python | /Chapter03/excercise1.py | 420 | 4.1875 | 4 | # This program parses a url
url = "http://www.flyingbear.co/our-story.html#:~:text=Flying%20Bear%20is%20a%20NYC,best%20rate%20in%20the%20city."
url_list = url.split("/") # Parsing begins at character (/)
domain_name = url_list[2] # Dictates at which character number parsing begins
print (domain_name.replace("www.",... | true |
61e27a466ee3a9d70062faf23f32d2a5ec427c7c | NickLuGithub/school_homework | /Python/課堂練習/b10702057-課堂練習3-1-1.py | 1,755 | 4.15625 | 4 | print("第一題");
print(1 == True);
print(1 == False);
print();
print(0 == True);
print(0 == False);
print();
print(0.01 == True);
print(0.01 == False);
print();
print((1, 2) == True);
print((1, 2) == False);
print();
print((0, 0) == True);
print((0, 0) == False);
print();
print('string' == True);
print('s... | false |
d6aead41f21280a466324b5ec51c9c86a57c35e6 | NickLuGithub/school_homework | /Python/課堂練習/b10702057-課堂練習7-1.py | 802 | 4.15625 | 4 | print("1")
list1 = [1,2,3,4]
a = [5, 6, 7, 8]
list1.append(a)
print(list1)
list1 = [1,2,3,4]
list1.extend(a)
print(list1)
print("2")
list1 = [1,2,3,4]
a = 'test'
list1.append(a)
print(list1)
list1 = [1,2,3,4]
list1.extend(a)
print(list1)
print("3")
list1 = [1,2,3,4]
a = ['a', 'b', 'c']
... | false |
f8b8f879cccda263a09997fb5132ab52fa827e4a | liuduanyang/Python | /廖大python教程笔记/jichu.py | 1,733 | 4.3125 | 4 | # python编程基础
a = 100
if a >= 0:
print(a)
else:
print(-a)
# 当语句以冒号:结尾时,缩进的语句视为代码块(相当于{}内的语句)
# Python程序是大小写敏感的
# 数据类型和变量
'''
数据类型:整数
浮点数
字符串('' 或 ""括起来的文本)
"I'm OK"包含的字符是I,',m,空格,O,K这6个字符
'I\'m \"OK\"!' 表示的字符串内容是:I'm "OK"!
布尔值(在Python中,可以直接用True、False表示布尔值(请注意大小写),也可以通过布尔... | false |
ff6f55f92091a43f543d07553876fde61b780da8 | liuduanyang/Python | /廖大python教程笔记/diedai.py | 1,360 | 4.3125 | 4 | # 迭代 (Iteration)
# 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代
# Python的for循环不仅可以用在list或tuple上,还可以作用在其他可迭代对象上 比如dict、字符串、
# 或者一些我们自定义的数据类型
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
print(key)
# b
# a
# c
# 因为字典存储是无序的 所以每次得到的顺序可能会不同
# for key in d 迭代key-value的key
# for value in d.values() ... | false |
57cf0f1364b7d4d2c0c3f3b8a8c869be4f7a261a | liuduanyang/Python | /廖大python教程笔记/dict.py | 2,204 | 4.28125 | 4 | # 字典
# Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)
# 存储,具有极快的查找速度。这种查找速度都非常快,不会随着字典大小的增加而变慢
d={'Michael':95,'Bob':75,'Tracy':85}
print(d['Michael'])
# 95
# 除了上述初始化方法外,还可以通过key来放入数据
d['Adam']=67
print(d['Adam'])
print(d)
# 67
# {'Adam': 67, 'Michael': 95, 'Bob': 75, 'Tracy': 85}
# 一个key只能对应一个v... | false |
9a915e306d84c786fd2290dc3180535c5773cafb | schase15/cs-module-project-iterative-sorting | /src/searching/searching.py | 1,967 | 4.375 | 4 | # Linear and Binary Search assignment
def linear_search(arr, target):
# Go through each value starting at the front
# Check to see if it is equal to the target
# Return index value if it is
# Return -1 if not found in the array`
for i in range(len(arr)):
if arr[i] == target:
... | true |
227bfbed621544f32bbddd18299c8fd0ea29fe0a | daisy-carolin/pyquiz | /python_test.py | 989 | 4.125 | 4 | x = [100,110,120,130,140,150]
multiplied_list=[element*5 for element in x]
print(multiplied_list)
def divisible_by_three():
x=range(10,100)
for y in x:
if y%3==0:
print(y)
x = [[1,2],[3,4],[5,6]],
flat_list = []
for sublist in x:
for num in sublist:
flat_list.append(num)
... | false |
996da01a75f050ffcdb755c5c5f2b16fb1ec8f1c | Shmuco/PY4E | /PY4E/ex_05_02/ex_05_02.py | 839 | 4.15625 | 4 | ##### 5.2 Write a program that repeatedly prompts a user for integer numbers until
#the user enters 'done'. Once 'done' is entered, print out the largest and
#smallest of the numbers. If the user enters anything other than a valid number
#catch it with a try/except and put out an appropriate message and ignore the
#num... | true |
48f85e68fcdd06ca468437c536ac7e27fd20ef77 | endreujhelyi/zerda-exam-python | /first.py | 431 | 4.28125 | 4 | # Create a function that takes a list as a parameter,
# and returns a new list with every second element from the original list.
# It should raise an error if the parameter is not a list.
# Example: with the input [1, 2, 3, 4, 5] it should return [2, 4].
def even_elements(input_list):
if type(input_list) == list:
... | true |
8fe7e9ee5da57e056d279168bc8c34789779109a | cainiaosun/study | /测试/UI自动化/测试工具__Selenium/selenium/Phy/class.py | 1,134 | 4.3125 | 4 | class Person:
'''Represents a person.'''
population = 0
def __init__(self,name,age):
'''Initializes the person's data.'''
self.name = name
self.age = age
print '(Initializing %s)' % self.name
# When this person is created, he/she
# adds to the population
... | false |
40eb347ec2a99811529a9af3aa536a16618d0ad3 | DoranLyong/CSE-python-tutorial | /Coding-Test/CodeUp/Python/036_number.py | 345 | 4.375 | 4 | """
[ref] https://codeup.kr/problem.php?id=1036
Question:
1. take one English letter
2. print it out as the decimal value of the ASCII code table.
"""
letter = input()
print(ord(letter))
"""
Program to find the ASCII value of a character:
https://beginnersbook.com/2019/03/python-program-to-find-ascii-... | true |
58dce475f4c94e14c6d58a4ee3c1836e34c82f21 | DoranLyong/CSE-python-tutorial | /Coding-Test/CodeUp/Python/037_number.py | 319 | 4.125 | 4 | """
[ref] https://codeup.kr/problem.php?id=1037
Question:
1. take one decimal ineger
2. print it out in ASCII characters
"""
num = int(input())
print(chr(num))
"""
Program to find the ASCII value of a character:
https://beginnersbook.com/2019/03/python-program-to-find-ascii-value-of-a-character/
""" | true |
173631da2b89f158a22cde74defe44465acce1b6 | wuhuabushijie/sample | /chapter04/4_1.py | 488 | 4.125 | 4 | '''鸭子类型,多态'''
class Cat:
def say(self):
print("I am a cat")
class Dog:
def say(self):
print("I am a dog")
def __getitem__(self):
return "bob8"
class Duck:
def say(self):
print("I am a duck")
animal_list = [Cat,Dog,Duck]
for animal in animal_list:
animal().say()
... | false |
4fcabbe7be3110a9ee278b5321eaa30319c9d7a7 | pri-nitta/firstProject | /CAP3/calorias.py | 1,093 | 4.21875 | 4 | #1 – O projeto HealthTrack está tomando forma e podemos pensar em algoritmos que possam ser reaproveitados
# quando estivermos implementando o front e o back do nosso sistema.
# Uma das funções mais procuradas por usuários de aplicativos de saúde é o de controle de calorias ingeridas em um dia.
# Por essa razão, você d... | false |
ae78936d1135929125080769c5fc815465e57728 | ALcot/-Python_6.26 | /script.py | 351 | 4.1875 | 4 | fruits = ['apple', 'banana', 'orange']
# リストの末尾に文字列「 grape 」を追加
fruits.append('grape')
# 変数 fruits に代入したリストを出力
print(fruits)
# インデックス番号が 0 の要素を文字列「 cherry 」に更新
fruits[0] = 'cherry'
# インデックス番号が 0 の要素を出力
print(fruits[0])
| false |
3442780fcf656417aa119190f13137e61db8d005 | jamessandy/Pycon-Ng-Refactoring- | /refcator.py | 527 | 4.21875 | 4 | #Example 1
num1 = 4
num2 = 4
result = num1 + num2
print(result)
#Example 2
num1 = int(input('enter the firExamst number:'))
num2 = int(input('enter the second number:'))
result = num1 + num2
print('your answer is:', result)
#Example 3
num1 = int(input('Enter number 1:'))
num2 = int(input('Enter number 2:'))
result =... | true |
4d9729e57e5e19855bd13b71df3b21ed4d00d98b | Tuhgtuhgtuhg/PythonLabs | /lab01/Task_1.py | 651 | 4.21875 | 4 | from math import sqrt
while True:
m = input("Введіть число \"m\" для обчислення формули z=sqrt((m+3)/(m-3)): ")
if ( m.isdigit()):
m = float(m)
if (m<=-3 or m > 3):
break
else:
print("""Нажаль число "m" повинно лежати у такому проміжку: m ∈ (-∞;-3]U(3;∞) !!!
Сп... | false |
e130159211e4dc6092a9943fa6a1c9422d058f68 | mclark116/techdegree-project | /guessing_game2.py | 2,321 | 4.125 | 4 | import random
history = []
def welcome():
print(
"""
____________________________________
Welcome to the Number Guessing Game!
____________________________________
""")
def start_game():
another = "y"
solution = random.randint(1,10)
value = "Oh no! That's not a valid value. Pl... | true |
cf7554340e039e9c317243a1aae5e5f9e52810f9 | IraPara08/raspberrypi | /meghapalindrom.py | 412 | 4.3125 | 4 | #Ask user for word
wordinput = input("Please Type In A Word: ")
#Define reverse palindrome
reverseword = ''
#For loop
for x in range(len(wordinput)-1, -1, -1):
reverseword = reverseword + wordinput[x]
#Print reverse word
print(reverseword)
#Compare
if wordinput == reverseword:
print("This is a palindrome!")... | true |
fed78ccbb8a565e936cacbac817485c26ab84383 | domlockett/pythoncourse2018 | /day03/exercise03_dl.py | 458 | 4.28125 | 4 | ## Write a function that counts how many vowels are in a word
## Raise a TypeError with an informative message if 'word' is passed as an integer
## When done, run the test file in the terminal and see your results.
def count_vowels(word):
vowels=('a','e','i','o','u')
count= 0
for i in word:
if type(... | true |
2074006981e41d2e7f0db760986ea31f6173d181 | ladas74/pyneng-ver2 | /exercises/06_control_structures/task_6_2a.py | 1,282 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Task 6.2a
Make a copy of the code from the task 6.2.
Add verification of the entered IP address.
An IP address is considered correct if it:
- consists of 4 numbers (not letters or other symbols)
- numbers are separated by a dot
- every number in the range from 0 to 255
If the ... | true |
27cc3bbaffff82dfb22f83be1bcbd163ff4c77f1 | ladas74/pyneng-ver2 | /exercises/05_basic_scripts/task_5_1.py | 1,340 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Task 5.1
The task contains a dictionary with information about different devices.
In the task you need: ask the user to enter the device name (r1, r2 or sw1).
Print information about the corresponding device to standard output
(information will be in the form of a dictionary).
An example ... | true |
70e15b366634efea90e939c6c169181510818fdb | Sushantghorpade72/100-days-of-coding-with-python | /Day-03/Day3.4_PizzaOrderCalculator.py | 881 | 4.15625 | 4 | '''
Project Name: Pizza Order
Author: Sushant
Tasks:
1. Ask customer for size of pizza
2. Do they want to add pepperoni?
3. Do they want extra cheese?
Given data:
Small piza: $15
Medium pizza: $20
Large pizza: $ 25
Pepperoni for Small Pizza: +$2
Pepperoni for medium & large pizza: +$3
Extra cheese ... | true |
0d5f545e7bacef8184a4224ad8e9816989ab6e2e | Long0Amateur/Self-learnPython | /Chapter 2 Loops/Chapter 2 (loops).py | 633 | 4.46875 | 4 | # Example 1
for i in range(5):
print('i')
print(sep='')
#Example 2
print('A')
print('B')
for i in range (5):
print('C')
print('D')
print('E')
print(sep='')
#Example 3
print('A')
print('B')
for i in range (5):
print('C')
for i in range (5):
print('D')
print('E')
print(sep... | false |
9b4a03cec322c2c28438a0c1df52d36f1dfce769 | Long0Amateur/Self-learnPython | /Chapter 5 Miscellaneous/swapping.py | 297 | 4.21875 | 4 | # A program swaps the values of 3 variables
# x gets value of y, y gets value of z, and z gets value of x
x = 1
y = 2
z = 3
hold = x
x = y
y = hold
hold = y
y = z
z = hold
hold = z
z = x
z = hold
print('Value of x =',x)
print('Value of y =',y)
print('Value of z =',z)
| true |
0e41bd56ce0c6b4761aa3bf3f86b181ea7b70697 | Tuman1/Web-Lessons | /Python Tutorial_String Formatting.py | 1,874 | 4.28125 | 4 | # Python Tutorial: String Formatting - Advanced Operations for Dicts, Lists, Numbers, and Dates
person = {'name':'Jenn', 'age': 23}
# WRONG example
# Sentence = 'My name is ' + person['name'] + ' and i am ' + str(person['age']) + ' years old.'
# print(Sentence)
# Sentence = 'My name is {} and i am {} years old.'.fo... | false |
280d6a67ced86fdb7c8f4004bb891ee7087ad18c | Ngyg520/python--class | /正课第二周/7-30/(重点理解)self对象.py | 1,556 | 4.21875 | 4 | """
座右铭:路漫漫其修远兮,吾将上下而求索
@project:正课第二周
@author:Mr.Yang
@file:self对象.PY
@ide:PyCharm
@time:2018-07-30 14:04:03
"""
class Student(object):
def __init__(self,name,age):
self.name=name
self.age=age
# print('self=',self)
def show(self):
print('调用了show函数')
# print('self=',self)... | false |
23b0fbe3cba25c9ef37ddbad2bb345086e63e6be | Ngyg520/python--class | /正课第二周/7-31/对象属性的保护.py | 2,251 | 4.21875 | 4 | """
座右铭:路漫漫其修远兮,吾将上下而求索
@project:正课第二周
@author:Mr.Yang
@file:对象属性的保护.PY
@ide:PyCharm
@time:2018-07-31 09:26:31
"""
#如果有一个对象,当需要对其属性进行修改的时候,有两种方法:
#1.对象名.属性名=属性值------------------>直接修改(不安全)
#2.对象名.方法名( )--------------------->间接修改
#为了更好的保护属性的安全,也就是不让属性被随意的修改,一般的处理方式:
#1,将属性定义为私有属性
#2.添加一个可以调用的方法(函数),通过调用方法来修改属性(还可以在方法中设... | false |
a62a4f8dfa911c1f3bde259e14efe019c5b7ddc1 | Ngyg520/python--class | /预科/7-23/生成器函数.py | 1,580 | 4.125 | 4 | """
座右铭:路漫漫其修远兮,吾将上下而求索
@project:预科
@author:Mr.Yang
@file:生成器函数.PY
@ide:PyCharm
@time:2018-07-23 14:34:00
"""
#生成器函数:当一个函数带有yieid关键字的时候,那么他将不再是一个普通的函数,而是一个生成器generator
#yieid和return;这俩个关键字十分的相似,yieid每次只返回一个值,而return则会把最终的结果一次返回
#每当代码执行到yieid的时候就会直接将yieid后面的值返回出,下一次迭代的时候,会从上一次遇到yieid之后的代码开始执行
def test():
list1=[]
... | false |
c4c6d1dfddde4594f435a910147ee36b107e87b9 | Pakizer/PragmatechFoundationProject | /tasks/7.py | 303 | 4.15625 | 4 | link[https://www.hackerrank.com/challenges/py-if-else/problem]
n = input('Bir eded daxil edin :')
n=int(n)
if n%2==0 and n>0:
if n in range(2,5):
print('Not Weird')
if n in range(6,20):
print ('Weird')
else:
print('Not Weird')
else:
print('Weird') | false |
edfd81e4cbd96b77f1666534f7532b0886f8ec4e | himashugit/python_dsa | /func_with_Arg_returnvalues.py | 617 | 4.15625 | 4 | '''
def addition(a,b):
result = a+b
return result # this value we're sending back to main func to print
def main():
a = eval(input("Enter your number: "))
b = eval(input("Enter your 2ndnumber: "))
result = addition(a,b) # calling addition func & argument value and storing in result
print(f... | true |
c9361ac9212e8bd0441b05a26940729dd6915861 | itsMagondu/python-snippets | /fib.py | 921 | 4.21875 | 4 | #This checks if a certain number num is a number in the fibbonacci sequence.
#It loops till the number is the sequence is either greater or equal to the number in the sequence.
#Thus we validate if the number is in the fibonacci sequence.
import sys
tot = sys.stdin.readline().strip()
try:
tot = int(tot)
except V... | true |
5ebb8cf419dd497c64b1d7ac3b22980f0c33b790 | sberk97/PythonCourse | /Week 2 - Mini Project Guess number game.py | 2,289 | 4.21875 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import random
import simplegui
# helper function to start and restart the game
def new_game():
# initialize global variables used in your code here
global s... | true |
8d82910e342182c0c6856ffe129bb94ad3391c39 | Evgeniy-code/python | /prob/calculator.py | 521 | 4.3125 | 4 | #!/usr/bin/env python3
a = float(input("введите первое число:"))
what = input("что делаем (+:-:*:/):")
b = float(input("введите второе число:"))
if what == "+":
d = a + b
print("равно:" + str(d))
elif what == "-":
d = a - b
print("равно:" + str(d))
elif what == "*":
d = a * b
print("равно:" + s... | false |
5c4362ae8eea49bd105ae1f0ffced5d62aba12ed | ArnoldKevinDesouza/258327_Daily_Commits | /Dict_Unsolved02.py | 209 | 4.5 | 4 | # Write a Python program to convert a list into a nested dictionary of keys
list = [1, 2, 3, 4]
dictionary = current = {}
for name in list:
current[name] = {}
current = current[name]
print(dictionary) | true |
3963dccc95056b06715cf81c7a8eab7091c682a5 | ArnoldKevinDesouza/258327_Daily_Commits | /If_Else_Unsolved04.py | 314 | 4.15625 | 4 | # Write a program to get next day of a given date
from datetime import date, timedelta
import calendar
year=int(input("Year:"))
month=int(input("\nMonth:"))
day=int(input("\nDay:"))
try:
date = date(year, month, day)
except:
print("\nPlease Enter a Valid Date\n")
date += timedelta(days=1)
print(date) | true |
dd652b879fd1162d85c7e3454f8b724e577f5e7e | Einsamax/Dice-Roller-V2 | /main.py | 2,447 | 4.375 | 4 | from time import sleep
import random
#Introduce user to the program
if __name__ == "__main__": #This does a good thing
print ("*" * 32)
print("Welcome to the Dice Roller!".center(32))
print ("*" * 32)
print()
sleep(1)
def roll_dice(diceamnt, diceint): #Defines function roll_dice
... | true |
c6aadc50833356e4ce23f7f2a898634ff3efd4a7 | dsimonjones/MIT6.00.1x---Introduction-to-Computer-Science-and-Programming-using-Python | /Week2- Simple Programs/Lecture4- Functions/Function isIn (Chap 4.1.1).py | 611 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
@author: ali_shehzad
"""
"""
Finger exercise 11: Write a function isIn that accepts two strings as
arguments and returns True if either string occurs anywhere in the other,
and False otherwise. Hint: you might want to use the built-in str
operation in.
"""
def isIn(str1, str2... | true |
3bc103df43f3b4e607efa104b1e3a5a62caa1469 | LaurenShepheard/VsCode | /Learningpython.py | 1,227 | 4.375 | 4 | for i in range(2):
print("hello world")
# I just learnt how to comment by putting the hash key at the start of a line. Also if I put a backslash after a command you can put the command on the next line.
print\
("""This is a long code,
it spreads over multiple lines,
because of the triple quotaions and b... | true |
20b609e21199215965d79601920124905c16ef2d | katesem/data-structures | /hash_table.py | 884 | 4.25 | 4 | '''
In Python, the Dictionary data types represent the implementation of hash tables. The Keys in the dictionary satisfy the following requirements.
The keys of the dictionary are hashable i.e. the are generated by hashing function which generates unique result for each unique value supplied to the hash function.
The o... | true |
02aa151e60891f3c43b27a1091a35e4d75fe5f7d | mshalvagal/cmc_epfl2018 | /Lab0/Python/1_Import.py | 1,610 | 4.375 | 4 | """This script introduces you to the useage of Imports in Python.
One of the most powerful tool of any programming langauge is to be able to resuse code.
Python allows this by setting up modules. One can import existing libraries using the import function."""
### IMPORTS ###
from __future__ import print_function # ... | true |
42f37b58b8e3b4583208ea054d30bef34040a6ed | inshaal/cbse_cs-ch2 | /lastquest_funcoverload_Q18_ncert.py | 1,152 | 4.1875 | 4 | """FUNCTION OVERLOADING IS NOT POSSIBLE IN PYTHON"""
"""However, if it was possible, the following code would work."""
def volume(a): #For volume of cube
vol=a**3
print vol, "is volume of cube"
def volume(a,b,c): #volume of cuboid |b-height
vol=a*b*c
print vol, "is volume of cuboid"
def volume(... | true |
6335c93ef76e37891cee92c97be29814aa91eb21 | Leonardo612/leonardo_entra21 | /exercicio_01/cadastrando_pessoas.py | 992 | 4.125 | 4 | """
--- Exercício 1 - Funções
--- Escreva uma função para cadastro de pessoa:
--- a função deve receber três parâmetros, nome, sobrenome e idade
--- a função deve salvar os dados da pessoa em uma lista com escopo global
--- a função deve permitir o cadastro apenas de pessoas com idade igual ou super... | false |
109d7adc06ec9c8d52fde5743dbea7ffb262ab33 | edenizk/python_ex | /dict.py | 1,321 | 4.21875 | 4 | def main():
elements = {"hydrogen": 1, "helium": 2, "carbon": 6}
print("print the value mapped to 'helium'",elements["helium"]) # print the value mapped to "helium"
elements["lithium"] = 3 # insert "lithium" with a value of 3 into the dictionary
print("elements = ",elements)
print("is there carb... | false |
579a2fbc1f237e1207be37752963d17f2011b629 | edenizk/python_ex | /ifstatement.py | 866 | 4.15625 | 4 | def main():
phone_balance = 10
bank_balance = 50
if phone_balance < 10:
phone_balance += 10
bank_balance -= 10
print(phone_balance)
print(bank_balance)
number = 145
if number % 2 == 0:
print("Number " + str(number) + " is even.")
else:
print("Number "... | true |
b404e386aa86f7e7a8abfdbbfb1a7e678920e420 | sn-lvpthe/CirquePy | /02-loops/fizzbuzz.py | 680 | 4.15625 | 4 |
print ("Dit is het FIZZBUZZ spel!")
end = input("""\nWe gaan even na of een getal deelbaar is door 3 OF 5 .\nOf door 3 EN 5.\n
Geef een geheel getal in tussen 1 en 100: """)
# try-except statement:
# if the code inside try fails, the program automatically goes to the except part.
try:
end = int(end) # convert ... | false |
1fb7b06f3ed69f53268c4b1f6fc0a39702f8274c | mishra-atul5001/Python-Exercises | /Search.py | 574 | 4.15625 | 4 | Stringy = '''
Suyash: Why are you wearing your pajamas?
Atul: [chuckles] These aren't pajamas! It's a warm-up suit.
Suyash: What are you warming up for Bro..!!?
Atul: Stuff.
Suyash: What sort of stuff?
Atul: Super-cool stuff you wouldn't understand.
Suyash: Like sleeping?
Atul: THEY ARE NOT PAJAMAS!
'''
print(Stringy)
... | true |
cc8e5d5db27730063c43f01ef610dcea40ec77df | lacra-oloeriu/learn-python | /ex15.py | 552 | 4.125 | 4 | from sys import argv# That is a pakege from argv
script, filename = argv#This is define the pakege
txt= open(filename)#that line told at computer ...open the file
print(f"Here's your file {filename}:")#print the text...and in {the name of file to open in extension txt}
print ( txt.read())
print("Type the filename ... | true |
af1191998cf3f8d5916e22b8b55da7766bead003 | huynhirene/ICTPRG-Python | /q1.py | 241 | 4.28125 | 4 | # Write a program that counts from 0 to 25, outputting each number on a new line.
num = 0
while num <= 26:
print(num)
num = num + 1
if num == 26:
break
# OR
for numbers in range(0,26):
print(numbers) | true |
113cddca4472e40432caf9672fdc4ce22f25fb86 | fjctp/find_prime_numbers | /python/libs/mylib.py | 542 | 4.15625 | 4 |
def is_prime(value, know_primes=[]):
'''
Given a list of prime numbers, check if a number is a prime number
'''
if (max(know_primes)**2) > value:
for prime in know_primes:
if (value % prime) == 0:
return False
return True
else:
raise ValueError('List of known primes is too short for the given value'... | true |
77f47d8da94d71e0e7337cf8dc9e4f3faa65c31a | orozcosomozamarcela/Paradigmas_de_Programacion | /recursividad.py | 1,132 | 4.125 | 4 |
# 5! = 5 * 4! = 120
# 4! = 4 * 3! = 24
# 3! = 3 * 2! = 6
# 2! = 2 * 1! = 2
# 1! = 1 * 0! = 1
# 0! = 1 = 1
#% * 4 * 3 * 2 * 1
def factorial (numero):
if numero == 0 :
return 1
else:
print ( f "soy el { numero } " )
#recur = factorial(numero -1)
#da = recur * numero
... | false |
a3c2ac4234daefa2a07898aa9cce8890ca177500 | orozcosomozamarcela/Paradigmas_de_Programacion | /quick_sort.py | 1,025 | 4.15625 | 4 |
def quick_sort ( lista ):
"""Ordena la lista de forma recursiva.
Pre: los elementos de la lista deben ser comparables.
Devuelve: una nueva lista con los elementos ordenados. """
print ( "entra una clasificación rápida" )
if len ( lista ) < 2 :
print ( "devuelve lista con 1 elemento" )
... | false |
44cc5b20276024979f97fb31cd221b90ba78e351 | Mahdee14/Python | /2.Kaggle-Functions and Help.py | 2,989 | 4.40625 | 4 | def maximum_difference(a, b, c) : #def stands for define
"""Returns the value with the maximum difference among diff1, diff2 and diff3"""
diff1 = abs(a - b)
diff2 = abs(b - c)
diff3 = abs(a - c)
return min(diff1, diff2, diff3)
#If we don't include the 'return' keyword in a function that requires... | true |
6b6dae17b4cdb0af548f79350deb1e6657084552 | IamHehe/TrySort | /1.bubble_sort.py | 603 | 4.15625 | 4 | # coding=utf-8
# author: dl.zihezhu@gmail.com
# datetime:2020/7/25 11:23
"""
程序说明:
冒泡排序法
(目标是从小到大排序时)
最好情况:顺序从小到大排序,O(n)
最坏情况:逆序从大到小排序,O(n^2)
平均时间复杂度:O(n^2)
空间复杂度:O(1)
"""
def bubbleSort(arr):
for i in range(1, len(arr)):
for j in range(0, len(arr) - i):
if arr[j] > a... | false |
0ab3c263766f174b04f319ba773a14e1e56170da | IamHehe/TrySort | /5.merge_sort.py | 2,389 | 4.15625 | 4 | # coding=utf-8
# author: dl.zihezhu@gmail.com
# datetime:2020/7/26 12:31
"""
程序说明:
归并排序
(目标是从小到大排序时)
最好情况:O(n log n)
最坏情况:O(n log n)
平均时间复杂度:O(n log n)
空间复杂度:自上到下:因为需要开辟一个等长的数组以及使用了二分的递归算法,所以空间复杂为O(n)+O(log n)。自下向上:O(1)
稳定
"""
# 自上向下分,递归
def merge_sort(arr):
if len(arr) < 2:
re... | false |
d990ed78e1ecc5dd47c002e438d23400c72badba | mochadwi/mit-600sc | /unit_1/lec_4/ps1c.py | 1,368 | 4.1875 | 4 | # receive Input
initialBalance = float(raw_input("Enter your balance: "))
interestRate = float(raw_input("Enter your annual interest: "))
balance = initialBalance
monthlyInterestRate = interestRate / 12
lowerBoundPay = balance / 12
upperBoundPay = (balance * (1 + monthlyInterestRate) ** 12) / 12
while True:
balan... | true |
fbaf789fbe6bfaede28d2b2d3a6a1673e229f57b | bledidalipaj/codefights | /challenges/python/holidaybreak.py | 2,240 | 4.375 | 4 | """
My kids very fond of winter breaks, and are curious about the length of their holidays including all the weekends.
Each year the last day of study is usually December 22nd, and the first school day is January 2nd (which means that
the break lasts from December 23rd to January 1st). With additional weekends at the... | true |
0bad5a8a7ee86e45043ef0ddf38406a9ee4d1032 | pmayd/python-complete | /code/exercises/solutions/words_solution.py | 1,411 | 4.34375 | 4 | """Documentation strings, or docstrings, are standard ways of documenting modules, functions, methods, and classes"""
from collections import Counter
def words_occur():
"""words_occur() - count the occurrences of words in a file."""
# Prompt user for the name of the file to use.
file_nam... | true |
95b308d6bdb204928c6b014c8339c2cc8693b7d7 | pmayd/python-complete | /code/exercises/most_repeating_word.py | 870 | 4.3125 | 4 | import doctest
def most_repeating_word(words: list) -> str:
"""
Write a function, most_repeating_word, that takes a sequence of strings as input. The function should return the string that contains the greatest number of repeated letters. In other words:
for each word, find the letter that appears the mo... | true |
59483e49c3cdf8fe1cf1871ec439b25ffd4daf15 | lisandroV2000/Recuperatorio-programacion | /ACT3.py | 784 | 4.15625 | 4 | #3. Generar una lista de números aleatoriamente y resuelva lo siguiente:
#a. indicar el rango de valores de la misma, diferencia entre menor y mayor
#b. indicar el promedio
#c. ordenar la lista de manera creciente y mostrar dichos valores
#d. ordenar la lista de manera decreciente y mostrar dichos valores
#e. hace... | false |
111c536fba28296ec4f2a93ab466360e57d839d6 | paul0920/leetcode | /question_leetcode/215_5.py | 1,471 | 4.25 | 4 | # Bucket sort algorithm
# Average time complexity: O(n)
# Best case: O(n)
# Worst case: O(n^2)
# Space complexity: O(nk), k: bucket count
# Bucket sort is mainly useful when input is uniformly distributed over a range
# Choose the bucket size & count, and put items in the corresponding bucket
nums = [3, 2, 1, 5,... | true |
0aa9a7c64282a574374fb4b9e9918215f0f013ec | paul0920/leetcode | /question_leetcode/48_2.py | 509 | 4.1875 | 4 |
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for row in matrix:
print row
m = len(matrix)
n = len(matrix[0])
# j only loops until i
for i in range(m):
for j in range(i):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
# j only loops until n / 2
for i in range(m):
for j in range(n / 2):
... | false |
65b13cf4b6251e6060c8ccf34a63ab703f93fd2b | paul0920/leetcode | /pyfunc/lambda_demo_1.py | 251 | 4.15625 | 4 |
my_list = [1, 5, 4, 6]
print map(lambda x: x * 2, my_list)
print (lambda x: x * 2)(my_list)
print my_list * 2
# A lambda function is an expression, it can be named
add_one = lambda x: x + 1
print add_one(5)
say_hi = lambda: "hi"
print say_hi()
| false |
d94c3e993bd855c950dfe809dba92957b40c4a20 | JimiofEden/PyMeth | /Week 1/TEST_roots_FalsePosition.py | 470 | 4.25 | 4 | import roots_FalsePosition
import numpy
'''
Adam Hollock 2/8/2013
This will calculate the roots of a given function in between two given
points via the False Position method.
'''
def f(x): return x**3+2*x**2-5*x-6
results = roots_FalsePosition.falsePosition(f,-3.8,-2.8,0.05)
print results
results = roots_FalsePositi... | true |
e579fadc31160475af8f2a8d42a20844575c95fa | mitalshivam1789/python | /oopfile4.py | 940 | 4.21875 | 4 | class A:
classvar1= "I am a class variable in class A."
def __init__(self):
self.var1 = "I am in class A's constructor."
self.classvar1 = "Instance variable of class A"
self.special = "Special"
class B(A):
classvar1="I am in class B"
classvar2 = "I am variable of class ... | true |
4ecd4d3a20e875b9c0b5019531e8858f4722b632 | victorbianchi/Toolbox-WordFrequency | /frequency.py | 1,789 | 4.5 | 4 | """ Analyzes the word frequencies in a book downloaded from
Project Gutenberg """
import string
def get_word_list(file_name):
""" Reads the specified project Gutenberg book. Header comments,
punctuation, and whitespace are stripped away. The function
returns a list of the words used in the book as a li... | true |
End of preview. Expand in Data Studio
Dataset created with this filter from Avelina/python-edu.
def my_filter(example):
score = example["score"] > 4.1
lengh = example["length_bytes"] < 3000 and example["length_bytes"] > 200
return score and lengh
A is_english boolean have been added with the model papluca/xlm-roberta-base-language-detection.
- Downloads last month
- 15