Tuples Basics
Jun 13 2015- POSTED BY projecth
Introduction Tuples are immutable lists. >>> my_tuple = (1,2,3) >>> my_tuple (1,2,3) Parentheses are not what makes a tuple a […]
Read MoreIntroduction Tuples are immutable lists. >>> my_tuple = (1,2,3) >>> my_tuple (1,2,3) Parentheses are not what makes a tuple a […]
Read Moreteachers_dict = {‘Jason Seifer’: [‘Ruby Foundations’, ‘Ruby on Rails Forms’, ‘Technology Foundations’], ‘Kenneth Love’: [‘Python Basics’, ‘Python Collections’]} def most_classes(teachers_dict): […]
Read MoreUnpacking Considering dictionaries, the format( ) function can be used several ways. Regular Way >>> my_string = “Hi! My name […]
Read MoreIntroduction >>> my_dict = {‘name’: ‘Kenneth’} >>> my_dict {‘name’: ‘Kenneth’} Key Order of keys can change over time. This is why […]
Read More[Start:Stop:Step] >>> my_list = list(range(20)) >>> my_list [0,1,2,3, … , 19] >>> my_list[::2] [0,2,4,6,8, … ,18] >>> my_list[2::2] [2,4,6,8, … […]
Read MoreItem Index >>> a_list = list(‘abzcd’) >>> a_list.index(‘z’) 2 Delete by index List Items Deletion >>> del a_list[2] >>> a_list [‘a’, […]
Read MoreCombining Lists append( list ) >>> a_list = [1, 2, 3] >>> a_list.append( [4, 5] ) >>> a_list [1, 2, […]
Read MoreMy Solution Guess a number from 1 to 10 game. import random def init_game(): print(“Guess a number between 1 and 10. […]
Read MoreIntroduction To Functions Definition def say_hello( ): print(“Hello!”) Arguments def add_to_two(num): print(num+2) >>> add_to_two(2) 4 Return def square(num): return num*num […]
Read MoreLists Lists my_list = [ 1, 2.5, ‘a’ ] >>> list(‘a’) # Function creates a list of characters from the […]
Read MoreNumeric Variables a = 1, b = 2 c = a + b >>> print(c) 3 int( variable ) [string_multiply]: input_string […]
Read MoreInput/Output Output: print(“Bashar”) Input: input(“What is your name?”) >>> name = input(“What is your name? “) What is your name? Bashar >>> print(name) Bashar String Concatination [lumberjack.py]: name = input(“What’s your name? “) […]
Read MoreAt the end of this course, we’re going to build a Guess the Number game. There are two ways to […]
Read MoreInstalling Python from http://www.python.org To automatically be able to access python through the command prompt, Make sure to install Add python.exe […]
Read More