Posts

Showing posts with the label Python

Python

Python Basics Today we’ll learn a new programming language called Python. A newer language than C, it has additional features as well as simplicity, leading to its popularity. Source code in Python looks a lot simpler than C. In fact, to print “hello, world”, all we need to write is: print ( "hello, world" ) Notice that, unlike in C, we don’t need to specify a newline in the  print  function or use a semicolon to end our line. To write and run this program, we’ll use the CS50 IDE, save a new file as  hello.py  with just the line above, and run the command  python hello.py . We can get strings from a user: answer = get_string ( "What's your name? " ) print ( "hello, " + answer ) We also need to import the Python version of the CS50 library,  cs50 , for just the function  get_string , so our code will look like this: from cs50 import get_string answer = get_string ( "What's your name? " ) print ( "hello, " +...