import random blocks = ["stone" , "granite" , "polished granite" , "diorite" , "polished diorite" , "andesite" , "polished andesite" , "calcite" , "tuff" , "grass block" , "dirt" , "coarse dirt" , "podzol" , "crimson mycelium" , "warped nylium" , "cobblestone" , "oak planks" , "spruce planks" , "birch planks" , "jungle planks" , "acacia planks" , "dark oak planks" , "crimson planks" , "warped planks" , "bedrock" , "sand" , "red sand" , "gravel" , "gold ore" , "iron ore" , "copper ore" , "coal ore" , "nether gold ore" , "oak log" , "spruce log" , "birch log" , "jungle log" , "acacia log" , "dark oak log" , "crimsson stem" , "warped stem" , "stripped oak log" , "stripped spruce log" , "stripped birch log" , "stripped jungle log" , "stripped acacia log" , "stripped dark oak log" , "stripped crimson stem" , "stripped warped stem" , "stripped oak wood" , "stripped spruce wood" , "stripped birch wood" , "stripped jungle wood" , "stripped acacia wood" , "stripped dark oak wood" , "stripped crimson hyphae" , "stripped warped hyphae" , "oak wood" , "spruce wood" , "birch wood" , "jungle wood" , "acacia wood" , "dark oak wood" , "crimson hyphae" , "warped hyphae" , "sponge" , "wet sponge" , "tinted glass" , "glass" , "lapis lazuli ore" , "block of lapis lazuli" , "sandstone" , "chiseled sandstone" , "cut sandstone" , "white wool" , "orange wool" , "magenta wool" , "light blue wool" , "yellow wool" , "lime wool" , "pink wool" , "gray wool" , "light gray wool" , "cyan wool" , "purple wool" , "blue wool" , "brown wool" , "green wool" , "red wool" , "black wool" , "block of gold" , "block of iron" , "oak slab" , "spruce slab" , "birch slab" , "jungle slab" , "acacia slab" , "dark oak slab" , "crimson slab" , "warped slab" , "stone slab" , "smooth stone slab" , "sandstone slab" , "cut sandstone slab" , "petrified oak slab" , "cobblestone slab" , "brick slab" , "stone brick slab" , "nether brick slab" , "quartz slab" , "red sand slab" , "cut red sand slab" , "purpur slab" , "prismarine slab" , "dark prismarine slab" , "prisarine brick slab" , "smooth quartz block" , "smooth red sandstone" , 'smooth sandstone' , "smooth stone" , "bricks" , "bookshelf" , "mossy cobblestone" , "obsidian" , "purpur block" , "purpur pillar" , "purpur stairs" , "oak stairs" , "diamond ore" , "block of diamond" , "cobblestone stairs" , "redstone ore" , "ice" , "snow block" , "clay" , "pumpkin" , "carved pumpkin" , "jack o' lantern" , "netherrack" , "soul sand" , "soul soil" , "basalt" , "polished basalt" , "glowstone" , "stone bricks" , "mossy stone bricks" , "chiseled stone bricks" , "melon" , "brick stairs" , "stone brick stairs" , "mycelium" , "nether bricks" , "cracked nether bricks" , "chiseled nether bricks" , "nether brick stairs" , "end stone" , "end stone stairs" , "sandstone stairs" , "emerald ore" , "block of emerald" , "spruce stairs" , "birch stairs" , "jungle stairs" , "crimson stairs" , "warped stairs" , "nether quartz ore" , "chiseled quartz block" , "block of quartz" , "quartz bricks" , "quartz pillar" , "quartz stairs" , "white terracotta" , "orange terracotta" , "magenta terracotta" , "light blue terracotta" , "yellow terracotta" , "lime terracotta" , "pink terracotta" , "gray terracotta" , "light gray terracotta" , "cyan terracotta" , "purple terracotta" , "blue terracotta" , "brown terracotta" , "green terracotta" , "red terracotta" , "black terracotta" , "hay bale" , "terracotta" , "block of coal" , "packed ice" , "acacia stairs" , "dark oak stairs" , "white stained glass" , "orange stained glass" , "magenta stained glass" , "light blue stained glass" , "yellow stained glass" , "lime stained glass" , "pink stained glass" , "gray stained glass" , "light gray stained glass" , "cyan stained glass" , "purple stained glass" , "blue stained glass" , "brown stained glass" , "green stained glass" , "red stained glass" , "black stained glass" , "prismarine" , "prismarine bricks" , "dark prismarine" , "prismarine stairs" , "prismarine bricks stairs" , "dark prismarine stairs" , "sea lantern" , "red sandstone" , "chiseled red sandstone" , "cut red sandstone" , "red sandstone stairs" , "magma block" , "nether wart block" , "warped wart block" , "red nether bricks" , "bone block" , "white concrete" , "orange concrete" , "magenta concrete" , "light blue concrete" , "yellow concrete" , "lime concrete" , "pink concrete" , "gray concrete" , "light gray concrete" , "cyan concrete" , "purple concrete" , "blue concrete" , "brown concrete" , "green concrete" , "red concrete" , "black concrete" , "white concrete powder" , "orange concrete powder" , "magenta concrete powder" , "light blue concrete powder" , "yellow concrete powder" , "lime concrete powder" , "pink concrete powder" , "gray concrete powder" , "light gray concrete powder" , "cyan concrete powder" , "purple concrete powder" , "blue concrete powder" , "brown concrete powder" , "green concrete powder" , "red concrete powder" , "black concrete powder", "dead tube coral block" , "dead brain coral block" , "dead bubble coral block" , "dead fire coral block" , "dead horn coral block" , "tube coral block" , "brain coral block" , "bubble coral block" , "fire coral block","horn coral block" , "blue ice" , "polished granite stairs" , "smooth red sandstone stairs" , "mossy stone brick stairs" , "polished diorite stairs" , "mossy cobblestone stairs" , "end stone brick stairs" , "stone stairs" , "smooth sandstone stairs" , "smooth quartz stairs" , "granite stairs" , "andesite stairs" , "red nether brick stairs" , "polished andesite stairs" , "diorite stairs" , "polished granite slab" , "smooth red sandstone slab" , "mossy stone brick slab" , "polished diorite slab" , "mossy cobblestone slab" , "end stone brick slab" , "smooth sandstone slab" , "smooth quartz slab" , "granite slab" , "andesite slab" , "red nether brick slab" , "polished andesite slab" , "diorite slab" , "dried kelp block" , "block of netherite" , "ancient debris" , "crying obsidian" , "blackstone" , "blackstone slab" , "blackstone stairs" , "gilded blackstone" , "polished blackstone" , "polished blackstone slab" , "polished blackstone stairs" , "chiseled polished blackstone" , "polished blackstone bricks" , "polished blackstone brick stairs" , "cracked polished blackstone bricks" , "block of amethyst" , "budding amethyst" , "copper block" , "lightly weathered copper block" , "semi-weathered copper block" , "weathered copper block" , "cut copper" , "lightly weathered cut copper" , "semi-weathered cut copper" , "weathered cut copper" , "cut copper stairs" , "lightly weathered cut copper stairs" , "semi-weathered cut copper stairs" , "weathered cut copper stairs" , "cut copper slab" , "lightly weathered cut copper slab" , "semi-weathered cut copper slab" , "weathered cut copper slab" , "waxed copper" , "waxed lightly weathered copper" , "waxed semi-weathered copper" , "waxed cut copper" , "waxed lightly weathered cut copper" , "waxed semi-weatehred cut copper" , "waxed cut copper stairs" , "waxed lightly weathered cut copper stairs" , "waxed semi-weathered cut copper stairs" , "waxed cut copper slab" , "waxed lightly weathered cut copper slab" , "waxed semi weathered cut copper slab" , "dripstone block"] chosen_block = random.choice(blocks) print("The 1st block is --" , chosen_block + " --") chosen_block = random.choice(blocks) print("The 2nd block is --" , chosen_block + " --") chosen_block = random.choice(blocks) print("The 3rd block is --" , chosen_block + " --")
Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.
OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample python program which takes name as input and print your name with hello.
import sys
name = sys.stdin.readline()
print("Hello "+ name)
Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.
When ever you want to perform a set of operations based on a condition IF-ELSE is used.
if conditional-expression
#code
elif conditional-expression
#code
else:
#code
Indentation is very important in Python, make sure the indentation is followed correctly
For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.
mylist=("Iphone","Pixel","Samsung")
for i in mylist:
print(i)
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while condition
#code
There are four types of collections in Python.
List is a collection which is ordered and can be changed. Lists are specified in square brackets.
mylist=["iPhone","Pixel","Samsung"]
print(mylist)
Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.
myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
Below throws an error if you assign another value to tuple again.
myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)
Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.
myset = {"iPhone","Pixel","Samsung"}
print(myset)
Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.
mydict = {
"brand" :"iPhone",
"model": "iPhone 11"
}
print(mydict)
Following are the libraries supported by OneCompiler's Python compiler
Name | Description |
---|---|
NumPy | NumPy python library helps users to work on arrays with ease |
SciPy | SciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation |
SKLearn/Scikit-learn | Scikit-learn or Scikit-learn is the most useful library for machine learning in Python |
Pandas | Pandas is the most efficient Python library for data manipulation and analysis |
DOcplex | DOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling |