Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

EIA 2018 - Esercizio 2.2 - Liste

# ESERCIZIO 2.2 - Liste
"""
Modificare la soluzione delle esercizio sulle stringhe in modo che i dati vengano inseriti nella lista LS e da lì recuperati per essere mostrati a video. 

Stampare in coda un messaggio che mostri LS. Ad esempio:
Struttura dati: ['Stefano',[10,'Ottobre',1994]]

Suggerimento: Leggete
- https://www.html.it/pag/15613/liste/
"""
    
print ("Hello World!");

Tunnels and Dragons

# Adventure Game Audra Liswith
print("You are lost underground in a maze of tunnels.")
import random
dangerTunnel = random.randint (1,2)
print("Dragon in tunnel ", dangerTunnel)
tunnelChoice = int(input("Choose tunnel 1 or tunnel 2: "))
print("You chose tunnel  ", tunnelchoice)
if tunnelChoice == dangerTunnel:
    print("You entered a tunnel with a dragon. Watch out!")
else:
        print("You entered an empty tunnel. You are safe for now.")
        

Execute Python-3 Online

# Hello World program in Python
    
print ("Hello World!")
print("Hola")
print("Mi nombre es Álvaro")

print("Has puesto el nombre:", "Álvaro")

lolo

def fact(n):
    return n*fact(n-1)
print(fact(5))

Operacoes Basicas 1

print("2 + 2 =",2 + 2)

print("5 + 4 - 1 =",5 + 4 - 1)

print("2 * (3 + 4) =",2 * (3 + 4))

print("1 + 2 * 3 / 4.0 =",1 + 2 * 3 / 4.0)

print("10 / 2 =",10 / 2)

print("(-7 + 2) * (-4) =",(-7 + 2) * (-4))

print("6 * 7.0 =",6 * 7.0)

print("2**5 =",2**5)

print("20 // 6 =",20 // 6)

print("1.25 % 0.5 =",1.25 % 0.5)

Operacoes Basicas 2

hello_world = "hello" + " " + "world"
print("hello_world =",hello_world)

hello_10 = "hello" * 10
print("10_hello =",10_hello)

a = [2,4,6,8]
b = [1,3,5,7]
print("a + b =",a + b)

list_3 = [1,2,3] * 3
print("list_3 =",list_3)

ffff

# Hello World program in Python
    
print ("Hello World!");

Sets

a_set = {1 , 2}
print("a_set =",a_set)

a_list = [1, 1, 2, 2, 3, 3]
print("a_list =",a_list)

a_set = set(a_list)
print("a_set =",a_set)

a_set = {1 , 1}
print("a_set =",a_set)

Execute Python-3 Online

# Hello World program in Python
    
print ("Hello World!");

print ("python")
print("\tpython")

#The \n is to create a new line \t to create a a space as if hitting the Tab key on keyboard.
print("Languages:\n\tPythong\n\tC\n\tJavaScript")
banned_users = ['carlos', 'jenny']
user = "Anna"
if user not in banned_users:
    print(user.title() + ", you can post a response in you wish.")



print("Accessories:\n\tPhone\n\tWatch\n\tCamera")
message = "One of Python's strengths is its diverse community"
print(message)

coco = ("Hello Mr. Simaj this is just a test.")
print(coco)


first_name = ("Coco ")
last_name = ("Goya")
full_name = first_name  + "" +  last_name
print(full_name)
print(full_name.title())
print(full_name.upper())
print(full_name.lower())

print('AB:\n"A person who never made a mistake never tried anything"')
famous_person = "AB"

famous_person.rstrip()
famous_person.lstrip()
famous_person.strip()
pass
pass

#make sure to always add a space on whatever end of your quotes if  you need it when creating a sentence.

print(2 + 2 )

age = 24
message = "Happy "  + str(age) + "rd Birthday!"


print (message)
print ( 4 + 4)
print ( 2 * 4 )
print (10 - 2 )
print (16.0 / 2)
#just storing a number in a variable to create a sentence. REMEMBER to always convert your variable in a string(str)
simaj = 7 
message = "Jonathan favorite number is "  + str(simaj)

print (message)

#The Zen of Python page 34



bicycles = ['trek','cannondale', 'redline', 'specialized']
print (bicycles)
print (bicycles[3])
print (bicycles [0])
print (bicycles[2])
print (bicycles [1])

#Just adding .title() to make the capitolized the first letter
print (bicycles[3].title())
print (bicycles[-1].title())


#Alwasy when creating a message remember to use quotations marks

message = "There's a " + bicycles[-2].title() + " on the wall." #You have to add a dote in quotations marks because if you dont it wont print it. or just create a full sentence. REMEMBER WHEN ALWAY ADDING A variable you have to add the plus sign on both ends without the quations marks in order to work.
print (message)


#original list...
names= ['Jennifer', 'Sarah', 'Yitzack']

message_2 = "Hey " + names[-3].title() + " would like to go to the gym later."
message_3 =  "Hey " + names[2].title() +  ", I cant go to the movies with you later because Im ganna go with " + names[0] + " to the gym, sorry bro..."
print(message_2)
print(message_3)


#This append command or whatever its called it can be useful to add something to a existing list...
names.append('Yesenia')
print(names)
#The zero was just to tell where the names has the be positioned in the list. 
names.insert(0,'Carlos')
print(names)
#just deleted the last names on the list using a negative one inside the brackets.
del names[-1]
print(names)
# I just took the last name and took it out the list then printed it.
jojo = names.pop(-1)
print(names)
print(jojo)
print("The name the was remove was " + jojo.title()+  ".") 


print("Here is the original list:")
print(names)

print("\nHere is the sorted list:")
print(sorted(names))


print("Here is the original list again:")
print(names)

names.reverse()
print (names)
len(names)
print("How many names are there in the list " + str(len(names)))

del names[2]
print(names)

#This exercis is from page number 46

print("Calors wont be avaible to make to the party")

names.append('Joanna')
print(names)
print ("this is the new list, everyone in it is invited to come.")


cars = ['bmw', 'audi', 'toyota', 'subaru']
cars.sort()
print(cars)
print ("This is my car list")

len(cars)
print("How many casrs int the list " + str(len(cars)))
cars.reverse()
print(cars)

cars.reverse()
print(cars)

magicians = ['alice', 'david', 'carolina']
for magician in magicians:
    print(magician)
    
names = ['Sarah', 'Jennifer', 'Joanna']
for name in names:
    print(name)
    
dogs_names = ['bear', 'Z', 'speedy', "LitteOne"]
for dog in dogs_names:
    print (dog)
#this is from page 55    
for magician in magicians:
    print(magician.title() + ", that was a great trick")
    print ("I cant wait to see your next trick, " + magician.title())

print("Thank you everyone that was a great show.")

#This an exercise from page 60

pizza = ['pepperoni', 'hawaiian', 'cheese']
for pizza in pizza:
    print("I like "+ pizza.title()+ " pizza...")
    
for value in range (1, 30):
    print(value)
    


numbers = list(range(0, 10))
print (numbers)


for value in range(0, 21):
    print(value)
    
numbers = list(range(0,9999))
print(numbers)

#WHY MIN() , MAX() AND SUM() DIDNT WORK???
digits = [1, 9999]
min(digits)
max(digits)
sum(digits)

odd_numbers = list(range(1,21,2))
print(odd_numbers)

three = list(range(3,33,3))
for x in three:
    print(x)
    
    
cubes = []
for y in range (1,11):
    cube = y **3
    cubes.append(cube)
    
print(cubes)

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])

print(7 % 3)





import this

sugar= this

1111

Shadrin = input ('Шадрин скурвился? ')

if Shadrin == 'да':
    print('Пиздить палкой')
    
else:
    print ('Пиздить сапогом')

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.