Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:39:56+00:00 2026-06-01T19:39:56+00:00

Can someone explain help me understand how the this bit of code works? Particularly

  • 0

Can someone explain help me understand how the this bit of code works? Particularly how the myHeap assignment works. I know the freq variable is assigned as a dictionary. But what about my myHeap? is it a Set?

    exe_Data = {
      'e' : 0.124167,
      't' : 0.0969225,
      'a' : 0.0820011,
      'i' : 0.0768052,
     }

    freq = exe_Data)

    myHeap = [[pct, [symbol, ""]] for symbol, pct in freq.items()]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:39:58+00:00Added an answer on June 1, 2026 at 7:39 pm
    exe_Data = {
      'e' : 0.124167,
      't' : 0.0969225,
      'a' : 0.0820011,
      'i' : 0.0768052,
     }
    

    The above code creates a dictionary called ‘exe_Data’. Another way to do this is to use the built-in constructor, dict() with keyword arguments as follows: exe_Data = dict(e=0.12467, t=0.0969225, a=0.0820011, i=0.0768052)

    freq = exe_Data)
    

    I think the above bit should read freq=exe_Data. It makes another reference to the dictionary created in the previous bit.

    myHeap = [[pct, [symbol, ""]] for symbol, pct in freq.items()]
    

    This last part creates a list using a list comprehension. It creates a list of lists of two things, The first thing is a key from the dictionary created and referenced above, and the second thing is a list containing the corresponding value from the dictionary and a blank string.

    EDIT:
    In answer to the comment, it would be the equivalent of writing:

    myHeap = []
    for key, val in freq.items():
        myHeap.append([key, [val, ""]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help explain the following bit of code. richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, richTextBox1.Font.Size,
Could someone please help explain why I can't get this to work? I properly
Possible Duplicate: Can someone explain this template code that gives me the size of
I have a query with regards to pointers, can someone help explain the following
Can someone explain this result to me. The first test succeeds but the second
Can someone explain what this means? int (*data[2])[2];
Can someone explain what the dict class is used for? This snippet is from
Can someone explain how MapReduce works with Cassandra .6? I've read through the word
I was wondering if someone could help me understand this problem. I prepared a
Can someone please help me understand the following: In the previous version of NHibernate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.