blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
a024445ad40df6cda322c6bb7aa1b2efafbd9cd3 | AngelValAngelov/Python-Advanced-Exercises | /Lists as Stacks and Queues - Lab/01. Reverse Strings.py | 247 | 4.34375 | 4 | def reversed_string(text):
s = list()
for letter in text:
s.append(letter)
new_s = list()
while s:
char = s.pop()
new_s.append(char)
return "".join(new_s)
print(reversed_string(input())) | false |
96ed6feaf59796961f8f5228a5402dcc7c70698b | Asilva-01/PythonEstudos | /Aulas_Modulo_Magico_6_2.py | 301 | 4.15625 | 4 | def main():
numero_escolhido = 3
numero_magico = int(input("Valor escolhido pelo magico: "))
if numero_magico > numero_escolhido:
print("Diminua o chute")
elif numero_magico < numero_escolhido:
print("Aumente o chute")
else:
print("Você acertou")
main()
| false |
f2b94660239c6fa96843a0d999ffe0c40b13bfa4 | shadiqurrahaman/python_DS | /tree/basic_tree.py | 1,644 | 4.15625 | 4 | from queue import Queue
class Node:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.queue = Queue()
def push_tree(self,data):
new_node = Node(data)
if self.root ... | true |
80ccc65227fafa80fc7c89c31b1030ed7bf6ace7 | jetli123/python_files | /廖雪峰-python/廖雪峰-getattr()、setattr()和hasattr().py | 1,675 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""仅仅把属性和方法列出来是不够的,配合 getattr()、setattr()以及
hasattr(),我们可以直接操作一个对象的状态:"""
class MyDog(object):
def __init__(self, x, y):
self.x = x
self.y = y
def power(self):
print self.x * self.y
obj = MyDog(9, 2)
obj.power()
"""紧接着,可以测试该对象的属性"""
print hasattr(obj, 'y') ... | false |
b5bc70ffb388b8e022763e404187d7d60b56db0e | jetli123/python_files | /廖雪峰-python/廖雪峰-面向对象之定制类-__str__.py | 1,815 | 4.21875 | 4 | # -*- coding: utf-8 -*-
__author__ = 'JetLi'
# -*- __str__ -*-
class Student(object):
def __init__(self, name):
self.name = name
def __str__(self):
return 'Student object (name: %s)' % self.name
__repr__ = __str__ # 直接显示变量调用的不是__str__(),而是__repr__(),两者的
# 区别是__st... | false |
123c032edcf3c3f86b49ee8c9dba5fd2afffa631 | jetli123/python_files | /廖雪峰-python/廖雪峰-面向对象之类的继承和多态.py | 1,539 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""在 OOP 程序设计中,当我们定义一个 class 的时候,可以从某个现有的
class 继承,新的 class 称为子类(Subclass),而被继承的 class 称为基
类、父类或超类(Base class、 Super class)。"""
class Animal(object): # Animal 是两个子类 dog 和 cat 的父类
def runs(self):
print('Animal is running...')
"""当子类和父类都存在相同的 runs()方法时,我们说,子类的 runs()覆盖了
父类的 runs()... | false |
91a29c4d16ea8e3459bf94a3303e090dd67617e3 | jetli123/python_files | /廖雪峰-python/廖雪峰-面向对象之调用不存在的属性__getattr__()方法.py | 1,549 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""当调用不存在的属性时,比如 score, Python 解释器会试图调用
__getattr__(
self, 'score')来尝试获得属性,这样,我们就有机会返回
score 的值"""
"""注意,只有在没有找到属性的情况下,才调用__getattr__,已有的属性,
比如 name,不会在__getattr__中查找。"""
class Student(object):
def __init__(self):
self.name = 'Michael'
def __getattr__(self, attr):
if a... | false |
2699742da7500f56858626be9c6369a58c96f0ed | jyoshnalakshmi/python_examples | /file_handling/file_write.py | 691 | 4.25 | 4 | #--------------------------------------------------------------------
#Description : Writing into the file
#Used Function : write()
#Mode : 'w'
#--------------------------------------------------------------------
with open('file1.py','w') as f:
print("write(This is write function using 'w')");
f.write("Hey this ... | true |
10b02c26c2f09f703ce16eab5d8a0183677d8fb2 | dhiraj1996-bot/Code-a-Thon | /list.py | 502 | 4.125 | 4 | #Question 2
list1 = ["aman","raj","ayush","gracie"]
list2 = ["akshay","rakesh","raj","ram"]
#creating a function to check for duplicate values and then removing them
#and creating list without the duplicate values
def find_common(list1,list2):
for x in list1:
for y in list2:
if x == y :
... | true |
dd52c000cd4d5d7a021449a7451de4fa84047042 | nkuhta/Python-Data-Structures | /2. Files/average_spam_confidence.py | 938 | 4.125 | 4 | ##############################################################
######### compute the average spam ############
##############################################################
# X-DSPAM-Confidence:0.8475
# Prompt for user input filename then search for the number and average
fname=input('Enter file... | true |
17601497f9bb20611bbca1bec0f8dcd40767db54 | nitschmann/python-lessons | /07_dictionaries/exc_47.py | 616 | 4.25 | 4 | # dictionaries - exercise 47
country_rivers = {
"China": "Yangtze",
"China": "Yangtze",
"China": "Ob-Irtysh",
"Germany": "Elbe",
"Germany": "Oder",
"Germany": "Rhine",
"USA": "Missouri",
"USA": "Yukon",
"USA": "Colorado"
}
country_river_li... | false |
b4846a2a1d6db0d4cbc3bb5a9097c509af4484a5 | nitschmann/python-lessons | /04_list_manipulations/exc_18.py | 374 | 4.25 | 4 | # list manipulations - exercise 18
cities = ["St. Petersburg", "Moscow", "Buenos Aires", "New York", "Stockholm",
"Amsterdam"]
print(cities)
print(sorted(cities))
print(cities)
print(sorted(cities, reverse = True))
print(cities)
cities.reverse()
print(cities)
cities.reverse()
print(cities)
cities.sort()
pri... | true |
058596c252eaf726187130550b12f9a293035d6f | nitschmann/python-lessons | /05_working_with_lists/exc_30.py | 335 | 4.53125 | 5 | # working with lists - exercise 30
my_pizzas = ["mista", "salami", "pepperoni"]
friend_pizzas = my_pizzas[:]
my_pizzas.append("parma")
friend_pizzas.append("magaritha")
print("My favorite pizzas are:")
for pizza in my_pizzas:
print(pizza)
print("\nMy friends' favorite pizzas are:")
for pizza in friend_pizzas:
... | false |
176a4b1c9ae3026deef18b839ce5c1744cba351b | Ntims/Nt_Python | /실습20190419-20194082-김민규/P0601-1.py | 274 | 4.3125 | 4 | for letter in "Python":
print("Current letter :",letter)
print()
fruits = ["banana", "apple", "mango"]
for fruit in fruits:
print("Current fruit:",fruit)
print("Using Index")
for index in range(len(fruits)):
print("Current fruit:", fruits[index])
| false |
2259528e78ea92e3b074f54438e62b0ca30c4b97 | rodrigojgrande/python-mundo | /desafios/desafio-037.py | 1,020 | 4.3125 | 4 | #Exercício Python 37: Escreva um programa em Python que leia um número inteiro qualquer e peça para o usuário escolher qual será a base de conversão: 1 para binário, 2 para octal e 3 para hexadecimal.
numero = int(input('Digite um número inteiro:'))
print('Escolha uma das bases para conversão:')
print('[ \033[1;33m1... | false |
0273bfcd36fb3155e3affb97bac7ac18345b3fa5 | rodrigojgrande/python-mundo | /desafios/desafio-103.py | 613 | 4.1875 | 4 | #Exercício Python 103: Faça um programa que tenha uma função chamada ficha(), que receba dois parâmetros opcionais: o nome de um jogador e quantos gols ele marcou. O programa deverá ser capaz de mostrar a ficha do jogador, mesmo que algum dado não tenha sido informado corretamente.
def ficha(nome='<desconhecido>', gol... | false |
30a64779a2aeb830ef34fdbaae0567c8a74f281d | rodrigojgrande/python-mundo | /desafios/desafio-009.py | 656 | 4.15625 | 4 | #Exercício Python 9: Faça um programa que leia um número Inteiro qualquer e mostre na tela a sua tabuada.
x = int (input('Digite um número para ver sua tabuada: '))
print('-' * 12)
print('{} X {:2} = {:2}'. format(x, 1, x*1))
print('{} X {:2} = {:2}'. format(x, 2, x*2))
print('{} X {:2} = {:2}'. format(x, 3, x*3))
pr... | false |
25d0ab0c0367387131fa13c0167970936a056d0f | rodrigojgrande/python-mundo | /desafios/desafio-060.py | 435 | 4.1875 | 4 | #Exercício Python 060: Faça um programa que leia um número qualquer e mostre o seu fatorial. Exemplo:
#5! = 5 x 4 x 3 x 2 x 1 = 120
from math import sqrt fatorial
f = factorial(x)
x = int(input('\033[1;34mDigite um número para calcular seu Fatorial:\033[m '))
print('Calculando {}! = '.format(x), end='')
total = x
whi... | false |
c6b204891b2357bc5773f4f8bcb519277bfb24bd | VitaliyYa/stepik-python | /1st_week/1.12-5_var-2.py | 594 | 4.3125 | 4 | """
task link: https://stepik.org/lesson/5047/step/5?unit=1086
Напишите программу, которая получает на вход три целых числа,по одному числу в строке,
и выводит на консоль в три строки сначала максимальное, потом минимальное, после чего оставшееся число.
На ввод могут подаваться и повторяющиеся числа.
"""
x = sorted([... | false |
f9aa373d5928ace3f4b80cc76fb891df82fc9efe | VitaliyYa/stepik-python | /3rd_week/3.2-7.py | 368 | 4.15625 | 4 | """
link task: https://stepik.org/lesson/3373/step/7?unit=956
"""
# Считайте, что функция f(x) уже определена выше. Определять её отдельно не требуется.
n = int(input())
dic = {}
for n in range(0, n):
n = int(input())
if dic.get(n) == None:
dic.setdefault(n, f(n))
print(dic[n])
| false |
ba3feed540cb189ed77fdf8266f2a639e76fb149 | RAKUZ4N/HelloPython_1 | /1.occupation/hellopython_1.4.py | 1,490 | 4.28125 | 4 | #Создайте 4 условия:
#1. Число А больше В но меньше С.
#2. Результат деления по модулю числа 7 на 3 умножить на 4.8.
#3. Создать два разных выражения которые равны друг другу.
#4. Создать 2 выражения которые не равны друг другу.
#Первое задание:
print("1. Число А больше В но меньше С.")
A = 50
print("A = 50")
B = 33... | false |
bf01b625f245b45164d8c1610ed95ab6becd4365 | RAKUZ4N/HelloPython_1 | /1.occupation/hellopython_1.6.py | 628 | 4.1875 | 4 | # PROBLEM 9:
# Создать 2 переменные.
# В первой год вашего рождения, Во второй
# 2020 год
# посчитайте сколько лет вам должно быть через 2 года/и сколько лет вам было два года назад
my_birthyears = 2002
print("Я родился в", my_birthyears, "году")
this_year = 2021
print("Текущий год", this_year)
res = this_year + 2... | false |
91d7b234c678b208c72ff61e43ddda24ee189ed0 | RAKUZ4N/HelloPython_1 | /4.occupation/Цикл_4.3.py | 353 | 4.125 | 4 | # 3. Напишите код, который берёт цифру 7, умножает саму на себя же 5 раз.
number = 7
print("У нас есть число", number, "надо умножит её саму на себя 5 раз")
for i in range(6):
print(number)
number *= 7
print("Программа завершилась!!!") | false |
6efd7abb2ddb79175cc5fcf9f3cf8f3d031bcd1c | jihongeek/Algo | /baekjoon/2920.py | 277 | 4.34375 | 4 | inputlist = input().split()
ascending = ["1","2","3","4","5","6","7","8"]
descending = list(reversed(ascending))
if inputlist == ascending:
print("ascending",end="")
elif inputlist == descending:
print("descending",end="")
else:
print("mixed",end="")
| false |
c3e5bce720be7b1d73cdc72befdaf18f9e6c27da | dipikarpawarr/TQ_Python_Programming | /PythonPracticePrograms/String/Remove_Occurrances_Of_Specific_Character.py | 257 | 4.28125 | 4 | # WAP to remove all occurences of given char from String
strInput = input("\nEnter the string = ")
charRemove = input("Which character you have to remove = ")
result = strInput.replace(charRemove,"")
print("\nBefore = ", strInput)
print("After = ",result) | true |
06970f054e1768bc231abc16a32fff9286e053f6 | dipikarpawarr/TQ_Python_Programming | /PythonPracticePrograms/String/Anagram_String.py | 456 | 4.15625 | 4 | # WAP to accept 2 string and check whether they are anagram or not eg) MARY ARMY
strInput1 = input("Enter the first string = ")
strInput2 = input("Enter the second string = ")
if len(strInput1) == len(strInput2):
sorted1 = sorted(strInput1)
s1 = "".join(sorted1)
sorted2=sorted(strInput2)
s2 = "".join... | true |
77bd1bf62927f89fbbfc01fd300a2d5ca7677dc3 | dipikarpawarr/TQ_Python_Programming | /PythonPracticePrograms/Flow Control - Loops/Count_Digits_In_Given_Number.py | 247 | 4.28125 | 4 | # Write a Python program to count number of digits in any number
num = int(input("Enter the number = "))
numHold = num
count = 0
while(num>0):
digit = num %10
count += 1
num //= 10
print("Total digits in the ",numHold," is = ", count) | true |
85bd50a7ef08b61082969d3a7a8b5a9a7efc04e9 | dipikarpawarr/TQ_Python_Programming | /PythonPracticePrograms/Flow Control - Loops/Pallindrome_Number.py | 576 | 4.125 | 4 | # WAP to check given no is palindrome or not. Original =Reverse
# Eg 1221, 141, 12321, etc
num = input("Enter the number = ")
print("\n---- Solution 1 ----")
reverse = num[::-1]
if num == reverse:
print(num," is palindrome")
else:
print(num, " is not palindrome")
# OR
print("\n---- Solution 2 ----")
num1 = ... | true |
e9f6c423bded4e9cedd97c1be8029fc071484c05 | sidneisilvadev/projetos | /calculadora elaborada.py | 407 | 4.125 | 4 | n1=int(input("digite numero :"))
n2=int(input("digite numero :"))
oper=input("digite soma = +,subtração = -,multiplicação = *,divisao = /:")
#soma
if (oper=="+"):
print("resultado = ",n1+n2)
#subtração
if (oper=="-"):
print("resultado = ",n1-n2)
#multiplicação
if (oper=="*"):
print("resultado = ",... | false |
4480bee0ef9545850813c86dc89463e0a42015a8 | mdfox760/pypractice | /range.py | 364 | 4.15625 | 4 | for i in range(5):
print(i)
print('***')
for x in range(5, 10):
print(x)
print('***')
for b in range(0, 10, 3):
print(b)
print('***')
for c in range(-10, -100, -30):
print(c)
a = ['Mary', 'had', 'a', 'little', 'lamb']
for i in range(len(a)):
print(i, a[i])
print(range(10))
range(0, 10)
# Cr... | false |
55c986710dc439d7818700236233a042e3ca1a76 | jerome1232/datastruct-tut | /src/2-topic-starter.py | 1,629 | 4.34375 | 4 | class Queue:
'''
This represents a queue implemented by a doubly
linked list.
'''
class Node:
'''
An individual node inside a linked list
'''
def __init__(self, data):
'''Initialize with provided data and no links.'''
self.data = data
self.previous = N... | true |
47f966adae31358284fc408907a2eea4a60f5c23 | kensekense/unige-fall-2019 | /metaheuristics/example_for_kevin.py | 2,864 | 4.4375 | 4 | '''
When you're coding, you want to be doing your "actions" inside of functions.
You are usually using your "global" space to put in very specific values.
Here's an example.
'''
import random
def modifier_function (input1, input2):
'''
For simplicity, I've named the inputs to this function input1 an... | true |
1eafc06083e85e6fff87c4a0c26b0c7a759844f9 | deleks-technology/myproject | /simpleCal.py | 1,493 | 4.21875 | 4 | print("Welcome to our simple Calculator... ")
print("====================================================================")
# Prompt User for first number
# to convert a string to a number with use the int()/ float()
first_number = float(input("Please input your first number: "))
print("=========================... | true |
24dccadfc40fb85d20305d92ba298bc511a6ea64 | niranjan2822/PythonLearn | /src/Boolean_.py | 804 | 4.375 | 4 | # Boolean represent one of two values :
# True or False
print(10 > 9) # --> True
print(10 == 9) # --> False
print(10 < 9) # --> False
# Ex :
a = 200
b = 300
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
# Output --> b is greater than a
# bool() --> The bool() function all... | true |
223bf6f986a50959f1f6f61520204ad384e2daec | sachdevavaibhav/CFC-PYDSA-TEST01 | /Test-01-Py/Ans-03.py | 281 | 4.1875 | 4 | # 3. Write a Python program to sum of two given integers. However, if the sum
# is between 15 to 20 it will return 20.
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
ans = num1 + num2
if 15 <= ans <= 20:
print(20)
else:
print(ans) | true |
17eec4b963a4a7fb27a29279261a1df059be22e3 | amaria-a/secu2002_2017 | /lab03/code/hangman.py | 2,022 | 4.15625 | 4 |
# load secret phrase from file
f = open('secret_phrase.txt','r')
# ignore last character as it's a newline
secret_phrase = f.read()[:-1]
# get letters to guess, characters to keep, initialize ones that are guessed
to_guess = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
to_keep = " ,'-"
guessed = []
# creat... | true |
42e1b76389b3f6dd99e36f7d8f4d3f89fe3af8c0 | mguid73/basic_stats | /basic_stats/basic_stats.py | 788 | 4.40625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Basic stats module
"""
def mean(a):
"""
input is the list of numbers you want to take the mean
"""
# computing amount
ctlist= []
for n in a:
n=1 # changing every value in the list to 1
ctlist.append(n) # creating a new list made up... | true |
43e2dccabe35905571ca61822de501fd25906b79 | AlexanderHurst/CrackingVigenereCypher | /vigenere.py | 2,009 | 4.1875 | 4 | from sys import argv
import string_tools
from sanitization import sanitize
# takes a secret message and key and returns
# vigenere ciphertext
# note secret message and key must be a list of numbers
# use string tools to convert
def encrypt(secret_message, secret_key):
cipher_text = []
# encrypting adds the k... | true |
eb8f13ba8ef2c9a7adad8dcc94081a8aa24cb93e | hsinhuibiga/Python | /insertion sort.py | 1,419 | 4.34375 | 4 |
# sorts the list in an ascending order using insertion sort
def insertion_sort(the_list):
# obtain the length of the list
n = len(the_list)
# begin with the first item of the list
# treat it as the only item in the sorted sublist
for i in range(1, n):
# indicate the current item to be p... | true |
1f0572c27e4187c8d5c335476f8e59b5288019e2 | yonghee555/Python-Study | /7_추상_데이터_타입/13_reverse_string_with_stack.py | 314 | 4.1875 | 4 | from stack import Stack
def reverse_string_with_stack(str1):
s = Stack()
revStr = ''
for c in str1:
s.push(c)
for _ in range(s.size()):
revStr += s.pop()
return revStr
if __name__ == "__main__":
str1 = "Hello!"
print(str1)
print(reverse_string_with_stack(str1)) | false |
d70613eaa55ed3f52e384a4f97e3a751d0723e87 | grimmi/learnpython | /linkedlist1.py | 1,132 | 4.125 | 4 | '''
Linked Lists - Push & BuildOneTwoThree
Write push() and buildOneTwoThree() functions to easily update and
initialize linked lists. Try to use the push() function within your
buildOneTwoThree() function.
Here's an example of push() usage:
var chained = null
chained = push(chained, 3)
chained = push(chained, 2)
ch... | true |
d3e25805b601aff974c730abd85b4368724d09d4 | grimmi/learnpython | /reversebytes.py | 810 | 4.125 | 4 | '''
A stream of data is received and needs to be reversed.
Each segment is 8 bits meaning the order of these segments need to be reversed:
11111111 00000000 00001111 10101010
(byte1) (byte2) (byte3) (byte4)
10101010 00001111 00000000 11111111
(byte4) (byte3) (byte2) (byte1)
Total number of bits will always be a mu... | true |
b813a38631d35d6ccc84b871fade7dc9ccbde14c | ll0816/My-Python-Code | /decorator/decorator_maker_with_arguments.py | 1,084 | 4.1875 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
# decorator maker with arguments
# Liu L.
# 12-05-15
def decorator_maker_with_args(d_arg1, d_arg2):
print "I make decorators! And I accept arguments:{} {}".format(d_arg1, d_arg2)
def decorator(func):
print "I am the decorator. Somehow you passed me arguments:... | true |
295ace8f90f7303eba831493003cdd7289a4c3c9 | ll0816/My-Python-Code | /decorator/dive_in_decorator.py | 1,094 | 4.21875 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
# dive in decorator
# Liu L.
# 12-05-15
def decorator_maker():
print "I make decorators! I am executed only once:"+\
"when you make me create a decorator"
def my_decorator(func):
print "I am a decorator! I am executed"+\
"only when you decorate a... | true |
3f9963f130edfeb952f10d9197645cf7ffce7ddb | RodionLe/Dawson-Python | /7/обработаем.py | 1,609 | 4.3125 | 4 | # Демонстрирует обработку исключительных ситуаций
try:
num = float(input("Введите число "))
except:
print("Похоже, это не число")
try:
num = float(input("\nВведите число "))
except ValueError:
print("Это не число")
# Обработка исключений нескоьких разных типов
print()
for value in (None, "Привет!"):
... | false |
b8fdbfa602d0928217d6fa18a3dee3bdfaf6890d | AnanthaVamshi/PySpark_Tutorials | /code/chap02/word_count_driver_with_filter.py | 2,672 | 4.21875 | 4 | #!/usr/bin/python
#-----------------------------------------------------
# This is a word count in PySpark.
# The goal is to show how "word count" works.
# Here we write transformations in a shorthand!
#
# RULES:
#
# RULE-1:
# Here I introduce the RDD.filter() transformation
# to ignore the words if the... | true |
0ceacfc9a01043c67e1b717c205fbaf9460d87c7 | N3CROM4NC3R/python_crash_course_exercises | /dictionarys/cities.py | 215 | 4.28125 | 4 | cities = {
"Valle de la Pascua" : "Venezuela",
"New york" : "Unite States",
"Atenas" : "Greek",
"Tokyo" : "Japan"
}
for city,country in cities.items():
print("The city "+city+" is in "+country)
| false |
aa60328ddf11240a19c9aa1360b49ae37777aee9 | shreya-trivedi/PythonLearn | /q03lenght.py | 515 | 4.21875 | 4 | #!/usr/bin/python3.5
'''
Problem Statement
Define a function that computes the length of a given list or string.
(It is true that Python has the len() function built in,
but writing it yourself is nevertheless a good exercise.)
'''
import sys
def get_lenght(word):
''' Function to get lenght of a string
Args... | true |
43ea03ea1d693d03366841964a2808e64626c414 | MihaiRr/Python | /lab11/Recursion.py | 1,335 | 4.46875 | 4 | # The main function that prints all
# combinations of size r in arr[] of
# size n. This function mainly uses
# combinationUtil()
def printCombination(arr, n, r):
# A temporary array to store
# all combination one by one
data = [""] * r
# Print all combination using
# te... | true |
86b6be121a3af8171cf502278d6a7cd974db0533 | jshubh19/pythonapps | /bankaccount.py | 2,486 | 4.15625 | 4 | # bank account
class BankAccount:
''' this is Janta ka Bank'''
def __init__(self,accountname='BankAccount',balance=20000): #for making class method we use __init__ const
self.accountname=accountname
self.balance=baalance
def deposite (self,value):
self.balance=self.balance+val... | true |
03db8cb0753c56ea69c9e69a1c30b8dc11212cad | rfc8367/R1 | /L15/Task_3.py | 1,028 | 4.1875 | 4 | import re
def password_patterns():
while True:
user_password = input('Enter your password: ')
length = len(user_password)
print(f'Your password length {length}')
if len(user_password) <= 8:
print('Password must contain at least 8 characters')
continue
... | false |
6c562dadd0b180b5357b4ce57c73b440cb7c06a3 | Mariam-Hemdan/ICS3U-Unit-4-01-Python | /while_loop.py | 470 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by : Mariam Hemdan
# Created on : October 2019
# This program uses while loop
def main():
# this program uses While loop
sum = 0
loop_counter = 0
# input
positive_integer = int(input("Enter an integer: "))
print("")
# process & output
while loop_coun... | true |
78eebbec669e95bedd57fb74714c56a8a3705178 | Pyabecedarian/Algorithms-and-Data-Structures-using-Python | /Stage_1/Task5_Sorting/bubble_sort.py | 729 | 4.28125 | 4 | """
Bubble Sort
Compare adjacent items and exchange those are out of order. Each pass through the list places the next
largest value in its proper place.
If not exchanges during a pass, then the list has been sorted.
[5, 1, 3, 2] ---- 1st pass ----> [1, 3, 2, 5]
Complexity: O(n^2)
"""
def bub... | true |
5e3a27d7f44acfc40517e889015a6bc778855ade | EarthBeLost/Learning.Python | /Exercise 3: Numbers and Math.py | 1,051 | 4.59375 | 5 | # This is the 3rd exercise!
# This is to demonstrate maths within Python.
# This will print out the line "I will now count my chickens:"
print "I will now count my chickens:"
# These 2 lines will print out their lines and the result of the maths used.
print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4
# Th... | true |
a3ee6737bc9880a213034cfc71ffd34b3f4d1215 | JakeGads/Python-tests | /Prime.py | 888 | 4.1875 | 4 | """
Ask the user for a number and determine whether the number is prime or not.
(For those who have forgotten, a prime number is a number that has no divisors.).
You can (and should!) use your answer to Exercise 4 to help you.
Take this opportunity to practice using functions, described below.
"""
def main():
run ... | true |
d546a4375fabc0e79a9d7668e12a7d9de2606cc1 | Monukushwaha/Python_Practice- | /conditional27.py | 215 | 4.125 | 4 | #Python program to print alphabet pattern 'T'.
for i in range(1,8):
for j in range(1,8):
if (i>1 and (j==1 or j==2 or j==4 or j==5)):
print(" ", end="")
elif(i<8 and j<=5):
print("*", end="")
print()
| false |
54c8d3a2094f4f575acd6ea4ecac7a4dc1746ec8 | green-fox-academy/wenjing-liu | /week-01/day-03/data_structure.py/product_db_2.py | 1,472 | 4.53125 | 5 | product_db = {
'milk': 200,
'eggs': 200,
'fish': 400,
'apples': 150,
'bread': 50,
'chicken': 550
}
def search_db(db):
print('Which products cost less than 201?')
smaller_keys = []
for key, value in product_db.items():
if value < 201:
smaller_keys.append(key)
if smaller_keys:
print(f... | true |
c874fd86801315b98f608f9011a54ef8299a8b54 | green-fox-academy/wenjing-liu | /week-01/day-05/matrix/matrix_rotation.py | 952 | 4.1875 | 4 | """
# Matrix rotation
Create a program that can rotate a matrix by 90 degree.
Extend your program to work with any multiplication of 90 degree.
"""
import math
def rotate_matrix(matrix, degree):
rotate_times = degree//90%4
print(rotate_times)
for rotate_time in range(rotate_times):
tmp_matrix = []
... | true |
75194eb550340de1c1ab9a31adc510fec7ef771b | green-fox-academy/wenjing-liu | /week-02/day-01/encapsulation-constructor/counter.py | 947 | 4.125 | 4 | class Counter:
def __init__(self, num = 0):
self.num = int(num)
self._initial_num = self.num
def add(self, number = 1):
if isinstance(number, (int, float)):
self.num += int(number)
else:
raise Exception('You must input number')
def get(self):
return self.num
def reset(se... | true |
12c1001a8ec9759c913683af89a5f8db183d87a7 | green-fox-academy/wenjing-liu | /week-02/day-02/decryption/reversed_order.py | 510 | 4.15625 | 4 | # Create a method that decrypts reversed-order.txt
def decrypt(file_name, result_file_name):
try:
with open(file_name, 'r') as source_file:
with open(result_file_name, 'a') as result_file:
line_list = source_file.readlines()
result_file.write(''.join(reverse_order(line_list)))
except Exce... | true |
6f8fa5537d1c905be5afa97b890f334fb16fcd43 | green-fox-academy/wenjing-liu | /week-01/day-02/loops/guess_the_number.py | 634 | 4.21875 | 4 | # Write a program that stores a number, and the user has to figure it out.
# The user can input guesses, after each guess the program would tell one
# of the following:
#
# The stored number is higher
# The stried number is lower
# You found the number: 8
magic_num = 5
print('Guess the number!')
is_found = False
whil... | true |
01e271b2fd0fbdd4b16f96d6171e294982bd0674 | green-fox-academy/wenjing-liu | /week-01/day-05/matrix/transposition.py | 465 | 4.15625 | 4 | """
# Transposition
Create a program that calculates the transposition of a matrix.
"""
def transposition_matrix(matrix):
result = []
for col_num in range(len(matrix[0])):
result.append([None]*len(matrix))
print(result)
for row_num in range(len(result)):
for col_num in range(len(result[row_num])):
... | true |
29031610a8bc863cea296a89d3bc058715762bf3 | green-fox-academy/wenjing-liu | /week-01/day-03/functions/bubble.py | 575 | 4.34375 | 4 | # Create a function that takes a list of numbers as parameter
# Returns a list where the elements are sorted in ascending numerical order
# Make a second boolean parameter, if it's `True` sort that list descending
def bubble(arr):
return sorted(arr)
def advanced_bubble(arr, is_descending = False):
sorted_a... | true |
6eeb0463f0b42acc6fde7d5b61449e790949897b | dylan-hanna/ICS3U-Unit-5-05-Python | /address.py | 816 | 4.125 | 4 | #!/usr/bin/env python3
# Created by: Dylan Hanna
# Created on: Nov 2019
# This program accepts user address information
def mailing(name_one, address_one, city_one, province_one, postal_code_one):
print(name_one)
print(address_one)
print(city_one, province_one, postal_code_one)
def main():
while Tru... | true |
821ad576d77ac6c4c70c4dc1371750ab272a373c | ShelbyBhai/Mini-Projects-in-Python | /Encryption/EncryptedMessage.py | 456 | 4.4375 | 4 | print("Enter the Given Text & Shift Value : ")
_input_string = input()
_shift_Value = int(input())
print(_input_string, _shift_Value)
encrypted_input_string = ""
for char in _input_string:
if char.isupper():
encrypted_input_string += chr((ord(char)+_shift_Value-65)%26+65)
elif char.islower():
... | false |
870d8536737e98f5e09e6475cea90552b8ae1aaf | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 4 - Style and Structure/73-multi-line-strings.py | 2,669 | 4.125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 4. Style & Structure > Section 3:
# Multi-line strings (1/2)
'''
Sometimes we end up wanting to use very long strings, and this can
cause some problems.
If you run pycodestyle on this, you'll get the following message:
some_script.py: E501 line too l... | true |
861a628085be4eea68e5e32c6cab55f2d0f36838 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/29-f-strings.py | 1,068 | 4.3125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 16: f-strings
# Do it in the terminal:
'''
f-strings is something that was added to Python in version 3.6—
so in order for this to work on your own computer, you must be sure
to have Python 3.6 or later. As a remin... | true |
8eafc4cab7035114ead9e844e3f5a57c3c489e01 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/24-slicing-word-triangle-exercise.py | 977 | 4.1875 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 12: Slicing(1/2)
'''
Exercise: Word triangle
find a partially completed for loop.
Goal is to finish the loop so that it prints out the following:
d
de
def
defi
defin
defini
definit
definite
definitel
definitely
'''... | true |
95e54eacc1da6c8c5b8724634c686b56b1ae1e41 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/43-mutable-vs-immutable.py | 905 | 4.3125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 3:
# Mutable vs. immutable
'''
List are mutable (can be modified)
Strings are immutable (cannot be modified)
'''
# Exercise 1 - Mutable
print('\nExercise 1 - Mutable:\n')
breakfast = ['toast', 'bacon', 'eggs']
pri... | true |
f9ca6dad8f3dc6f8363fe1b8a49072604bb770ab | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/66-convert-string-into-list.py | 800 | 4.5625 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 17:
# Find and replace (1/2)
# Convert a string into a list
# Approach 1 (without using split method)
def list_conversion(string):
list = []
for index in string:
list.append(index)
return list
... | true |
46b0b93e3d86c6cc425459be309bd3bd15ed3d1c | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/19-range-function.py | 1,245 | 4.71875 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 9:
# The range function, revisited
'''
Earlier, we used the range function with for loops.
We saw that instead of using a list like this:
'''
print()
for side in [0, 1, 2, 3]:
print(side)
print()
# Range can ... | true |
9580691741d7e3c606279cd91512724f8c087993 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/56-break-exercise-no-repeating-words.py | 686 | 4.21875 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 10:
# Infinite loops and breaking out
# Exercise - Repeated words:
'''
Write an function to store the words input by the user
and exit the while loop when a word is repeated.
There's another way to exit from an in... | true |
4e4ed96929cf2fe0808c10535714fb92c2f7e6e8 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/45-augmented-assignments.py | 941 | 4.59375 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 4:
# Augmented assignments
# Try them on interpreter
>>> n = 1
>>> n = n + 2
>>> n = 2
>>> n = n * 3
>>> n
6
>>> n = 5
>>> n = n / 2
>>> n
2.5
>>> n = 10
>>> n = n - 6
>>> n
4
>>> s = "Hello"
>>> s = s + " wor... | false |
612dbf123309396abbe8755f327c1e0eed8d5303 | divineBayuo/NumberGuessingGameWithPython | /Number_Guessing_GameExe.py | 1,959 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 3 10:52:42 2021
@author: Divine
"""
#putting both programs together
#importing required libs
import tkinter as tk
import random
import math
root = tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()
#making the game cod... | true |
cca6ea9561c63a741e72107d537b70054a4220c2 | goateater/MyCode | /learn_python/basic_string_operations.py | 785 | 4.5 | 4 | #!/usr/bin/env python
bso = """
Basic String Operations
----------------------
Strings are bits of text. They can be defined as anything between quotes:
As you can see, the first thing you learned was printing a simple sentence. This sentence was stored by Python as a string.
However, instead of immediately printin... | true |
78b6c9150a4804af6f60d62d040fc09c9f86d0a1 | nfbarrett/CCIS-1505-02 | /Session11/Test2-Q28.py | 549 | 4.21875 | 4 | blnDone = False # sets Boolean to false
while blnDone == False: # checks Boolean is still false
try: # repeats this until Boolean is true
num = int(input( "Enter your age" )) # asks for number, converts input into integer
blnDone = True # sets Boolean to true
except (ValueError): # if input is n... | true |
ba771d7f4f312d4276781c88642d7aae08baaf7d | nfbarrett/CCIS-1505-02 | /Session11/Test2-Q27.py | 837 | 4.46875 | 4 | def maximumValue( x, y, z ): # calls the function for maximumvalue
maximum = x # if position 1 is max this will be displayed
if y > maximum: # checks if position 2 is larger that position 1
maximum = y # if position 2 is larger, position 2 will be displayed
if z > maximum: # checks if position 3 is... | true |
dfc321e797972f83c637e08ca943ffa9568a3496 | nfbarrett/CCIS-1505-02 | /Session06/p6.py | 1,733 | 4.1875 | 4 | # Programer: Nick Barrett
# Date Written: Oct 01, 2019
# Program Name: P6.py
# Company Name: HTC-CCIS1505
#step 1
print("Step 1")
lstWeekDays = []
int_Counter=0
while int_Counter <= 6:
strWeekDay = input("Enter day of the week: ")
int_Counter += 1 # count up by 1
strWeekDay = strWeekDay.title()
lstWee... | false |
15b5733f80fddc8c8a22522ae0653f1de90546bf | liujiantao007/Perform-Object-Detection-With-YOLOv3-in-Keras | /Draw_rectangle/single_rectangle_cv2.py | 911 | 4.3125 | 4 | # Python program to explain cv2.rectangle() method
# importing cv2
import cv2
from matplotlib import pyplot as plt
path ='2.jpg'
# Reading an image in default mode
image = cv2.imread(path)
# Window name in which image is displayed
window_name = 'Image'
# Start coordinate, here (5, 5)
# represents the top ... | true |
5d9b8983b5652dc449658873bfd8b237fdc57b64 | jsheridanwells/Python-Intro | /7_dates.py | 955 | 4.375 | 4 | #
# Example file for working with date information
#
from datetime import date
from datetime import time
from datetime import datetime # imports standard modules
def main():
## DATE OBJECTS
# Get today's date from the simple today() method from the date class
today = date.today()
print('la fecha es ', today... | true |
a1a92e7de2c597aaa4d1a6443bc2354216c9f1f5 | pavan1126/python-1-09 | /L3 8-09 Reverse order.py | 379 | 4.25 | 4 | #copying elements from one array to another array in reverse order
a=[1,2,3,4,5]
b=[None]*len(a)
length=len(a)
#logic starts here
for i in range(0,length):
b[i]=a[length-i-1]
#printing output
print("the elements of first array is")
for i in range(0,length):
print(a[i])
print("the elements of reversed... | true |
48784ce85ac8a8ce79dd42790846e894523904cf | eessm01/100-days-of-code | /e_bahit/wrappers_decorators.py | 1,341 | 4.53125 | 5 | """The Original Hacker. N.4. Wrappers y Decoradores.
Closure. Es una función que dentro de ella contiene a
otra función la cual es retornada cuando el closure es
invocado.
DECORADOR. Es aquel closure que cómo parámetro recibe
una función (llamada función "decorada") cómo único
argumento.
WRAPPER. No es más que la fu... | false |
dd9f0ef34231d01242086ef70453cb401ef37a77 | eessm01/100-days-of-code | /platzi_OOP_python/bubble_sort.py | 567 | 4.125 | 4 | from random import randint
def bubble_sort(one_list):
n = len(one_list)
limit = n - 1
for i in range(n):
for j in range(limit):
if one_list[j] > one_list[j+1]:
one_list[j], one_list[j+1] = one_list[j+1], one_list[j]
limit -= 1
return one_list
if __na... | false |
84eb0afd3ad225fc0e23eb56292b845ed1d4e4ec | eessm01/100-days-of-code | /python_for_everybody_p3/files_exercise1.py | 348 | 4.375 | 4 | """Python for everybody.
Exercise 1: Write a program to read through a
file and print the contents of the file (line
by line) all in upper case. Executing the
program will look as follows:
"""
fname = input('Enter a file name: ')
try:
fhand = open(fname)
except:
print('File not found')
exit()
for line... | true |
c2516b677840cbb77294f74049e04bed243b559c | eessm01/100-days-of-code | /platzi_comp_thinking/dictionaries.py | 600 | 4.21875 | 4 | my_dict = {
'David': 35,
'Erika': 32,
'Jaime': 50
}
print(my_dict)
valor = my_dict.get('Juan', 99)
print(valor)
valor = my_dict.get('Jaime', 30)
print(valor)
my_dict['Jaime'] = 20
print(my_dict)
my_dict['Pedro'] = 42
print(my_dict)
del my_dict['Jaime']
print(my_dict)
for llave in my_dict.keys():
... | false |
b01c74c82073bf2a8cfdbbba7ac08bfd433a4560 | eessm01/100-days-of-code | /platzi_OOP_python/insertion_sort.py | 799 | 4.21875 | 4 | from random import randint
def insertion_sort(one_list):
# iterate over one_list from 1 to list's length
for i in range(1, len(one_list)):
current_element = one_list[i]
# iterate over all elements in the left side (from i-1 to 0)
for j in range(i-1,-1,-1):
# compare cur... | true |
3869deac3ad24925a63d2cdaeb4db9431e08a8af | eessm01/100-days-of-code | /real_python/day10_11_dear_pythonic_santa_claus.py | 1,732 | 4.28125 | 4 | #!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""
Exercises from https://realpython.com/python-thinking-recursively/
The algorithm for interative present delivery implemented in Python
Now that we have some intuition about recursion, let's introduce the formal
definition of a recursive function. A recursive function ... | true |
a856343bc217c4d0e4e6b4fce3212d587cef5e38 | eessm01/100-days-of-code | /project_euler/5_smallest_multiple.py | 592 | 4.21875 | 4 | def get_smallest_multiple(max_divisor):
is_find = False
initial_smallest_number = 2520
while not is_find:
for i in range(max_divisor, 1, -1):
if initial_smallest_number % i > 0:
break
else:
if i == 2:
is_find = True
... | false |
c2cde7223eafaf4d2c98b3bdef23a6653511f93e | BitPunchZ/Leetcode-in-python-50-Algorithms-Coding-Interview-Questions | /Algorithms and data structures implementation/binary search/index.py | 678 | 4.34375 | 4 |
def binarySearch(arr, target):
left = 0
right = len(arr)-1
while left <= right:
mid = (left+right)//2
# Check if x is present at mid
if arr[mid] == target:
return mid
# If x is greater, ignore left half
elif arr[mid] < target:
left = mid + ... | true |
2ed7c2c6e4649e464527da216f9c51a6bca47ac1 | MaxFallishe/Python__web | /Basic_python/Дз1/Dz1_2.py | 564 | 4.125 | 4 | import math
a = int(input("Введите число a:" ))
b = int (input("Введите число b:"))
c = int (input("Введите число c:"))
D = b ** 2 - 4 * a * c
print(D)
if D < 0:
print("Корней нет")
elif D == 0:
x = -b / 2 * a
print ("Корень = ",x)
else:
x1 = (-b + math.sqrt(D)) / (2 * a)
x2 = (-b - math.sqrt(D)) / (2 * a)
... | false |
efd43f194e740f108d25a1a7a8e3fce39e208d5a | DhananjayNarayan/Programming-in-Python | /Google IT Automation with Python/01. Crash Course on Python/GuestList.py | 815 | 4.5 | 4 | """
The guest_list function reads in a list of tuples with the name, age, and profession of each party guest, and prints the sentence "Guest is X years old and works as __." for each one.
For example, guest_list(('Ken', 30, "Chef"), ("Pat", 35, 'Lawyer'), ('Amanda', 25, "Engineer"))
should print out:
Ken is 30 years... | true |
1bf31d944d5650e5c3c2bd35a75dbef782f24ec7 | ReDi-school-Berlin/lesson-6-exercises | /6-dictionaries/dictionaries.py | 1,298 | 4.5 | 4 | # What are some differences between dictionaries and lists?
# dict is not indexable
# lists are ordered and dictionaries aren't
# dictionaries cannot have duplicate keys
# --------------------
# How to create an empty dictionary
person = {}
# --------------------
# add values for this person, like name, phon... | true |
9dc5d49761e60130666eb29c350de8612300e18e | Scimitarr/Python-scripts | /lab2.py | 1,630 | 4.125 | 4 | print("------------ZADANIE-1--------------------")
initialCapital = 20000
percent = 0.03
maxTimeYears = 10
year = 1
capital = initialCapital
while year <= maxTimeYears:
capital = capital * (1+percent)
print("Capital at the end of %d year is %d" % (year, capital))
year += 1
print("Through %d years ... | false |
9a27ab3cacd389a2bd69066a4241542185256072 | tomdefeo/Self_Taught_Examples | /python_ex284.py | 419 | 4.3125 | 4 | # I changed the variable in this example from
#
text in older versions of the book to t
# so the example fits on smaller devices. If you have an older
# version of the book, you can email me at cory@theselftaughtprogrammer.io
# and I will send you the newest version. Thank you so much for purchasing my book!
impor... | true |
d6c7cd46e60e6aa74cdd28de4f94aa45a65eb861 | GarrisonParrish/binary-calculator | /decimal_conversions.py | 1,823 | 4.1875 | 4 | """Handle conversions from decimal (as integer/float) to other forms."""
# NOTE: A lot of this code is just plain bad
def dec_to_bin(dec: int, N: int = 32):
"""Converts decimal integer to N-bit unsigned binary as a list. N defaults to 32 bits."""
# take dec, use algorithm to display as a string of 1's and 0... | true |
f0d5e4afb2071cdcba9d49f6925a597a466ad245 | EroshenkoD/BBP_Python_hillel | /lesson_12/task_2.py | 624 | 4.21875 | 4 | """
2. Имеется строка вида: AABABBAABBBAB. Необходимо написать функцию которая заменит буквы A на B, а B, соответственно,
на A. Замену можно производить ТОЛЬКО используя функцию replace(). В результате применения функции к исходной строке,
функция должна вернуть строку: BBABAABBAAABA
"""
s = 'AABABBAABBBAB'
def repl... | false |
2726d03db151046c1091b93d14a5593c2d368e52 | vrillusions/python-snippets | /ip2int/ip2int_py3.py | 963 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Asks for an IPv4 address and convert to integer.
In Python v3.3 the ipaddress module was added so this is much simpler
"""
import sys
import ipaddress
__version__ = '0.1.0-dev'
def main(argv=None):
"""The main function.
:param list argv: List of arguments ... | true |
30d6d86bbcdcfee563d26985ccfaae90c8480397 | Splufic-Automation-Systems-Ltd/Python-Training-Online-Cohort-One | /Week Three/Day 2/temp.py | 340 | 4.375 | 4 |
import math
# a python program that converts temperature from Farenheit to Celcius
# get the user input
fahrenheit = input('Enter the temperature in degrees Fahrenheit: ')
# calculate the result
result = (5/9 * (int(fahrenheit) - 32))
result = math.trunc(result)
# print the result
print(f'The temperature in degrees C... | true |
d1d792d85b93fcb95cfc3183cf05541dd8579d84 | rotus/the-python-bible | /tuple_examples.py | 248 | 4.125 | 4 | # Tuples, like lists, hold values - Except tuple data CANNOT be changed
# Useful for storing data/values that never need updated or modified
our_tuple = (1,2,3,"a","b")
print(our_tuple)
# Pull data out of individual elements
print(our_tuple[3])
| true |
9cf228ee2b0cd2fa8899ce07b5ccc5738d729e92 | rotus/the-python-bible | /dictionary_basics.py | 394 | 4.5625 | 5 | # Used to store values with "keys" and then can retreive values based on those keys
students = {"Alice":25, "Bob":27, "Claire":17, "Dan":21, "Emma":25}
print(students)
# extract Dan's value from dict
print(students["Dan"])
# Update Alice's age
print(students["Alice"])
students["Alice"] = 26
print(students["Alice"])... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.