0% found this document useful (0 votes)
5 views3 pages

Variables and Data Types

The document presents two problems involving Python programs for storing and displaying personal information. The first program collects basic user data such as name, age, height, and contact details, while the second program creates a comprehensive personal profile that includes additional details like hobbies, education, and skills using various data types. Each solution demonstrates the use of different Python data structures to effectively manage and display user information.

Uploaded by

Guru Teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Variables and Data Types

The document presents two problems involving Python programs for storing and displaying personal information. The first program collects basic user data such as name, age, height, and contact details, while the second program creates a comprehensive personal profile that includes additional details like hobbies, education, and skills using various data types. Each solution demonstrates the use of different Python data structures to effectively manage and display user information.

Uploaded by

Guru Teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Problem 1:

1. A program is designed to store and display personal information collected


from a user for a registration form. This information includes various data
types.write a python program to display personal info

Solution:

# String: User's full name


name = "John Doe"

# Integer: User's age


age = 30

# Float: User's height in meters


height = 1.75

# Boolean: True if the user is currently a student


is_student = False

# List of Integers: User's favorite numbers


favorite_numbers = [7, 14, 21]

# Dictionary: User's contact information


contact_details = {
"email": "[email protected]",
"phone": "123-456-7890"
}

# Displaying the collected information


print(name)
print(age)
print(height)
print(is_student)
print(favorite_numbers)
print(contact_details)
Problem 2:

Real-Time Scenario: Personal Profile Data Aggregator

Scenario Description:
A Python program is designed to create a comprehensive personal profile for a user.
This profile includes various details such as personal information, hobbies,
education, and contact details. Each piece of information is stored using a different
Python data type.

Data Types and Their Usage:


​ int: Age of the user.
​ float: User's average score or rating.
​ string: User's name.
​ list: List of user's favorite books.
​ tuple: User's birth date (year, month, day).
​ dictionary: User's education details (key: level, value: institution name).
​ set: Set of user's skills.
​ boolean: User's employment status.
​ frozen set: User's immutable set of languages known.

Solution:

# String: User's name


name = "Alice Johnson"

# Integer: User's age


age = 28

# Float: User's average score


average_score = 8.7

# List: User's favorite books


favorite_books = ["1984", "To Kill a Mockingbird", "The Great Gatsby"]

# Tuple: User's birth date (year, month, day)


birth_date = (1995, 5, 12)

# Dictionary: User's education details


education = {
"High School": "Springfield High",
"College": "State University",
"Masters": "Prestige Institute of Technology"
}

# Set: User's skills


skills = {"Programming", "Data Analysis", "Creative Writing"}

# Boolean: User's employment status


is_employed = True

# Frozen Set: User's known languages


known_languages = frozenset(["English", "Spanish", "French"])

# Aggregated Personal Profile


personal_profile = {
"Name": name,
"Age": age,
"Average Score": average_score,
"Favorite Books": favorite_books,
"Birth Date": birth_date,
"Education": education,
"Skills": skills,
"Employment Status": is_employed,
"Known Languages": known_languages
}

# Display the personal profile


for key, value in personal_profile.items():
print(f"{key}: {value}")

You might also like