SlideShare a Scribd company logo
Basic use of Python
-Practice-
National Institute of Technology, Anan College, JAPAN
Yoshiki Satotani
1. Basic operations
Basic data types
• Create following lists with range function.
1. [0, 1, 2, 3, 4]
2. [3, 4, 5, 6, 7]
3. [3, 6, 9, 12, 15, 18]
4. [2, 4, 6, 8, 12, 16, 20] hint: use + operator
Basic data types
• Create a dictionary that
1. Keys are [0, 1, …, 10]
2. Values are (key) * 2
i.e. d[0]=0, d[1]=2, d[2]=4, …, d[10]=20
Hint: use zip() function
2. Control flow statements
Control flow statements practice
• For integer variable named ‘x’,
• Print ‘fizz’ if x can be divided by 3
• Print ‘buzz’ if x can be divided by 5
(e.g. if x is 10, print ‘buzz’, x is 15, print ‘fizz buzz’)
(hint: use % operator(e.g. 10 % 3 = 1, 14 % 5 = 4))
Control flow statements practice
• Create a list only contains
• Multiple of 3 or 5 (3, 5, 6, 9…)
• Between 1 and 20
i.e. [3, 5, 6, 9, 10, 12, 15, 18, 20]
Control flow statements practice
• Find the 10-th Fibonacci sequence
• Fibonacci sequence is
• 0, 1, 1, 2, 3, 5, 8, …
• The next number is found by adding up the two numbers before it(e.g.
5th number 3 = 2 + 1).
• Hint: You need to use recursive function
3. Graph with matplotlib
Graph practice
• Draw the graph of
binary entropy function
𝐻 𝑝 = −𝑝log2 𝑝 − 1 − 𝑝 log2 1 − 𝑝
• Hint: use np.log2 to
calculate log2

More Related Content

PPTX
Python basics
NexThoughts Technologies
 
PPTX
Basic use of Python
Yoshiki Satotani
 
PPTX
Python PCEP How To Talk To Computer
IHTMINSTITUTE
 
PPTX
Session 05 cleaning and exploring
bodaceacat
 
PPTX
Session 02 python basics
bodaceacat
 
PPTX
An Overview of the Java Programming Language
Salaam Kehinde
 
PPT
4 b file-io-if-then-else
Malik Alig
 
PDF
Python Cheat Sheet
Muthu Vinayagam
 
Basic use of Python
Yoshiki Satotani
 
Python PCEP How To Talk To Computer
IHTMINSTITUTE
 
Session 05 cleaning and exploring
bodaceacat
 
Session 02 python basics
bodaceacat
 
An Overview of the Java Programming Language
Salaam Kehinde
 
4 b file-io-if-then-else
Malik Alig
 
Python Cheat Sheet
Muthu Vinayagam
 

What's hot (20)

PDF
Talk Code
Agiliq Solutions
 
PDF
FSB: TreeWalker - SECCON 2015 Online CTF
YOKARO-MON
 
PPT
1 arrays and sorting
notshoaib
 
PDF
OREO - Hack.lu CTF 2014
YOKARO-MON
 
PDF
Beginning Python
Agiliq Solutions
 
PPTX
Python for Beginners(v3)
Panimalar Engineering College
 
DOCX
Mcq cpup
tahir_ali786
 
ODP
Hands on Session on Python
Sumit Raj
 
PDF
Python Basics #1
Roland Askew
 
PPT
Collection Core Concept
Rays Technologies
 
PDF
Slink into Elixir
LINE Corporation
 
PDF
Introduction to python programming
Rakotoarison Louis Frederick
 
PDF
Python - Lecture 6
Ravi Kiran Khareedi
 
PDF
Java Unit 1 Project
Matthew Abela Medici
 
PPTX
More About Strings
Munazza-Mah-Jabeen
 
PDF
The Ring programming language version 1.2 book - Part 10 of 84
Mahmoud Samir Fayed
 
PPTX
Iteration
Pooja B S
 
PDF
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
Mohammad Reza Kamalifard
 
PDF
Class 2: Welcome part 2
Marc Gouw
 
Talk Code
Agiliq Solutions
 
FSB: TreeWalker - SECCON 2015 Online CTF
YOKARO-MON
 
1 arrays and sorting
notshoaib
 
OREO - Hack.lu CTF 2014
YOKARO-MON
 
Beginning Python
Agiliq Solutions
 
Python for Beginners(v3)
Panimalar Engineering College
 
Mcq cpup
tahir_ali786
 
Hands on Session on Python
Sumit Raj
 
Python Basics #1
Roland Askew
 
Collection Core Concept
Rays Technologies
 
Slink into Elixir
LINE Corporation
 
Introduction to python programming
Rakotoarison Louis Frederick
 
Python - Lecture 6
Ravi Kiran Khareedi
 
Java Unit 1 Project
Matthew Abela Medici
 
More About Strings
Munazza-Mah-Jabeen
 
The Ring programming language version 1.2 book - Part 10 of 84
Mahmoud Samir Fayed
 
Iteration
Pooja B S
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
Mohammad Reza Kamalifard
 
Class 2: Welcome part 2
Marc Gouw
 
Ad

Viewers also liked (12)

PPT
Global marketing
Ronald M. Herber
 
DOC
Stewart Kane CV 2016
Stewart Kane
 
PPTX
Catálogo de-productos-fashion-woman-s.a
Jezee Llanque
 
DOC
አሰስዳ
kedir jemal
 
PDF
Vpmsc Client Introduction Package (1)
Cory Gilmore
 
PDF
รักษาโรคมะเร็ง
pornkanok02
 
PDF
NetIQ Advanced Authentication
Finceptum Oy
 
DOC
Akshat Mathur- Architect
akshat mathur
 
PPTX
Pelajaran6
Firda_123
 
PDF
W.Melis_Sample1_CONF_Logo-Signage-Booth. Concept to final
Wendy Melis
 
DOCX
GRaMmEr MistaKEs 常见语法错误
路人 路过
 
Global marketing
Ronald M. Herber
 
Stewart Kane CV 2016
Stewart Kane
 
Catálogo de-productos-fashion-woman-s.a
Jezee Llanque
 
አሰስዳ
kedir jemal
 
Vpmsc Client Introduction Package (1)
Cory Gilmore
 
รักษาโรคมะเร็ง
pornkanok02
 
NetIQ Advanced Authentication
Finceptum Oy
 
Akshat Mathur- Architect
akshat mathur
 
Pelajaran6
Firda_123
 
W.Melis_Sample1_CONF_Logo-Signage-Booth. Concept to final
Wendy Melis
 
GRaMmEr MistaKEs 常见语法错误
路人 路过
 
Ad

Similar to Basic use of Python (Practice) (20)

PDF
PyLecture4 -Python Basics2-
Yoshiki Satotani
 
PPTX
Python programming lab3 250215
profbnk
 
PDF
Python_ 3 CheatSheet
Dr. Volkan OBAN
 
PDF
Mementopython3 english
ssuser442080
 
PDF
Python3
Sourodip Kundu
 
PDF
datastructure-1 lab manual journals practical
AlameluIyer3
 
PDF
Python3 cheatsheet
Gil Cohen
 
PDF
Introduction to python cheat sheet for all
shwetakushwaha45
 
PDF
Python 101 1
Iccha Sethi
 
PDF
Mementopython3 english
yassminkhaldi1
 
PPTX
Python.pptx
AshaS74
 
PDF
Python lecture 05
Tanwir Zaman
 
PPTX
Introduction To Programming with Python-4
Syed Farjad Zia Zaidi
 
PDF
bv-python-einfuehrung aplication learn.pdf
Mohammadalhaboob2030
 
PDF
Python Part 1
Mohamed Ramadan
 
ODP
Python basics
Himanshu Awasthi
 
PPTX
Introduction to Python and TensorFlow
Bayu Aldi Yansyah
 
PDF
Python Cheatsheet_A Quick Reference Guide for Data Science.pdf
zayanchutiya
 
PDF
Python for System Programming Lab Manual (21BRL67)
THANMAY JS
 
PDF
Class 5: If, while & lists
Marc Gouw
 
PyLecture4 -Python Basics2-
Yoshiki Satotani
 
Python programming lab3 250215
profbnk
 
Python_ 3 CheatSheet
Dr. Volkan OBAN
 
Mementopython3 english
ssuser442080
 
datastructure-1 lab manual journals practical
AlameluIyer3
 
Python3 cheatsheet
Gil Cohen
 
Introduction to python cheat sheet for all
shwetakushwaha45
 
Python 101 1
Iccha Sethi
 
Mementopython3 english
yassminkhaldi1
 
Python.pptx
AshaS74
 
Python lecture 05
Tanwir Zaman
 
Introduction To Programming with Python-4
Syed Farjad Zia Zaidi
 
bv-python-einfuehrung aplication learn.pdf
Mohammadalhaboob2030
 
Python Part 1
Mohamed Ramadan
 
Python basics
Himanshu Awasthi
 
Introduction to Python and TensorFlow
Bayu Aldi Yansyah
 
Python Cheatsheet_A Quick Reference Guide for Data Science.pdf
zayanchutiya
 
Python for System Programming Lab Manual (21BRL67)
THANMAY JS
 
Class 5: If, while & lists
Marc Gouw
 

Recently uploaded (20)

PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
PPTX
The Power of IoT Sensor Integration in Smart Infrastructure and Automation.pptx
Rejig Digital
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
AbdullahSani29
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
DOCX
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
The Power of IoT Sensor Integration in Smart Infrastructure and Automation.pptx
Rejig Digital
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Software Development Company | KodekX
KodekX
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
AbdullahSani29
 
Doc9.....................................
SofiaCollazos
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 

Basic use of Python (Practice)

  • 1. Basic use of Python -Practice- National Institute of Technology, Anan College, JAPAN Yoshiki Satotani
  • 3. Basic data types • Create following lists with range function. 1. [0, 1, 2, 3, 4] 2. [3, 4, 5, 6, 7] 3. [3, 6, 9, 12, 15, 18] 4. [2, 4, 6, 8, 12, 16, 20] hint: use + operator
  • 4. Basic data types • Create a dictionary that 1. Keys are [0, 1, …, 10] 2. Values are (key) * 2 i.e. d[0]=0, d[1]=2, d[2]=4, …, d[10]=20 Hint: use zip() function
  • 5. 2. Control flow statements
  • 6. Control flow statements practice • For integer variable named ‘x’, • Print ‘fizz’ if x can be divided by 3 • Print ‘buzz’ if x can be divided by 5 (e.g. if x is 10, print ‘buzz’, x is 15, print ‘fizz buzz’) (hint: use % operator(e.g. 10 % 3 = 1, 14 % 5 = 4))
  • 7. Control flow statements practice • Create a list only contains • Multiple of 3 or 5 (3, 5, 6, 9…) • Between 1 and 20 i.e. [3, 5, 6, 9, 10, 12, 15, 18, 20]
  • 8. Control flow statements practice • Find the 10-th Fibonacci sequence • Fibonacci sequence is • 0, 1, 1, 2, 3, 5, 8, … • The next number is found by adding up the two numbers before it(e.g. 5th number 3 = 2 + 1). • Hint: You need to use recursive function
  • 9. 3. Graph with matplotlib
  • 10. Graph practice • Draw the graph of binary entropy function 𝐻 𝑝 = −𝑝log2 𝑝 − 1 − 𝑝 log2 1 − 𝑝 • Hint: use np.log2 to calculate log2