Skip to content

Python Journey

My Coding Blog

Menu
  • Links
Menu

Author: coden00b

Python Project1: Guess Number

Posted on December 31, 2024 by coden00b

Code: import random import time correctanswer = random.randint(1,20) guesscount = 1 print(“I will be selecting numbers between 1 and 20”) print(“Picking a number…”) time.sleep(2) guess = int(input(“Guess a number: “)) while guess != correctanswer:     guesscount += 1     if guess < correctanswer:         guess = int(input(“You need to make…

Read more

The Zen of Python

Posted on January 6, 2023 by coden00b

What will happen if you open up a terminal, then type “import this”? In windows: >>> import this C:\Users\darwin>python Python 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail…

Read more

Python>>String Interpolation and Formatting

Posted on August 31, 2022August 31, 2022 by coden00b

String Interpolation is a process substituting values of variables into placeholders in a string Few methods as follow: a. .format() = is for simple positional formatting that  uses to  substitute in place of braces {}. Example: >> print (‘Welcome to {}’.format(‘ Linux Tutorials’)) Welcome to Linux Tutorials >> title = “Linux Tutorials” >>> print(‘Welcome to…

Read more

Python>>String Methods

Posted on August 29, 2022August 29, 2022 by coden00b

Here are some common String Methods or Attributes that you can use in modifying strings. Assuming x is the string: a. x.upper()  – converts to upper case > x = ‘Free Linux Tutorials’ >>> x.upper() ‘FREE LINUX TUTORIALS’ >>> print(x) Free Linux Tutorials >>> y = x.upper() >>> print (y) FREE LINUX TUTORIALS   b….

Read more

Python>>String Concatenation

Posted on August 29, 2022August 29, 2022 by coden00b

String concatenation is simply adding strings together. Here are sample String Concatenation: Sample1: >> a = ‘Free’ >>> b = ‘Linux’ >>> c = ‘Tutorials’ >>> a + b + c ‘FreeLinuxTutorials’ >>> d = a + b + c >>> print (d) FreeLinuxTutorials >>> Sample2: >>> a = ‘Welcome’ >>> b = ‘to my’…

Read more

Python>>Strings: Indexing and Slicing

Posted on August 23, 2022August 24, 2022 by coden00b

I will be showing more examples of indexing and slicing as a form of my practice to familiarize this. From the previous lesson/posts, the syntax for slicing as follows: string[start : end : step] Example1: (Indexing and Slicing in Strings) W r i t e C o d e O n l i n e…

Read more

Python>>Data Type:Strings

Posted on August 23, 2022 by coden00b

Strings are text type and are sequences of character data. It is represented by quotation marks, either single or double quotes. Example: “Hello” ‘What is your name?’ >>> “Hello” ‘Hello’ >>> x = ‘What is your name?’ >>> print (x) What is your name? >>> Some key notes: 1.Escape sequences in strings = use backslash…

Read more

Python>>Data Type:Float

Posted on August 23, 2022August 23, 2022 by coden00b

Floating point number is real numbers with decimal point (.)or fractional part. It can be positive or negative. Example: 5678.90 -2.88 0.99 >>> z = -1.234 >>> type(z) <class ‘float’> Let’s do arithmetic: >>> x = 8+8.1 >>> print (x) 16.1 >>> print (type(x)) <class ‘float’> Some key notes: 1. numbers separated with underscore can…

Read more

Python>>Data Type:Integer

Posted on August 23, 2022August 23, 2022 by coden00b

Integers or Int are whole numbers without the decimal point or fractional part. It can be positive or negative or zero.It can be binary, octal or hexadecimal values. Let’s do mathematical calculation: Arithmetic operators:   addition = + subtraction = – multiplication = * division = / modulus = % exponent = ** floor division…

Read more

Basic Data Types in Python

Posted on August 23, 2022 by coden00b

There are few data types in Python namely: integers (int) – numeric type, whole numbers (can be positive or negative), e.g. 1,2,3 floating (float) – numeric type,numbers with decimal point, e.g. 1.1, 2.20, 3.450 complex (complex) – numeric type, real + imaginary,e.g. 5+6q strings (str) – text type, sequences of characters,e.g. “Euan”, “1234” dictionaries (dict)…

Read more
  • 1
  • 2
  • Next

Recent Posts

  • Python Project1: Guess Number
  • The Zen of Python
  • Python>>String Interpolation and Formatting
  • Python>>String Methods
  • Python>>String Concatenation

Archives

  • December 2024
  • January 2023
  • August 2022

Tags

.format attributes concatenation count data type find float fstring guess indexing interpolation len lower methods number project python random replace slicing string strings template time upper zen
© 2025 Python Journey | Powered by Minimalist Blog WordPress Theme