Skip to main content

Getting started with coding

It's been while since we posted! So,let's continue our project.
One of the essential data structures that we'll be using extensively is "SETS" in python.
Just for the essence,here's a quick look at it:

********CODE*********
      my_list = []
my_set = set()
my_list.append('a')
my_set.add('a')
print(my_list)  # Output: ['a']
print(my_set)  # Output: {'a'}
my_list.append('b')
my_set.add('b')
print(my_list)  # Output: ['a', 'b']
print(my_set)  # Output: {'b', 'a'}
my_list.append('a')
my_set.add('a')
print(my_list)  # Output: ['a', 'b', 'a']
print(my_set)  # Output: {'b', 'a'}

********END**********

The reason behind using SETS over LISTS is elements in a set are unique and unordered.
By using this data structure,we can build our vocabulary for the application.
Learn more about SETS in python : https://docs.python.org/2/library/sets.html

See you guys in the next post!
              -Kartik Mehetre

Comments

Post a Comment

Popular posts from this blog

Further into the lists..

So, let's continue our learnings about the lists in python!      Why and how  to use list comprehension ? List is one of the most useful collection data type in python.It is a collection which is ordered and changeable.It Allows duplicate members.   Many of us would have thought of what if we want to manipulate each and every  list element? Suppose you are given a list of numbers and you want to add 1 to each element in your list: my_list = [1, 3, 3, 7] my_list_plus_one = my_list + 1  and if you have thought of some code like above then its not gonna  work. You would get this error:   TypeError : can only concatenate list (not "int") to list.  Python thinks that you want to add a list and an integer together, which doesn’t make any sense. So how do we manipulate the list? The answer is using list comprehension syntax. Example: my_list_plus_one = [num + 1 for num in my_list] print(my_list_plus_one)  # Output: [2, 4, 4, 8] Essentially...

Journey towards Creating Hangman.

I love when people take a sophisticated tool and use it to play video games. Take Unity for example. I first saw my friends created a game in Unity, which was an Virtual reality game. My friends Vivek and Payas then inspired me to more efficiently waste time in creating something of my own like their VR game. Rather than jumping directly to a VR game so we thought to start something from the basics. So, the other day I had an immense amount of college work to do and decided it was the perfect time to make a hangman game.  So, What is hangman? In its purest form, hangman is a word game played between two people. One person selects a secret word, and the other tries to determine the word by guessing it letter-by-letter. The player with the secret writes a series of dashes, one representing each letter in the solution. Initially, no information is known about the target word, other than its length. The solver calls out letters, one-by-one. If a called letter appears in the solutio...

Project Documentation

Course Project Title: HANGMAN GAME in Python Description: An interactive game of Hangman developed using python(an object programming language).The project consists of a number of functions used in the game by making use of inbuilt Python libraries.The game offers the user to choose number of attempts and also shows a graphical output. Link for project report: here Final Code File :  Python Code Topic 1: Hangman graphic function Presentor's info:  Name: Siddhesh Ramajgol Div: TY-L Roll no: 57 GR.no : 1710081 Video Link:   Hangman Graphic Function Topic 2: Get no.of attempts and word length Presentor's info:  Name:  Kartik Mehetre Div: TY-L Roll no: 47 GR.no :  1710382 Video Link:  No.of attempts and word length Topic 3: Get next letter and display words Presentor's info:  Name: Shreya Uttarwar Div: TY-L Roll no: 69 GR.no :  1710360 Video Link:  Get next letter and display ...