var1 = input("What school do you go to?:")
var2 = input("What sport do you like?:")
var3 = input("What class are you taking right now?:")
my_list = [var1, var2, var3]
my_dict = {
var1,
var2,
var3
}
print(my_list)
print(my_dict)
print("Hi, I go to " + var1 + ", I like " + var2 + ", and I'm taking " + var3)
['Del Norte', 'soccer', 'CSP']
{'Del Norte', 'soccer', 'CSP'}
Hi, I go to Del Norte, I like soccer, and I'm taking CSP
%%javascript
let fullName = "Jane Smith";
let age = 32;
let email = "jane.smith@example.com";
let hobby = "Mountain Climbing";
let dietaryPreferences = "Vegetarian";
let initials = fullName.slice(0, 2); //first two letters of the name
let randomNum = Math.floor(Math.random() * 900) + 100;
let uniqueID = initials + randomNum;
let userInfo = {
fullName: fullName,
age: age,
email: email,
hobby: hobby,
dietaryPreferences: dietaryPreferences,
uniqueID: uniqueID
};
let output = `
<h3>Personal Info:</h3>
<ul>
<li><b>Full Name:</b> ${userInfo.fullName}</li>
<li><b>Age:</b> ${userInfo.age}</li>
<li><b>Email:</b> ${userInfo.email}</li>
<li><b>Hobby:</b> ${userInfo.hobby}</li>
<li><b>Dietary Preferences:</b> ${userInfo.dietaryPreferences}</li>
<li><b>Unique ID:</b> ${userInfo.uniqueID}</li>
</ul>
`;
element.html(output);
<IPython.core.display.Javascript object>
string1 = "I am taking CSP"
string2 = "This is the second sentence"
print("String 1:", string1)
length1 = len(string1)
print("Length of String 1:", length1)
def count_vowels(text):
vowels = "aeiouAEIOU"
return sum(1 for char in text if char in vowels)
print("Vowel Count in String 1:", count_vowels(string1))
def avg_word_length(text):
words = text.split()
return sum(len(word) for word in words) / len(words) if words else 0
print("Average Word Length in String 1:", avg_word_length(string1))
def is_palindrome(text):
cleaned = "".join(text.lower().split())
return cleaned == cleaned[::-1]
print("Is String 1 a Palindrome?", is_palindrome(string1))
print("\nString 2:", string2)
length2 = len(string2)
print("Length of String 2:", length2)
print("Vowel Count in String 2:", count_vowels(string2))
print("Average Word Length in String 2:", avg_word_length(string2))
print("Is String 2 a Palindrome?", is_palindrome(string2))
String 1: I am taking CSP
Length of String 1: 15
Vowel Count in String 1: 4
Average Word Length in String 1: 3.0
Is String 1 a Palindrome? False
String 2: This is the second sentence
Length of String 2: 27
Vowel Count in String 2: 8
Average Word Length in String 2: 4.6
Is String 2 a Palindrome? False
<IPython.core.display.Javascript object>