This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| marks = {'Math' : 90, 'English' : 85, 'Physics' : 91, 'Chemistry' : 90, 'Economics' : 95} | |
| # Method 1: | |
| for subject in marks.keys(): | |
| print subject, marks[subject] | |
| ''' | |
| Economics 95 | |
| Chemistry 90 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| marks = {'Math' : 90, 'English' : 85, 'Physics' : 91, 'Chemistry' : 90, 'Economics' : 95} | |
| print marks['Economics'] #-> 95 | |
| print 'French' in marks #-> False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| marks = {'Math' : 90, 'English' : 85, 'Physics' : 91, 'Chemistry' : 90, 'Economics' : 95} | |
| print marks.keys() | |
| ''' | |
| Math | |
| English | |
| Physics | |
| Chemistry | |
| Economics | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sun_data = [ | |
| [43.8, 60.5, 190.2, 144.7, 240.9, 210.3, 219.7, 176.3, 199.1, 109.2, 78.7, 67.0], | |
| [49.9, 54.3, 109.7, 102.0, 134.5, 211.2, 174.1, 207.5, 108.2, 113.5, 68.7, 23.3], | |
| [63.7, 72.0, 142.3, 93.5, 150.1, 158.7, 127.9, 135.5, 92.3, 102.5, 62.4, 38.5], | |
| [51.0, 57.9, 133.4, 110.9, 112.4, 199.3, 124.0, 178.3, 102.1, 100.7, 55.7, 58.0], | |
| [69.5, 94.3, 187.6, 152.5, 170.2, 226.9, 237.6, 242.7, 177.3, 101.3, 53.9, 59.0], | |
| [65.9, 96.6, 122.5, 124.9, 216.3, 192.7, 269.3, 184.9, 149.1, 81.5, 48.7, 31.3], | |
| [48.1, 62.0, 121.5, 127.3, 188.5, 196.3, 274.3, 199.9, 144.7, 102.6, 65.4, 48.9], | |
| [43.4, 89.2, 71.4, 133.2, 179.5, 166.2, 119.2, 184.7, 79.3, 103.1, 48.9, 62.3], | |
| [50.9, 66.6, 99.7, 103.1, 185.0, 181.3, 140.1, 202.3, 143.0, 79.1, 65.9, 41.2], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| naturals = [] | |
| naturals = [i for i in integers if i >= 0] | |
| print naturals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| integers = [-1, -2, -5, 0, 1, 6, 7] | |
| naturals = [] | |
| for i in integers: | |
| if i >= 0: | |
| naturals.append(i) | |
| print naturals |
NewerOlder