Posts

LIST IN PYTHON

  Hey Shouters!! Today we learn about all the important functions on lists in python. In this tutorial, we will learn about all the important things about the Lists. The main parts that we will learn about are: Definition of List String and list similarities Declaration and Initialization Slice and Index Operations Over List Going through a List Update a List Nested List Some Examples Of List Methods Add Elements to a List Deleting an Item From a List All important functions Definition of Lists in Python- The list is an abstract datatype. In Python, A-class ‘list’ is present with multiple methods. The list is a build-in mutable sequence. The list does not follow FIFO or LIFO techniques. Insertion and deletion can take in any position. Similarities between STRINGS AND LISTS- Strings are basically a sequence of characters. Similarly, Lists are basically a sequence of values. These values are Mutable values. That means We can update those values in our progr

Tuple

Image
  Hey Shouters!! Today we learn about all the important functions and operations supported by tuples in python. In this tutorial, we will learn about all the important things about tuples. The main parts that we will learn about are: Introduction Creating Tuple Comprehension and Generator List and Dictionaries Operations over tuple Methods used in the tuple Tuple and Function Boolean and tuple Short Note Introduction Tuples are group of values within first brackets i.e. (1,2,3,'str',22.333). Tuples and Strings are immutable whereas list and dictionaries are mutable. Tuples are faster than lists. Tuple can be a dictionary keys but list cannot. Tuples can be used as values in sets whereas lists can not. Creating Tuple No. 1> There are a Tuple class and using tuple class constructor, you can create tuples as well as you can apply conversion like string to tuple, list to tuple and so on. Tuple allows indexing

PYTHON TRINKET

Image
  Play Snake . Eat the food at the coordinate point, but don't eat yourself! In the game of Snake , the player uses the arrow keys to move a " snake " around the board. As the snake finds food, it eats the food, and thereby grows larger. The game ends when the snake either moves off the screen or moves into itself. WORLD RECORD : Medusa, a reticulated python, clocked in at 7.67 meters (25 feet, 2 inches) long in its official world record measurement, on October 12, 2011. Snake, classic arcade game. Exercises 1. How do you make the snake faster or slower? 2. How can you make the snake go around the edges? 3. How would you move the food? 4. Change the snake to respond to arrow keys. 1. SNAKE GAME PYTHON CODE from turtle import * from random import randrange from freegames import square,vector food=vector(0,0) snake=[vector(10,0)] aim=vector(0,-10) def change(x, y): aim.x=x aim.y=y def inside(head): #boundary return -200 < head.x < 190