This file contains 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
#include <iostream> | |
using namespace std; | |
struct Node | |
{ | |
int data; | |
Node *next; | |
}; | |
class link | |
{ | |
public: |
This file contains 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
week_temps_f = "75.1,77.7,83.2,82.5,81.0,79.5,85.7" | |
temp_list = week_temps_f.split(',') #converting string into a list | |
lst=[float(i) for i in temp_list] #converting string values of list into float | |
avg_temp = sum(lst)/len(lst) #calculating average |
This file contains 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
addition_str = "2+5+10+20" | |
lst = addition_str.split('+') #converting string into list | |
new_lst = [int(i) for i in lst] #converting strings into integer | |
sum_val = sum(new_lst) #Sum of list | |
This file contains 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
original_str = "The quick brown rhino jumped over the extremely lazy fox." | |
counter = 0 #intializing a counter varialble | |
for i in original_str: | |
counter += 1 #adding 1 after every iteration | |
num_chars = counter #getting the result |
This file contains 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
str1 = "Today you are you! That is truer than true! There is no one alive who is you-er than you!" | |
if 'false' in str1: | |
output = "False. You aren't you?" | |
elif "true" in str1: | |
output = "True! You are you!" | |
else: | |
output = "Neither true nor false" |
This file contains 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
percent_rain = [94.3, 45, 100, 78, 16, 5.3, 79, 86] | |
resps = [] | |
for i in percent_rain: | |
if i > 90: | |
resps.append("Bring an umbrella.") | |
elif i >80: | |
resps.append("Good for the flowers?") | |
elif i > 50: | |
resps.append("Watch out for clouds!") | |
else: |
This file contains 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
words = ["water", "chair", "pen", "basket", "hi", "car"] | |
num_words = 0 | |
for i in words: | |
if len(i) > 3: | |
num_words += 1 |
This file contains 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
words = ["adopt", "bake", "beam", "confide", "grill", "plant", "time", "wave", "wish"] | |
past_tense = [] | |
for i in words: | |
if(i[len(i)-1] == 'e'): | |
i += 'd' | |
else: | |
i += 'ed' | |
past_tense.append(i) |
This file contains 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
rainfall_mi = "1.65, 1.46, 2.05, 3.03, 3.35, 3.46, 2.83, 3.23, 3.5, 2.52, 2.8, 1.85" | |
months = rainfall_mi.split(",") | |
count = 0 | |
for i in months: | |
if float(i) > 3.0: | |
count += 1 | |
num_rainy_months = count |
This file contains 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
items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"] | |
count = 0 | |
for i in items: | |
if 'w' in i: | |
count += 1 | |
acc_num = count |
OlderNewer